A space to discuss online store customization, theme development, and Liquid templating.
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.
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.
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.
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.
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.