How to show % discount on a product using debut theme

Hai. You know how to make this 60% off and this big Buy Now button?

BTW, your percentage calculation comes out inversed if the discount is more than 50%. In my store it should come out to 63%, it came out to 37%.

Hi Tejas

I have tried many codes but it did not work out. Please help me with your code:

  1. Where to insert your code?

My domain is teacherhero.net

hello

here is my site.

https://suubula.com/

I put the code but it is not working.

Hello there!

I have the same problem, With debut theme I cannot see discount prices on my store www.pepitocat.com, can anyone help please? I have already tried to add the code mentioned in previous comments but din’t work.

Thank you very much

Cristina

Hi tejas,

How can I show the discount % off on Collection page? I want to display on top left side of the product images on collection page. Please help.

Thanks.

can someone help me to edit the code ?? because i tried to add this after line 12 and nothing is working…

here is my code


  {%- if variant.compare_at_price > variant.price -%}
    {{ 'products.general.regular_price' | t }}
    
      
        {{ variant.compare_at_price | money }}
      
    
    {{ 'products.general.sale_price' | t }}
  {%- else -%}
    {{ 'products.general.regular_price' | t }}
    
      
    
    {{ 'products.general.sale_price' | t }}
  {%- endif -%}

 
  
    {{ variant.price | money }}
  

  

    {%- capture unit_price_separator -%}
      / {{ 'general.accessibility.unit_price_separator' | t }} 
    {%- endcapture -%}

    {%- capture unit_price_base_unit -%}
      
        {%- if variant.unit_price_measurement -%}
          {%- if variant.unit_price_measurement.reference_value != 1 -%}
            {{- variant.unit_price_measurement.reference_value -}}
          {%- endif -%}
          {{ variant.unit_price_measurement.reference_unit }}
        {%- endif -%}
      
    {%- endcapture -%}
    
      {{ 'products.general.unit_price' | t }}
      {{ variant.unit_price | money }}{{- unit_price_separator -}}{{- unit_price_base_unit -}}
    
  

The issue with the above solution is that the % off shown is too high. To avoid misleading customers, you should make sure that the displayed discount is rounded down. This works well:

assign percentDiscount = comparePrice | minus: price | times: 0.10 | divided_by: comparePrice | times: 1000.00 | floor

Hello sir

Want to make some changes in my shopify store’s product page..

We have a unique buy it now button on the product page & it is named with ’ PAY ONLY 25% NOW & REST COD’

What we offer is, that if someone clicks on this button, 75% discount code will be automatically applied to its cart and customer will only have to pay 25% payment

And the change we want is in the button, we want this button to show discounted product price.

For example - Product price is 1000 INR

What we want is, that button text should be ’ PAY ONLY 25% ( 250 INR ) NOW & REST COD’

we want to add discounted product price on the button .

Please assist us in this matter

We would be highly thankful to you

Our store’s URL - https://lamansh.in

Thank you

Regards

Nikhil jain

Lamansh.in

lamansh.in@gmail.com

Hi, So I have added the code into the product page and for a product, with a single variant it works well, but I am trying to put it on a product that has 3 variants and it does not refresh when the buyer clicks the other variant only if I refresh the page does it show the correct percentage.

How can we make this work.

Also is there code to say how much the difference is between the price and compare at price so an actual figure of 3€ for example displayed after the % discount that is calculated as above when the user switches between the variants?

Hi Everyone,

I am using Live theme. May I know how to show % discount on every product. And How to make proper layout of qty and add to cart button on home page. Please help me to fix this.

Thank you.

Hello Ankur, your solution worked fine for me. An additional question. Is there a way to show the discount text in a different color or with Bold Style? Thanks a lot for your help

its not working on my site url :www.smithandblake.com

Hi,

Can’t get this working, I am using theme Brooklyn.

Here’s the url www.bakstur.fo

please help.

Hello Everybody!

I am currently using the them Canopy. But my theme does not show anywhere Sections > product-template.liquid file or Assets > product-price.liquid file. Therefore Im not able to paste the above code anywhere. Does anybody have an idea and can help me please.

Thanks a lot !

Blanca

Didn’t work on my theme (Cart). Can you please help? I want to change the ā€œSaleā€ button that’s in green to show the % of discount for that product. https://www.discountpricesus.com/collections/jewelry

Hi @Lovelyn12 I’m not sure if this is what you are looking for but this app Codeboost I use let’s you promote discount codes across your website really well. You can add custom messages including the percentage the discount code will apply on the eligible products, fully customizable.

I like it because I do not have to modify any theme code.

Description from marketplace:

Codeboost will allow you to display badges and messages above eligible products in the collections page, product page and cart page. Additionally you can only show these promotions selectively and privately to specific customers!

Hopefully this helps!

Tejas, I am trying to do a similar thing can you help me with my website?

{% assign diff = product.compare_at_price | minus: product.price %}
{{ diff | times: 100.0 | divided_by: product.compare_at_price | split: '.' | first }}%

How do you do this on the Dawn theme? Thank you