Automattic / woocommerce-subscriptions-core

Subscriptions core package for WooCommerce
Other
87 stars 33 forks source link

Classic Checkout is missing recurring shipping options. #688

Open maxlaf opened 1 week ago

maxlaf commented 1 week ago

Describe the bug

The classic cart and checkout do not provide controls for users to select different shipping methods for the initial and recurring shipments. I believe this may be regression with some history to it, and a fix may be blocked.

Block Checkout 6AEljf.png

Shortcode Checkout GsZ5vT.png

To Reproduce

  1. Set up some sub products and at least 2 shipping shipping methods.
  2. Set up additional cart/checkout pages for shortcode checkout.
  3. Create a cart that qualifies for multiple shipping methods.
  4. Go through default checkout with the blocks and observe recurring shipment options at cart/checkout
  5. Go through shortcode checkout and observe missing recurring shipment options

Expected behavior

Initial and Recurring shipments to be separated and provide shipping options for each.

Actual behavior

No recurring shipment options. I presume it defaults to the first available.

Product impact

Additional context

This issue seems to have some history to it and it may be a regression. I consider the impact to be high considering all sites using shortcode checkout are affected, but I suspect this may not be an easy fix or could be blocked given the history. As Block Checkout is unaffected by this, at least users have a potential workaround.

These issues and fixes all seem to be related:

Discussion in woosupport: p1724432266964989-slack-C3NCP7ZJ6

mattallan commented 6 days ago

Hey @maxlaf, thanks for opening this issue!

While I understand there are some inconsistencies in how recurring shipping methods are displayed between the block checkout and the shortcode checkout, this behavior appears to be working as expected. However, if I’m missing a bug, please let me know!

From your screenshot, it looks like the store has set a Free Shipping requirement, such as a minimum spend of $50 for Free Shipping to apply:

image

Because this requirement is met during the initial purchase, Free Shipping is available. However, since the subscription is only $20/month, it doesn't qualify for Free Shipping. As a result, the only available shipping option for the subscription is Flat Rate shipping, which is why you don’t see radio buttons for multiple shipping options in the cart/checkout shortcode.

Although the block checkout looks different, it’s essentially showing the same behavior.


Also worth mentioning. Our wcs_cart_totals_shipping_html() function handles displaying recurring shipping options on the shortcode checkout and cart pages. There are two scenarios where recurring shipping options are not shown as radio buttons:

  1. Only one shipping option is available.
  2. The shipping rates for the initial purchase match the rates for the subscription.

In the second case, if the shipping rate for the initial purchase is updated, the same shipping method will automatically be applied to the subscription.

This is another difference between how we display/use shipping options on the block checkout versus shortcode checkout and could potentially be improved.

EjayhanFernandes commented 4 days ago

@mattallan I did some tests myself, and I was able to replicate the bug reported by @maxlaf:

9rBxnX.png

mSWQBV.png

mattallan commented 4 days ago

@EjayhanFernandes thanks for confirming!

On the shortcode checkout, if you switch the initial cart to use Flat rate two shipping method, does the recurring shipping method also update to flat rate two with the correct totals?

If so, this is the expected behaviour I briefly touched on at the bottom of my previous message:

Also worth mentioning. Our wcs_cart_totals_shipping_html() function handles displaying recurring shipping options on the shortcode checkout and cart pages. There are two scenarios where recurring shipping options are not shown as radio buttons:

  1. Only one shipping option is available.
  2. The shipping rates for the initial purchase match the rates for the subscription.

In the second case, if the shipping rate for the initial purchase is updated, the same shipping method will automatically be applied to the subscription.

On the shortcode checkout, if the shipping rates available on the initial purchase also match the available shipping rates for the subscription, we don't show two radio options and instead, updating the shipping methods for the initial cart will automatically update the recurring carts shipping option.

Here's a recording of what the expected behaviour for the shortcode checkout is:

https://github.com/user-attachments/assets/4c548c82-75d5-41de-8a7c-e3e7e0e29e93

EjayhanFernandes commented 4 days ago

On the shortcode checkout, if you switch the initial cart to use Flat rate two shipping method, does the recurring shipping method also update to flat rate two with the correct totals?

On the shortcode checkout, if you switch the initial cart to use the "Flat rate two" shipping method, the recurring shipping method also updates to "Flat rate two" with the correct totals, as seen here:

https://github.com/user-attachments/assets/260d1eb4-0116-4af5-aa01-4036c9915ce6

On the shortcode checkout, if the shipping rates available on the initial purchase also match the available shipping rates for the subscription, we don't show two radio options and instead, updating the shipping methods for the initial cart will automatically update the recurring carts shipping option.

Given that this is the expected behavior for the cart/checkout shortcodes, are you saying there is no bug or issue here? And that adding such a feature (separate options for initial and recurring shipping) to the classic cart/checkout shortcode might not be necessary? If so, since the cart/checkout block includes a feature to select different shipping methods for initial and recurring shipments (as shown below), merchants who want that feature would need to switch to the cart/checkout block.

https://github.com/user-attachments/assets/23f1557d-c7ff-47d7-9d9c-ba702e50c944

mattallan commented 4 days ago

Thanks @EjayhanFernandes!

Given that this is the expected behavior for the cart/checkout shortcodes, are you saying there is no bug or issue here?

Yeah, so there's not necessarily a bug here, but I wanted to make sure I wasn't missing a serious issue where shipping methods weren't showing on the shortcode checkout when they're expected.

If so, since the cart/checkout block includes a feature to select different shipping methods for initial and recurring shipments (as shown below), merchants who want that feature would need to switch to the cart/checkout block.

We do have a filter that this merchant could use:

add_filter( 'wcs_cart_totals_shipping_html_price_only', '__return_false' );

This will force the recurring shipping methods to be displayed on the shortcode checkout whenever there's multiple shipping options.

image