fix on basket

This commit is contained in:
Ludovic CANDELLIER
2022-04-17 00:16:36 +02:00
parent fe1e14d2c0
commit a12dd0c653
5 changed files with 30 additions and 15 deletions

View File

@@ -8,9 +8,18 @@ use \Cart;
class ShopCart
{
public static function add($item)
public static function add($item, $update = false)
{
$ret = self::get()->add($item);
if (self::has($item['id'])) {
if ($update) {
self::remove($id);
$ret = self::get()->add($item);
} else {
$ret = self::get()->update($item['id'], ['quantity' => $item['quantity']]);
}
} else {
$ret = self::get()->add($item);
}
return [
'count' => self::count(),
'quantity' => self::getTotalQuantity(),