Merge branch 'ticket/r15587-refund-paypal'

This commit is contained in:
Michael RICOIS 2018-02-26 11:50:28 +01:00
commit b9016d4131

View File

@ -803,33 +803,26 @@ class AdminOrders extends AdminTab
if ($order->getCurrentState() != (int)Configuration::get('PS_OS_REFUND')) { if ($order->getCurrentState() != (int)Configuration::get('PS_OS_REFUND')) {
$refundIsFull = false; $refundIsFull = false;
$orderSlip = OrderSlip::getOrdersSlip($order->id_customer, $order->id); $orderSlip = OrderSlip::getOrdersSlip($order->id_customer, $order->id);
if (count($orderSlip) > 0) { if (count($orderSlip) == 1) {
if ($orderSlip['shipping_cost'] == 1) { $slip = $orderSlip[0];
$orderSlipDetail = OrderSlip::getOrdersSlipDetail($orderSlip['id_order_slip']); if ($slip['shipping_cost'] == 1) {
if (count($orderSlipDetail) > 0) { $orderProducts = $order->getProductsDetail();
foreach ($orderSlipDetail as $k => $v) { $refundIsFull = true;
$refundDetail[$v['id_order_detail']] = $v; 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 // Change order state
if ($refundIsFull === true) { if ($refundIsFull === true) {
$history = new OrderHistory(); $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->changeIdOrderState((int)Configuration::get('PS_OS_REFUND'), (int)($order->id));
$history->add();
} }
} }