Skip to content

Conversation

@im3dabasia
Copy link
Contributor

@im3dabasia im3dabasia commented Sep 9, 2025

Description

Added cache purging for WooCommerce products when updated via REST API. Hooked into the WooCommerce product update hook to trigger purging after a product is updated. This ensures the frontend always serves fresh product data after updates via REST API.

Testing Instructions

  1. Enable REST API in WooCommerce settings.
  2. Optionally, relax permissions while testing by adding a filter to allow all REST API requests. ( Snippet down below)
  3. Use Postman or Thunder Client to make a request to a specific product endpoint. Update any detail of your choice, for example the stock quantity.
  4. Verify that the product is updated in the Admin.
  5. Verify that the product cache is purged by checking that the frontend returns the updated data.

Add this snippet for testing purposes to relax permissions

add_filter( 'woocommerce_rest_check_permissions', function( $permission, $context, $object_id, $post_type ) {
    return true;
}, 10, 4 );

Screencast

External link (Recorded via Loom in a Linux setup)
https://www.loom.com/share/ce38d9b59e554cc99c957bf4d0119697?sid=9ed596af-52b3-4826-adae-37e15b927ee0

@im3dabasia im3dabasia marked this pull request as ready for review September 9, 2025 07:01
@im3dabasia im3dabasia merged commit 68a517c into master Sep 10, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants