How let user enter discount code and create URL for user

Topic summary

Goal: Add an input field on a Shopify page to let users enter a discount code and, on button click, redirect to a URL formatted as /discount/<entered_code> (example: https://morningragecoffee.com/discount/ERHS24001).

Approach suggested:

  • Use a Custom Liquid section or block in an Online Store 2.0 (OS 2.0) theme.
  • Implement a textbox and button that builds the redirect URL using the entered value, optionally leveraging Shopify routes.

Notes:

  • “Liquid” is Shopify’s templating language; OS 2.0 refers to Shopify’s current theme architecture supporting flexible sections/blocks.
  • The responder referenced an untested code snippet, but the actual code is not shown in the thread.
  • They offered further customization (e.g., conditional logic or routes) via paid services and requested more context details if needed.

Status/outcome:

  • No confirmed solution or working code posted.
  • Key next step is to implement and test the Custom Liquid input-and-redirect logic.
  • Discussion remains open with unanswered implementation specifics.
Summarized with AI on December 12. AI used: gpt-5.

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 :waving_hand: roughly use a custom-liquid section or block; assuming an OS2.0 theme

And some code like this UNTESTED code:


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.

1 Like