Hello,
I followed a similar post on discussion to edit code in liquid theme that automatically adds a “new arrival” wording to my product title automatically. I applied the solution to my store but it is not working. The solution is to add the following but it didn’t work on my site. I have attached the screenshot of where I added and hope someone can advise what went wrong.
Thanks!!!
{% assign created = product.published_at | date:'%Y%m%d' %}
{% assign today = 'now' | date:'%Y%m%d' %}
{% assign diff = today | minus: created %}
{% if diff < 30 %}<p class="new-arrival-badge">NEW ARRIVAL</p>{% endif %}
The posted code works, I’ve just tested.
Are you sure that are you applying the code to the right template?
Is the collection settings setup to show products list or products grid? Because if it is the grid, you need to add the code into product-card-grid.liquid file, for Debut theme.
Thanks for your reply! I added to product list not Grid and in the area
shown in the screenshot. Not sure why it didn’t work.
Is it possible to see your website with this code enabled? Can you post an URL?
Ok, as I thought.
You need to add the code to the template product-card-grid.liquid
To be sure, add an HTML content before your code, so that we can check the source and see that the code is executing.
{% assign created = product.published_at | date:'%Y%m%d' %}
{% assign today = 'now' | date:'%Y%m%d' %}
{% assign diff = today | minus: created %}
{% if diff < 30 %}
NEW ARRIVAL
{% endif %}
Ok let me try. Is that a particular area I should add the code? I can’t
find any “product title” wordings in the product card grid.
Just scroll to the end of the file, around line 45, you’ll see this code
{{ product.title }}
Thank you! It works now!!
Happy it worked out. Please, remember to accept the solution and press Like if it helped.
1 Like
Oh, one more question. If I want the “NEW ARRIVAL” wording to be in a
specific color, where do I enter the color code in the script provided?
BTW, how do I change the color of the “NEW ARRIVAL” words? Where do I insert the color code?
You can add a line like this to your theme.css file and tune the color as you prefer (in this example is red)
.new-arrival-badge {
color: #FF0000;
}
1 Like