What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: How to add script tag on checkout page?

How to add script tag on checkout page?

abdullah_omar04
Excursionist
24 0 1

Hello, 

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:

abdullah_omar04_0-1609427948674.png

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. 

Thank you

Replies 4 (4)

HunkyBill
Shopify Partner
4853 60 568

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.

 

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
abdullah_omar04
Excursionist
24 0 1

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?

HunkyBill
Shopify Partner
4853 60 568

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!

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
abdullah_omar04
Excursionist
24 0 1

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.