I’m working on a Checkout UI Extension to automatically add a product to cart when a Buy X Get Y discount code is added. I am using useDiscountCodes (doc here) to read the applied codes. The issue that I have the error “discount code isn’t valid for the items in your cart”, because the discount cannot be applied to the current checkout and my
Not specially, I am not allowed to add the discount because the gift product (“Y” product in “Buy X Get Y”) is not added to cart yet. But I need to read the discount code to add the product so I’m blocked Is there any way to intercept the not applied discount code in a checkout UI extension? Or maybe a best way to automatically add a product when the Buy X Get Y discount is entered? Using a Shopify Function or something?
It is exactly the solution I’m working on @Stephen2020 I’m also improving the UX a bit by adding an error message and by removing the discount code when not applicable. To avoid having a product full-price in the cart in case the BXGY discount cannot be applied.
Is this something you’re working on for the App Store? Or is this a personal project where you wouldn’t mind sharing the code? I’m trying to accomplish this very thing.