Jump to content

Wierd bug in discount percentage on 1.6.0.6


Recommended Posts

When applying a discount for 55%, 56%, 57% etc. for products in catalog price rules, this happens on the product information page, and on the quick-view page.

 

roj3F.jpg

It looks ok in the cart and checkout.

 

If I apply a discount for 60% or another (round) number, it is ok..

 

This is a clean install of prestashop 1.6.0.6, default theme, without any third party modules installed.

 

Anyone know how to fix?

Link to comment
Share on other sites

Someone that actually knows what they are doing will need to look at this.

 

A temporary fix for you is to go to,

 

prestashop\themes\default-bootstrap\js\product.js
 
Line 594
 
Comment out,
reduction = productPriceDisplay * (parseFloat(selectedCombination['specific_price'].reduction_percent) / 100) + reduction_price; if (reduction_price && (displayPrice || noTaxForThisProduct))

And add this right under it,

reduction = productPriceDisplay * (selectedCombination['specific_price'].reduction_percent) / 100) + reduction_price; if (reduction_price && (displayPrice || noTaxForThisProduct)

In this case the display is the only thing being messed up. If you look in the code the number is correct. Removing parseFloat fixes the display problem. But it is just a hack. 

Link to comment
Share on other sites

  • 1 month later...

I think culprit is line 619 of file

 

prestashop\themes\default-bootstrap\js\product.js

 

that is:

$('#reduction_percent_display').html('-' + 
parseFloat(selectedCombination['specific_price'].reduction_percent) + '%');

See parseFloat function.

 

My hack is round to at most 2 decimal places in JavaScript:

$('#reduction_percent_display').html('-' + ( 
Math.round((selectedCombination['specific_price'].reduction_percent + 0.00001) * 
100) / 100 ) + '%');

For details, see:

 

http://stackoverflow.com/questions/11832914/round-to-at-most-2-decimal-places-in-JavaScript

 

 

Happy PrestaShopping 4 all

 

 

  • Like 1
Link to comment
Share on other sites

Julien Bourdeau added a comment - Today 11:23 AM

 

Hi,

the following patch fix all issues on the product page:

https://github.com/PrestaShop/PrestaShop/commit/dbcbe532c43dc5972d399272738af56b22690e26

 

Please note I redone all the javascript calculation which is used only with product with combinations.

For the rest it's being fixed on the tax branch: https://github.com/PrestaShop/PrestaShop/tree/taxes

Best regards,

 

Link to comment
Share on other sites

  • 2 weeks later...

This worked for me, as I want no decimals on discount percentages:

 

Replace

$('#reduction_percent_display').html('-' + parseFloat(selectedCombination['specific_price'].reduction_percent) + '%');

By

$('#reduction_percent_display').html('-' + ps_round(parseFloat(selectedCombination['specific_price'].reduction_percent)) + '%');
Edited by sambrista (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...
  • 3 months later...

 

hey guys I tried everything you said but I'm still struggling with my percentage's decimals
Does any of you know how to fix it on the front page
 

 

 

hi guys, sory my english, me too, i cant show fine, i used 1.6.0.9 i put 17.1545 in bo and in front end in product page i see 17.1545% . i want see 17% or 18%

 

help!

Link to comment
Share on other sites

Try to round the specificPrice.reduction value in /themes/*/product.tpl

<span id="reduction_percent_display">
    {if $product->specificPrice && $product->specificPrice.reduction_type == 'percentage'}-{$product->specificPrice.reduction*100}%{/if}
</span>
Link to comment
Share on other sites

 

Try to round the specificPrice.reduction value in /themes/*/product.tpl

<span id="reduction_percent_display">
    {if $product->specificPrice && $product->specificPrice.reduction_type == 'percentage'}-{$product->specificPrice.reduction*100}%{/if}
</span>

hi tuk66, not how to make the modification, can you tell me how it should be the line you indicate to operate as needed?

 

sory my english :-(

 

regards

Link to comment
Share on other sites

  • 5 months later...

hi tuk66, not how to make the modification, can you tell me how it should be the line you indicate to operate as needed?

 

sory my english :-(

 

regards

 

 

Hi joseangel (the football player?change nick :D :D) 

You should modify the files /themes/yourtheme/product.tpl   and /themes/yourtheme/product-list.tpl   

with the round function. 

You should find in your file the correct line and modify it, like the following example :

 

<span id="reduction_percent_display">

    {if $product->specificPrice && $product->specificPrice.reduction_type == 'percentage'}-{round($product->specificPrice.reduction*100)}%{/if}

</span>

 

 

bye bye

Link to comment
Share on other sites

×
×
  • Create New...