Automattic / woocommerce-subscriptions-core

Subscriptions core package for WooCommerce
Other
82 stars 29 forks source link

Trashing, untrashing and deleting subscriptions from admin list table don't fire off subscription related hooks #390

Closed james-allan closed 1 year ago

james-allan commented 1 year ago

Describe the bug

When you use the bulk or row actions on the WooCommerce > Subscriptions list table to trash,untrash (restore) or delete subscriptions, the subscription specific hooks - eg woocommerce_trash_subscription - don't fire.

This is caused the way WC core handles these bulk actions.

In the Automattic\WooCommerce\Internal\Admin\Orders\ListTable WC core specifically gets the order data store code ref and calls the delete function on that, which means when you delete a subscription, order hooks are fired instead.

To Reproduce

  1. Hook onto a hook like woocommerce_trash_subscription and error log or add a breakpoint.
  2. Enable HPOS
  3. Go to WooCommerce > Subscriptions.
  4. Select a subscription
  5. From the drop down select "Move to trash"
  6. Click apply.
  7. Note that the woocommerce_trash_subscription hook doesn't fire.

This applies to permanently deleting, trashing and untrashing.

Expected behavior

The subscription datastore functions to trash/delete subscriptions should be called over the order data store.

Actual behavior

The order datastore functions are being called instead, meaning order trash hooks are firing instead.

Product impact

Additional context