What a DIY Liquid + JavaScript timer involves
This is the approach a developer would usually take on an Online Store 2.0 theme. It's described in steps rather than as copy-paste code, because the exact markup depends on your theme.
- Back up the themeDuplicate your live theme before changing anything, so you can roll back. Code changes go live as soon as you save them on the published theme.
- Store the deadline in a metafieldCreate a product metafield definition (Add definition) with the type Date and time, for example named "Sale ends". Shopify stores this value in ISO 8601 format in UTC. Then fill in the date and time on each product that should show a timer.
- Print it with LiquidOn the product page, add a Custom Liquid block in the theme editor (or edit the product section's code). Inside it, check that the metafield has a value, and only then output an empty container element that carries the deadline as a data attribute. Convert the date to a Unix timestamp with Liquid's date filter and the %s format so JavaScript can read it as a plain number.
- Count down with JavaScriptAdd a small script that finds the container, reads the timestamp, multiplies it by 1,000 to get milliseconds and subtracts the current time from Date.now(). Every second (setInterval with 1,000 ms), split the remaining milliseconds into days, hours, minutes and seconds with whole-number division and write them into the container.
- Hide it when time runs out, in JavaScriptWhen the remaining time reaches zero, stop the interval and remove the container. Run the same check as soon as the script loads, so a deadline that passed earlier never flashes on screen. Don't rely on Liquid's 'now' to hide it: Shopify's documentation notes that 'now' reflects when the Liquid was last rendered and might not update on every page view because of caching.
- Style and test itAdd CSS that uses your theme's fonts and colours, wrap any animation in a prefers-reduced-motion media query, and test on a phone, on a product without the metafield, and after the deadline passes.
Where DIY timers usually break
- Two dates for one deadline. The timer reads your metafield; the discount has its own dates in Discounts. Change one and forget the other, and the timer shows a deadline that isn't true. Liquid's discount objects describe what's applied to a cart, not a discount's schedule, so the usual DIY fix is discipline, not code.
- Many products. A metafield per product is fine for five products and tedious for 300. You'd need bulk editing, or code that reads a date from a collection or a theme setting instead.
- Collection pages. Badges on product cards mean editing the theme's product card snippet, which appears on collection pages, search results and home page sections, each with its own layout quirks.
- Theme updates. Shopify's help docs say code edits are carried into a theme update only if they don't conflict with it; otherwise the update reports that code edits couldn't be included and you copy them over yourself.
- Hand-over. Whoever wrote the code is the only one who can change it confidently. Six months later, a new sale date means opening theme files again.
DIY vs a no-code app
| Coded in Liquid + JS | QuickOff (no code) | |
|---|---|---|
| Setup | A few hours for one product page timer, more for cards | Create a timer, add the app block, turn on the embed |
| Follows a Shopify discount | No, you keep dates in sync by hand | Yes: reads the discount's start and end, follows changes |
| Which products | Whatever you code: per-product metafields or custom logic | All, specific products or specific collections |
| Collection page badges | Edit the card snippet | App embed, switched on once |
| Hides when it ends | Only if you code it | Automatically |
| Theme updates | Code edits may need copying over | App block and embed are managed in the theme editor, not theme files |
| Daily recurring, country targeting | Significant extra code | Pro (daily recurring) and Plus (country targeting) |
| Cost | Your or a developer's time | Free plan (2 timers); Pro $7.99/month |
The no-code route with QuickOff
- Install and create a timerInstall QuickOff from the Shopify App Store and create a timer: an end date, a Shopify discount to follow, fixed minutes per visitor, or daily recurring (Pro).
- Choose products and textPick the products or collections, write the title and sub-heading, and keep the Match my theme style so the timer uses your theme's fonts, colours and corner radius.
- Place itIn Online Store → Edit theme, add the QuickOff app block to the product page with Add block → Apps, and switch on the app embed under App embeds for product card badges. Full walkthrough: add a timer to product pages.
- PublishThe timer goes live, and it disappears by itself when it ends. If you sync it to a discount, change the discount's dates and the timer follows. See discount-synced timers.
On performance, the two routes are closer than people expect. QuickOff places the timer's data in the page through an app metafield, so the storefront makes no extra calls to QuickOff's servers, and it loads one small script. Details in will a timer slow down my store?.
When coding it yourself makes sense
- You have a developer who already maintains your theme and is happy to own the code.
- You need one timer on one template with a date that rarely changes, like a yearly event.
- You want behaviour no app offers and are prepared to maintain it through theme updates.
Whichever route you choose, the deadline must be real. A coded timer that resets on every visit is just as misleading as an app that does it; see our guide to honest urgency.
Frequently asked questions
Can I add a countdown timer to Shopify without an app?
Yes. Store the deadline in a Date and time metafield, output it in a Custom Liquid block on the product page and count down with a short JavaScript snippet. It works well for simple cases; it doesn't follow your discounts or hide itself unless you code that.
Why does my Liquid countdown show the wrong time or stay up after the deadline?
Liquid's 'now' is the time the page was last rendered, which can be cached, so it's not reliable for live countdowns. Do the counting and the hiding in JavaScript in the shopper's browser.
Will a theme update remove my custom timer code?
Not necessarily. Shopify carries code edits into an update when they don't conflict with it. When they do conflict, the update says the edits couldn't be included and you need to copy them over. Keep a copy of your code.
Do timer apps edit my theme code?
QuickOff doesn't need you to edit theme files. It's added through an app block on the product page and an app embed for product cards, both managed in the theme editor.
Is a coded timer faster than an app?
A well-written coded timer is light. QuickOff is built to be light too: timer data sits in the page itself, there are no extra calls to QuickOff's servers, and it loads one small script.
Sources
- Shopify.dev: Liquid date filter (note on 'now' and caching)
- Shopify Help Center: Metafield content types (Date and time)
- Shopify Help Center: Creating custom metafield definitions
- Shopify Help Center: Editing theme code
- Shopify Help Center: Updating themes (code edits and conflicts)
- Shopify Help Center: Extending themes with apps (Custom Liquid, app blocks, app embeds)
- MDN: Date.now()