Back to Shopify Liquid
Coupon Code 2
Shopify Liquid

Coupon Code 2

This snippet creates a stylized coupon display section featuring an animated 'shine' effect and ticket-style edge notches. It presents multiple discount codes side-by-side with clear headers and requirement descriptions, using a CSS keyframe animation for visual urgency.

EasyCouponSalesPromotions BadgeCROProduct Page
160 lines · 5.6 KB
Setup 5–10 minutes 4 min read 160 lines
Key features
  • Animated CSS shine overlay
  • Ticket-style notched borders
  • Responsive flexbox layout
  • Custom Josefin Sans typography integration
  • Keyframe-driven horizontal slide animation
Best use cases
  • Highlighting multiple discount tier options on a product page.
  • Welcome discount codes for first-time visitors in the header or footer.
Compatibility
  • Shopify Online Store 2.0
  • Most Shopify themes

The code

Shopify Liquid
1<div class='section-template--20099374219593__e3f1ef9e-093d-47e8-ac9b-d45f4c5fae55-settings' id='coupon-body-template--20099374219593__e3f1ef9e-093d-47e8-ac9b-d45f4c5fae55'>
2 <div class='coupon-body-template--20099374219593__e3f1ef9e-093d-47e8-ac9b-d45f4c5fae55'>
3 <div class='coupon-body-bg-template--20099374219593__e3f1ef9e-093d-47e8-ac9b-d45f4c5fae55'>
4 </div>
5 <div class='coupon-item-template--20099374219593__e3f1ef9e-093d-47e8-ac9b-d45f4c5fae55'>
6 <p class='coupon-header-template--20099374219593__e3f1ef9e-093d-47e8-ac9b-d45f4c5fae55'>
7 EXTRA 10% OFF
8 </p>
9 <p class='coupon-text-template--20099374219593__e3f1ef9e-093d-47e8-ac9b-d45f4c5fae55'>
10 On purchase of $100+ (use code : 10OFFTODAY)
11 </p>
12 </div>
13 <div class='coupon-item-template--20099374219593__e3f1ef9e-093d-47e8-ac9b-d45f4c5fae55'>
14 <p class='coupon-header-template--20099374219593__e3f1ef9e-093d-47e8-ac9b-d45f4c5fae55'>
15 EXTRA 5% OFF
16 </p>
17 <p class='coupon-text-template--20099374219593__e3f1ef9e-093d-47e8-ac9b-d45f4c5fae55'>
18 For first time users (use code : FIRST5)
19 </p>
20 </div>
21 </div>
22</div>
23<style>
24 .coupon-body-bg-template--20099374219593__e3f1ef9e-093d-47e8-ac9b-d45f4c5fae55 {
25 display: block!important;
26 background-image: linear-gradient(to left, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.3) 70%, rgba(255, 255, 255, 0.05) 100%), linear-gradient(to right, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.3) 70%, rgba(255, 255, 255, 0.05) 100%);
27 position: absolute;
28 top: 0;
29 bottom: 0;
30 left: 0;
31 width: 40px;
32 z-index: 10;
33 transform: rotate(-20deg);
34 animation: slide 8s linear 0s infinite;
35 }
36 @keyframes slide {
37 0% {
38 transform: translateX(0%);
39 }
40 100% {
41 transform: translateX(80rem);
42 }
43 }
44 </style><style>@font-face {
45 font-family: 'Josefin Sans';
46 font-weight: 400;
47 font-style: normal;
48 font-display: swap;
49 src: url('//section.store/cdn/fonts/josefin_sans/josefinsans_n4.c8300d95fd4ce72542a6efba9c682da40d144fba.woff2?h1=c2VjdGlvbi5zdG9yZQ&h2=c2VjdGlvbi1zdG9yZS1hcHAuYWNjb3VudC5teXNob3BpZnkuY29t&hmac=1081bc13bac779d73b77022741d8b8608aa5451af6a05907fc023625940c00f1') format('woff2'),
50 url('//section.store/cdn/fonts/josefin_sans/josefinsans_n4.ed7230a86e75b34b997bd12a5e1b87fcaf7104d8.woff?h1=c2VjdGlvbi5zdG9yZQ&h2=c2VjdGlvbi1zdG9yZS1hcHAuYWNjb3VudC5teXNob3BpZnkuY29t&hmac=3f19a3e11bab2423756ce410220df09957f15affd53a78fa0ec435e5660aa636') format('woff');
51}
52
53 @font-face {
54 font-family: 'Josefin Sans';
55 font-weight: 400;
56 font-style: normal;
57 font-display: swap;
58 src: url('//section.store/cdn/fonts/josefin_sans/josefinsans_n4.c8300d95fd4ce72542a6efba9c682da40d144fba.woff2?h1=c2VjdGlvbi5zdG9yZQ&h2=c2VjdGlvbi1zdG9yZS1hcHAuYWNjb3VudC5teXNob3BpZnkuY29t&hmac=1081bc13bac779d73b77022741d8b8608aa5451af6a05907fc023625940c00f1') format('woff2'),
59 url('//section.store/cdn/fonts/josefin_sans/josefinsans_n4.ed7230a86e75b34b997bd12a5e1b87fcaf7104d8.woff?h1=c2VjdGlvbi5zdG9yZQ&h2=c2VjdGlvbi1zdG9yZS1hcHAuYWNjb3VudC5teXNob3BpZnkuY29t&hmac=3f19a3e11bab2423756ce410220df09957f15affd53a78fa0ec435e5660aa636') format('woff');
60}
61
62
63 .section-template--20099374219593__e3f1ef9e-093d-47e8-ac9b-d45f4c5fae55 {
64 border-top: solid #000000 0px;
65 border-bottom: solid #000000 0px;
66 margin-top: 0px;
67 margin-bottom: 0px;
68 overflow: hidden;
69
70 }
71
72 .section-template--20099374219593__e3f1ef9e-093d-47e8-ac9b-d45f4c5fae55-settings {
73 max-width: 120rem;
74 margin: 0 auto;
75 padding-top: 9px;
76 padding-bottom: 0px;
77 padding-left: 0rem;
78 padding-right: 0rem;
79 }
80
81 .coupon-body-template--20099374219593__e3f1ef9e-093d-47e8-ac9b-d45f4c5fae55 {
82 padding: 6px 30px;
83 border-radius: 12px;
84 border: 0px solid #000000;
85 background-color: #19c8ae;
86 position: relative;
87 overflow: hidden;
88display: flex;
89 flex-direction: row;
90 gap: 9px;
91 }
92
93 .coupon-body-template--20099374219593__e3f1ef9e-093d-47e8-ac9b-d45f4c5fae55:after,
94 .coupon-body-template--20099374219593__e3f1ef9e-093d-47e8-ac9b-d45f4c5fae55:before {
95 content: '';
96 position: absolute;
97 top: 50%;
98 transform: translateY(-50%);
99 width: 20px;
100 height: 20px;
101 border-radius: 50%;
102 background-color: #ffffff;
103 }
104
105 .coupon-body-template--20099374219593__e3f1ef9e-093d-47e8-ac9b-d45f4c5fae55:before {
106 left: -10px;
107 }
108
109 .coupon-body-template--20099374219593__e3f1ef9e-093d-47e8-ac9b-d45f4c5fae55:after {
110 right: -10px;
111 }
112
113 .coupon-header-template--20099374219593__e3f1ef9e-093d-47e8-ac9b-d45f4c5fae55 {
114 margin: 0px;
115 font-size: 14px;
116 color: #ffffff;
117 line-height: 130%;
118 text-transform: unset;
119 text-align: left;
120 font-weight: 700;
121 }
122
123 .coupon-text-template--20099374219593__e3f1ef9e-093d-47e8-ac9b-d45f4c5fae55 {
124 margin: 0px;
125 margin-top 3px;
126 font-size: 12px;
127 color: #ffffff;
128 line-height: 130%;
129 text-transform: unset;
130 text-align: left;
131 }
132
133 @media(min-width: 1024px) {
134
135 .section-template--20099374219593__e3f1ef9e-093d-47e8-ac9b-d45f4c5fae55 {
136 margin-top: 0px;
137 margin-bottom: 0px;
138 }
139
140 .section-template--20099374219593__e3f1ef9e-093d-47e8-ac9b-d45f4c5fae55-settings {
141 padding: 0 5rem;
142 padding-top: 12px;
143 padding-bottom: 0px;
144 padding-left: 0rem;
145 padding-right: 0rem;
146 }
147
148 .coupon-body-template--20099374219593__e3f1ef9e-093d-47e8-ac9b-d45f4c5fae55 {
149 padding: 8px 40px;
150 }
151
152 .coupon-header-template--20099374219593__e3f1ef9e-093d-47e8-ac9b-d45f4c5fae55 {
153 font-size: 16px;
154 }
155
156 .coupon-text-template--20099374219593__e3f1ef9e-093d-47e8-ac9b-d45f4c5fae55 {
157 margin-top 4px;
158 font-size: 12px;
159 }
160 }</style>

How to install Coupon Code 2 on your Shopify theme

This snippet belongs in sections/main-product.liquid, directly under the Add to cart button, where it reinforces the purchase decision. Expect the whole job to take about 5–10 minutes.

  1. 1From your Shopify admin, open Online Store → Themes, click the button on your live theme and choose Duplicate. Always work on a copy so you can roll back instantly.
  2. 2On the duplicated theme, click … → Edit code to open the theme code editor.
  3. 3Open sections/main-product.liquid in the file tree. If your theme uses different file names, search for the template that renders the area where you want the block to show up.
  4. 4Click Copy code on this page, then paste the snippet directly under the Add to cart button, where it reinforces the purchase decision.
  5. 5The snippet ships with its own scoped <style> block, so you do not need to touch base.css or theme.css. If you prefer to keep CSS centralised, move the contents of the style tag into your theme stylesheet and delete the inline block.
  6. 6Click Save, then hit Preview and check the block on desktop, tablet and mobile widths.
  7. 7When you are happy with the result, publish the duplicated theme from Online Store → Themes → Actions → Publish.

How to customise it

Every value below lives inside the snippet, so you can adapt Coupon Code 2 to your brand without touching the rest of the theme.

  • Colours — the snippet uses #000000, #19c8ae, #ffffff. Replace those values inside the style block with your brand palette, keeping at least a 4.5:1 contrast ratio between text and background so the block stays accessible.
  • Gradient — swap the linear-gradient(...) declaration for a flat background colour if you want a more minimal, theme-native look.
  • Typography — the block declares font-family: 'Josefin Sans'. Delete that line to inherit your theme font instead, which usually looks better integrated.
  • Sizing — adjust the font-size values (14px, 12px, 16px) and the padding so the block carries the same visual weight as the elements around it.
  • Cornersborder-radius: 12px controls the roundness. Set it to 0 for a sharper editorial look, or increase it for a softer, app-like feel.
  • Responsive behaviour — the @media query defines the mobile breakpoint. Adjust the pixel value if your theme uses a different breakpoint scale.

Common mistakes to avoid

These are the issues merchants run into most often when installing a snippet like this one.

  • Editing the live theme directly. Duplicate it first — a single unbalanced Liquid tag can take a storefront down mid-campaign.
  • Pasting the code into the wrong file. Dropped into layout/theme.liquid instead of sections/main-product.liquid, this block will render on every page of the store, including ones where it makes no sense.
  • Renaming the CSS classes in the markup but not in the style block, or vice versa. The class names have to match exactly or the styling silently disappears.
  • Publishing without testing on a real phone. Most Shopify traffic is mobile, and layout problems almost always surface there first.

Performance notes

What this block costs you in load time, and how to keep that cost at zero.

  • The CSS is inline and scoped to this block, so it adds no extra network request. At a few kilobytes it has no measurable effect on your Lighthouse score.
  • The animation runs on CSS keyframes. Animate only transform and opacity where you can — animating width, height or top forces a layout recalculation on every frame.
  • Run PageSpeed Insights before and after you add the block so you have a concrete number rather than a guess.

SEO & accessibility

How to add this block without damaging your on-page structure or your rich results.

  • Nothing in this snippet should replace your page <h1>. Keep product and page headings intact and use <h2> or <h3> for the block's own heading so the document outline stays clean.
  • If the block shows review or rating content, keep it consistent with the structured data your review app already outputs. Duplicating or contradicting rating markup can cost you the rich result entirely.
  • The block does not create a new URL, so there is no canonical or indexing change to make. It improves on-page engagement signals rather than crawlability.
Frequently asked questions

Coupon Code 2 — questions merchants ask

Will this snippet work with my theme?

It is built with standard Liquid, HTML and CSS, so it works with Dawn and virtually every Online Store 2.0 theme, as well as most vintage themes. The only thing that changes between themes is the file you paste it into — if yours has no sections/main-product.liquid, look for the equivalent template that renders the same area.

Do I need an app to use it?

No. This is theme code you own outright: no monthly fee, no third-party script tag, and no app that can break your storefront the next time it updates.

How long does it take to add “Coupon Code 2” to a store?

Most merchants have it live in under fifteen minutes — duplicate the theme, paste the code, adjust the colours and copy, preview on mobile, publish.

The styling looks broken after pasting. How do I fix it?

Confirm you copied the whole snippet including the closing style tag, then check whether one of your theme's own CSS rules is overriding it. If a theme rule wins, increase the specificity of the snippet's selector rather than scattering !important through the file.

Will it slow my store down?

Not meaningfully. It is inline markup with scoped CSS and at most a few lines of vanilla JavaScript — no external libraries, no extra HTTP request. Optimising your product images will always have a far bigger impact on load time.

Can I use it on a client store or a commercial project?

Yes. Every snippet in the MCO Hub library is free to copy, modify and ship on any store, including client work. Attribution is appreciated but not required.

Related snippets

Keep exploring