Woocommerce hook that fires after a product stock quantity is updated via REST A
-
Hi,
I hope you can help me with this question I have.I have Woocommerce that updates the stock quantity via REST API, however I use the caching plugin WP Fastest Cahe, and it only clears the product cache if it is manually updated by WP Admin (backend) when the API updates the amount of stock the plugin does not trigger the product cache clearing. They do however provide a hook for that purpose which is //it clears the post with ID 1923 wpfc_clear_post_cache_by_id(1923); the link that explains it all is this https://www.wpfastestcache.com/tutorial/delete-the-cache-by-calling-the-function/
I am not a programmer but does the code below work? What can I do to trigger the hook when there is the API update ?
Any tips?
I would be very grateful for some help ??
add_action( 'woocommerce_update_product', 'remover_cache_produto', 10, 1 ); function remover_cache_produto($post_id) { $product = wc_get_product($post_id); wpfc_clear_post_cache_by_id($post_id); //clean cache }
- The topic ‘Woocommerce hook that fires after a product stock quantity is updated via REST A’ is closed to new replies.