Gomlers Posted April 17, 2014 Share Posted April 17, 2014 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. 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 More sharing options...
Bill Dalton Posted April 17, 2014 Share Posted April 17, 2014 I'm no help to you, but yeah, I just gave it a try and you are correct. This is a bug. Link to comment Share on other sites More sharing options...
Gomlers Posted April 17, 2014 Author Share Posted April 17, 2014 Good to know I wasn't wrong. Thanks for checking.. I don't know how to report it.. can you help me report it? Link to comment Share on other sites More sharing options...
Bill Dalton Posted April 17, 2014 Share Posted April 17, 2014 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 More sharing options...
Bill Dalton Posted April 17, 2014 Share Posted April 17, 2014 I have reported the bug, you can follow it here, http://forge.prestashop.com/browse/PNM-2248 Link to comment Share on other sites More sharing options...
Gomlers Posted April 17, 2014 Author Share Posted April 17, 2014 Great, thanks! Link to comment Share on other sites More sharing options...
tbfNation Posted May 22, 2014 Share Posted May 22, 2014 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 1 Link to comment Share on other sites More sharing options...
Bill Dalton Posted May 23, 2014 Share Posted May 23, 2014 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 More sharing options...
sambrista Posted June 4, 2014 Share Posted June 4, 2014 (edited) 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 June 4, 2014 by sambrista (see edit history) Link to comment Share on other sites More sharing options...
algomp Posted June 12, 2014 Share Posted June 12, 2014 (edited) 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 Edited June 12, 2014 by algomp (see edit history) Link to comment Share on other sites More sharing options...
algomp Posted July 17, 2014 Share Posted July 17, 2014 Up Link to comment Share on other sites More sharing options...
joseangel2003 Posted November 7, 2014 Share Posted November 7, 2014 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 More sharing options...
tuk66 Posted November 7, 2014 Share Posted November 7, 2014 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 More sharing options...
joseangel2003 Posted November 8, 2014 Share Posted November 8, 2014 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 More sharing options...
mario.poletti75 Posted April 30, 2015 Share Posted April 30, 2015 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) 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 More sharing options...
Recommended Posts