-
-
Notifications
You must be signed in to change notification settings - Fork 230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Currency conversions result in incorrect values #6077
Comments
This looks like the conversion is done on the total USD cost 39.99 4 0.83509400 = 133.58 So technically the figures are correct, even though they do not add up. Rather than straight rounding, you could use OR Have to change how the calculation is done. i.e. convert unit price and round, then apply multiples. OR Display all the items in their default currency and only round the total with I expect you have already worked all this out. Just wanted to clarify. |
Yep, I saw that processing. What I'm grappling with is the possibility that there are stores that have products that are unit-priced at less than 0.01; for example, a hardware store that sells nails at 0.0625 per nail with a minimum of 100. For that pricing, you'd want P.S. Since we're dealing with store's profit and loss, the calculations are not technically correct since they neither make sense nor do they add up! |
That been the case. Should you stick with the store base currency and just display the total converted to the guest currency? |
Could you elaborate on your comment? I don't understand the suggestion. |
TL;DR This issue has its basis in:
I was able to coerce the zencart/includes/modules/pages/shopping_cart/header_php.php Lines 116 to 123 in 832a820
to $tax_rate = zen_get_tax_rate($products[$i]['tax_class_id']);
// $ppe is product price each, before one-time charges added
$ppe = $products[$i]['final_price'];
$ppe = zen_round(zen_add_tax($ppe, $tax_rate), $currencies->get_decimal_places($_SESSION['currency']));
// -----
// If pricing is currently being displayed in a currency *other than* the site's
// default, convert the per-item pricing now so that any quantity > 1 will be
// multiplying based on that currency-converted value.
//
if ($_SESSION['currency'] !== DEFAULT_CURRENCY) {
$ppe = $currencies->value($ppe);
}
// $ppt is product price total, before one-time charges added
$ppt = $ppe * $products[$i]['quantity'];
// -----
// NOTE: Telling the currencies' formatter not to convert to the current currency
// in use, since any conversion was performed when determining the product's
// per-item price.
//
$productsPriceEach = $currencies->format($ppe, false) . ($products[$i]['onetime_charges'] != 0 ? '<br>' . $currencies->display_price($products[$i]['onetime_charges'], $tax_rate, 1) : '');
$productsPriceTotal = $currencies->format($ppt, false) . ($products[$i]['onetime_charges'] != 0 ? '<br>' . $currencies->display_price($products[$i]['onetime_charges'], $tax_rate, 1) : ''); That's only a small part of the equation, though, as the shopping-cart class' total calculation is still off. The products' total summation (i.e. an order's So far, I've found the following modules to require change for these calculations:
That said, the correction for this issue will be extremely complicated since it requires changes for the templating as well. |
Using
master
branch as of 2023-12-09 7:56PM Eastern Time, with the demo products, running PHP 8.2.No logs are generated, just that incorrect
The text was updated successfully, but these errors were encountered: