Skip to content

Commit

Permalink
Jetpack Sync - HPOS module: Add missing handlers for removing or tras…
Browse files Browse the repository at this point in the history
…hing subscriptions (#40047)

* Jetpack Sync: Add hooks for removed and trashed Shop Subscriptions
  • Loading branch information
fgiannar authored Nov 5, 2024
1 parent dcadf8f commit bb42d75
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Jetpack Sync: Add missing handlers for removing or trashing shop_subscription orders
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,13 @@ 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_action( 'woocommerce_delete_subscription', $callable );
add_filter( 'jetpack_sync_before_enqueue_woocommerce_delete_order', array( $this, 'on_before_enqueue_order_trash_delete' ) );
add_filter( 'jetpack_sync_before_enqueue_woocommerce_delete_subscription', array( $this, 'on_before_enqueue_order_trash_delete' ) );
add_action( 'woocommerce_trash_order', $callable );
add_action( 'woocommerce_trash_subscription', $callable );
add_filter( 'jetpack_sync_before_enqueue_woocommerce_trash_order', array( $this, 'on_before_enqueue_order_trash_delete' ) );
add_filter( 'jetpack_sync_before_enqueue_woocommerce_trash_subscription', array( $this, 'on_before_enqueue_order_trash_delete' ) );
}

/**
Expand Down Expand Up @@ -425,6 +429,12 @@ private static function wc_get_order_status_keys() {
);
}

if ( function_exists( 'wcs_get_subscription_statuses' ) ) {
// @phan-suppress-next-line PhanUndeclaredFunction -- Checked above. See also https://github.com/phan/phan/issues/1204.
$wc_subscription_statuses = array_keys( wcs_get_subscription_statuses() );
$wc_order_statuses = array_merge( $wc_order_statuses, $wc_subscription_statuses );
}

return array_unique( $wc_order_statuses );
}

Expand Down

0 comments on commit bb42d75

Please sign in to comment.