diff --git a/Gruntfile.js b/Gruntfile.js index 00690669..62c38fd7 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -18,6 +18,7 @@ var jsSite = [ jsBase, jsBootstrap, 'node_modules/currency.js/dist/currency.min.js', + 'build/js/plugins/smooth_products/js/smoothproducts.min.js', 'build/js/site.js', ] @@ -25,6 +26,7 @@ var cssSite = [ 'node_modules/bootstrap/dist/css/bootstrap.min.css', 'node_modules/@fortawesome/fontawesome-free/css/all.min.css', 'node_modules/animate.css/animate.min.css', + 'build/js/plugins/smooth_products/css/smoothproducts.css', 'build/css/shadow.css', 'build/css/site.css', ] diff --git a/app/Http/Controllers/Shop/BasketController.php b/app/Http/Controllers/Shop/BasketController.php index 468d8c3c..7e7655f4 100644 --- a/app/Http/Controllers/Shop/BasketController.php +++ b/app/Http/Controllers/Shop/BasketController.php @@ -25,7 +25,8 @@ class BasketController extends Controller { $offer_id = $request->input('offer_id'); $quantity = $request->input('quantity'); - return Offers::addBasket($offer_id, $quantity); + $update = $request->input('update') ?? false; + return Offers::addBasket($offer_id, $quantity, $update); } diff --git a/app/Repositories/Core/User/ShopCart.php b/app/Repositories/Core/User/ShopCart.php index 21cb4af0..37b08dfa 100644 --- a/app/Repositories/Core/User/ShopCart.php +++ b/app/Repositories/Core/User/ShopCart.php @@ -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(), diff --git a/app/Repositories/Shop/Offers.php b/app/Repositories/Shop/Offers.php index 5fb6db2d..05afbf98 100644 --- a/app/Repositories/Shop/Offers.php +++ b/app/Repositories/Shop/Offers.php @@ -7,22 +7,21 @@ use App\Repositories\Core\User\ShopCart; class Offers { - public static function addBasket($offer_id, $quantity = 1) + public static function addBasket($offer_id, $quantity = 1, $update = false) { - if (ShopCart::has($offer_id)) { + if (ShopCart::has($offer_id) && !$quantity) { $ret = ShopCart::remove($offer_id); } $data = $quantity ? Offers::getBasketData($offer_id, $quantity) : false; - return $data ? ShopCart::add($data) : false; + return $data ? ShopCart::add($data, $update) : false; } public static function getFull($id, $sale_channel_id = false) { $sale_channel_id = $sale_channel_id ? $sale_channel_id : SaleChannels::getDefaultID(); - return Offer::with([ + $offer = Offer::with([ 'article.article_nature', 'article.product', - 'article.image', 'tariff' => function ($query) use ($sale_channel_id) { $query->bySaleChannel($sale_channel_id); }, @@ -32,6 +31,8 @@ class Offers 'tariff.price_lists.price_list_values', 'variation', ])->find($id); + $offer->article->image = Articles::getFullImageByArticle($offer->article); + return $offer; } public static function getPrice($id, $quantity = 1, $sale_channel_id = false) @@ -56,7 +57,7 @@ class Offers 'quantity' => (int) $item->quantity, 'price' => $item->price, 'variation' => $offer->variation->name, - 'image' => Articles::getPreviewSrc($offer->article->image), + 'image' => Articles::getPreviewSrc(Articles::getFullImageByArticle($offer->article)), ]; } return $data ?? false; diff --git a/resources/views/Shop/Baskets/basket.blade.php b/resources/views/Shop/Baskets/basket.blade.php index ac17dd52..8305648a 100644 --- a/resources/views/Shop/Baskets/basket.blade.php +++ b/resources/views/Shop/Baskets/basket.blade.php @@ -28,7 +28,7 @@ @endforeach