{%- comment -%} MIT License · (c) 2026 Lintel · https://lintelagency.com/resources/shopify-sections {%- endcomment -%} {%- comment -%} Countdown banner: heading, text, button and a timer to an end date and time. Three layouts: inline bar, banner over an image or color, split image and text. The server renders the end date as text ("Ends 31 December"); a small custom element turns the timer on and updates it every second (or every minute without seconds). The end time is read in the UTC offset chosen in the settings, so every visitor sees the same deadline. Depends on: snippets/lib-button.liquid, snippets/lib-image.liquid {%- endcomment -%} {%- liquid assign s = section.settings assign heading_tag = s.heading_tag | default: 'h2' assign eager = false if section.index <= 2 assign eager = true endif assign end_date = s.end_date | strip assign end_time = s.end_time | strip | default: '23:59' if end_time.size == 4 assign end_time = '0' | append: end_time endif assign end_iso = '' if end_date.size == 10 assign end_iso = end_date | append: 'T' | append: end_time | append: ':00' | append: s.utc_offset endif comment Server-side state: compare the deadline with the render time. Cached pages can be a little stale, so the custom element re-checks in the browser. endcomment assign ended = false if end_iso != blank assign end_epoch = end_iso | date: '%s' | plus: 0 assign now_epoch = 'now' | date: '%s' | plus: 0 if end_epoch > 0 and end_epoch <= now_epoch assign ended = true endif comment Midday keeps the printed day stable whatever the shop's time zone is. endcomment assign end_date_text = end_date | append: ' 12:00' | date: '%-d %B' endif assign hide_section = false if ended and s.end_behavior == 'hide' and request.design_mode != true assign hide_section = true endif assign has_image = false if s.image != blank or s.image_mobile != blank assign has_image = true endif -%} {%- unless hide_section -%}
{%- if s.ends_prefix != blank %}{{ s.ends_prefix | escape }} {% endif -%} {{- end_date_text -}}
{%- if s.end_behavior != 'zero' -%}{%- if s.end_behavior == 'hide' -%} This countdown has ended, so the section is hidden on your live store. {%- else -%} {{- s.ended_message | escape -}} {%- endif -%}
{%- endif -%}Set an end date as YYYY-MM-DD to show the countdown.
{%- endif -%} {%- if s.button_label != blank -%}Vases, candles and tableware, while the kiln cools down for the year.
"}, {"type": "header", "content": "Countdown"}, {"type": "text", "id": "end_date", "label": "End date", "info": "Format YYYY-MM-DD, for example 2026-12-31.", "default": "2026-12-31"}, {"type": "text", "id": "end_time", "label": "End time", "info": "24-hour format HH:MM, for example 23:59. Leave blank for 23:59.", "default": "23:59"}, { "type": "select", "id": "utc_offset", "label": "Time zone of the end time (UTC offset)", "info": "The date and time above are read in this offset, so the timer ends at the same moment for every visitor wherever they are. Pick your shop's offset, and remember daylight saving time: for example UTC+01:00 is winter time in Berlin, UTC+02:00 summer time.", "options": [ {"value": "-12:00", "label": "UTC−12:00"}, {"value": "-11:00", "label": "UTC−11:00"}, {"value": "-10:00", "label": "UTC−10:00 (Hawaii)"}, {"value": "-09:30", "label": "UTC−09:30"}, {"value": "-09:00", "label": "UTC−09:00 (Alaska)"}, {"value": "-08:00", "label": "UTC−08:00 (Pacific standard)"}, {"value": "-07:00", "label": "UTC−07:00 (Mountain standard, Pacific daylight)"}, {"value": "-06:00", "label": "UTC−06:00 (Central standard)"}, {"value": "-05:00", "label": "UTC−05:00 (Eastern standard, Central daylight)"}, {"value": "-04:00", "label": "UTC−04:00 (Atlantic, Eastern daylight)"}, {"value": "-03:30", "label": "UTC−03:30"}, {"value": "-03:00", "label": "UTC−03:00"}, {"value": "-02:00", "label": "UTC−02:00"}, {"value": "-01:00", "label": "UTC−01:00"}, {"value": "+00:00", "label": "UTC±00:00 (London winter)"}, {"value": "+01:00", "label": "UTC+01:00 (Central Europe winter, London summer)"}, {"value": "+02:00", "label": "UTC+02:00 (Central Europe summer)"}, {"value": "+03:00", "label": "UTC+03:00"}, {"value": "+03:30", "label": "UTC+03:30"}, {"value": "+04:00", "label": "UTC+04:00"}, {"value": "+04:30", "label": "UTC+04:30"}, {"value": "+05:00", "label": "UTC+05:00"}, {"value": "+05:30", "label": "UTC+05:30 (India)"}, {"value": "+05:45", "label": "UTC+05:45"}, {"value": "+06:00", "label": "UTC+06:00"}, {"value": "+06:30", "label": "UTC+06:30"}, {"value": "+07:00", "label": "UTC+07:00"}, {"value": "+08:00", "label": "UTC+08:00"}, {"value": "+09:00", "label": "UTC+09:00"}, {"value": "+09:30", "label": "UTC+09:30"}, {"value": "+10:00", "label": "UTC+10:00"}, {"value": "+10:30", "label": "UTC+10:30"}, {"value": "+11:00", "label": "UTC+11:00"}, {"value": "+12:00", "label": "UTC+12:00"}, {"value": "+13:00", "label": "UTC+13:00"}, {"value": "+14:00", "label": "UTC+14:00"} ], "default": "+00:00" }, {"type": "checkbox", "id": "show_seconds", "label": "Show seconds", "info": "Without seconds the timer updates once a minute.", "default": true}, {"type": "text", "id": "label_days", "label": "Days label", "default": "Days"}, {"type": "text", "id": "label_hours", "label": "Hours label", "default": "Hours"}, {"type": "text", "id": "label_minutes", "label": "Minutes label", "default": "Minutes"}, {"type": "text", "id": "label_seconds", "label": "Seconds label", "default": "Seconds", "visible_if": "{{ section.settings.show_seconds }}"}, {"type": "text", "id": "ends_prefix", "label": "End date prefix", "info": "Shown before the end date, e.g. \"Ends 31 December\". Visible before the timer starts; screen readers hear it with the time left, updated once a minute.", "default": "Ends"}, { "type": "select", "id": "end_behavior", "label": "When the timer reaches zero", "info": "The section also checks the end date when the page is built, so an ended offer does not flash on load.", "options": [ {"value": "hide", "label": "Hide the section"}, {"value": "message", "label": "Show a message"}, {"value": "zero", "label": "Keep showing 00"} ], "default": "message" }, {"type": "text", "id": "ended_message", "label": "Ended message", "default": "This offer has ended. Thank you for shopping with us.", "visible_if": "{{ section.settings.end_behavior == 'message' }}"}, {"type": "header", "content": "Image"}, {"type": "image_picker", "id": "image", "label": "Desktop image", "info": "Optional in the bar and banner layouts (shown behind the text); the split layout shows it beside the text."}, {"type": "image_picker", "id": "image_mobile", "label": "Mobile image", "info": "Optional. Shown below 750px; a portrait crop works best."}, { "type": "select", "id": "image_position", "label": "Image position on desktop", "options": [ {"value": "left", "label": "Left"}, {"value": "right", "label": "Right"} ], "default": "left", "visible_if": "{{ section.settings.layout == 'split' }}" }, {"type": "range", "id": "overlay_opacity", "label": "Overlay opacity", "min": 0, "max": 90, "step": 5, "unit": "%", "default": 40, "visible_if": "{{ section.settings.layout != 'split' }}", "info": "The overlay uses the background color."}, {"type": "header", "content": "Button"}, {"type": "text", "id": "button_label", "label": "Button label", "default": "Shop the sale"}, {"type": "url", "id": "button_url", "label": "Button link"}, { "type": "select", "id": "button_style", "label": "Button style", "options": [ {"value": "primary", "label": "Solid"}, {"value": "outline", "label": "Outline"}, {"value": "text", "label": "Text link"} ], "default": "primary" }, {"type": "checkbox", "id": "button_new_tab", "label": "Open link in a new tab", "default": false}, {"type": "header", "content": "Layout"}, { "type": "select", "id": "layout", "label": "Layout", "options": [ {"value": "bar", "label": "Inline bar"}, {"value": "banner", "label": "Banner"}, {"value": "split", "label": "Split image and text"} ], "default": "banner" }, { "type": "select", "id": "content_valign_mobile", "label": "Content position on mobile", "info": "Place the text where the mobile image has space.", "options": [ {"value": "top", "label": "Top"}, {"value": "center", "label": "Middle"}, {"value": "bottom", "label": "Bottom"} ], "default": "center", "visible_if": "{{ section.settings.layout == 'banner' }}" }, { "type": "select", "id": "digit_style", "label": "Digit style", "options": [ {"value": "boxes", "label": "Boxes"}, {"value": "plain", "label": "Plain with colons"} ], "default": "boxes" }, {"type": "text_alignment", "id": "text_alignment", "label": "Alignment on desktop", "info": "Banner and split layouts.", "default": "center"}, { "type": "select", "id": "text_alignment_mobile", "label": "Alignment on mobile", "options": [ {"value": "left", "label": "Left"}, {"value": "center", "label": "Center"}, {"value": "right", "label": "Right"} ], "default": "center" }, {"type": "header", "content": "Colors"}, {"type": "color", "id": "color_bg", "label": "Background", "default": "#1C1917"}, {"type": "color_background", "id": "color_bg_gradient", "label": "Background gradient", "info": "Optional. Covers the background color."}, {"type": "color", "id": "color_text", "label": "Text", "default": "#FAFAF9"}, {"type": "color", "id": "color_accent", "label": "Accent (button)", "default": "#E8B04A"}, {"type": "color", "id": "color_accent_text", "label": "Text on accent", "default": "#1C1917"}, {"type": "header", "content": "Spacing and visibility"}, {"type": "range", "id": "padding_top", "label": "Top padding on desktop", "min": 0, "max": 200, "step": 4, "unit": "px", "default": 64}, {"type": "range", "id": "padding_bottom", "label": "Bottom padding on desktop", "min": 0, "max": 200, "step": 4, "unit": "px", "default": 64}, {"type": "range", "id": "padding_top_mobile", "label": "Top padding on mobile", "min": 0, "max": 160, "step": 4, "unit": "px", "default": 40}, {"type": "range", "id": "padding_bottom_mobile", "label": "Bottom padding on mobile", "min": 0, "max": 160, "step": 4, "unit": "px", "default": 40}, { "type": "select", "id": "show_on", "label": "Show on", "options": [ {"value": "all", "label": "All devices"}, {"value": "desktop", "label": "Desktop only"}, {"value": "mobile", "label": "Mobile only"} ], "default": "all" }, {"type": "text", "id": "anchor_id", "label": "Anchor ID", "info": "Optional. Link to this section with #your-id."}, {"type": "header", "content": "Motion"}, {"type": "checkbox", "id": "animate", "label": "Animate digits when they change", "info": "Always off when the visitor prefers reduced motion.", "default": true} ], "presets": [ { "name": "Lib · Countdown banner" } ] } {% endschema %}