Advertisement
Guest User

Untitled

a guest
Nov 30th, 2015
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. {% comment %}
  2.  
  3. Get a products sale percentage based off it's compare_at_price vs it's price
  4.  
  5. Example usage:
  6. {% include 'sale_percentage' with product %} Off
  7. Outputs for a product with a compare at price of £10 and a price of £5:
  8. "50% Off"
  9.  
  10. {% endcomment %}
  11.  
  12. {% assign was_price = sale_percentage.compare_at_price %}
  13. {% assign now_price = sale_percentage.price %}
  14.  
  15. {% if product.compare_at_price > product.price %}
  16. {{ was_price | minus: now_price | times: 100.0 | divided_by: was_price | round }}
  17. {% endif %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement