Strky Posted December 2, 2014 Share Posted December 2, 2014 Hello, when I use a discount on the product, get a price with decimals (eg. 716.00> 15%> 608.80), but when I turned off decimals, it shows (608), but the acquisition of two product, show the final price in 1213 instead of 1212. Also, does not change anything if I set the rounding up or down. PS v. 1.6.0.5 Any ideas? All help greatly appreciated... Link to comment Share on other sites More sharing options...
Strky Posted January 8, 2015 Author Share Posted January 8, 2015 (edited) I tried the solution and here it is... In classes/Product.php add before Group reduction (around rows 2770) // Group reduction if ($use_group_reduction) { $reduction_from_category = GroupReduction::getValueForProduct($id_product, $id_group); if ($reduction_from_category !== false) $group_reduction = $price * (float)$reduction_from_category; else // apply group reduction if there is no group reduction for this category $group_reduction = (($reduc = Group::getReductionByIdGroup($id_group)) != 0) ? ($price * $reduc / 100) : 0; } this code $price = Tools::ps_round($price,0); so the code will look something like $price = Tools::ps_round($price,0); // Group reduction if ($use_group_reduction) { $reduction_from_category = GroupReduction::getValueForProduct($id_product, $id_group); if ($reduction_from_category !== false) $group_reduction = $price * (float)$reduction_from_category; else // apply group reduction if there is no group reduction for this category $group_reduction = (($reduc = Group::getReductionByIdGroup($id_group)) != 0) ? ($price * $reduc / 100) : 0; } But if we want to work only when rounding the decimal number are off, need to add IF. In classes/Currency.php add function under this code (around rows 281) public static function getCurrency($id_currency) { return Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' SELECT * FROM `'._DB_PREFIX_.'currency` WHERE `deleted` = 0 AND `id_currency` = '.(int)($id_currency)); } add this code public static function getDesonoff($id_decimal) { $id_decimal = Db::getInstance()->getValue("SELECT decimals FROM "._DB_PREFIX_."currency"); return $id_decimal; } And add IF, in to the classes/Product.php to our code add new code with IF if (Currency::getDesonoff($id_decimal) == 0){ $price = Tools::ps_round($price,0); } Edited January 8, 2015 by Strky (see edit history) Link to comment Share on other sites More sharing options...
nomealternativo Posted July 14, 2015 Share Posted July 14, 2015 Hi Striky, I tried your solution, but the price changes only in product page, the price in cart is shown without rounding. Any ideas? Link to comment Share on other sites More sharing options...
Strky Posted July 27, 2015 Author Share Posted July 27, 2015 Hi, what is your prestashop version? Link to comment Share on other sites More sharing options...
Recommended Posts