Skip to content

Commit

Permalink
Jetpack Sync: Fix a bug in syncing HPOS 'woocommerce_delete_order' ac…
Browse files Browse the repository at this point in the history
…tions (#39562)

* Jetpack Sync: Fix a bug in syncing HPOS 'woocommerce_delete_order' actions
  • Loading branch information
fgiannar authored Sep 30, 2024
1 parent 0c6a95a commit 1fe8e76
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Jetpack Sync: Fix a bug in syncing HPOS 'woocommerce_delete_order' actions
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ public function init_listeners( $callable ) {
add_filter( "jetpack_sync_before_enqueue_woocommerce_after_{$type}_object_save", array( $this, 'expand_order_object' ) );
}
add_action( 'woocommerce_delete_order', $callable );
add_filter( 'jetpack_sync_before_enqueue_woocommerce_delete_order', array( $this, 'expand_order_object' ) );
add_filter( 'jetpack_sync_before_enqueue_woocommerce_delete_order', array( $this, 'on_before_enqueue_order_trash_delete' ) );
add_action( 'woocommerce_trash_order', $callable );
add_filter( 'jetpack_sync_before_enqueue_woocommerce_trash_order', array( $this, 'expand_order_object' ) );
add_filter( 'jetpack_sync_before_enqueue_woocommerce_trash_order', array( $this, 'on_before_enqueue_order_trash_delete' ) );
}

/**
Expand Down Expand Up @@ -259,6 +259,28 @@ public function expand_order_object( $args ) {
return $this->filter_order_data( $order_object );
}

/**
* Convert order ID to array.
*
* @access public
*
* @param array $args Order ID.
*
* @return array
*/
public function on_before_enqueue_order_trash_delete( $args ) {
if ( ! is_array( $args ) || ! isset( $args[0] ) ) {
return false;
}
$order_id = $args[0];

if ( ! is_int( $order_id ) ) {
return false;
}

return array( 'id' => $order_id );
}

/**
* Filters only allowed keys from order data. No PII etc information is allowed to be synced.
*
Expand Down

0 comments on commit 1fe8e76

Please sign in to comment.