Liquid, JavaScript, themes, sales channels
Hi, I'm looking a way to display "new" if a product is in stock for less of 15 days for example, could you please help?
Solved! Go to the solution
This is an accepted solution.
So glad to hear that!
Please, if you don't mind can you please like my post or accept it as a solution.
Thx in advance
Hi @FredAz
Welcome to Shopify Community.
Aibek is here from Speedimize.io agency.
Hope this solution can help you:
{% comment %} Product created date by seconds {% endcomment %}
{% assign productCreatedAt = product.created_at | date: '%s' %}
{% comment %} Current date by seconds {% endcomment %}
{% assign today = 'now' | date: '%s' %}
{% comment %} Difference in seconds {% endcomment %}
{% assign diffSeconds = today | minus: productCreatedAt %}
{% comment %} Difference in days {% endcomment %}
{% assign diffDays = diffSeconds | divided_by: 3600 | divided_by: 24 %}
{% if diffDays > 15 %}
old product
{% else %}
new product
{% endif %}
Where old product and new product are registered, you can insert your own values. For example, the new icon, etc.
We recommend experimenting with a copy of the theme so that there are no downtimes.
Kind Regards.
This is an accepted solution.
So glad to hear that!
Please, if you don't mind can you please like my post or accept it as a solution.
Thx in advance
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024