Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

109
Visualizações
Shopify Liquid show content based on dates

On my shopify store I want to show a html banner in a liquid file from 02/01/2022 - 02/14/2022. It's only for Valentines day orders so I want to auto show the banner just on those dates from the 1st to the 14th.

Any help is greatly appreciated.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

From the Spotify liquid documentation, you can create a conditional code path using the code snippet below:

{% assign start = "2022-01-02" | date: '%s' %}
{% assign end = "2022-02-14" | date: '%s' %}
{% assign today = "now" | date: '%s' %}
{% if  start <= today and today <= end %}
    <h2>Show banner</h2>
{% endif %}

This code will only show the banner within the specified timeframes. You can try it out on the Liquid editor here: https://liquidjs.com/playground.html

about 4 years ago · Juan Pablo Isaza Relatório

0

Use a simple if-statement. With Date() you get all info that you need.

const date = new Date();

if (date.getDate() > 14 && date.getMonth() === 1 && date.getFullYear() === 2022) {
    document.getElementById('banner').style.display = 'none';
}
<div id="banner">BANNER</div>

Ensure that date.getMonth() is set to 1 for February, since values start with 0.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda