Goal: Auto-add the free “Y” item at checkout when a Buy X Get Y (BXGY) discount code is applied using Shopify Checkout UI extensions.
Current implementation: The OP uses the useApplyCartLinesChange hook to add the item after the discount code is entered. Issue: an alert message in the discount/reduction form persists even after the item is successfully added, and they ask if there’s a way to refresh/reset the reduction form to clear the alert.
Related report: Another developer is trying the same pattern (free product via discount code) but says the discount isn’t applied unless the free item is already present in the cart. They request guidance on configuration/implementation to make it apply without pre-adding the free item.
Requests/outstanding questions:
How to programmatically refresh or reset the discount/reduction form to remove the alert after auto-adding the item.
How to ensure a BXGY discount applies without the free item already in the cart.
Status: No confirmed solution or workaround shared; one participant asks if a fix was found. Discussion remains open. A screenshot of the persistent alert in the discount section is central to the issue.
Summarized with AI on December 24.
AI used: gpt-5.
i’m building feature auto add item in the checkout page when apply discount code bxgy with checkout-ui extension,
i can add item to the cart line using useApplyCartLinesChange after apply discount code, but the problem i can’t remove alert text after item added to the cart.
Hi Pebian, I am trying to set the same feature using the checkout UI extension but currently facing an issue where I’m attempting to apply a discount code for a free product, but it seems the discount isn’t being applied unless a free item is included. Could you please guide how to resolve this? How did you set this?