New Shopify Certification now available: Liquid Storefronts for Theme Developers

Show % save discount in product page (Brooklyn Theme)

Blochef
Tourist
5 1 1

Hi All,

 

I am using Brooklyn theme and I want to show the save % in the product page for each variant.

I have followed the code provided in post https://community.shopify.com/c/shopify-discussions/show-discounts-on-products-in-debut-theme/m-p/59... but it did not works fine for me. Currently my product page is showing like below. and I want to add a discount % behind the sales price

Regular Price  Sales Price 

Regular Price  Sales Price (-50%)

 

below is the code I have to show the crossed regular price and sales price, and anyone can help me check where should I add for the discount %?screenshot.png

 

 

 

  <span id="ProductPrice"
    class="product-single__price
    {% if variant.compare_at_price > variant.price %} on-sale{% endif %}"
    itemprop="price"
    content="{{ variant.price | divided_by: 100.00 }}">
   {{ variant.price | money }}
   
  </span>

 

 

 

 

 

Thanks!

Replies 3 (3)
SagarikaDas
Shopify Partner
246 24 93

Hey @Blochef,

Hope you are doing well.

Please follow the steps:

  1. Go to Online Store > Theme > Edit code
  2. Open Sections > product-template.liquid file
  3. Paste the below code after the product price (line: 139).
  4. Save the changes.
{% if product.compare_at_price_max > product.price %}
You save {{ product.compare_at_price_max | minus: product.price | times: 100.0 | divided_by: product.compare_at_price_max | money_without_currency | times: 100 | remove: '.0'}}%
{% endif %}
{% if product.compare_at_price_max > product.price %} ({{ product.compare_at_price | minus: product.price | money }}){% endif %}

SagarikaDas_2-1634296513709.png

 

SagarikaDas_1-1634296392949.png

Hope this will help you! Thanks!

 

 

► If the answer solve your issue please ✔ Accept it and hit like

► Need help with theme customization, speed optimization, fixing bugs?


► Let's connect: Mail me Or Skype me: live:.cid.2667d78144ce77ad
Blochef
Tourist
5 1 1

Hi @SagarikaDas ,

 

Thank you for your help! I have inserted the code into the product.template. however, the calculation of the saved amount is not reflecting as per the variant changed like below

is there a code that I should change in the code for item price ?

Screen Shot 2021-10-15 at 19.02.02.png

 

Thank you

 

Best Regards,

Wendy

SagarikaDas
Shopify Partner
246 24 93

Hey @Blochef,

I tried it but didn't get the expected result. I would suggest you hire a Shopify expert

► If the answer solve your issue please ✔ Accept it and hit like

► Need help with theme customization, speed optimization, fixing bugs?


► Let's connect: Mail me Or Skype me: live:.cid.2667d78144ce77ad