matik4 Posted Wednesday at 02:27 PM Share Posted Wednesday at 02:27 PM Hi all, I know this version is quite old now, but sharing a fix I had to implement on a PrestaShop 1.7.6.7 site with multi-currency enabled. Posting here because I couldn’t find a clear solution for this specific case anywhere. The issue: When an order was placed in a non-default currency (e.g. shop base in EUR, customer pays in CHF), the order itself showed the correct totals in the order currency. But in ps_order_detail, the product line prices (product_price, original_product_price, unit/totals) were stored in the shop’s base currency. This meant inconsistencies: order summary looked fine, but the order details showed the wrong currency values (in BO and order confirmation emails). To resolve, you need to override OrderDetail class. Drop this into /override/classes/order/OrderDetail.php and clear cache: <?php class OrderDetail extends OrderDetailCore { /** * Set detailed product price to the order detail. * * @param Order $order * @param Cart $cart * @param array $product */ protected function setDetailProductPrice(Order $order, Cart $cart, $product) { $currency = new Currency((int) $order->id_currency); $this->setContext((int) $product['id_shop']); $id_tax_address = (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}; $nullVar = null; $price_tax_incl = Product::getPriceStatic( (int) $product['id_product'], true, (int) $product['id_product_attribute'], 6, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, $id_tax_address, $nullVar, true, true, $this->context ); $price_tax_excl = Product::getPriceStatic( (int) $product['id_product'], false, (int) $product['id_product_attribute'], 6, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, $id_tax_address, $nullVar, true, true, $this->context ); $price_tax_incl = Tools::ps_round($price_tax_incl, 6); $price_tax_excl = Tools::ps_round($price_tax_excl, 6); $converted_excl = Tools::convertPrice($price_tax_excl, $currency); if ($converted_excl === false || $converted_excl === null) { $converted_excl = 0.0; } $this->original_product_price = (float) Tools::ps_round($converted_excl, 6); $this->product_price = $this->original_product_price; $this->unit_price_tax_excl = (float) Tools::ps_round(Tools::convertPrice((float) $product['price'], $currency), 6); $this->unit_price_tax_incl = (float) Tools::ps_round(Tools::convertPrice((float) $product['price_wt'], $currency), 6); $this->total_price_tax_excl = (float) Tools::ps_round(Tools::convertPrice((float) $product['total'], $currency), 6); $this->total_price_tax_incl = (float) Tools::ps_round(Tools::convertPrice((float) $product['total_wt'], $currency), 6); $this->purchase_supplier_price = (float) $product['wholesale_price']; if ($product['id_supplier'] > 0 && ($supplier_price = ProductSupplier::getProductPrice( (int) $product['id_supplier'], $product['id_product'], $product['id_product_attribute'], true )) > 0 ) { $this->purchase_supplier_price = (float) $supplier_price; } $this->setSpecificPrice($order, $product); $this->group_reduction = (float) Group::getReduction((int) $order->id_customer); $shop_id = $this->context->shop->id; $quantity_discount = SpecificPrice::getQuantityDiscount( (int) $product['id_product'], $shop_id, (int) $cart->id_currency, (int) $this->vat_address->id_country, (int) $this->customer->id_default_group, (int) $product['cart_quantity'], false, null, null, $nullVar, true, true, $this->context ); $unit_price = Product::getPriceStatic( (int) $product['id_product'], true, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 2, null, false, true, 1, false, (int) $order->id_customer, null, $id_tax_address, $nullVar, true, true, $this->context ); $unit_price = Tools::ps_round($unit_price, 6); $this->product_quantity_discount = 0.00; if ($quantity_discount) { $this->product_quantity_discount = $unit_price; if (Product::getTaxCalculationMethod((int) $order->id_customer) == PS_TAX_EXC) { $this->product_quantity_discount = Tools::ps_round($unit_price, 6); } if (isset($this->tax_calculator)) { $this->product_quantity_discount -= $this->tax_calculator->addTaxes($quantity_discount['price']); $this->product_quantity_discount = Tools::ps_round($this->product_quantity_discount, 6); } } $this->discount_quantity_applied = ( ($this->specificPrice && $this->specificPrice['from_quantity'] > 1) ? 1 : 0 ); } } ✌️ 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now