I am trying to create an app that will automatically apply a discount code for a user. I am taking this approach using the script tag. On the checkout page there is an input field where user can enter discount code, like the one below:
That's the page I need my script to work but it seems script tags don't work on checkout page.
Is there any way to make the script tag work on this page so I can automatically apply the discount?
If it is not possible, any idea on how to automatically apply discount code for a user will be great.
Please help me resolve this.
You cannot affect checkout for any plan except Plus.
If you want the customer to have an automatically applied discount code, you can provide the discount code to their "transfer" to checkout, by decorating the URL with a query parameter. Shopify will use the discount code you provide in the checkout form, saving the customer from having to type it in. There used to be Shopify documentation lessons on this, you'll have search for them on your own, but they should still exist.
Hey @HunkyBill , thanks for the idea but I don't really get it.
How do I exactly transfer to checkout by sending discount code through query parameters?
Last time I checked, every cart.liquid renders some button with a link to checkout. Find that, decorate it with your discount code, and you're exactly there. Note that you can go to checkout directly from anywhere in a Shopify theme, meaning you can decorate the URL and transfer there from anywhere. Note that if you wanted to directly checkout a product, you can provide its ID, a quantity and discount too. Fancy!
I don't know much about liquid, but if it can get the job done then I will definitely look into it.
Thanks a lot!
Any resources to learn about liquid will be highly appreciated.