Automattic / woocommerce-subscriptions-core

Subscriptions core package for WooCommerce
Other
80 stars 29 forks source link

[WC Blocks] Show "FREE" instead of $0.00 in order summary if shipping is free #623

Closed opr closed 1 month ago

opr commented 1 month ago

[!NOTE]
This PR is a follow up to https://github.com/woocommerce/woocommerce/pull/47553 please wait for that to be merged (or check that PR out) before testing this.

Description

This PR will show the text 'FREE' in bold and capital letters in the recurring totals area of the order summary on the Cart and Checkout blocks.

Before After
image image

How to test this PR

  1. Have at least two shipping options set up, one should be free shipping.

  2. Go to WooCommerce -> Settings -> Shipping -> Shipping Settings and ensure Enable the shipping calculator on the cart page is checked.

  3. Add a subscription item to your cart and go to the Cart block.

  4. In the order summary, find the recurring totals section and the recurring packages section.

  5. In the recurring packages section select the free shipping rate. The shipping price in the recurring totals area should now say 'FREE'.

  6. Change the recurring package's shipping method to flat rate and ensure the correct price shows in the recurring totals section. It should not say 'FREE'.

  7. Go to the Checkout block and do the same, ensure the correct value shows for free and paid shipping.

Product impact

opr commented 1 month ago

@mattallan thanks a lot for your review and suggestions.

I just pushed up a small commit to make sure the string is translatable

🤦🏼 Yeah that's my bad, thanks for catching that.

should we include the CSS in subscriptions as well instead of relying on Woo

Great idea, actually, ~I'll take care of that.~ On second thought, how do you feel about the fact that in versions <9.0 "$0.00" will be shown in the main order summary, but FREE would be shown in WC Subscriptions? Seems like a lot of work to solve for something so minor (We'd need to port this version checking function over to WC Subscriptions, unless similar exists already?) but would love to hear your thoughts on ensuring the consistency between core and WC Subscriptions.

mattallan commented 1 month ago

how do you feel about the fact that in versions <9.0 "$0.00" will be shown in the main order summary, but FREE would be shown in WC Subscriptions?

I feel like someone will notice the inconsistency so I;v just pushed up https://github.com/Automattic/woocommerce-subscriptions-core/pull/623/commits/9124f653af5f9eb666c53756f27b4aa03ec4752b which uses isWcVersion() to only show the "free" label when the store has 9.0+

@opr let me know if there will be problems with this. Subscriptions requires a minimum of WC 7.9 and I've confirmed there's no issues on that version.

opr commented 1 month ago

Thanks @mattallan this is great! I appreciate you using isWcVersion, I didn't realise that was exported!

I think this is ready to go then. Should we hold off on merging this until https://github.com/woocommerce/woocommerce/pull/47553 is merged? Just in case that doesn't make it into the 9.0 release for any reason?

mattallan commented 1 month ago

Great, thanks @opr! I see your PR into WooCommerce core was merged and tagged for the 9.0 milestone so we'll get this merged here as well.

PS. I added a small clarification in the changelog entry to include the WC version.