Skip to content

Make coupon work

The Coupon component itself only displays a code with click-copy support; for customers to actually get the discount at checkout, you must first create the discount code in Shopify Admin.

i18n hint: “Create the discount in Shopify Admin and paste it here. Click copies and applies to checkout.”

Path:

Shopify Admin
→ Top nav → Discounts
→ Create discount

Choose discount type, fill in code value, discount amount, validity period, etc.

Image: Shopify Discounts page + Create discount form

After creation, copy the Code (e.g. WELCOME20) from the Discounts list.

3. Create a Coupon component in tt-blocks editor

Section titled “3. Create a Coupon component in tt-blocks editor”

In the wizard pick a “Discount” template, or in an existing widget’s Content tab”+ Add item” → Coupon.

In the Coupon component’s Code (code) field, paste the value from Shopify.

Image: Coupon editor Code field filled

Recommend matching the Expires at (expiresAt) field to Shopify Discounts validity period.

Tip: “Coupon auto-hides on storefront after this time. Leave empty for no expiration.”

Publish the widget.

Customer clicks coupon →

  • Auto-copies to clipboard (toast: “Copied!”)
  • Simultaneously triggers fetch("/discount/CODE", { redirect: "manual" }) to auto-apply discount
  • Discount auto-takes-effect when customer enters checkout — no manual paste needed

Image: storefront coupon rendering + click toast + applied at checkout

Coupon component’s “display + copy + apply” flow is compatible with all Shopify discount types (calculation handled by Shopify):

Shopify discount typeCompatibleNotes
Amount off productsCustomer enters checkout, Shopify applies per rule
Buy X get YSame
Amount off orderSame
Free shippingSame
Automatic discount (no code needed)Not applicable (Coupon component is a code field; auto discount needs no code input)

Currently one Coupon component holds 1 code. To display multiple discount codes:

  • Use Button list container with multiple Coupon children
  • Or build multiple widgets with visibility rules to display them separately

After expiresAt is reached:

  • Client widget.js detects current time > expiresAtthe entire coupon component auto-hides (code no longer shown)
  • No need for merchant to unpublish manually; to revoke earlier, edit the component and clear code or unpublish the widget