Swiss rounding to 0.05 only affect output but not used for further calculations
-
Yes, there are several threads regarding rounding. But non of them matching my issue or (in my opinion) are the wrong way – what I will try to explain.
In Switzerland they have no 1 or 2 cents coins (there called Rappen or Rappli) – centimes in english.
So they do a rounding to the lower or next 0.05 CHF.Let me first say, that the customer stick to this and did not wan’t to do a 0.1 rounding. That might be easily solved with the woocommerce decimal point setting and just showing a trailing zero.
First I tried with the filter woocommerce_calculated_total but that has no affect to the cart items.
Then I found several apparent solutions with the filter raw_woocommerce_price which seemed to me to be up to the task.But it came out that it didn’t and that in several issues.
1. Sum for bigger Qty:
It best visualized when you have a large quantity of a product.
The unit price is rounded, what it should like.
The sum is also shown as a rounded to 5 centimes. But this sum is not the sum of X times the rounded unit price. It is the rounded sum of the not rounded unit prices.2. Shopping cart total is incorrect:
When you have many items in the cart you can see, that the unrounded individual items are added together and only then sum is rounded.3. The real the debited price differs to that shown in checkout:
The price shown in the checkout is rounded but the price send to a.e. strip is not. In worst case it is higher – just centimes but the first customers already complaining about it.3. The price in xml-exports also differs:
We export the orders with WP-All-Export and import them in a ERP. In the xml also the not rounded values appear.My conclusion is, that this filter only manipulates the output view, but that these values are nut used for the further calculation.
Then my attempt was to find a hook near the the setting woocommerce_price_num_decimals and try to change these rounding in our way.
But that only used in the function wc_get_price_decimals() which did nothing more than return the the number of the decimals. A search for this functions shows 99 results in 46 files. I think that’s a dead end.Is there a solution to really manipulate the prices which are used for all further calculations?
The page I need help with: [log in to see the link]
- The topic ‘Swiss rounding to 0.05 only affect output but not used for further calculations’ is closed to new replies.