Filters collapsed, customer auth and register, fix on basket recalculation

This commit is contained in:
Ludovic CANDELLIER
2022-04-20 00:16:16 +02:00
parent a12dd0c653
commit 94234218d6
31 changed files with 218 additions and 251 deletions

View File

@@ -12,10 +12,13 @@ class ShopCart
{
if (self::has($item['id'])) {
if ($update) {
self::remove($id);
self::remove($item['id']);
$ret = self::get()->add($item);
// $ret = self::get()->update($item['id'], ['quantity' => $item['quantity']]);
} else {
$ret = self::get()->update($item['id'], ['quantity' => $item['quantity']]);
// self::remove($item['id']);
// $ret = self::get()->add($item);
}
} else {
$ret = self::get()->add($item);
@@ -45,7 +48,7 @@ class ShopCart
public static function clear()
{
Cart::clear();
return Cart::session(Auth::id())->clear();
return self::get()->clear();
}
public static function has($id)
@@ -70,7 +73,17 @@ class ShopCart
public static function getTotal()
{
return self::get()->getTotal();
return number_format(round(self::get()->getTotal(),2),2);
}
public static function getItemQuantity($id)
{
return self::getItem($id) ? (int) self::getItem($id)->quantity : 0;
}
public static function getItem($id)
{
return Cart::get($id);
}
public static function getContent()
@@ -80,6 +93,6 @@ class ShopCart
public static function get()
{
return Cart::session(Users::getId());
return Cart::session('_token');
}
}