Skip to content

Commit e21f992

Browse files
authored
Add "sale badge" snippet
1 parent da7d3ea commit e21f992

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This is a list of useful Shopify Snippets that I often reference while developin
1010
* [Back or Continue Shopping link on Cart](#back-or-continue-shopping-link-on-cart)
1111
* [Add Class or Id to Form](#add-class-or-id-to-form)
1212
* [Add Custom Badge on Products using product tag](#add-custom-badge-on-products-using-product-tag)
13+
* [Add On Sale Badge on Products Based on Price](#add-on-sale-badge-on-products-based-on-price)
1314
* [Insert Block inside a for loop at any position](#insert-block-inside-a-for-loop-at-any-position)
1415

1516

@@ -100,6 +101,15 @@ This code adds a limited badge on products with "limited" tag on them. Add this
100101
{% endfor %}
101102
```
102103

104+
## Add On Sale Badge on Products Based on Price
105+
* Products must have "Compare at price" field fill in admin.
106+
* Shows Badge when "compare_at_price_max" > "product price"
107+
```html
108+
{% if product.compare_at_price_max > product.price %}
109+
<img class="sale-product" src="{{ 'sale-badge.png' | asset_url }}" alt="On Sale Badge">
110+
{% endif %}
111+
```
112+
103113
## Insert Block inside a for loop at any position
104114
This code inserts "new-block" div at position 4.
105115
```html

0 commit comments

Comments
 (0)