July 17, 20188 yr I can't seem to get rounding correct in the cart, very frustrating. As you can see in my screen shot my first line item should = $81.54 ($27.18 x 3) and then the 2 lines together should = $99.53. I can't and do not want to round in this way. The round should not go past 2 decimal places. This would be not different than buying clothing in a brick-and-mortar retail store, they would not round in this way. I have tried 4 decimal places in preferences-->General as well as every option under 'Round mode.' I have also tried 'Round on each item' and 'Round on each line'.
July 17, 20188 yr Admin note: it looks like you tried to post three times, landing in the moderation queue each time. I'll remove the other two postings. If one of them has something which is missing here, please add it here as well.
July 18, 20188 yr 27.18 x 3 = 81.54 81.54 + 17.98 = 99.52 Looks like rounding is right, just the total of the first line displays one cent too high. It displays $81.55, while it calculates with $81.54. I've recorded a Github issue to not forget this: https://github.com/thirtybees/thirtybees/issues/553
September 26, 20188 yr This is caused by the CartCore class' getProducts. There is a switch-case over Configuration::get('PS_ROUND_TYPE') which in the default case calls the Tools::ps_round function. The second parameter is _TBPRICEDATABASEPRECISION_ which is in the config set to 6 on default installation. It should use _PSPRICEDISPLAYPRECISION_ or _PSPRICECOMPUTE_PRECISION_ which are both set from (int) Configuration::get('PS_PRICE_DISPLAY_PRECISION'). Until there is a fix, you could use an override for the CartCore class which puts _PSPRICECOMPUTEPRECISION_ instead of _TBPRICEDATABASEPRECISION_ in that spot. Not pretty, but at least it'll work.
December 18, 20187 yr I just modified /config/settings.inc and add this line at the bottom for a quick fix : define('TBPRICEDATABASEPRECISION_','2'); 2 decimals is what i needed, that fixed a lot of problems on cart amounts.
December 18, 20187 yr @zen that's quite simple solution. is it fix the bug? @traumflug said in Rounding issue in shopping cart: I've recorded a Github issue to not forget this: https://github.com/thirtybees/thirtybees/issues/553
November 13, 20197 yr Ahm I tested the define statement but this didn't help me at all, probably also because the define variable is just written wrong. Who knows how it might be? _TBPRICEDATABASEPRECISION_ OR even _TB_PRICE_DATABASE_PRECISION_ ?? I tried it all. I have a product in my cart which is 19.50 Euro. I have it twice so the total price of this line should be 39, but instead it's 39.10. I don't know why the rounding is being done again on the total when you already have it calculating/showing the unit price. Why not take the unit price and calculate the total from there? This way you won't have to deal with any more decimals that could negatively lead to a wrong total and you get what everyone would actually expect. Wouldn't this make sense for all currencies (didnt think this through for crypto, but I don't need to as there's no module yet for bitcoins)? What do I have to do to get this rounding correct? We round to 0.10. So 0.95 is going to be 1 and 0.94 is going to be 0.90. This works for all products perfectly, but as soon as I add more than one of the same product I have wrong totals displayed in checkout for each line and of course the total in the end as well. I tried to transfer my own rounding code from an old prestashop and it worked in the front end (i finally had the correct line totals), but when editing a product the price tab stays empty and the products edit page can never be fully loaded... Maybe someone who knows the TB code better can help me at least to get this code to work: classes/tools.php - function ps_round() in switch statement I added the following case on top: case PS_ROUND_CHF_10CTS: return round(10 * $value) / 10; js/tools.js - function ps_round() after else if (method===2) I added: else if (method == 6) { tmp_value = Math.round(10 * value) / 10; return tmp_value; } config/defines.inc.php - line 181: define('PS_ROUND_CHF_10CTS', 6); controllers/admin/AdminPreferencesController.php - __construct(): added following array values into $roundMode: [ 'value' => PS_ROUND_CHF_10CTS, 'name' => $this->l('Round to nearest 10cts') ], Thanks for clarification and help on this 🙂 And btw: the amount of decimals to display that can be defined in admin isn't doing anything. I can set it to 1, i can set it to 3, but the amount of decimals is always 2. Doesn't also seem to have no impact on the rounding. I'm still on 1.0.8. I have deleted all prestashop modules and replaced them with thirty bees ones. The shop should be clean, without overrides that would have an impact. All the best, Oli Edited November 13, 20197 yr by oliiiix
November 13, 20197 yr @oliiiix Have you tried to set your rounding rule to "per article" instead of "per line"? If it is set to per line, it will round each position after adding the amounts per article, that is useful for shops selling, for example, ropes in feet or something. If you only set articles by piece instead of per foot or per lbs, then you should set the rounding rule to "per article".
November 13, 20197 yr 1 hour ago, oliiiix said: I'm still on 1.0.8. There was a price rounding overhaul as part of 1.1.0 release. It's very likely your issue was solved as part of this overhaul. Upgrade. https://thirtybees.com/blog/prices-done-right/
November 13, 20197 yr That's great! Thanks a lot, I'll try that tomorrow. Didn't upgrade because of our own tools that are also retrieving stuff from the TB database 😉 But if the changes are not that big, I'll certainly be able to upgrade without problems! Thanks for this information 🙂 EDIT: Today morning I got the update to work and the price rounding issue is gone! Thanks a lot!!! Edited November 14, 20197 yr by oliiiix
November 14, 20197 yr Rounding to 10 Rappen needs no code changes. One can set the number of decimals in general preferences, set this to 1 and turn auto-formatting of the currency off. Only caveat then: display after the decimal is limited to one digit then as well. As the second digit is always zero, it can get hardcoded in the theme. About prices and rounding: https://thirtybees.com/blog/prices-done-right/
November 14, 20197 yr Hallo Markus Thanks a lot! I did that, but was using 1.0.8 as said by Petr from Datakick the problem was fixed by making the upgrad to 1.1.0. But as I mentioned in my previous post, the amount of displayed numbers is always two, no matter what I'm setting the decimal amount to. It's already set to 1, but still displays two decimals (which I like). I'm pretty sure I have no code in place at all that would do that... But if this works for you then it's probably my shop even though since TB I trust my shop again completely 😉 Thanks so much! Guess I'm also going to support ThirtyBees very soon with a small amount, I'm already thinking about transferring all our prestashops to thirty bees as TB is just a blessing after prestashop 😉
Create an account or sign in to comment