Personalized checkout and custom promotions with Shopify Scripts
Need to add a code snipet to this page
https://morningragecoffee.com/pages/ehrs-band-fundraiser
With a text box to enter a discount code - then press a button to be redirected to the URL with that entered discount code embedded, like this:
https://morningragecoffee.com/discount/ERHS24001
Thanks in advance
Hi @NewtoAllThis 👋 roughly use a custom-liquid section or block; assuming an OS2.0 theme
And some code like this UNTESTED code:
<script>
function redirectToDiscountURL(){
var discountCode=document.getElementById("discountCode").value;
var url="https://website.com/discount/"+discountCode;
window.location.href=url;
}
</script>
<input type="text" id="discountCode" placeholder="Enter discount code" />
<button onclick="redirectToDiscountURL()">Apply Discount</button>
Good luck.
If you need it further customized such as to be conditional or to use routes etc then contact me for services.
Contact info in forum signature.
ALWAYS please provide context, examples: store url, theme name, post url(s) , or any further detail in ALL correspondence.
Contact paull.newton+shopifyforum@gmail.com for the solutions you need
Save time & money ,Ask Questions The Smart Way
Problem Solved? ✔Accept and Like solutions to help future merchants
Answers powered by coffee Thank Paul with a ☕ Coffee for more answers or donate to eff.org
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025