Shopify Code Snippets: Copy-Paste Code for Dawn and Horizon
Search tested CSS and Liquid code for Dawn and Horizon, see exactly where to paste each snippet, and copy it in one click. Every card links to its full guide.
Shows the real saving, so $40.00 down to $29.99 reads "25% off", and falls back to your normal sale text when a variant isn't on sale. Duplicate your theme first, and redo the edit if a theme update replaces the file.
Dawn: product cards
Where to paste: Edit code > snippets/card-product.liquid. Search products.product.on_sale (it appears twice) and replace each of those two lines with this. Save.
Hide the quantity selector in the cart and cart drawer
Hides the quantity box in cart lines only, so the product page box and the remove button stay. Dawn's second rule hides the Quantity column heading but keeps its space.
Dawn
Where to paste: Online Store > Themes > Edit theme > Theme settings (gear icon) > Custom CSS. Paste, then Save.
/* Dawn: hide quantity in the cart page and cart drawer */
quantity-input.cart-quantity {
display: none;
}
.cart-items__heading--quantity {
visibility: hidden;
}
Horizon
Where to paste: Online Store > Themes > Edit theme > Theme settings (gear icon) > Custom CSS. Paste, then Save.
/* Horizon: hide quantity in the cart page and cart drawer */
.cart-items__quantity .quantity-selector-wrapper {
display: none;
}
Shows "You're $17.50 away from free shipping" with a bar that fills up, and hides when the cart is empty. In Step 1, change USD and 50 to your currency and your free shipping minimum.
Step 1: the snippet file (both themes)
Where to paste: Duplicate your theme, then Edit code > snippets folder > add a new file named free-shipping-bar.liquid. Paste this and Save.
Where to paste: Cart drawer: snippets/cart-drawer.liquid, paste right under the line that starts with <div class="cart-drawer__footer". Cart page: sections/main-cart-footer.liquid, paste right under the line that starts with <div class="js-contents". For the drawer, set Theme settings > Cart > Type to Drawer.
{% render 'free-shipping-bar' %}
Step 2, Horizon: show it in the cart
Where to paste:snippets/cart-summary.liquid, paste right above the line <div class="cart-totals">. This one line covers the cart drawer and the cart page.
{% render 'free-shipping-bar' %}
Optional, Dawn: live update in a Custom Liquid section
Where to paste: Only if you put the render line in a Custom Liquid section on Dawn's cart page: paste this under the render line in the same Liquid code box. Inside the drawer and cart footer, the bar updates by itself.
Shows one "Add this to your order" card, picked from a custom.cart_upsell product metafield (Settings > Metafields and metaobjects > Products, type Product) with a store-wide fallback. Change gift-box on line 7 to your fallback product's handle.
The upsell code
Where to paste: Cart page, no files: open the Cart template in the theme editor. Dawn: Add section > Custom Liquid, drag it between Items and Subtotal. Horizon: Add block inside the Cart section > Custom Liquid. Paste into Liquid code. For the cart drawer instead: Edit code > snippets > add a file named cart-upsell.liquid and paste this.
{%- comment -%}
Cart upsell (zobaer.me). Shows one add-on product in the cart.
1. Each product can point to its add-on with a product metafield: custom.cart_upsell (type: Product).
2. If no product in the cart has one, the store-wide fallback below is used.
{%- endcomment -%}
{%- liquid
assign fallback_handle = 'gift-box'
assign upsell = nil
for item in cart.items
assign pick = item.product.metafields.custom.cart_upsell.value
if pick != blank and pick.available
assign in_cart = cart.items | where: 'product_id', pick.id | size
if in_cart == 0
assign upsell = pick
break
endif
endif
endfor
if upsell == nil and fallback_handle != blank
assign pick = all_products[fallback_handle]
if pick != blank and pick.available
assign in_cart = cart.items | where: 'product_id', pick.id | size
if in_cart == 0
assign upsell = pick
endif
endif
endif
-%}
{%- if cart.item_count > 0 and upsell -%}
{%- assign v = upsell.selected_or_first_available_variant -%}
<div class="cart-upsell">
<p class="cart-upsell__title">Add this to your order</p>
<div class="cart-upsell__card">
{%- if upsell.featured_image -%}
<img class="cart-upsell__img" src="{{ upsell.featured_image | image_url: width: 160 }}" alt="{{ upsell.title | escape }}" width="64" height="64" loading="lazy">
{%- endif -%}
<div class="cart-upsell__info">
<a class="cart-upsell__name" href="{{ upsell.url }}">{{ upsell.title }}</a>
<span class="cart-upsell__price">{{ v.price | money }}</span>
</div>
{%- if upsell.has_only_default_variant -%}
<form action="{{ routes.cart_add_url }}" method="post">
<input type="hidden" name="id" value="{{ v.id }}">
<input type="hidden" name="quantity" value="1">
<button type="submit" class="cart-upsell__btn">Add</button>
</form>
{%- else -%}
<a class="cart-upsell__btn" href="{{ upsell.url }}">Choose</a>
{%- endif -%}
</div>
</div>
<style>
.cart-upsell { margin: 0 0 16px; }
.cart-upsell__title { margin: 0 0 8px; font-size: 0.9em; font-weight: 600; }
.cart-upsell__card { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid rgba(128, 128, 128, 0.3); border-radius: 8px; }
.cart-upsell__img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.cart-upsell__info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 0.9em; line-height: 1.3; }
.cart-upsell__name { color: inherit; text-decoration: none; overflow-wrap: anywhere; }
.cart-upsell__card form { margin: 0; flex-shrink: 0; }
.cart-upsell__btn { display: inline-block; flex-shrink: 0; padding: 8px 16px; border: 1px solid currentColor; border-radius: 6px; background: transparent; color: inherit; font: inherit; font-size: 0.9em; text-decoration: none; cursor: pointer; }
</style>
{%- endif -%}
Cart drawer, Dawn: render line
Where to paste:snippets/cart-drawer.liquid, paste right above <div class="drawer__footer">. Save.
{% render 'cart-upsell' %}
Cart drawer, Horizon: render line
Where to paste:snippets/cart-summary.liquid, paste right above <div class="cart-totals">. This covers the drawer and the cart page, so don't also add the Custom Liquid block or the card shows twice.
A looping text bar that pauses on hover and stops for shoppers who reduce motion. Change the three messages, and hide the built-in Announcement bar so you don't show two.
Any theme with a Custom Liquid section
Where to paste: Online Store > Themes > Edit theme > Header area > Add section > Custom Liquid. Drag it above the Header section and paste into Liquid code. Dawn: set Top and Bottom padding to 0. Horizon: set Width to Full. Save.
Remove "Powered by Shopify" from the footer in code
Try the no-code way first: a space in Edit default theme content (Dawn) or the Copyright block checkbox (Horizon). Use this only when those fail, on a duplicate theme, because an update can bring the line back.
Dawn: delete this line
Where to paste: Edit code > sections/footer.liquid. Search powered_by_link and delete this whole line, tags included. Save.
Remove the Shopify logo from the Horizon password page
In Horizon, a space in Edit default theme content removes the words but not the logo, while deleting this paragraph removes both. Don't delete the whole password footer, because the Enter using password button lives there.
Horizon: delete this paragraph
Where to paste: Edit code > sections/password-footer.liquid. Delete the paragraph that starts with <p class="password-footer__powered-by">, down to its closing </p>. Save.
Prints the logos of the payment methods your store accepts, using the same filter as Dawn's footer, and updates when you change providers. Horizon needs no code: add its Payment icons block under Details.
Dawn
Where to paste: Edit theme > Products > Default product > Product information > Add block > Custom Liquid. Paste into Liquid code, drag it under Buy buttons, Save.
For a wide designed badge, since Dawn's Product information section has no Image block. Upload the image in Content > Files, copy its link, and write alt text that says what the badge says.
Dawn
Where to paste: Edit theme > Products > Default product > Product information > Add block > Custom Liquid. Paste, replace the link and the alt text, Save.
A ready size chart table in inches. The numbers are examples only, so replace them with your own product measurements.
Any theme
Where to paste: Online Store > Pages > Add page (title: Size chart). In the content editor click Show HTML (the <> icon), paste this, Save.
<p>Measurements are in inches. Between two sizes? Choose the larger one.</p>
<table>
<tr><th>Size</th><th>Chest</th><th>Waist</th><th>Hips</th></tr>
<tr><td>XS</td><td>31-32</td><td>24-25</td><td>34-35</td></tr>
<tr><td>S</td><td>33-34</td><td>26-27</td><td>36-37</td></tr>
<tr><td>M</td><td>35-36</td><td>28-29</td><td>38-39</td></tr>
<tr><td>L</td><td>37-39</td><td>30-32</td><td>40-42</td></tr>
<tr><td>XL</td><td>40-42</td><td>33-35</td><td>43-45</td></tr>
</table>
Hides the installments message on product pages and in the cart, but shoppers can still choose installments at checkout. Horizon has a Show Shop Pay payment options checkbox instead.
Dawn
Where to paste: Online Store > Themes > Edit theme > Theme settings (gear icon) > Custom CSS. Paste, then Save.
Section CSS only affects that one section, so product pages keep their prices. Also set Quick add to None in the same section, because its pop-up shows the price.
Dawn
Where to paste: Edit theme > Collections > Default collection > Product grid section. Scroll to Custom CSS at the bottom of the section settings, paste, Save.
Hides the price of sold-out products on cards and of sold-out variants on product pages, while the Sold out badge stays. The price comes back when a shopper picks an in-stock variant.
Dawn
Where to paste: Online Store > Themes > Edit theme > Theme settings (gear icon) > Custom CSS. Paste, then Save.
Rule 1 shows "Contact for price" on products tagged hide-price, Rule 2 shows "Log in to see prices" to guests, and Rule 3 hides sold-out prices, so delete the rules you don't need. The editor preview isn't logged in, so it shows the login text everywhere.
Dawn: top of the file
Where to paste: Duplicate your theme. On the copy: Edit code > snippets/price.liquid. Paste directly above the line {%- unless target == null and placeholder == null -%}.
{%- liquid
assign hide_price = false
assign hide_price_text = 'Contact for price'
# Rule 1: products with the tag hide-price
if product.tags contains 'hide-price'
assign hide_price = true
endif
# Rule 2: visitors who are not logged in
if customer == blank
assign hide_price = true
assign hide_price_text = 'Log in to see prices'
endif
# Rule 3: sold-out products and variants
if available == false and placeholder == blank
assign hide_price = true
assign hide_price_text = ''
endif
-%}
{%- if hide_price -%}
<div class="price price--hidden">
<span class="price-item">{{ hide_price_text }}</span>
</div>
{%- else -%}
Horizon: top of the file
Where to paste: Duplicate your theme. On the copy: Edit code > snippets/price.liquid. Paste directly above the line <div ref="priceContainer">.
{%- liquid
assign hide_price = false
assign hide_price_text = 'Contact for price'
# Rule 1: products with the tag hide-price
if product_resource.tags contains 'hide-price'
assign hide_price = true
endif
# Rule 2: visitors who are not logged in
if customer == blank
assign hide_price = true
assign hide_price_text = 'Log in to see prices'
endif
# Rule 3: sold-out products and variants
if product_resource != blank and selected_variant.available == false
assign hide_price = true
assign hide_price_text = ''
endif
-%}
{%- if hide_price -%}
<div ref="priceContainer">
<span class="price">{{ hide_price_text }}</span>
</div>
{%- else -%}
Both themes: close the rule
Where to paste: Add this as the very last line of price.liquid, then Save. Without it the file breaks.
{%- endif -%}
Optional: approved (wholesale) buyers only
Where to paste: Replace Rule 2 in the code above with this, and tag approved customers wholesale in your admin.
# Rule 2: everyone except customers tagged wholesale
unless customer.tags contains 'wholesale'
assign hide_price = true
assign hide_price_text = 'Log in to see prices'
endunless
Replace Add to cart with a Contact for price button
Hides the buy buttons for tagged products and guests and shows a contact or login button instead (change /pages/contact to your page). It only hides the buttons, so set a product to draft if it must never sell online.
Dawn
Where to paste: Edit theme > Products > Default product > Product information > Add block > Custom Liquid, right under the price. Paste, Save.
{%- liquid
assign hide_buy = false
assign button_text = 'Contact for price'
assign button_link = '/pages/contact'
if product.tags contains 'hide-price'
assign hide_buy = true
endif
if customer == blank
assign hide_buy = true
assign button_text = 'Log in to see prices'
assign button_link = routes.account_login_url
endif
-%}
{%- if hide_buy -%}
<style>
.product-form__buttons, .product-form__quantity { display: none; }
</style>
<a class="button button--full-width" href="{{ button_link }}">{{ button_text }}</a>
{%- endif -%}
Horizon
Where to paste: Edit theme > Products > Default product > Product information > Add block > Custom Liquid, right under the price. Paste, Save.
{%- liquid
assign hide_buy = false
assign button_text = 'Contact for price'
assign button_link = '/pages/contact'
if product.tags contains 'hide-price'
assign hide_buy = true
endif
if customer == blank
assign hide_buy = true
assign button_text = 'Log in to see prices'
assign button_link = routes.account_login_url
endif
-%}
{%- if hide_buy -%}
<style>
.buy-buttons-block { display: none; }
</style>
<a class="button" href="{{ button_link }}">{{ button_text }}</a>
{%- endif -%}
Each H3 heading in the product description becomes a tab, plus a Care guide tab (metafield descriptors.care_guide) and a Shipping & returns tab (page shipping-returns) when they exist. Hide the old description afterwards.
Dawn and Horizon
Where to paste: Dawn: Product information > Add block > Custom Liquid. Horizon: under Details in Product information > Add block > Custom Liquid. Paste into Liquid code, drag the block to where the description sits, Save.
{%- liquid
assign first_tab = 'Description'
assign lt = '<'
assign h_open = lt | append: 'h3'
assign h_close = lt | append: '/h3>'
assign source = product.description
assign care = product.metafields.descriptors.care_guide
if care != blank
assign care_html = care | metafield_tag
assign source = source | append: h_open | append: '>Care guide' | append: h_close | append: care_html
endif
assign shared = pages['shipping-returns']
if shared.content != blank
assign source = source | append: h_open | append: '>Shipping & returns' | append: h_close | append: shared.content
endif
assign parts = source | split: h_open
assign uid = 'ptabs-' | append: product.id
assign n = 0
assign tabs = ''
assign panels = ''
-%}
{%- for part in parts -%}
{%- liquid
if forloop.first
assign title = first_tab
assign body = part
assign check = body | strip_html | strip
if check == ''
continue
endif
else
assign head = part | split: h_close | first
assign title = h_open | append: head | strip_html | strip | default: 'Details'
assign body = part | remove_first: head | remove_first: h_close
endif
assign n = n | plus: 1
-%}
{%- capture tabs -%}{{ tabs }}<button type="button" role="tab" id="{{ uid }}-t{{ n }}" aria-controls="{{ uid }}-p{{ n }}" aria-selected="{% if n == 1 %}true{% else %}false{% endif %}"{% if n != 1 %} tabindex="-1"{% endif %}>{{ title | escape_once }}</button>{%- endcapture -%}
{%- capture panels -%}{{ panels }}<div class="ptabs__panel rte" role="tabpanel" id="{{ uid }}-p{{ n }}" aria-labelledby="{{ uid }}-t{{ n }}" tabindex="0"{% if n != 1 %} hidden{% endif %}>{{ body }}</div>{%- endcapture -%}
{%- endfor -%}
{%- if n > 0 -%}
<div class="ptabs" data-ptabs>
<div class="ptabs__list" role="tablist" aria-label="Product details">{{ tabs }}</div>
{{ panels }}
</div>
{%- endif -%}
<style>
.ptabs { width: 100%; min-width: 0; margin: 24px 0; }
.ptabs__list { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid rgba(128, 128, 128, 0.35); }
.ptabs__list::-webkit-scrollbar { display: none; }
.ptabs [role="tab"] { flex: none; margin: 0 0 -1px; padding: 12px 16px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: inherit; font: inherit; opacity: 0.7; cursor: pointer; white-space: nowrap; }
.ptabs [role="tab"][aria-selected="true"] { opacity: 1; font-weight: 600; border-bottom-color: currentColor; }
.ptabs [role="tab"]:focus-visible { outline: 2px solid currentColor; outline-offset: -4px; }
.ptabs__panel { padding: 16px 0; overflow-wrap: break-word; }
.ptabs__panel[hidden] { display: none; }
.ptabs__panel img { max-width: 100%; height: auto; }
.ptabs__panel table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.ptabs__panel :is(th, td) { padding: 6px 10px; border: 1px solid rgba(128, 128, 128, 0.35); text-align: left; }
</style>
<script>
(function () {
if (window.ptabsReady) return;
window.ptabsReady = true;
function pick(tab) {
var box = tab.closest('[data-ptabs]');
box.querySelectorAll('[role="tab"]').forEach(function (t) {
var on = t === tab;
t.setAttribute('aria-selected', on ? 'true' : 'false');
t.tabIndex = on ? 0 : -1;
box.querySelector('#' + t.getAttribute('aria-controls')).hidden = !on;
});
tab.focus();
tab.scrollIntoView({ block: 'nearest', inline: 'nearest' });
}
document.addEventListener('click', function (e) {
var tab = e.target.closest('[data-ptabs] [role="tab"]');
if (tab) pick(tab);
});
document.addEventListener('keydown', function (e) {
var tab = e.target.closest('[data-ptabs] [role="tab"]');
if (!tab) return;
var all = Array.prototype.slice.call(tab.parentNode.querySelectorAll('[role="tab"]'));
var i = all.indexOf(tab);
var go = { ArrowRight: i + 1, ArrowLeft: i - 1 + all.length, Home: 0, End: all.length - 1 }[e.key];
if (go === undefined) return;
e.preventDefault();
pick(all[go % all.length]);
});
})();
</script>
A muted, looping video with a heading and a button on top, which stops for shoppers who reduce motion. Replace the two PASTE links with links from Content > Files, or delete the poster line if you have no image.
Dawn and Horizon
Where to paste: Edit theme > Add section > Custom Liquid. Paste into Liquid code and drag it under the header. Dawn: set Top and Bottom padding to 0. Horizon: set Width to Full. Save.
Upload your font files in Content > Files and paste their links, because Custom CSS only accepts cdn.shopify.com links. Change Brand Sans to your font's name, and use the theme-wide box, not a section's box.
Dawn
Where to paste: Online Store > Themes > Edit theme > Theme settings (gear icon) > Custom CSS. Paste, then Save.
The file_url filter finds the file in Content > Files by its name. Keep the html:root part in Custom CSS, and expect to redo this after a theme update.
Any theme
Where to paste: Duplicate your theme, then Edit code > layout/theme.liquid. Paste just above {{ content_for_header }}. Save.
Adds a 96 x 96 icon and a 180 x 180 apple-touch-icon, because Dawn and Horizon only output 32 x 32. Upload a favicon of at least 180 x 180 pixels, and remember that Google decides which icon it shows.
Dawn and Horizon
Where to paste: Edit code > layout/theme.liquid. Find the line with settings.favicon and paste this under the endif that closes that favicon block. Save.
No snippets match that search. Try another word, or clear the filters.
These Shopify code snippets come from my own step-by-step guides. I tested each one against the real Dawn or Horizon theme files before it went into a guide. Search the Shopify code snippets library above, copy the code with one click, and read the “Where to paste” line so it lands in the right place. Below, I explain where Shopify code snippets belong, how to test a change and how to undo it.
Here is what you will learn:
How to find and copy Shopify code snippets in the library
Where Shopify custom CSS goes, and the limits of the Custom CSS box
Where Shopify Liquid code goes, and when you need Edit code
How to test a change, and how to undo it if something breaks
What changes between Dawn and Horizon
How to use the Shopify code snippets library
Each card in this library of Shopify code snippets does one job, such as “Hide the Sale badge but keep Sold out”. The tags show the theme it was tested on and the kind of code it is.
The free Shopify code snippets page on a computer screen.
Type a word in the search box, like badge, price or cart. The search looks at the title, the note and the code itself.
Pick your theme. Dawn and Horizon also show code marked Any theme, because that code works in both.
Pick a type if you only want one kind. Choose CSS when you don’t want to touch any theme files.
Read the Where to paste line. It names the exact box or file.
Click Copy, paste the code, then click Save.
A card for both themes has a Dawn version and a Horizon version. Pick one theme in the filter and the other version hides. Bigger jobs come in steps, so do every step, in order. Each card links to its full guide, which shows the no-code way first. New guides add new Shopify code snippets, so the count grows over time.
Shopify custom CSS or Liquid: what is the difference?
Most Shopify code snippets fall into two groups, and each group goes in a different place.
CSS changes how things look. It can hide a badge, change a color or set a font. It can’t add new content, read your products or know who is logged in. CSS is the safest code to add, because it never touches the theme files.
Liquid builds the page. Liquid is Shopify’s template language. Shopify Liquid code can read the cart total, a product’s tags or whether a customer is logged in, and then print HTML. A free shipping bar that says “$17.50 away” needs Liquid, because CSS can’t do sums with your cart.
HTML and JavaScript cards usually go in the same places as Liquid.
Code type
What it does
Where it goes
Risk
CSS
Changes the look
Custom CSS box
Low
Liquid
Builds content from store data
Custom Liquid or Edit code
Medium
HTML
Adds fixed content
Page editor or Custom Liquid
Low
JavaScript
Adds behavior
Custom Liquid or Edit code
Medium
Where to paste Shopify custom CSS
Shopify gives modern themes two Custom CSS boxes. You don’t open any theme file for either of them.
The Shopify code snippets page also works on a phone.
The theme-wide Custom CSS box
Go to Online Store and click Edit theme. Open Theme settings (the gear icon) and click Custom CSS. Paste your code and click Save. Code here works on every page of the store, including the cart drawer. It doesn’t work on the checkout page.
The Custom CSS box in one section
Click any section in the theme editor and scroll to the bottom of its settings. That box only styles that one section. It’s handy for hiding prices in one collection grid only.
The limits of Shopify custom CSS
Shopify’s help page on adding custom CSS lists the rules. These are the ones that trip people up:
The theme-wide box holds 1,500 characters. A section box holds 500.
The @import, @charset and @namespace rules are blocked in both boxes.
A section box only allows @media, @container, @layer and @supports. So a font with @font-face must go in the theme-wide box.
The content property isn’t allowed, so you can’t add text with ::before or ::after.
Any link inside the CSS must point to cdn.shopify.com. Upload fonts and images in Content, then Files, and use those links.
A theme update can rename classes, and then your CSS quietly stops working.
Every CSS card here fits well under these limits, but count your characters if you stack several.
One more plus: Shopify copies theme settings, including this box, into an updated theme version. So Shopify custom CSS survives an update even when a file edit might not.
Where to paste Shopify Liquid code
Liquid has two homes. Use the first one whenever the card allows it.
Custom Liquid blocks and sections (no theme files)
Dawn and Horizon both have a Custom Liquid section, which you add with Add section like any other. Product pages also take a Custom Liquid block. Paste your Shopify Liquid code into the Liquid code box and save. To undo it, delete the block. Nothing else in the theme changes.
The box holds up to 50 KB, far more than any card needs. Shopify won’t save it if the Liquid has an error, which is a useful safety net. It also closes any HTML tag you left open, so paste the whole snippet. One limit matters: code in this box can’t read theme settings, such as your favicon. That’s why the favicon card goes in theme.liquid.
Edit code (theme files)
Some Shopify Liquid code changes what the theme itself prints, like the price or the sale badge text. That needs Edit code. Always work on a copy first:
Go to Online Store, then Themes.
Click the … button next to your live theme and choose Duplicate.
On the copy, click … and choose Edit code.
Open the file named on the card. Press Ctrl + F (Command + F on a Mac) to find the line it mentions.
Paste or replace exactly what the card says, then click Save.
Preview the copy and test it. Publish it only when everything works.
Basic, Grow and Advanced plans allow up to 20 themes in your library. If you’re at the limit, delete an old copy before you duplicate. Paid themes need to be bought before you can edit their code.
A red line under the code is Theme Check warning you. Hover over it and read the message before you save.
How to test Shopify code snippets
I test Shopify code snippets the same way on every client store. It takes about five minutes.
Test at phone width. Open the preview on your phone and look for anything that runs off the screen.
Check every place the code touches. Check cart code on the cart page and in the cart drawer. Check price code on product cards, the product page and search results.
Try the odd cases. Test an empty cart, a sold-out product and a product with several variants.
Test as a shopper. The theme editor preview isn’t logged in as a customer. Login rules, like “Log in to see prices”, only show their real result on the live store with a customer account.
Reload when nothing changes. Hard-refresh with Ctrl + Shift + R, then check that you saved the theme you’re previewing.
How to undo Shopify code snippets
How you undo Shopify code snippets depends on where you pasted the code.
Where you pasted
How to undo
Custom CSS box
Delete the code and save
Custom Liquid block or section
Delete the block or section
A theme file
Restore it from Timeline
Anything on a duplicate
Keep the old theme live
For a theme file, open it in Edit code and use the Timeline view. Click an older entry to compare it, then right-click it and choose Restore contents. Shopify notes that this restores one file at a time and replaces the whole file. It can’t bring back a deleted file, and the history is limited. Files in the assets folder have no Timeline at all.
That’s why the duplicate matters. If you break something, you don’t need to remember what you changed. Your live theme is still the untouched one.
Dawn vs Horizon: why Shopify Liquid code differs
Dawn and Horizon are both free Shopify themes, but they are built very differently inside. Shopify Liquid code for one rarely works in the other without changes. Not sure which one you have? My Dawn vs Horizon comparison shows how to tell them apart.
Class names differ. Dawn’s card badge sits in .card__badge, while Horizon uses .product-badges. CSS that names one theme’s classes does nothing in the other.
Font names differ. Dawn’s body font is –font-body-family. Horizon uses –font-body–family, with two dashes in the middle. Miss one dash and the font never changes.
Files differ. Dawn’s cart drawer and cart page use separate files. Horizon’s share one summary file, so one line covers both.
Horizon has more settings. Some jobs that need code in Dawn are a checkbox in Horizon, like removing “Powered by Shopify”. The cards say so.
Custom Liquid sections start differently. Dawn’s adds 40 px of padding on top and 52 px at the bottom. Horizon’s starts at 0 and has a Width setting. For an edge-to-edge bar, set Dawn’s padding to 0 and Horizon’s width to Full.
A paid theme uses its own class names and file names, so start with the Any theme cards there.
Worked examples with Shopify code snippets
Worked example 1: hide the Sale badge on Dawn (CSS)
A Dawn store ends a sale but keeps the compare-at prices for a week. The owner wants the crossed-out price to stay and the badge to go.
Type badge in the search box and pick Dawn.
Find “Hide the Sale badge but keep Sold out” and click Copy.
In the theme editor, open Theme settings, then Custom CSS. Paste and save.
Check a sale product and a sold-out product on a phone. The Sale badge is gone, and Sold out still shows.
To undo it, delete those lines from the box. No theme file is touched. The full Shopify sale badge guide covers color, text and “% off” too.
Worked example 2: add a free shipping bar on Horizon (Liquid)
A Horizon store ships free over $50. The owner wants the cart to show how much is left to spend.
Search shipping and open the free shipping bar card.
Duplicate the theme, then open Edit code on the copy.
Step 1: add a file named free-shipping-bar.liquid in the snippets folder. Paste the Shopify Liquid code, keep USD and 50, and save.
Step 2: open snippets/cart-summary.liquid. Paste the one render line right above the cart-totals line.
Preview the copy. With $32.50 in the cart, the bar says “$17.50 away from free shipping”. At $50, it says the order ships free.
Check the drawer and the cart page, then publish the copy.
Pasting Liquid into Custom CSS. The CSS box only takes CSS. Anything with {% or {{ belongs in a Custom Liquid block or a theme file.
Using Shopify code snippets for the wrong theme. Check your theme’s name in Online Store, then Themes. Copy the version that matches it.
Editing the live theme. One typo in a theme file can break a page for every shopper. Work on a duplicate.
Skipping a step. Cards with steps need every one of them. Leave one out and the Shopify Liquid code does nothing, or the page breaks.
Forgetting file edits at update time. Shopify keeps your code edits in an update only when they don’t clash with it. Before you update, check my theme update tracker and test your Shopify code snippets again on the new version.
More free tools like this one are on the Shopify tools page.
FAQ
Questions about the Code Snippets Library
Can’t find your answer? Ask me directly, I’m happy to help.
Go to Online Store, click Edit theme, open Theme settings and click Custom CSS. Shopify custom CSS there works on every page except checkout. For one section only, use the box at the bottom of that section’s settings.
Why is my Shopify custom CSS not working?
Usually the class name comes from a different theme, so the rule matches nothing. Also check for a missing bracket, a blocked rule like @import, or the content property, which Shopify doesn’t allow. Then hard-refresh the page.
What is the Shopify custom CSS limit?
The theme-wide box for Shopify custom CSS holds 1,500 characters, and each section’s box holds 500. If you need more, combine rules, delete comments, or move the CSS into a theme file on a duplicate theme.
Can you add your own code to Shopify?
Yes. Add CSS in the Custom CSS box, Shopify Liquid code and HTML in a Custom Liquid block, and anything else through Edit code. Paid themes need to be bought before you can edit their code.
What is the difference between Shopify snippets and sections?
A section is a part of a page that you can add, move and set up in the theme editor. A snippet is a small reusable file in the snippets folder that sections pull in with a render line. Don’t confuse them with the Shopify code snippets in this library, which are simply ready-made pieces of code.
Can I add Shopify custom CSS for mobile only?
Yes. Wrap your Shopify custom CSS in a media query, such as @media (max-width: 749px), and it only applies to small screens. Dawn and Horizon switch to their phone layout below 750 pixels.
More free tools
Other free Shopify tools
◎ Free calculator
Shopify Fee Calculator
Add up plan, card, PayPal and third-party fees, then see which Shopify plan is cheapest for you.