For discussing the development and usage of Checkout UI extensions, post-purchase extensions, web pixels, Customer Accounts UI extensions, and POS UI extensions
I have set up a shipping discount function which applies a 100% shipping discount for "members" (users with a tag applied) on my shop. These members should only get to use this perk four times per year, which I'll manage via a DB or metafield, no problems here. The tricky part is we want to allow members the option to opt-out of using one of their free shipping perks for whatever reason, let's say on an especially small order. I have figured out how to use a Checkout UI extension above the shipping methods area to present this option, however, I cannot figure out how to somehow flag the order as waiving free shipping (REST call to the custom app perhaps?), nor can I figure out how I can go about making the shipping discount Function re-run. I'm hoping there is some straightforward way to do this, but have thought of a couple other ideas if not:
- We could direct users wishing to waive free shipping to a profile page, where they could toggle off an option (metafield?) on their account, then return to the checkout. This flow redirection should re-trigger the checkout calculations.
- We could create a dummy product called "Waive shipping" that we add or remove from the cart on the checkout page, which presumably would also re-trigger the calculations, but I have not tested this theory.
Would love to hear any other "clever" solutions if there really isn't any other way to force a recalculation on the checkout page. Thanks in advance!
Solved! Go to the solution
This is an accepted solution.
Hi Daveelton,
You could try setting a cart attribute when the customer opts out of the shipping discount. I am not totally sure if that will trigger a recalculation of discounts, but it's worth a shot, and would be the most straightforward option.
Best,
Tobe
This is an accepted solution.
Hi Daveelton,
You could try setting a cart attribute when the customer opts out of the shipping discount. I am not totally sure if that will trigger a recalculation of discounts, but it's worth a shot, and would be the most straightforward option.
Best,
Tobe
Thank you! I had actually tried this already, but your comment made me try it again, and I now realize I must have been doing something incorrectly previously. I suspect I may have been setting the attribute value to true/false, where it actually requires a string - this time I awaited the call and logged the response which let me know this was a problem. Anyway, thanks again!