39 lines
1.7 KiB
PHP
39 lines
1.7 KiB
PHP
<?php
|
|
class OrderReturn extends OrderReturnCore {
|
|
|
|
public static function getOrderDetailReturnQty($product) {
|
|
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'].'
|
|
')) {
|
|
$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'].'
|
|
') + (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;
|
|
}
|
|
}
|
|
|