WooCommerce – Clear Cache on Stock Update via Rest API

Hello @negapo,

The updates via the Woo API are not triggering the hooks we are monitoring and clearing the cache when triggered.

Adding them may lead to increased cache purge requests when, for example, an automatic inventory update is performed, and there are a lot of products and requests towards the site. Other operations may also trigger it.

You can, however, create a custom file with the function below in it and use curl to trigger it and clear your website’s cache:

if (function_exists('sg_cachepress_purge_cache')) {
    sg_cachepress_purge_cache();
}

You can also protect it so only requests that contain or provide any form of authentication can access it. This, of course is up to you, and the authentication can range from a random file name to URL password protection or other security means.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer