Automattic / woocommerce-subscriptions-core

Subscriptions core package for WooCommerce
Other
85 stars 31 forks source link

[HPOS] Fixes the Cancel and remove personal data subscription bulk action on HPOS stores. #381

Closed mattallan closed 1 year ago

mattallan commented 1 year ago

Fixes #376

Description

image

While testing PR https://github.com/Automattic/woocommerce-subscriptions-core/pull/367 I found an issue with the Cancel and remove personal data not working on stores with HPOS enabled. This was caused by the new ListTable class handling this bulk action request for Orders as well as subscriptions.

To fix this, we need to introduce a new action name to prevent WooCommerce from handling it automatically. To do this, this PR adds a new action called wcs_remove_personal_data and then handles this action manually using the handle_bulk_actions-woocommerce_page_wc-orders--shop_subscription action hook.

How to test this PR

  1. Enable HPOS on your store.
  2. Purchase multiple subscriptions on the checkout
  3. Go to the Subscriptions list table
  4. Select one or multiple subscriptions and use the Cancel and remove personal data action
  5. Confirm the subscriptions are canceled with all their data removed.
  6. Confirm the admin notice is shown
  7. Run the same checks with HPOS disabled.

Product impact