From my testing with the conversion from AUD to EUR, or any other currency I have set, the display for payment information is now correct.
Thank you Lat9
OldNGrey
ZC158a PHP 8.2.15
MySQL 10.6.16-MariaDB
I think I figured out part of the problem. In my currency with rate 155 (JPY) I use 0 decimal. It seems that currency conversion in cart rounds to 0 decimals before conversion:
Product price 48.34 becomes 48 which multiply by 155 gives 7440 which is exactly the wrong price I got in cart without tax.
Second product price 35.00 has 0 as decimal. This is why price after conversion is still right. I don't know where it is in the code yet.
When displaying prices with tax:
Product 1: 48.34 x 1.1 = 53.174 ----> 53 x 155 = 8215 Which is what I got.
Product 2: 35.00 x 1.1 = 38.5 ----> 39 x 155 = 6045 Which is what I got too!
Rounding to new decimal setting should be done after conversion.
Calculation in last checkout screen is different and there might be something else to figure out...
Thank you for taking the time to check this out. It would help me to reproduce and then correct the issue if I could verify:
Store currency, number of decimal digits (sounds like 2)
What is the 1.1 that multiplies the product pricing, for example 48.34 x 1.1 = 53.174
Store currency, converted to JPY with a 155 conversion rate.
The main currency is default US$. I use a default cart with demo data to which I added Japanese yen as currency with rate (including factor 1.05) of 155 (155.00000000) and has 0 decimal. Then I modified Tax to apply worldwide and at a 10% rate which makes it easier for debugging. Then, I modified some products prices and one is 48.3400 without tax and the other is 35.0000 without tax too.
Now, I suppose you understand 48.34 (price w.o.t.) x 1.1 (10% tax).
1.1 is 1 + 10/100...
I looked at the code and find some rounding (line 118 in shopping cart header and some in shopping cart class) I can suppress to get correct prices, but then the 'one digit off' bug comes back. I think these rounding were added to correct this bug, but in fact hide it.
Probably, the right thing to do would be to do a rounding after currency conversion (if necessary) but before any other calculation like adding tax, then a last rounding before displaying.
I could not find where currency conversion is done for subtotals. It seems subtotal is calculated differently depending on page you are: cart, checkout payment and checkout confirmation... If you know where this currency conversion is done, please let me know.
Thanks for the quick response, @pilou2, it is much appreciated. I'm off to configure my testing site with that information and will hopefully have some idea of where the issue lies later today.
The sub-total calculations for the shopping-cart page's display are performed by the page's header_php.php, first via call to the shopping-cart class' show_total method, with the returned value then formatted into the currently-selected currency.
During the checkout, the subtotal calculation is performed within the order-class' cart method. The overall total and tax are further manipulated by the various order-total modules to produce the order's final tax and total.
Hi,
Sorry for asking on this but. I'm just at a point in making a payment plugin, and have looked a a few other one's and am getting a mixed view on 'order's final total' that's sent to payment gateway as some are using : "$amount_total=round($order->info['total']*$order->info['currency_value'],$decimal_places)*$multiplied_by;" but to me the amount sent to the payment gateway should just be "$order->info['total']" untouched by any sort of "$order->info['currency_value']" as this in my view is dealt with for cart total, am i right on this please?
just to let you know what "$multiplied_by" is, the "presentment currencies - Zero-decimal currencies. Three-decimal currencies ..." which are needed before sending to the gateway.
So if currency conversion is done at cart to order point then, this
"$amount_total=round($order->info['total']*$order->info['currency_value'],$decimal_places)"
is just making the amount to pay bigger by currency rate of the order and not matching the displaid amount in checkout before and after payment has been taken and shown on success page?
Bookmarks