How to add NEW badge to latest products in Shopify

There are many ways to attach visitor’s attention to a product. One of the most popular ways is by adding a small badge, usually on the top left or right corner of the product image. We’ve all seen this little red circle “Sale” icon near the product container.

This article helps you know how to create a simple “New” icon badge for a product, based on the date the product is published/created in Shopify. It is automatically added and removed from a product after a certain period of time (which we are able to adjust regarding our preferences).

Here’s the liquid code:

You can change days variable to your value. In this case we’ve set it to 7, which equals to 7 days.

Now, what if a product is having 2 or more badges at the same time? For example a “Sale” badge, because its price is reduced and a “New” badge, because it’s newly listed in your store. You can create another simple if statement and organize the order of the badges like so:

You can go ahead and build upon this snippet.

Happy coding!

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *