Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save royvn/6ac359d91606a4af9f539fdcfa6074af to your computer and use it in GitHub Desktop.
Save royvn/6ac359d91606a4af9f539fdcfa6074af to your computer and use it in GitHub Desktop.
Calculate product discount in percentage
{%- liquid
assign discount_percentage = product.compare_at_price | minus: product.price | times: 100.0 | divided_by: product.compare_at_price | round | abs
echo discount_percentage
-%}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment