boran Posted February 26, 2009 Share Posted February 26, 2009 Hi,On http://old.boran.ie:8084/shop1 there is a test shop that has Swiss Francs as the default currency but also allows orders in Euros.If one orders 6 of the product "General Donation 25 Francs Suisse" in Euros, this is 6 x 15.43 Euros = 92.59 Euros.If one makes the above order with Payment by Bank wire, PS then sends out two emails1. An order confirmation to the client which shows a correct total of 92.59 euros, 2. a second 'New Order' email to the shop administrator with a total of 57.15 euros. Which is wrong. This email looks like this:Commande 001010 passée le 26-02-2009Paiement : Bank WireRéférence Article Prix unitaire Quantité Prix total General Donation 25 Francs Suisse 15,43 € 6 92,59 €Produits 57,15 €Réductions 0,00 €Emballage cadeau 0,00 €Frais de port 0,00 €Total 57,16 €Note that the total for that detail line is correct, but the lines "Produit" and "Total" are wrong.Now that is email is wrong is not so bad, the serious problem is that if one pays via Paypal, the amount request from Paypal is 57.16, i.e. the wrong amount is requested, and paid!Analysis- Version: I've tested this on SVN 463 (2 weeks old) and SVN 298 (Jan 9th). - Does not happen with the default currencyAny suggestions please? Link to comment Share on other sites More sharing options...
boran Posted February 26, 2009 Author Share Posted February 26, 2009 I've just noticed that the difference between the correct and reported total exactly corresponds to the Euro/CHF exchange rate.So the order is for 6 × 15.43 Euros = 92.59 EurosBut the reported total is 57,16, which is in fact 92.59 * 0.6172840.617284 is the exchange rate Euro/CHF in the shop at th moment.So, it seems like PS calculates the line total correctly 92.59 Euros, but when then applies the CHF/Euro conversion rate and "converts" it to Euros, even though its already Euros.So, for the order confirmation, and payment request, the exchange rate is applied twice.But, as noted in the original post, the order confirmation email is correct.Perhaps someone could explain the differences in the way these totals are calculated, and where I might start looking? Link to comment Share on other sites More sharing options...
boran Posted March 16, 2009 Author Share Posted March 16, 2009 I think I've found one issue, in modules/mailalerts/mailalerts.phpIn hookNewOrder(), when building $itemsTable, Tools::displayPrice() is called with a "false" paramter not to do conversionWhereas the totals are converted: '{total_paid}' => Tools::displayPrice($order->total_paid, $currency),^M '{total_products}' => Tools::displayPrice($order->getTotalProductsWithTaxes(), $currency) So I changed those lines to: '{total_paid}' => Tools::displayPrice($order->total_paid, $currency, false, false),^M '{total_products}' => Tools::displayPrice($order->getTotalProductsWithTaxes(), $currency, false, false), This is a tentative fix, the total products line in the confirmation email seem correct.I'm not sure though, could someone with PS experience please confirm? Link to comment Share on other sites More sharing options...
boran Posted March 17, 2009 Author Share Posted March 17, 2009 Looking at classes/PaymentModule.php confirms the above issue, in that file, which generates the 'Order Confirmation' sent to the customer, the relevant lines are as follows (note the last two false parameters meaning no conversion): '{total_paid}' => Tools::displayPrice($order->total_paid, $currency, false, false),^M '{total_products}' => Tools::displayPrice($order->total_paid - $order->total_shipping - $order->total_wrapping+ $order->total_discounts, $currency, false, false),^M This, then begs the question as to why the code is duplicated, and in this case different, between classes/PaymentModule.php and modules/mailalerts/mailalerts.php. With the 'Order Confirmation' and 'New Order' emails in two different classes they have to be maintained/corrected in parallel, which will lead to future inconsistencies?Reviewing the differences would indicate that total_discounts, total_shipping, total_wrapping also need to be corrected in the same way.Looking at the total_products the calculation in done differently in each case. modules/mailalerts/mailalerts.php: '{total_products}' => Tools::displayPrice($order->getTotalProductsWithTaxes(), $currency, false), classes/PaymentModule.php '{total_products}' => Tools::displayPrice($order->total_paid - $order->total_shipping - $order->total_wrapping+ $order->total_discounts, $currency, false, false), getTotalProductsWithTaxes() is in classes/Order.php and does the quantity*price+tax for each item, so its what a product should cost. Does this difference make sense? The logical for calulating totals should only be in one place, probably in the Order class? Link to comment Share on other sites More sharing options...
doigro Posted May 6, 2009 Share Posted May 6, 2009 Hello, Can you sum up what must be done to fix this? Link to comment Share on other sites More sharing options...
boran Posted May 6, 2009 Author Share Posted May 6, 2009 Well the third comment indicates one immediate fix to modules/mailalerts/mailalerts.php.The fourth indicates that total_discounts, total_shipping, total_wrapping are probably also wrong, and asks why different formulas are used to calculate the totals?.I was trying to understand the reasons behind the current code. Should total_products not be calculated in exactly the same way in mailalerts.php and PaymentModule.php (i.e. the quote line in comment 4 for PaymentModule.php should be replaced with the one from mailalerts.php).Sean Link to comment Share on other sites More sharing options...
Kitlam123 Posted March 26, 2011 Share Posted March 26, 2011 Did you ever get this figured out...I have a client who would happily pay to have his store set so all the emails, history page and shopping cart would show the prices, taxes, subtotals etc. All the same and in the same format...as it stands now it is almost mpossible to debug. Link to comment Share on other sites More sharing options...
Jero Posted August 12, 2011 Share Posted August 12, 2011 After almost a year this issue still remain unsolved. Any new insights? Fix from post #3 dosen't work for me. Price is still the same. Link to comment Share on other sites More sharing options...
Recommended Posts