Hello, how can you show discount on product page (I’m using ride theme).With multiple varients
Hello there
To show the discount on a product page in the Shopify “Ride” theme, you can use the following steps:
-
Navigate to the theme editor in your Shopify store’s admin panel.
-
From the “Sections” directory, select the “product-template.liquid” file. This file contains the code for the product pages in your store.
-
Scroll down to the section of the code that displays the product price. It should look something like this:
{% if product.compare_at_price > product.price %}
Regular price
~~{{ product.compare_at_price | money }}~~
{{ product.price | money }}
Sale
{% else %}
{{ product.price | money }}
{% endif %}
- Within the “else” block, add a line of code to calculate and display the discount as a percentage. Here is an example of how you can do this:
{% else %}
{% assign discount = (product.compare_at_price | minus: product.price) %}
{% assign discount_percent = (discount | times: 100) | divided_by: product.compare_at_price %}
{{ product.price | money }}
{{ discount_percent | round }}% off
{% endif %}
Save your changes and publish the theme to apply the discount to the product page.
I hope these steps help you show the discount on a product page in the Shopify “Ride” theme! Let me know if you have any questions.
Hello I don’t find the file: product-template.liquid