Skip to content

Commit

Permalink
Merge pull request #8303 from justinshreve/bulk-edit-webhook-8116
Browse files Browse the repository at this point in the history
Execute the 'order.updated' webhook when bulk editing and using the status action buttons (fixes #8116)
  • Loading branch information
claudiosanches committed Jun 5, 2015
2 parents 816a01a + 0fb9851 commit ecac3fb
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions includes/admin/class-wc-admin-post-types.php
Expand Up @@ -1351,6 +1351,7 @@ public function bulk_action() {
foreach ( $post_ids as $post_id ) {
$order = wc_get_order( $post_id );
$order->update_status( $new_status, __( 'Order status changed by bulk edit:', 'woocommerce' ) );
do_action( 'woocommerce_order_edit_status', $post_id, $new_status );
$changed++;
}

Expand Down
1 change: 1 addition & 0 deletions includes/class-wc-ajax.php
Expand Up @@ -465,6 +465,7 @@ public static function mark_order_status() {
if ( wc_is_order_status( 'wc-' . $status ) && $order_id ) {
$order = wc_get_order( $order_id );
$order->update_status( $status );
do_action( 'woocommerce_order_edit_status', $order_id, $status );
}
}

Expand Down
1 change: 1 addition & 0 deletions includes/class-wc-webhook.php
Expand Up @@ -561,6 +561,7 @@ private function get_topic_hooks( $topic ) {
'order.updated' => array(
'woocommerce_process_shop_order_meta',
'woocommerce_api_edit_order',
'woocommerce_order_edit_status',
),
'order.deleted' => array(
'wp_trash_post',
Expand Down
12 changes: 12 additions & 0 deletions includes/updates/woocommerce-update-2.4.php
Expand Up @@ -58,6 +58,18 @@
}
}

// Make sure order.update webhooks get the woocommerce_order_edit_status hook
$order_update_webhooks = get_posts( array(
'posts_per_page' => -1,
'post_type' => 'shop_webhook',
'meta_key' => '_topic',
'meta_value' => 'order.updated'
) );
foreach ( $order_update_webhooks as $order_update_webhook ) {
$webhook = new WC_Webhook( $order_update_webhook->ID );
$webhook->set_topic( 'order.updated' );
}

// Update fully refunded orders to ensure they have a refund line item so reports add up
$refunded_orders = get_posts( array(
'posts_per_page' => -1,
Expand Down

0 comments on commit ecac3fb

Please sign in to comment.