Skip to content

Instantly share code, notes, and snippets.

@schaeken
Created January 7, 2016 22:25
Show Gist options
  • Save schaeken/994a5c69e472a27c7968 to your computer and use it in GitHub Desktop.
Save schaeken/994a5c69e472a27c7968 to your computer and use it in GitHub Desktop.
Show percentage saved with a discount code instead of amount saved

You have

"You saved $5 with discount: 50SHIRTSFREE"

You want

"You saved 25% with discount: 50SHIRTSFREE"

{% if discounts %}
  {% assign discount = discounts_amount | times: 1.00 %}
  {% assign price = subtotal_price | times: 1.00 %}
  <p>You saved {{ discount | divided_by: price | times: 100.00 | round: 0 }}% with discount: {{ discounts.first.code }}</p> 
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment