bebeboutik/override/classes/OrderReturn.php

39 lines
1.7 KiB
PHP
Raw Normal View History

<?php
class OrderReturn extends OrderReturnCore {
2017-10-11 16:14:59 +02:00
public static function getOrderDetailReturnQty($product, $id_state = 0) {
if(Db::getInstance()->getRow('
SELECT `id_order`
FROM `'._DB_PREFIX_.'shipping_history`
WHERE `id_order` = '.(int) $product['id_order'].'
AND `id_sale` = '.(int) $product['id_sale'].'
2017-10-11 16:14:59 +02:00
') || ($id_state != 0 && $id_state == 4)) {
$qty = (int) $product['product_quantity'] - max((int) $product['product_quantity_refunded'], (int) $product['product_quantity_return']);
} else {
$qty = (int) Db::getInstance()->getValue('
SELECT SUM(`quantity`)
FROM `'._DB_PREFIX_.'lapostews`
WHERE `id_order_detail` = '.(int) $product['id_order_detail'].'
') + (int) Db::getInstance()->getValue('
SELECT SUM(`quantity`)
FROM `'._DB_PREFIX_.'mondialrelay_parcel`
WHERE `id_order_detail` = '.(int) $product['id_order_detail'].'
2017-05-24 10:12:15 +02:00
') + (int) Db::getInstance()->getValue('
SELECT SUM(`quantity`)
FROM `'._DB_PREFIX_.'philea_parcel`
WHERE `id_order_detail` = '.(int) $product['id_order_detail'].'
') - max($product['product_quantity_return'], $product['product_quantity_refunded']);
}
$qty -= (int) Db::getInstance()->getValue('
SELECT SUM(d.`product_quantity`)
FROM `'._DB_PREFIX_.'order_return_detail` d
LEFT JOIN `'._DB_PREFIX_.'order_return` r
ON d.`id_order_return` = r.`id_order_return`
WHERE d.`id_order_detail` = '.(int) $product['id_order_detail'].'
AND r.`state` < 3
');
return $qty;
}
}