paby Posted July 17, 2012 Posted July 17, 2012 Hello, I sell products to high price in euros, which never have centimes. I want that all the prices of my site, with the exception of the basket (because of the other amounts: the VAT, the postal charges…) are not shown with centimes. E.g. 100 € and not 100,00 € Have you any idea, somebody? Thanks ! Presta 1.4.7 Share this post Link to post Share on other sites More sharing options...
math_php Posted July 17, 2012 Posted July 17, 2012 (edited) Hi, You can change _PS_PRICE_DISPLAY_PRECISION_ in defines.inc.php I had not try the behaviour for the cart, vat and transport. You could also change the Tools function displayPrice to such behaviour : - Product price 200.00 then display 200 - Product price 200.21 then display 200.21 The explanation is not clear but to sum it up : if there are decimals show them else do not (all of these in displayPrice function). Bon developpement Edited July 17, 2012 by math_php (see edit history) 1 Share this post Link to post Share on other sites More sharing options...
paby Posted July 17, 2012 Posted July 17, 2012 I made a success, thank you very much. But it also influences the VAT and the postal charges. I am going to reflect about it... Bye ! Share this post Link to post Share on other sites More sharing options...
math_php Posted July 18, 2012 Posted July 18, 2012 Hi, I have the solution you asked : - let _PS_PRICE_DISPLAY_PRECISION_ unchanged (value = 2) Make an override of the tools::displayPrice (copy and paste it in your override) and modify this part of the code switch ($c_format) { /* X 0,000.00 */ case 1: $ret = $c_char.$blank.number_format($price, $c_decimals, '.', ','); break; /* 0 000,00 X*/ case 2: $ret = number_format($price, $c_decimals, ',', ' ').$blank.$c_char; break; /* X 0.000,00 */ case 3: $ret = $c_char.$blank.number_format($price, $c_decimals, ',', '.'); break; /* 0,000.00 X */ case 4: $ret = number_format($price, $c_decimals, '.', ',').$blank.$c_char; break; } To this $prix =(int)$price; if ($prix<$price){ // if $price not an integer then display decimals like configured switch ($c_format) { /* X 0,000.00 */ case 1: $ret = $c_char.$blank.number_format($price, $c_decimals, '.', ','); break; /* 0 000,00 X*/ case 2: $ret = number_format($price, $c_decimals, ',', ' ').$blank.$c_char; break; /* X 0.000,00 */ case 3: $ret = $c_char.$blank.number_format($price, $c_decimals, ',', '.'); break; /* 0,000.00 X */ case 4: $ret = number_format($price, $c_decimals, '.', ',').$blank.$c_char; break; } } else { // $price is a nice round price, do not display decimals $ret = $price; if ($c_format ==2 || $c_format==4){$ret.=$blank.$c_char;} } Then with this I have a product at 150.€ displayed and everything that need decimals will still be displayed with decimals. 1 Share this post Link to post Share on other sites More sharing options...
paby Posted July 18, 2012 Posted July 18, 2012 Hi, Yes, that's better ! Thanks a lot ! Paby Share this post Link to post Share on other sites More sharing options...
tozi Posted January 15, 2014 Posted January 15, 2014 (edited) I have the same problem. My version of prestashop is 1.5.6.1. When is it defines.inc.php? Edited January 15, 2014 by tozi (see edit history) Share this post Link to post Share on other sites More sharing options...
febcomwebshop Posted March 28, 2014 Posted March 28, 2014 (edited) Please i have this same problem when ever i imput 18000 it will show 18.00 and in store front gives out 12.89 but i used V1.4.0.17 Edited March 28, 2014 by febcomwebshop (see edit history) Share this post Link to post Share on other sites More sharing options...
dzoxen Posted April 1, 2014 Posted April 1, 2014 Hi, is there a way to do this but to keep decimals in cart? Share this post Link to post Share on other sites More sharing options...
Stefand Posted May 16, 2014 Posted May 16, 2014 Please let me know how to do this in 1.5.6 Share this post Link to post Share on other sites More sharing options...
SAAR Posted May 26, 2015 Posted May 26, 2015 Hi, I have the solution you asked : - let _PS_PRICE_DISPLAY_PRECISION_ unchanged (value = 2) Make an override of the tools::displayPrice (copy and paste it in your override) and modify this part of the code switch ($c_format) { /* X 0,000.00 */ case 1: $ret = $c_char.$blank.number_format($price, $c_decimals, '.', ','); break; /* 0 000,00 X*/ case 2: $ret = number_format($price, $c_decimals, ',', ' ').$blank.$c_char; break; /* X 0.000,00 */ case 3: $ret = $c_char.$blank.number_format($price, $c_decimals, ',', '.'); break; /* 0,000.00 X */ case 4: $ret = number_format($price, $c_decimals, '.', ',').$blank.$c_char; break; }To this $prix =(int)$price; if ($prix<$price){ // if $price not an integer then display decimals like configured switch ($c_format) { /* X 0,000.00 */ case 1: $ret = $c_char.$blank.number_format($price, $c_decimals, '.', ','); break; /* 0 000,00 X*/ case 2: $ret = number_format($price, $c_decimals, ',', ' ').$blank.$c_char; break; /* X 0.000,00 */ case 3: $ret = $c_char.$blank.number_format($price, $c_decimals, ',', '.'); break; /* 0,000.00 X */ case 4: $ret = number_format($price, $c_decimals, '.', ',').$blank.$c_char; break; } } else { // $price is a nice round price, do not display decimals $ret = $price; if ($c_format ==2 || $c_format==4){$ret.=$blank.$c_char;} } Then with this I have a product at 150.€ displayed and everything that need decimals will still be displayed with decimals. I need help! The price of a product the price does not show decimal at all. It always rounds the price . For example it shows this € 60 but not this € 60,50. I have checked the round mode , you can choose 5 round mode but nothing changes this issue Please help! Share this post Link to post Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now