Prevent both creation and update webhooks firing on product save.
Closes #10970 cc @claudiosmweb
This commit is contained in:
parent
854793e5ea
commit
9b590dfa75
|
@ -155,9 +155,10 @@ class WC_Webhook {
|
||||||
} elseif ( 'order' == $this->get_resource() && ! in_array( get_post_type( absint( $arg ) ), wc_get_order_types( 'order-webhooks' ) ) ) {
|
} elseif ( 'order' == $this->get_resource() && ! in_array( get_post_type( absint( $arg ) ), wc_get_order_types( 'order-webhooks' ) ) ) {
|
||||||
$should_deliver = false;
|
$should_deliver = false;
|
||||||
|
|
||||||
} elseif ( 0 === strpos( $current_action, 'woocommerce_process_shop' ) ) {
|
} elseif ( 0 === strpos( $current_action, 'woocommerce_process_shop' ) || 0 === strpos( $current_action, 'woocommerce_process_product' ) ) {
|
||||||
// the `woocommerce_process_shop_*` hook fires for both updates
|
// the `woocommerce_process_shop_*` and `woocommerce_process_product_*` hooks
|
||||||
// and creation so check the post creation date to determine the actual event
|
// fire for create and update of products and orders, so check the post
|
||||||
|
// creation date to determine the actual event
|
||||||
$resource = get_post( absint( $arg ) );
|
$resource = get_post( absint( $arg ) );
|
||||||
|
|
||||||
// a resource is considered created when the hook is executed within 10 seconds of the post creation date
|
// a resource is considered created when the hook is executed within 10 seconds of the post creation date
|
||||||
|
|
Loading…
Reference in New Issue