We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
See https://gist.github.com/mrcave/7cdf6707273252de04094d4ed8d0d43c
//clear entire cache when stock is reduced or replenished function clear_cache_when_stock_changes( $order ) { if(class_exists('PhpRedis_Purger') || class_exists('Predis_Purger')){ global $nginx_purger; $nginx_purger->purge_all(); } } add_action( 'woocommerce_reduce_order_stock', 'clear_cache_when_stock_changes', 10, 1 ); add_action( 'woocommerce_restore_order_stock', 'clear_cache_when_stock_changes', 10, 1 );
//only clear product page caches when stock changes function clear_product_page_caches_when_stock_changes( $order ) { if(class_exists('PhpRedis_Purger') || class_exists('Predis_Purger')){ if($order){ global $nginx_purger; foreach ( $order->get_items() as $item_id => $item ) { $product_id = $item->get_product_id(); $nginx_purger->purge_post( $product_id ); } } } } add_action( 'woocommerce_reduce_order_stock', 'clear_product_page_caches_when_stock_changes', 10, 1 ); add_action( 'woocommerce_restore_order_stock', 'clear_product_page_caches_when_stock_changes', 10, 1 );
The text was updated successfully, but these errors were encountered:
No branches or pull requests
See https://gist.github.com/mrcave/7cdf6707273252de04094d4ed8d0d43c
The text was updated successfully, but these errors were encountered: