App reviews, troubleshooting, and recommendations
We are developing a Checkout UI extension that adds a custom line item. However, when we add the line item through code, Shopify re-renders the shipping method section and automatically selects the first shipping method. How can we retain the previously selected shipping method?
Hi @akshay_joseph ,
When a Checkout UI Extension modifies the cart — such as by adding a custom line item — Shopify's checkout may re-evaluate the available shipping options. This can trigger a re-render of the shipping method section and reset the selected option to the default (usually the first one).
Currently, there’s no direct API method to persist or reapply the previously selected shipping method after cart changes within a Checkout UI Extension.
However, here are a few workarounds you might consider:
Capture and Reapply (Limited Support):
While you can use the useShippingOptionTarget and useSelectedShippingOption hooks to observe the selected method before the line item is added, there's no supported way to programmatically reapply that selection after the re-render.
Minimize Triggering Cart Updates:
If possible, defer adding the custom line item until after the shipping method is finalized, or batch changes together to reduce re-renders.
Provide User Feedback:
If a reset is unavoidable, consider alerting users to double-check their shipping method, or guide them back to their previous choice.
Hope this will help, Let me know if you need more guidence.
Regards,
Dotsquares Ltd
Problem Solved? ✔ Accept and Like solution to help future merchants.
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025