• Resolved SJW

    (@whitsey)


    I have built a REST API process that updates WooCommerce products when triggered by the user within their own system.

    Problem: When we change the price, nothing happens until the cache is cleared.

    Is there a way to clear the cache for a specific product/post ID when the REST API modifies the product data

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @whitsey

    Thank you for reaching out and I am happy to help!
    Can you please sahre more information about this so we can have full picture of the proccess and what you are trying to achieve. We need to make sure that we can reproduce this step-by-step

    triggered by the user within their own system.

    Can you please clarify this and let me know in which wat the user triggers this in their own system?

    And to clarify, once the ?REST API modifies the product data, do you want W3TC to automatically purge the cache for specific product/post ID?

    Thank you in advance for clarification on this.

    Thanks!

    Thread Starter SJW

    (@whitsey)

    Hi @vmarko

    They log into their ERP, they update the price. The ERP triggers an update using the REST API as documented here: https://woocommerce.github.io/woocommerce-rest-api-docs/#update-a-product and here https://woocommerce.github.io/woocommerce-rest-api-docs/#batch-update-products

    The response indicates that the price for product with id 794 has been successfully updated.

    I view the product using the URL in the json response $response->permalink but the price on the web store is still showing the old value.

    When I log into WordPress, an view the product, the price is correct BUT W3TC is still caching the page with the old price. I need to manually purge the cache to update the pricing for the public.

    What I want: When the update is triggered via $woocommerce->put('products/794', $data) I want to automatically clear the cache for woocommerce product with post_ID = 794 or, if a batch update is performed $woocommerce->post('products/batch', $data) clear the cache of all products in the “update” array

    • This reply was modified 6 months, 2 weeks ago by SJW.
    • This reply was modified 6 months, 2 weeks ago by SJW. Reason: Added batch process
    • This reply was modified 6 months, 2 weeks ago by SJW.
    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @whitsey

    Thank you for your feedback and for the detailed explenation.

    I have to check this and share this with the team also. I’ll get back to you once I have more information

    Thanks!

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @whitsey

    Thank you for your patience.
    What you can do in this case is to use w3tc_flush_post($product_id); or w3tc_flush_url() for some catalog pages and call these when the API updates the price.

    Pelase note that there is no direct approach in the W3TC for now, however, we are working on some awesome things when it comes to the cases such as this one.

    Thanks!

    Thread Starter SJW

    (@whitsey)

    thanks, i can make that work.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Triggering clear cache on Woocommerce REST API Update’ is closed to new replies.