When using block-based checkout in WooCommerce an issue occurs where a renewal order is created during the checkout process and it is not associated with the subscription. Normally paying for a failed renewal should resume the order payment, rather than create a new one.
To Reproduce
Activate the following plugins: WooCommerce, WooCommerce Subscriptions, any Gateway (eg Stripe).
Create a block based checkout page.
New page
/checkout block
Save
Make note of the page URL.
Make sure you have 2 shipping method options.
Purchase a subscription.
Create a pending renewal order for the subscription.
Navigate to the subscription details page and click the "Pay" button.
Proceed through the checkout process using block-based checkout.
Change the chosen shipping method.
Process the checkout.
Observe that an order is created, but it is not associated with the subscription.
Expected Behavior
When using block-based checkout, the order created during the checkout process should be correctly associated with the subscription.
Actual Behavior
With block-based checkout enabled, the order created during checkout is not associated with the subscription.
Additional Information
Disabling block-based checkout and using the [woocommerce_checkout] shortcode resolves the issue, and the order is correctly associated with the subscription.
There are a couple of functions which are used to ensure that when a customer pays for a failed renewal order that the existing order gets resumed rather than a new order being created. For the block based checkout, there must be a gap in this.
Check the following functions:
WCS_Cart_Renewal::set_order_awaiting_payment()
WCS_Cart_Renewal::update_cart_hash()
The expectation is that when WC core determines if a new order should be created or if it should be resumed they use a cart hash system. On the standard checkout we update the cart hash right before WC makes the cart hash comparison to ensure that they match. We need to check how this works with the block checkout.
Describe the bug
When using block-based checkout in WooCommerce an issue occurs where a renewal order is created during the checkout process and it is not associated with the subscription. Normally paying for a failed renewal should resume the order payment, rather than create a new one.
To Reproduce
/checkout
blockExpected Behavior
When using block-based checkout, the order created during the checkout process should be correctly associated with the subscription.
Actual Behavior
With block-based checkout enabled, the order created during checkout is not associated with the subscription.
Additional Information
Disabling block-based checkout and using the [woocommerce_checkout] shortcode resolves the issue, and the order is correctly associated with the subscription.
There are a couple of functions which are used to ensure that when a customer pays for a failed renewal order that the existing order gets resumed rather than a new order being created. For the block based checkout, there must be a gap in this.
Check the following functions:
WCS_Cart_Renewal::set_order_awaiting_payment()
WCS_Cart_Renewal::update_cart_hash()
The expectation is that when WC core determines if a new order should be created or if it should be resumed they use a cart hash system. On the standard checkout we update the cart hash right before WC makes the cart hash comparison to ensure that they match. We need to check how this works with the block checkout.