Skip to content

Instantly share code, notes, and snippets.

@holdinghandsfeedingducks
Created July 18, 2017 03:41
Show Gist options
  • Save holdinghandsfeedingducks/134525f0b18c04ee1be69d8d6728ac8b to your computer and use it in GitHub Desktop.
Save holdinghandsfeedingducks/134525f0b18c04ee1be69d8d6728ac8b to your computer and use it in GitHub Desktop.
{% assign saved_amount = compare_price | minus: product_price %}
{% comment %}
Unless this store uses multiple currencies,
we will remove the decimals when they are equal to 00,
or when the amount is > 10 (dollars, pounds, etc.).
{% endcomment %}
{% if shop.money_format contains 'money' %}
{% assign saved_amount = saved_amount | money %}
{% else %}
{% if saved_amount > 1000 %}
{% if shop.money_format contains '{{amount}}' and shop.money_format contains '.' %}
{% assign saved_amount = saved_amount | money_without_trailing_zeros %}
{% elsif shop.money_format contains '{{amount}}' %}
{% assign saved_amount = saved_amount | money | split: '.' | first %}
{% elsif shop.money_format contains '{{amount_with_comma_separator}}' %}
{% assign saved_amount = saved_amount | money | split: ',' | first %}
{% else %}
{% assign saved_amount = saved_amount | money_without_trailing_zeros %}
{% endif %}
{% else %}
{% assign saved_amount = saved_amount | money_without_trailing_zeros %}
{% endif %}
{% endif %}
{{ 'products.general.save_html' | t: saved_amount: saved_amount }}
{% comment %}
{% if compare_price > product_price %}
Save {{ compare_price | minus: product_price }}%
{% endif %}
{% endcomment %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment