Skip to content
This repository was archived by the owner on May 21, 2025. It is now read-only.

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

Merged
merged 5 commits into from
May 21, 2024

Conversation

opr
Copy link
Contributor

@opr opr commented May 16, 2024

Note

This PR is a follow up to woocommerce/woocommerce#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'.
  1. 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'.
  2. Go to the Checkout block and do the same, ensure the correct value shows for free and paid shipping.

Product impact

  • Added changelog entry (or does not apply)
  • Will this PR affect WooCommerce Subscriptions? yes~/no/tbc~, add issue ref
  • Will this PR affect WooCommerce Payments? yes/no/tbc, add issue ref
  • Added deprecated functions, hooks or classes to the spreadsheet

@opr opr changed the title [Checkout block] Show "FREE" instead of $0.00 in order summary if shipping is free [WC Blocks] Show "FREE" instead of $0.00 in order summary if shipping is free May 16, 2024
@@ -91,9 +91,12 @@ const ShippingTotal = ( {
? parseInt( values.total_shipping, 10 ) +
parseInt( values.total_shipping_tax, 10 )
: parseInt( values.total_shipping, 10 );

const valueToShow =
0 === shippingTotals ? <strong>Free</strong> : shippingTotals;
Copy link
Contributor Author

@opr opr May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The styling to capitalise this is handled by CSS in WC Blocks, which is why an additional class was added to the TotalsWrapper below.

@opr opr requested review from james-allan May 16, 2024 15:38
@opr opr added type: task The issue is an internally driven task (e.g. from another A8c team). labels May 16, 2024
Copy link
Contributor

@mattallan mattallan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @opr for the changes, I just pushed up a small commit to make sure the string is translatable but apart from that this is good to be merged :)

I'll wait for the PR to be merged into WooCommerce core first.

I had a question regarding styling... for stores running older versions of WooCommerce, do you think it's okay to just show the label as "Free" instead of "FREE" or should we include the CSS in subscriptions as well instead of relying on Woo?

Thanks!

@opr
Copy link
Contributor Author

opr commented May 17, 2024

@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
Copy link
Contributor

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 9124f65 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
Copy link
Contributor Author

opr commented May 20, 2024

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 woocommerce/woocommerce#47553 is merged? Just in case that doesn't make it into the 9.0 release for any reason?

@mattallan
Copy link
Contributor

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.

@mattallan mattallan merged commit 3346293 into trunk May 21, 2024
9 checks passed
@mattallan mattallan deleted the update/free-shipping-recurring-total branch May 21, 2024 00:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: task The issue is an internally driven task (e.g. from another A8c team).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants