After some digging I found we still have a get_posts() inside our get_subscriptions_from_token() function.
This PR updates this function to use wcs_get_orders_with_meta_query() so that this function works in both HPOS and non-HPOS.
How to test this PR
Testing with both HPOS and non HPOS enabled:
Purchase two active subscriptions with WC Payments
Go to My Account > Payment methods
Add a new payment method (i used card number5555555555554444)
After this card is added. Click "Make default"
You should see a notice to update your subscriptions to use this new payment method
Click "Yes"
Go to My Account > Subscriptions and confirm all of your active subscriptions have the new payment method
When testing on trunk and HPOS enabled, you won't even see the notice to update all of your subscriptions, this is because the get_posts() doesn't work in HPOS.
Product impact
[x] Added changelog entry (or does not apply)
[x] Will this PR affect WooCommerce Subscriptions? yes/no/tbc, add issue ref
[x] Will this PR affect WooCommerce Payments? yes/no/tbc, add issue ref
[ ] Added deprecated functions, hooks or classes to the spreadsheet
Fixes #128
Description
While testing https://github.com/Automattic/woocommerce-payments/pull/5254 I noticed updating all payment methods for subscriptions was still broken on stores that have HPOS enabled.
After some digging I found we still have a
get_posts()
inside ourget_subscriptions_from_token()
function. This PR updates this function to usewcs_get_orders_with_meta_query()
so that this function works in both HPOS and non-HPOS.How to test this PR
Testing with both HPOS and non HPOS enabled:
5555555555554444
)When testing on
trunk
and HPOS enabled, you won't even see the notice to update all of your subscriptions, this is because theget_posts()
doesn't work in HPOS.Product impact