I am trying to create a stock sync system that communicates with WooCommerce via REST API and webhooks. It works simply like that:
The issue here is that it creates some kind of infinite loop as when the product is updated on other website it fires webhook again and creates a new event in my API again.
Question: Is it possible to prevent WooCommerce from firing product update webhooks ONLY when product is updated via REST API (or specific function)?
Yes, there is an example using the filter woocommerce_webhook_should_deliver
here: https://shanerutter.co.uk/fix-woocommerce-webhook-loop/
Also, I've had luck un-scheduling the Action Scheduler actions upon their creation, which is a consequence of a REST API inventory type sync job firing product updated hooks and web hooks:
add_action( 'init', function() {
as_unschedule_all_actions( 'adjust_download_permissions' );
} );