From e2079093aeb9d99d0e4e7ea41ead72102761be59 Mon Sep 17 00:00:00 2001 From: aNiassy Date: Wed, 13 Jun 2012 08:10:12 +0000 Subject: [PATCH] [-] FO : #PSCFI-5795 : fixed a bug where the opc freeze when an Order is to 0 --- classes/order/OrderDetail.php | 5 ++++- classes/order/OrderHistory.php | 12 +++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/classes/order/OrderDetail.php b/classes/order/OrderDetail.php index 3b18eca23..b6a269c5f 100644 --- a/classes/order/OrderDetail.php +++ b/classes/order/OrderDetail.php @@ -303,7 +303,10 @@ class OrderDetailCore extends ObjectModel if (count($this->tax_calculator->taxes) == 0) return true; - + + if ($order->total_products <= 0) + return true; + $ratio = $this->unit_price_tax_excl / $order->total_products; $order_reduction_amount = $order->total_discounts_tax_excl * $ratio; $discounted_price_tax_excl = $this->unit_price_tax_excl - $order_reduction_amount; diff --git a/classes/order/OrderHistory.php b/classes/order/OrderHistory.php index 6620f96f3..4c88bc741 100644 --- a/classes/order/OrderHistory.php +++ b/classes/order/OrderHistory.php @@ -222,7 +222,9 @@ class OrderHistoryCore extends ObjectModel if ($new_os->paid == 1) { $invoices = $order->getInvoicesCollection(); - $payment_method = Module::getInstanceByName($order->module); + if ($order->total_paid != 0) + $payment_method = Module::getInstanceByName($order->module); + foreach ($invoices as $invoice) { $rest_paid = $invoice->getRestPaid(); @@ -232,10 +234,14 @@ class OrderHistoryCore extends ObjectModel $payment->order_reference = $order->reference; $payment->id_currency = $order->id_currency; $payment->amount = $rest_paid; - $payment->payment_method = $payment_method->displayName; + + if ($order->total_paid != 0) + $payment->payment_method = $payment_method->displayName; + else + $payment->payment_method = null; + $payment->conversion_rate = 1; $payment->save(); - Db::getInstance()->execute(' INSERT INTO `'._DB_PREFIX_.'order_invoice_payment` VALUES('.(int)$invoice->id.', '.(int)$payment->id.', '.(int)$order->id.')');