New Shopify Certification now available: Liquid Storefronts for Theme Developers

Adding live counter on the DAWN theme

Solved
mshresthafashio
Tourist
4 0 0

How can i add a live counter on the DAWN theme?

mshresthafashio_0-1699674132838.png

 

Accepted Solution (1)
theycallmemakka
Shopify Partner
993 201 213

This is an accepted solution.

Hi @mshresthafashio ,

 

If you are using a default dawn theme, you can use below Section to add a counter to your site.

 

Follow below steps to add the section to your site.

 

Step 1:Go the theme > Edit Code

makkaomakka_0-1699675239132.png

 

 

Step 2: Create a new section

makkaomakka_1-1699675274855.png

 

Step 3: Copy below conten to the new section

makkaomakka_2-1699675298272.png

 

{{ 'section-rich-text.css' | asset_url | stylesheet_tag }}
{%- style -%}
  .section-{{ section.id }}-padding {
    padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px;
    padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px;
  }

  @media screen and (min-width: 750px) {
    .section-{{ section.id }}-padding {
      padding-top: {{ section.settings.padding_top }}px;
      padding-bottom: {{ section.settings.padding_bottom }}px;
    }
  }
{%- endstyle -%}

<div class="isolate{% unless section.settings.full_width %} page-width{% endunless %}">
  <div class="rich-text content-container color-{{ section.settings.color_scheme }} gradient{% if section.settings.full_width %} rich-text--full-width content-container--full-width{% endif %} section-{{ section.id }}-padding">
    <div class="rich-text__wrapper rich-text__wrapper--{{ section.settings.desktop_content_position }}{% if section.settings.full_width %} page-width{% endif %}">
      <div class="rich-text__blocks {{ section.settings.content_alignment }}">
                      <h2
                class="rich-text__heading rte inline-richtext {{ section.settings.block_heading_size }}{% if settings.animations_reveal_on_scroll %} scroll-trigger animate--slide-in{% endif %}"
                {% if settings.animations_reveal_on_scroll %}
                  data-cascade
                  style="--animation-order: 0;"
                {% endif %}
              >
                <div id="countdown" class="countdown" style="opacity: 0;">
                  <span id="hours">00</span>:<span id="minutes">00</span>:<span id="seconds">00</span>
                </div>
                  <style>
                    .countdown {
                      display: inline;
                      text-align: center;
                      font-weight: 600; 
                    }
                  </style>
                <script>const targetDate=new Date;targetDate.setUTCHours(17,0,0,0);const countdownElement=document.getElementById("countdown");function updateCountdown(){let t=new Date,e=targetDate-t;e>0?(document.getElementById("hours").textContent=formatTime(Math.floor(e/36e5)),document.getElementById("minutes").textContent=formatTime(Math.floor(e%36e5/6e4)),document.getElementById("seconds").textContent=formatTime(Math.floor(e%6e4/1e3))):(targetDate.setDate(targetDate.getDate()+1),targetDate.setUTCHours(17,0,0,0))}function formatTime(t){return t<10?`0${t}`:t}updateCountdown(),document.getElementById("countdown").style.opacity=1,setInterval(updateCountdown,1e3);</script>
              </h2>
      </div>
    </div>
  </div>
</div>

{% schema %}
{
  "name": "Countdown",
  "tag": "section",
  "class": "section",
  "disabled_on": {
    "groups": ["header", "footer"]
  },
  "settings": [
        {
        "type": "inline_richtext",
        "id": "block_heading",
        "default": "Talk about your brand",
        "label": "t:sections.rich-text.blocks.heading.settings.heading.label"
      },
      {
        "type": "select",
        "id": "block_heading_size",
        "options": [
          {
            "value": "h2",
            "label": "t:sections.all.heading_size.options__1.label"
          },
          {
            "value": "h1",
            "label": "t:sections.all.heading_size.options__2.label"
          },
          {
            "value": "h0",
            "label": "t:sections.all.heading_size.options__3.label"
          },
          {
            "value": "hxl",
            "label": "t:sections.all.heading_size.options__4.label"
          }
        ],
        "default": "h1",
        "label": "t:sections.all.heading_size.label"
      },
    {
      "type": "select",
      "id": "desktop_content_position",
      "options": [
        {
          "value": "left",
          "label": "t:sections.rich-text.settings.desktop_content_position.options__1.label"
        },
        {
          "value": "center",
          "label": "t:sections.rich-text.settings.desktop_content_position.options__2.label"
        },
        {
          "value": "right",
          "label": "t:sections.rich-text.settings.desktop_content_position.options__3.label"
        }
      ],
      "default": "center",
      "label": "t:sections.rich-text.settings.desktop_content_position.label",
      "info": "t:sections.rich-text.settings.desktop_content_position.info"
    },
    {
      "type": "select",
      "id": "content_alignment",
      "options": [
        {
          "value": "left",
          "label": "t:sections.rich-text.settings.content_alignment.options__1.label"
        },
        {
          "value": "center",
          "label": "t:sections.rich-text.settings.content_alignment.options__2.label"
        },
        {
          "value": "right",
          "label": "t:sections.rich-text.settings.content_alignment.options__3.label"
        }
      ],
      "default": "center",
      "label": "t:sections.rich-text.settings.content_alignment.label"
    },
    {
      "type": "color_scheme",
      "id": "color_scheme",
      "label": "t:sections.all.colors.label",
      "default": "background-1"
    },
    {
      "type": "checkbox",
      "id": "full_width",
      "default": true,
      "label": "t:sections.rich-text.settings.full_width.label"
    },
    {
      "type": "header",
      "content": "t:sections.all.padding.section_padding_heading"
    },
    {
      "type": "range",
      "id": "padding_top",
      "min": 0,
      "max": 100,
      "step": 4,
      "unit": "px",
      "label": "t:sections.all.padding.padding_top",
      "default": 40
    },
    {
      "type": "range",
      "id": "padding_bottom",
      "min": 0,
      "max": 100,
      "step": 4,
      "unit": "px",
      "label": "t:sections.all.padding.padding_bottom",
      "default": 52
    }
  ],
  "presets": [
    {
      "name": "Countdown"
    }
  ]
}
{% endschema %}

 

 

Step 4: Save changes

 

Step 5: Use this section from theme customize

makkaomakka_3-1699675353536.pngmakkaomakka_4-1699675405457.png

Referance: https://mangit.myshopify.com/

 

If I managed to help you then, don't forget to Like it and Mark it as Solution!

 

Best Regards,

Makka

  

 

❤️❤️

Buy me a coffee


For quick response - Message Me


Increase Xmas sales with BOGO+ Easy Free Gift Upsell. Get 30% OFF for 3 months with code "BFWIZZ30".

View solution in original post

Replies 3 (3)
theycallmemakka
Shopify Partner
993 201 213

Can you provide link to your store?

❤️❤️

Buy me a coffee


For quick response - Message Me


Increase Xmas sales with BOGO+ Easy Free Gift Upsell. Get 30% OFF for 3 months with code "BFWIZZ30".

theycallmemakka
Shopify Partner
993 201 213

This is an accepted solution.

Hi @mshresthafashio ,

 

If you are using a default dawn theme, you can use below Section to add a counter to your site.

 

Follow below steps to add the section to your site.

 

Step 1:Go the theme > Edit Code

makkaomakka_0-1699675239132.png

 

 

Step 2: Create a new section

makkaomakka_1-1699675274855.png

 

Step 3: Copy below conten to the new section

makkaomakka_2-1699675298272.png

 

{{ 'section-rich-text.css' | asset_url | stylesheet_tag }}
{%- style -%}
  .section-{{ section.id }}-padding {
    padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px;
    padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px;
  }

  @media screen and (min-width: 750px) {
    .section-{{ section.id }}-padding {
      padding-top: {{ section.settings.padding_top }}px;
      padding-bottom: {{ section.settings.padding_bottom }}px;
    }
  }
{%- endstyle -%}

<div class="isolate{% unless section.settings.full_width %} page-width{% endunless %}">
  <div class="rich-text content-container color-{{ section.settings.color_scheme }} gradient{% if section.settings.full_width %} rich-text--full-width content-container--full-width{% endif %} section-{{ section.id }}-padding">
    <div class="rich-text__wrapper rich-text__wrapper--{{ section.settings.desktop_content_position }}{% if section.settings.full_width %} page-width{% endif %}">
      <div class="rich-text__blocks {{ section.settings.content_alignment }}">
                      <h2
                class="rich-text__heading rte inline-richtext {{ section.settings.block_heading_size }}{% if settings.animations_reveal_on_scroll %} scroll-trigger animate--slide-in{% endif %}"
                {% if settings.animations_reveal_on_scroll %}
                  data-cascade
                  style="--animation-order: 0;"
                {% endif %}
              >
                <div id="countdown" class="countdown" style="opacity: 0;">
                  <span id="hours">00</span>:<span id="minutes">00</span>:<span id="seconds">00</span>
                </div>
                  <style>
                    .countdown {
                      display: inline;
                      text-align: center;
                      font-weight: 600; 
                    }
                  </style>
                <script>const targetDate=new Date;targetDate.setUTCHours(17,0,0,0);const countdownElement=document.getElementById("countdown");function updateCountdown(){let t=new Date,e=targetDate-t;e>0?(document.getElementById("hours").textContent=formatTime(Math.floor(e/36e5)),document.getElementById("minutes").textContent=formatTime(Math.floor(e%36e5/6e4)),document.getElementById("seconds").textContent=formatTime(Math.floor(e%6e4/1e3))):(targetDate.setDate(targetDate.getDate()+1),targetDate.setUTCHours(17,0,0,0))}function formatTime(t){return t<10?`0${t}`:t}updateCountdown(),document.getElementById("countdown").style.opacity=1,setInterval(updateCountdown,1e3);</script>
              </h2>
      </div>
    </div>
  </div>
</div>

{% schema %}
{
  "name": "Countdown",
  "tag": "section",
  "class": "section",
  "disabled_on": {
    "groups": ["header", "footer"]
  },
  "settings": [
        {
        "type": "inline_richtext",
        "id": "block_heading",
        "default": "Talk about your brand",
        "label": "t:sections.rich-text.blocks.heading.settings.heading.label"
      },
      {
        "type": "select",
        "id": "block_heading_size",
        "options": [
          {
            "value": "h2",
            "label": "t:sections.all.heading_size.options__1.label"
          },
          {
            "value": "h1",
            "label": "t:sections.all.heading_size.options__2.label"
          },
          {
            "value": "h0",
            "label": "t:sections.all.heading_size.options__3.label"
          },
          {
            "value": "hxl",
            "label": "t:sections.all.heading_size.options__4.label"
          }
        ],
        "default": "h1",
        "label": "t:sections.all.heading_size.label"
      },
    {
      "type": "select",
      "id": "desktop_content_position",
      "options": [
        {
          "value": "left",
          "label": "t:sections.rich-text.settings.desktop_content_position.options__1.label"
        },
        {
          "value": "center",
          "label": "t:sections.rich-text.settings.desktop_content_position.options__2.label"
        },
        {
          "value": "right",
          "label": "t:sections.rich-text.settings.desktop_content_position.options__3.label"
        }
      ],
      "default": "center",
      "label": "t:sections.rich-text.settings.desktop_content_position.label",
      "info": "t:sections.rich-text.settings.desktop_content_position.info"
    },
    {
      "type": "select",
      "id": "content_alignment",
      "options": [
        {
          "value": "left",
          "label": "t:sections.rich-text.settings.content_alignment.options__1.label"
        },
        {
          "value": "center",
          "label": "t:sections.rich-text.settings.content_alignment.options__2.label"
        },
        {
          "value": "right",
          "label": "t:sections.rich-text.settings.content_alignment.options__3.label"
        }
      ],
      "default": "center",
      "label": "t:sections.rich-text.settings.content_alignment.label"
    },
    {
      "type": "color_scheme",
      "id": "color_scheme",
      "label": "t:sections.all.colors.label",
      "default": "background-1"
    },
    {
      "type": "checkbox",
      "id": "full_width",
      "default": true,
      "label": "t:sections.rich-text.settings.full_width.label"
    },
    {
      "type": "header",
      "content": "t:sections.all.padding.section_padding_heading"
    },
    {
      "type": "range",
      "id": "padding_top",
      "min": 0,
      "max": 100,
      "step": 4,
      "unit": "px",
      "label": "t:sections.all.padding.padding_top",
      "default": 40
    },
    {
      "type": "range",
      "id": "padding_bottom",
      "min": 0,
      "max": 100,
      "step": 4,
      "unit": "px",
      "label": "t:sections.all.padding.padding_bottom",
      "default": 52
    }
  ],
  "presets": [
    {
      "name": "Countdown"
    }
  ]
}
{% endschema %}

 

 

Step 4: Save changes

 

Step 5: Use this section from theme customize

makkaomakka_3-1699675353536.pngmakkaomakka_4-1699675405457.png

Referance: https://mangit.myshopify.com/

 

If I managed to help you then, don't forget to Like it and Mark it as Solution!

 

Best Regards,

Makka

  

 

❤️❤️

Buy me a coffee


For quick response - Message Me


Increase Xmas sales with BOGO+ Easy Free Gift Upsell. Get 30% OFF for 3 months with code "BFWIZZ30".