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?
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.
Great ! Works perfectly ! Thanx
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