Skip to content

Commit

Permalink
Prevent both creation and update webhooks firing on product save.
Browse files Browse the repository at this point in the history
Closes #10970 cc @claudiosmweb
  • Loading branch information
mikejolley committed May 27, 2016
1 parent 854793e commit 9b590df
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions includes/class-wc-webhook.php
Expand Up @@ -155,9 +155,10 @@ private function should_deliver( $arg ) {
} 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
Expand Down

0 comments on commit 9b590df

Please sign in to comment.