API for Validating Discount Codes

2 0 1

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.

Replies 4 (4)

Shopify Expert
11196 226 2287

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?

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★

2 0 1

My use case is to directly mimic the behaviour of the discount code input in the Shopify checkout. 

Shopify Partner
18 0 2

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.



Freelancer | Software Developer | Shopify Customization Guru | Shopify Public App Creator | sanket972528@gmail.com | https://sannket.com
Shopify Partner
7 0 0

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.