Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Hi all, I was wondering if there is an API to call in order to validate a discount code as it is done on the Shopify order page. If there is any other information surrounding using discount codes and APIs, I would be very grateful.
There's not a direct endpoint for it but doesn't mean you can't use the price rules and the info you have on the customer / cart / etc to work it out.
Out of interest, what's the use case?
My use case is to directly mimic the behaviour of the discount code input in the Shopify checkout.
I have some what same requirement.
In my scenario, Discount code url is provided to Customers, and if customer came from that link, then predefined products have $50 discount. This works well. But customer only get to know final discounted price on checkout page. I want to show them that info. (about discount code is going to apply) on cart page.
Is there any way to identify from current CART info. that, discount code will be apply on this checkout (and customer came from that shared link)?
Any way to know about that?
P.S: I knw that checkout api access is not there for public. otherwise, I may have way to resolve my case.
I did this using an AWS lambda function that hits - /admin/api/2019-10/discount_codes/lookup.json?code=
Then I just check the content type returned. If it's html it's likely a valid discount code, if is json is the not found error.
Just have a form setup to hit the AWS endpoint and it returns me True / False.