overriding lastNondeOrdered

This commit is contained in:
Christophe LATOUR 2017-12-04 11:21:34 +01:00
parent ce0d4a379d
commit f5aece5f7a

View File

@ -151,6 +151,35 @@ class Cart extends BaseCart
));
}
public static function getMaxIdOrdered($id_customer) {
$max_id = parent::getMaxIdOrdered($id_customer);
if (!$max_id) {
$max_id = \Db::getInstance()->getValue('
SELECT MAX(c.`id_cart`)
FROM '._DB_PREFIX_.'cart c
WHERE c.`id_customer` = '.(int)$id_customer.'
');
}
return $max_id;
}
public static function lastNoneOrderedCart($id_customer)
{
if (($max_id_cart = self::getMaxIdOrdered($id_customer))) {
$id_cart = \Db::getInstance()->getValue('
SELECT MIN(c.id_cart)
FROM '._DB_PREFIX_.'cart c
LEFT JOIN '._DB_PREFIX_.'orders o ON (c.`id_cart` = o.`id_cart`)
WHERE o.`id_order` IS NULL
AND c.`id_customer` = '.(int)$id_customer.'
AND c.`id_cart` >= '.(int)$max_id_cart.'
');
return $id_cart ? $id_cart : false;
}
return false;
}
public function apiGetAvailableCarriers(Request $request) {
$customer = $request->user();
$address = new ApiAddress((int)($this->id_address_delivery));