How do you show discount percentages on products on Shopify?

Asked 2 months ago

It's time to schedule a sale in my store, and while I have displayed the total discounts on the cart page before, I like the idea of showing my customers the percentage that is discounted on each product that is on sale in the store. If I understand correctly, Shopify can do this, but how?

Ruben Dickson

Sunday, July 31, 2022

You can show the percentage discount on Shopify by modifying the liquid files. To accomplish the said task, follow these steps:

  1. Log in to your account.
  2. Go to Online Store.
  3. Select and expand the Theme.
  4. You'll see an option to edit the code and find the "product-price.liquid" file. Add the following code after the 12th line:

{% if compare_at_price %}

{% capture discount %}

{{ compare_at_price | minus:price | times:100 | divided_by:compare_at_price }}%

{% endcapture %}

{{ discount }}

{% endif %}

5. Replace {{ discount }} is the percentage discount you can use at any point in the liquid file.

Write an answer...


Please follow our  Community Guidelines

Can't find what you're looking for?