PHP code example of codelight / woocommerce-product-variation-stock-cache
1. Go to this page and download the library: Download codelight/woocommerce-product-variation-stock-cache library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
codelight / woocommerce-product-variation-stock-cache example snippets
$args['meta_query'][] = [
'key' => Cache::getInstance()->getCacheKey(['attribute_name' => 'attribute_value']),
'value' => 'instock',
];
$args['meta_query'][] = [
'key' => Cache::getInstance()->getCacheKey(['pa_size' => 'm']),
'value' => 'instock',
];
$args['meta_query'][] = [
'key' => Cache::getInstance()->getCacheKey(['pa_size' => 'm', 'pa_color' => 'red']),
'value' => 'instock',
];
add_filter('codelight/variation_stock/tracked_attributes', function(array $attributes) {
// modify your attributes here
return $attributes;
});
add_filter('codelight/variation_stock/key_prefix', function() {
return '_custom_prefix';
});
add_filter('codelight/variation_stock/autoload', function() {
return false;
});