Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {% comment %}
- Get a products sale percentage based off it's compare_at_price vs it's price
- Example usage:
- {% include 'sale_percentage' with product %} Off
- Outputs for a product with a compare at price of £10 and a price of £5:
- "50% Off"
- {% endcomment %}
- {% assign was_price = sale_percentage.compare_at_price %}
- {% assign now_price = sale_percentage.price %}
- {% if product.compare_at_price > product.price %}
- {{ was_price | minus: now_price | times: 100.0 | divided_by: was_price | round }}
- {% endif %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement