Discount app - is it even possible with current Shopify's APIs?

cypcz
New Member
8 0 0
Hey all, I’m exploring a possibility of building public app for discount codes. Management part is going to use Admin API (create, update and delete discount codes) - I have this resolved. I’m concerned about merchant’s customers part as I’m unsure how to solve following 2 questions:
  1. Integrate simple input and submit button to apply discount code during checkout. Is there a standardized way to be able to add it to store regardless of theme the store is using along with some JavaScript code (to make API call)?
  2. When customer clicks on submit button to apply discount code, the API call to my app’s backend needs to happen. My backend checks the used discount code and calculates the actual discount. To calculate the discount, backend needs to know the content of customer’s cart. This gets mi to these points:
  • Is there an API to query customer’s cart (I checked Storefront API, but that doesn’t have any queries, only mutations)? Or will the cart content need to be sent along with discount code to my app’s backend?
  • If the above step is done and I have the discount amount calculated, how do I apply it to customer’s checkout. I again checked Storefront API and I’d only be able to apply Shopify’s discount codes with checkoutDiscountCodeApplyV2, but not the already calculated discount. The outstanding question is how do I send the discount information back to customer and apply it to Shopify’s checkout?
Is it even possible to build such application? Any suggestion or idea will be extremely helpful as I’ve been trying to figure this out few days already. Thank you 🙏 
Replies 5 (5)

HunkyBill
Shopify Expert
4846 60 552

1. No. You cannot affect checkout with your App. The only code that can affect checkout would be Plus accounts, and even then, careful modifications.

2. That is not how Discounts work in Shopify. If a customer uses one, and it is valid, it was already created and exists. You cannot make one up at this point.

3. You can easily pass the contents of a cart back to your App using a Proxy call. No trouble there.

You should really study up on the price rules and discount calls you can make, and then decide if you can use that for your App idea. Once the customer commits a discount code, you're pretty much done, there is nothing else you can do.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
cypcz
New Member
8 0 0

Hi HunkyBill, thank you for your reply.

1. Could you link me to the API that allows updating checkout if you have Plus account?

2. Not sure we understand each other here. Discount code is not created during checkout, but in advance by my custom public app. Then during checkout, I'd like to verify the used discount code on my app's backend and calculate the actual discount.

3. How can I access cart content? Could you point me to the API, please?

I'm not sure what you mean by "customer commits a discount code". I want customers to verify discount code against my backend.

HunkyBill
Shopify Expert
4846 60 552

There is no API for changing checkout. You can access the Liquid, and insert your own JS and HTML or CSS as needed.

When you create a Discount Code in Shopify, it exists. If you created it in your App, good for you. It exists. No matter. During checkout, you do not get to play with that discount code. You could send it to your App in Plus, using JS. You could also check it using Shopify Scripts in a Plus store, but not using your App.

You should probably explain what you mean when you say you need to verify a discount code. It would not exist in the first place if your App or the merchant did not create it, so what is your App going to verify?

I told you you can use a Proxy to access cart content. That is not an API, it is an App Proxy. Obviously, if you have an App, you can add a Proxy extension to it. Look it up.

Customers do not verify Discount Codes. They use them. There should be no question, if a customer is issued a Discount Code for a Shopify store, it should just work for them. Why would they be issued a non-working code in the first place? Makes no sense.

 

 

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
cypcz
New Member
8 0 0

Shopify's discount codes are limited. That's what I'd like to solve with my app. As an example, I want to create a custom discount code, that makes cheapest item in your cart go for free. So to answer your main question - by verifying the discount code, in this case, I mean checking if it's active, checking customer's cart, figuring out the cheapest item and ultimately determining the discount. Then I have to somehow propagate this discount to checkout (update it).

Changing the checkout on the frontend with HTML, CSS and JS is no use, because (at least to my knowledge) checkout is stored on Shopify's backend. That means I may be able to update it client side for the customer, but when customer completed checkout, Shopify takes whatever is saved on the backend, it doesn't care what's in customer's browser.

HunkyBill
Shopify Expert
4846 60 552

Well, for the most common situation, unless a standard Discount code is not sufficient, you could send the cart back to your App, determine the cheapest item, then create a Discount code for the use by the customer, and send that back to them to use in Checkout. You'll find all kinds of flakey with that, as in the customer can always change their cart and screw those codes up, but whatever. You want to fill a niche, you can do it.

And zero of what you need involves HTML, JS or CSS so I don't know where you got that, other than I mentioned, you can alter those in checkout on Plus stores. Clearly, you won't be needing to alter any of that.

All in all, as you are now finding out, your idea is probably of limited appeal for what it is worth. You can certainly do it, but to what end. Shopify has Discount Code infrastructure, and for better or worse, sticking with it is usually the best bet.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com