Solved

Can you display new products in stock for less than 15 days on Shopify?

FredAz
Excursionist
15 1 3

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?

Accepted Solution (1)
Not applicable

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

View solution in original post

Replies 3 (3)

Not applicable

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.

FredAz
Excursionist
15 1 3
Great ! Works perfectly ! Thanx
Not applicable

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