Update the checkout blocks hook that's attached to the process checkout flow to use the latest hook #523
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related issue: https://github.com/woocommerce/woocommerce-subscriptions/issues/4540
Description
There is an issue where processing a Switch request on a block checkout results in a new subscription being created instead of the existing subscription being updated. This issue was caused by our
WC_Subscriptions_Checkout
class using a deprecated checkout block hook while ourWC_Subscriptions_Switcher
is using the latest store API hook.This was causing problems because WooCommerce calls the deprecated hooks first before the latest hook resulting in
WC_Subscriptions_Checkout::process_checkout
running beforeWC_Subscriptions_Switcher::process_checkout
which was creating the extra subscription correctly.It's important that the switcher class processes the checkout first so that it can remove any items from the recurring cart to prevent subscriptions from being created on the switch.
Note
This PR removes the
version_compare
on\Automattic\WooCommerce\Blocks\Package::get_version()
because Subscriptions supports WooCommerce 7.7 at a minimum which already comes bundled with Checkout Blocks v10.0.2.Therefore I've removed all of the deprecated hooks and conditions checking for older versions of checkout blocks that we no longer support.
I'm not sure if there are any concerns with stores installing an older version of checkout blocks as a standalone plugin but I don't think we should cater to that.
Open to discuss this :)
How to test this PR
Important
To follow these testing instructions you'll need to have the main Woo Subscriptions plugin active to access switching.
There's also another bug that prevents you from submitting a $0 switch checkout when using the block checkout. This will be addressed in a PR to the main repository.
trunk
you'll notice you now have two active subscriptions for the same variable productIn order to be able to bipass the checkout erroring with "No valid payment method" I had to stub
WC_Subscriptions_Order::order_needs_payment()
to returnfalse
on the first line.Product impact