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')) {
$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();
}
}