JKIRK
1
Hi,
I have created a countdown and want to hide it after the expiry date which is the 17th of December.
The countdown section is called AnnouncementBar__Wrapper40.
Here is the code:
{%- if section.settings.enable_bar -%}
{%- unless section.settings.home_page_only and template != 'index' -%}
<div class="AnnouncementBarnew">
<div class="AnnouncementBar__Wrapper60">
<div class="AnnouncementBartext">
{{ section.settings.content }}
</div>
<div class="AnnouncementBartext">
{{ section.settings.content2 }}
</div>
</div>
<div class="AnnouncementBar__Wrapper40">
{% include 'countdown-timer',
title: "CHRISTMAS LAST ORDER",
end_date: "Dec 17, 2022"
%}
</div>
</div>
{%- endunless -%}
{%- endif -%}
Ujjaval
2
JKIRK
3
Hi, this is the code I am using but when it expires it goes into minus numbers and still displays.
Here is the test https://apm-staging.myshopify.com/
Hi @JKIRK ,
Please send me the code of countdown-timer.liquid file, I will check it for you
@JKIRK
Try use this code for timer snippet code
.multicolumn .title-wrapper-with-link {
display: flex;
justify-content: center;
}
{% if end_date != blank %}
{% if title != blank %}#### {{ title }}{% endif %}
00
Days
00
Hours
00
Minutes
00
Seconds
{% endif %}
JKIRK
6
Thanks for the reply, I would like to hide the timer once it has expired.
Hi @JKIRK
You can try to use this code
{% liquid
assign current_time = "now" | date: "%s" | times: 1
assign expire_time = "2022-12-17" | date: "%s" | times: 1
assign count_time = expire_time | minus: current_time
%}
{%- if section.settings.enable_bar -%}
{%- unless section.settings.home_page_only and template != 'index' -%}
{{ section.settings.content }}
{{ section.settings.content2 }}
{% if count_time > 0 %}
{% include 'countdown-timer',
title: "CHRISTMAS LAST ORDER",
end_date: "Dec 17, 2022"
%}
{% endif %}
{%- endunless -%}
{%- endif -%}
JKIRK
8
Great thanks, it works. Can I add a time as well?