skullxcrusher Posted December 25, 2015 Share Posted December 25, 2015 I need 3 decimal places in the price instead of two. How to change it in version PrestaShop™ 1.5.6.3 ? for example i have products that are for 1.101 its showing only 1.10 how to make it show 1.101 Link to comment Share on other sites More sharing options...
tuk66 Posted December 27, 2015 Share Posted December 27, 2015 Do you use the default template? It should work in it. Link to comment Share on other sites More sharing options...
skullxcrusher Posted December 27, 2015 Author Share Posted December 27, 2015 im using super market theme responsive Link to comment Share on other sites More sharing options...
tuk66 Posted December 28, 2015 Share Posted December 28, 2015 That's it. Your theme isn't compatible with more than two decimals. Link to comment Share on other sites More sharing options...
bellini13 Posted December 28, 2015 Share Posted December 28, 2015 no theme is, that is because Prestashop itself assumes 2 decimal currency and rounds anything past that to 2 decimals, even the default theme is hardcoded for this I replied to an old forum topic which outlines the changes required on PS v1.5 to support 3 decimals. You would have to search for it but should not be too hard to find. Link to comment Share on other sites More sharing options...
El Patron Posted December 28, 2015 Share Posted December 28, 2015 I need 3 decimal places in the price instead of two. How to change it in version PrestaShop™ 1.5.6.3 ? for example i have products that are for 1.101 its showing only 1.10 how to make it show 1.101 what currency are you working with? this information will be most useful. Link to comment Share on other sites More sharing options...
bellini13 Posted December 29, 2015 Share Posted December 29, 2015 there are a decent number of currencies that use 3 decimals BHD Bahraini dinar 3IQD Iraqui dinar 3JOD Jordan dinar 3KWD Kuwaiti dinar 3LYD Libyan dinar 3OMR Omani rial 3TND Tunesian dinar 3 1 Link to comment Share on other sites More sharing options...
skullxcrusher Posted December 29, 2015 Author Share Posted December 29, 2015 what currency are you working with? this information will be most useful. BHD Bahraini dinar 3 KWD Kuwaiti dinar 3 Saudi Riyal Link to comment Share on other sites More sharing options...
tuk66 Posted December 29, 2015 Share Posted December 29, 2015 Look at the /themes/default/product.tpl file. There is $priceDisplayPrecision variable which can be set in code, and its default value is 2. Link to comment Share on other sites More sharing options...
skullxcrusher Posted December 29, 2015 Author Share Posted December 29, 2015 (edited) Look at the /themes/default/product.tpl file. There is $priceDisplayPrecision variable which can be set in code, and its default value is 2. did the changes but nothing. still the same {if !isset($priceDisplayPrecision)} {assign var='priceDisplayPrecision' value=3} {/if} {if !$priceDisplay || $priceDisplay == 2} {assign var='productPrice' value=$product->getPrice(true, $smarty.const.NULL, $priceDisplayPrecision)} {assign var='productPriceWithoutReduction' value=$product->getPriceWithoutReduct(false, $smarty.const.NULL)} {elseif $priceDisplay == 1} {assign var='productPrice' value=$product->getPrice(false, $smarty.const.NULL, $priceDisplayPrecision)} {assign var='productPriceWithoutReduction' value=$product->getPriceWithoutReduct(true, $smarty.const.NULL)} {/if} var productPriceWithoutReduction = '{$productPriceWithoutReduction}'; var productPrice = '{$productPrice}'; Edited December 29, 2015 by skullxcrusher (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted December 29, 2015 Share Posted December 29, 2015 as I said before, search for the post I did on this topic. There are more changes required, changing the theme precision is not enough 1 Link to comment Share on other sites More sharing options...
skullxcrusher Posted December 29, 2015 Author Share Posted December 29, 2015 This is pretty sad the way its been implemented, but here is how you support 3 decimal places in Prestashop v1.5. Keep in mind, this is a global site change, so it will impact currencies that are only 2 decimal places. All Prices will be shown with 3 decimals if you make this change.To summarize, you would need to make the following changes to use a 3 decimal place price. Read below for more details1) Change the config/defines.inc.phpdefine('_PS_PRICE_DISPLAY_PRECISION_', 3);2) Override Tools::ps_round so the precision is switched globally from 2 to 33) Search for the usage of string_format, and ensure 3f is used instead of 2f. I only get 2 hits when I search, which is prices.tpl and AdminRangePriceController.phpThe detailed explanation1. Change the config/defines.inc.phpThere is a config file named defines.inc.php, which has a setting _PS_PRICE_DISPLAY_PRECISION_define('_PS_PRICE_DISPLAY_PRECISION_', 2);This is used by the Tools::displayPrice function in conjunction with the currency format to show the price on a majority of the site. I changed the 2 to a 3 on a local test site and it seems to be working 90%.2. Override Tools::ps_roundThere are still some places where only 2 decimals are showing, and that is because of functions like Product::getPriceStatic and Product::priceCalculation also do decimal formatting, and instead of using the above setting, they hard coded 2. So in the AdminProductsController, where the product price is entered, rounds the price to 2 decimalProduct::getPriceStatic($this->_list[$i]['id_product'], true, null, 2, null, false, true, 1, true);Those functions just pass the decimal value to Tools::ps_round, so a simple override of the ps_round function, you could doif ($precision==2) $precision=33. Search for the usage of string_formatThe last thing I could find is within the actual smarty templates, there is also price formatting. For example, in prices.tpl (which is used to show the admin product price), they are using string_format:'%.2f'This is taking the 3 decimal price, and formatting it to 2 decimal, so changing it to string_format:'%.3f' fixes that display issue.I suppose you could just remove the string_format entirely, but that will result in showing the full 6 decimal places is this the one u mean? Link to comment Share on other sites More sharing options...
skullxcrusher Posted December 29, 2015 Author Share Posted December 29, 2015 thanks, it did the jobChange the config/defines.inc.phpThere is a config file named defines.inc.php, which has a setting _PS_PRICE_DISPLAY_PRECISION_define('_PS_PRICE_DISPLAY_PRECISION_', 2);This is used by the Tools::displayPrice function in conjunction with the currency format to show the price on a majority of the site. I changed the 2 to a 3 on a local test site and it seems to be working 90%. Link to comment Share on other sites More sharing options...
bellini13 Posted December 30, 2015 Share Posted December 30, 2015 is this the one u mean? yes Link to comment 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