All guides › Free shipping message on the product page
Shopify free shipping message on the product page, without an app
Disclosure: I build No-App Sections; this guide was written with AI assistance. The code on this page was written for this guide. It passes Shopify's Theme Check inside Dawn 16.0.0 and automated tests in headless Chrome, run against Dawn's own cart and variant events with mocked store data. It hasn't been run on a live store yet, so try it on a duplicate theme first.
A free shipping bar in the cart only helps shoppers who have already added something. On the product page, the useful message is different: "Spend £12.00 more and your order ships free", or better, "Add this to your cart and your order ships free" when the product in front of them closes the gap. This guide builds that message as a Dawn block, with no app.
What the message has to know
Three numbers, all in pence or cents, the way Liquid stores money:
- Your threshold, from Settings → Shipping and delivery. £50.00 is
5000. - What's already in the cart:
cart.total_price. Thecartobject is available on every page, not only the cart page. - The price of the selected variant:
product.selected_or_first_available_variant.price.
That gives three states:
| Situation | Message |
|---|---|
| Cart already at or over the threshold | Your order already qualifies for free shipping. |
| One of this variant would reach it | Add this to your cart and your order ships free. |
| Still short, even with this variant | Spend £30.00 more and your order ships free. |
Liquid can work all of that out on page load. Two things change afterwards without a reload: the shopper picks another variant, and the shopper adds to cart (Dawn's cart drawer or pop-up opens instead of leaving the page). Dawn announces both through its small pub/sub helper in assets/pubsub.js, so a few lines of JavaScript keep the message right.
The block code
Change assign threshold = 5000 to your own minimum in pence/cents. Everything else can stay as it is.
{%- comment -%}
Free shipping message for the product page (Dawn "Custom Liquid" block).
Set the threshold to match Settings > Shipping and delivery, in pence/cents: 5000 = £50.00.
{%- endcomment -%}
{%- liquid
assign threshold = 5000
assign variant = product.selected_or_first_available_variant
assign remaining = threshold | minus: cart.total_price
-%}
<p
class="pfs"
id="pfs-{{ section.id }}"
data-section="{{ section.id }}"
data-threshold="{{ threshold }}"
data-cart-total="{{ cart.total_price }}"
data-variant-price="{{ variant.price }}"
role="status"
>
{%- if remaining <= 0 -%}
Your order already qualifies for free shipping.
{%- elsif variant.price >= remaining -%}
Add this to your cart and your order ships free.
{%- else -%}
Spend {{ remaining | money }} more and your order ships free.
{%- endif -%}
</p>
<style>
.pfs { margin: 0 0 1rem; font-size: 1.4rem; }
</style>
<script>
(function () {
var el = document.getElementById('pfs-{{ section.id }}');
if (!el) return;
var moneyFormat = {{ shop.money_format | json }};
var threshold = parseInt(el.dataset.threshold, 10);
var cartTotal = parseInt(el.dataset.cartTotal, 10);
var variantPrice = parseInt(el.dataset.variantPrice, 10);
function group(n, decimals, thousands, point) {
var parts = (n / 100).toFixed(decimals).split('.');
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, thousands);
return parts.join(point);
}
function money(cents) {
return moneyFormat.replace(/\{\{\s*(\w+)\s*\}\}/, function (match, key) {
switch (key) {
case 'amount_no_decimals': return group(cents, 0, ',', '.');
case 'amount_with_comma_separator': return group(cents, 2, '.', ',');
case 'amount_no_decimals_with_comma_separator': return group(cents, 0, '.', ',');
case 'amount_with_space_separator': return group(cents, 2, ' ', ',');
case 'amount_no_decimals_with_space_separator': return group(cents, 0, ' ', ',');
case 'amount_with_apostrophe_separator': return group(cents, 2, "'", '.');
default: return group(cents, 2, ',', '.');
}
});
}
function render() {
var remaining = threshold - cartTotal;
if (remaining <= 0) el.textContent = 'Your order already qualifies for free shipping.';
else if (variantPrice >= remaining) el.textContent = 'Add this to your cart and your order ships free.';
else el.textContent = 'Spend ' + money(remaining) + ' more and your order ships free.';
}
function init() {
if (typeof subscribe !== 'function' || typeof PUB_SUB_EVENTS === 'undefined') return;
/* The theme editor can re-render this block: drop the old listeners first. */
var store = (window.pfsUnsubscribe = window.pfsUnsubscribe || {});
if (store[el.dataset.section]) store[el.dataset.section].forEach(function (off) { off(); });
store[el.dataset.section] = [
subscribe(PUB_SUB_EVENTS.cartUpdate, function () {
fetch(window.routes.cart_url + '.js', { headers: { Accept: 'application/json' } })
.then(function (r) { return r.json(); })
.then(function (cart) { cartTotal = cart.total_price; render(); })
.catch(function () {});
}),
subscribe(PUB_SUB_EVENTS.variantChange, function (event) {
if (!event.data || event.data.sectionId !== el.dataset.section || !event.data.variant) return;
variantPrice = event.data.variant.price;
render();
})
];
}
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', init);
else init();
})();
</script>
How it works:
- The Liquid at the top renders the correct sentence straight away, so the message is right even before (or without) JavaScript.
PUB_SUB_EVENTS.variantChangeis published by Dawn'sproduct-info.jswith the new variant inevent.data.variant. The block only reacts whenevent.data.sectionIdis its own section, so a quick-add pop-up on the same page can't change it.PUB_SUB_EVENTS.cartUpdatefires after Dawn's add to cart, cart drawer and cart page changes. The block then asks Shopify for/cart.jsand uses itstotal_price.- The JavaScript formats money with your store's own format (
shop.money_format), including the comma-decimal and no-decimal variants, so "£12.00" or "12,00 €" looks the same as the price above it. - Dawn loads
pubsub.jswithdefer, after this inline script runs, so the listeners are attached onDOMContentLoaded. In the theme editor, the block removes its old listeners before adding new ones.
Add it to your product page
- Duplicate your theme. In Online Store → Themes, open the … menu on your live theme and choose Duplicate. Work on the copy.
- Open the product template. Click Customize on the copy, then pick Products → Default product from the page selector at the top.
- Add a Custom Liquid block. In the Product information section, click Add block → Custom Liquid. Drag it to just below Price.
- Paste the code. Paste the block code into the Custom Liquid box and set your threshold. Click Save.
- Test, then publish. Preview the copy with the checklist below. When it behaves, publish the copy, or repeat the steps on your live theme.
Other themes
Most Online Store 2.0 themes have a Custom Liquid block (sometimes called "Custom liquid" or "Liquid"). The Liquid half works in all of them, so the message is right whenever the page loads. The live updates depend on Dawn's subscribe and PUB_SUB_EVENTS globals. If your theme doesn't have them, the script quietly does nothing and the message corrects itself on the next page view. Themes built on Dawn (many free and paid themes are) usually keep the same pub/sub file.
Things to check before you rely on it
- Use the same number as your shipping rate. If the free rate starts at £50, the threshold must be
5000, not50. - Discounts.
cart.total_priceis the cart total after discounts that Shopify has already applied to the cart. A discount code typed in at checkout isn't known yet, so test a discounted order at checkout to see where your free rate actually starts. - Other currencies. If you sell in more than one currency with Shopify Markets, a fixed
5000is wrong for other currencies. Use the multi-currency version instead. - Quantity. "Add this to your cart" assumes one unit. That's deliberate: it's the cheapest way for the shopper to qualify.
Testing checklist
- Empty cart, a £15 product: "Spend £35.00 more…".
- Pick a dearer variant that covers the gap: the sentence switches to "Add this to your cart…" without a reload.
- Add to cart from the drawer-enabled product page: the message updates when the drawer opens.
- Go over the threshold: "Your order already qualifies…".
- Browser console (F12): no errors.
Want a progress bar in the cart too? It's free
This block is for the product page. For the header or cart, I've packaged a free free-shipping bar section: a progress bar with your threshold, messages and colours set in the theme editor. It uses your store's money format and refreshes after the theme's AJAX cart changes. It's tested on Dawn and Horizon. Other Online Store 2.0 themes may need small style tweaks. You get it by entering your email on a short form.
FAQ
Why does it say "Add this to your cart" when I'm buying two?
It looks at one unit of the selected variant, because that is the cheapest way to qualify. Once you add to cart, the message switches to "already qualifies".
Does it use the sale price?
Yes. variant.price is the price the shopper pays now. The compare-at price is ignored.
Can I use a percentage bar here instead of a sentence?
You can, but on a product page a sentence tied to this product converts the idea better: it answers "will this one get me free shipping?". For a bar, use the free section or the Dawn cart-drawer tutorial.
Will it slow the page down?
No extra request happens on page load. It only fetches /cart.js after the cart changes, which is a small JSON file.
Can I change the wording?
Yes, but change it in both places: the Liquid at the top (first page load) and the render() function (live updates), or the text will jump after the first cart change.