diff --git a/adm/tabs/AdminOrders.php b/adm/tabs/AdminOrders.php index a54d28ac..28be25f0 100755 --- a/adm/tabs/AdminOrders.php +++ b/adm/tabs/AdminOrders.php @@ -803,33 +803,26 @@ class AdminOrders extends AdminTab if ($order->getCurrentState() != (int)Configuration::get('PS_OS_REFUND')) { $refundIsFull = false; $orderSlip = OrderSlip::getOrdersSlip($order->id_customer, $order->id); - if (count($orderSlip) > 0) { - if ($orderSlip['shipping_cost'] == 1) { - $orderSlipDetail = OrderSlip::getOrdersSlipDetail($orderSlip['id_order_slip']); - if (count($orderSlipDetail) > 0) { - foreach ($orderSlipDetail as $k => $v) { - $refundDetail[$v['id_order_detail']] = $v; + if (count($orderSlip) == 1) { + $slip = $orderSlip[0]; + if ($slip['shipping_cost'] == 1) { + $orderProducts = $order->getProductsDetail(); + $refundIsFull = true; + foreach ($orderProducts as $k => $line) { + if ($line['product_quantity'] != $line['product_quantity_refunded']) { + $refundIsFull = false; + break; } - $orderProducts = $order->getProductsDetail(); - // Check line - $refundIsFull = false; - if (count($orderProducts) == count($refundDetail)) { - $refundIsFull = true; - foreach($orderProducts as $k => $line) { - if ($line['product_quantity'] != $refundDetail[$line['id_order_detail']]['product_quantity']) { - $refundIsFull = false; - break; - } - } - } } } } // Change order state if ($refundIsFull === true) { $history = new OrderHistory(); - $history->id_order = (int)$order->id; + $history->id_order = (int)($order->id); + $history->id_employee = (int)($cookie->id_employee); $history->changeIdOrderState((int)Configuration::get('PS_OS_REFUND'), (int)($order->id)); + $history->add(); } }