diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php index ccabb1ca0..ff61d9925 100755 --- a/packages/Webkul/Checkout/src/Cart.php +++ b/packages/Webkul/Checkout/src/Cart.php @@ -294,6 +294,40 @@ class Cart return false; } + /** + * Remove all items from cart. + * + * @return \Webkul\Checkout\Models\Cart|null + */ + public function removeAllItems(): ?CartModel + { + $cart = $this->getCart(); + + Event::dispatch('checkout.cart.delete.all.before', $cart); + + if (! $cart) { + return $cart; + } + + foreach ($cart->items as $item) { + $this->cartItemRepository->delete($item->id); + + if ($cart->items->count() == 0) { + $this->cartRepository->delete($cart->id); + + if (session()->has('cart')) { + session()->forget('cart'); + } + } + } + + $cart->save(); + + Event::dispatch('checkout.cart.delete.all.after', $cart); + + return $cart; + } + /** * Remove cart items, whose product is inactive. * diff --git a/packages/Webkul/Shop/src/Http/Controllers/CartController.php b/packages/Webkul/Shop/src/Http/Controllers/CartController.php index 98fea5dad..9b79bbbd8 100755 --- a/packages/Webkul/Shop/src/Http/Controllers/CartController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/CartController.php @@ -105,6 +105,22 @@ class CartController extends Controller return redirect()->back(); } + /** + * Removes the item from the cart if it exists. + * + * @return \Illuminate\Http\Response + */ + public function removeAllItems() + { + $result = Cart::removeAllItems(); + + if ($result) { + session()->flash('success', trans('shop::app.checkout.cart.item.success-all-remove')); + } + + return redirect()->back(); + } + /** * Updates the quantity of the items present in the cart. * diff --git a/packages/Webkul/Shop/src/Resources/lang/ar/app.php b/packages/Webkul/Shop/src/Resources/lang/ar/app.php index 2a9692228..5f0a88524 100644 --- a/packages/Webkul/Shop/src/Resources/lang/ar/app.php +++ b/packages/Webkul/Shop/src/Resources/lang/ar/app.php @@ -503,6 +503,8 @@ return [ 'continue-registration' => 'متابعة التسجيل', 'proceed-to-checkout' => 'انتقل إلى الخروج', 'remove' => 'احذف', + 'remove-all-items' => 'Remove all items', + 'confirm-action' => 'Confirm this action?', 'remove-link' => 'احذف', 'move-to-wishlist' => 'انقل إلى قائمة الأمنيات', 'move-to-wishlist-success' => 'نقل العنصر إلى قائمة الأمنيات', @@ -521,6 +523,7 @@ return [ 'success' => 'تم بنجاح إضافة العنصر إلى العربة', 'success-remove' => 'تم إزالة العنصر بنجاح من العربة', 'error-add' => 'لا يمكن إضافة العنصر إلى العربة ، رجاء حاول مرة أخرى ', + 'success-all-remove' => 'All items is successfully removed from the cart.', 'inactive' => 'An item is inactive and was removed from cart', 'inactive-add' => 'Inactive item cannot be added to cart', ], diff --git a/packages/Webkul/Shop/src/Resources/lang/de/app.php b/packages/Webkul/Shop/src/Resources/lang/de/app.php index e0454f3ee..45e04a263 100755 --- a/packages/Webkul/Shop/src/Resources/lang/de/app.php +++ b/packages/Webkul/Shop/src/Resources/lang/de/app.php @@ -501,6 +501,8 @@ return [ 'proceed-to-checkout' => 'Zur Kasse', 'remove' => 'Entfernen', 'remove-link' => 'Entfernen', + 'remove-all-items' => 'Remove all items', + 'confirm-action' => 'Confirm this action?', 'move-to-wishlist' => 'Zur Wunschliste verschieben', 'move-to-wishlist-success' => 'Artikel wurde erfolgreich auf die Wunschliste verschoben.', 'move-to-wishlist-error' => 'Das Objekt kann nicht auf die Wunschliste verschoben werden. Bitte versuchen Sie es später erneut.', @@ -517,6 +519,7 @@ return [ 'error_remove' => 'Keine Artikel aus dem Warenkorb zu entfernen', 'success' => 'Artikel wurde erfolgreich zum Warenkorb hinzugefügt', 'success-remove' => 'Artikel wurde erfolgreich aus dem Warenkorb entfernt', + 'success-all-remove' => 'All items is successfully removed from the cart.', 'error-add' => 'Artikel kann nicht zum Warenkorb hinzugefügt werden. Bitte versuchen Sie es später erneut', 'inactive' => 'Ein Artikel ist inaktiv und wurde aus dem Warenkorb entfernt.', 'inactive-add' => 'Ein inaktiver Artikel kann nicht zum Warenkorb hinzugefügt werde.', diff --git a/packages/Webkul/Shop/src/Resources/lang/en/app.php b/packages/Webkul/Shop/src/Resources/lang/en/app.php index 3777614cc..a9de070e2 100755 --- a/packages/Webkul/Shop/src/Resources/lang/en/app.php +++ b/packages/Webkul/Shop/src/Resources/lang/en/app.php @@ -160,7 +160,7 @@ return [ 'not-activated' => 'Your activation seeks admin approval', 'resend-verification' => 'Resend verification mail again', 'show-password' => 'Show Password', - + ], 'forgot-password' => [ @@ -500,6 +500,8 @@ return [ 'empty' => 'Your shopping cart is empty', 'update-cart' => 'Update Cart', 'continue-shopping' => 'Continue Shopping', + 'remove-all-items' => 'Remove all items', + 'confirm-action' => 'Confirm this action?', 'continue-registration' => 'Continue Registration', 'proceed-to-checkout' => 'Proceed To Checkout', 'remove' => 'Remove', @@ -519,6 +521,7 @@ return [ 'error_remove' => 'No items to remove from the cart.', 'success' => 'Item is successfully added to cart.', 'success-remove' => 'Item is successfully removed from the cart.', + 'success-all-remove' => 'All items is successfully removed from the cart.', 'error-add' => 'Item cannot be added to cart, please try again later.', 'inactive' => 'An item is inactive and was removed from cart.', 'inactive-add' => 'Inactive item cannot be added to cart.', diff --git a/packages/Webkul/Shop/src/Resources/lang/es/app.php b/packages/Webkul/Shop/src/Resources/lang/es/app.php index 727d2361f..12ef3a458 100644 --- a/packages/Webkul/Shop/src/Resources/lang/es/app.php +++ b/packages/Webkul/Shop/src/Resources/lang/es/app.php @@ -505,6 +505,8 @@ return [ 'proceed-to-checkout' => 'Continuar con el pago', 'remove' => 'Eliminar', 'remove-link' => 'Eliminar', + 'remove-all-items' => 'Remove all items', + 'confirm-action' => 'Confirm this action?', 'move-to-wishlist' => 'Mover a la lista de deseos', 'move-to-wishlist-success' => 'Artículo movido a la lista de deseos', 'move-to-wishlist-error' => 'El artículo no se puede añadir a la lista de deseos, por favor inténtalo más tarde', @@ -520,6 +522,7 @@ return [ 'error_remove' => 'No hay artículos que eliminar en el carrito', 'success' => 'El artículo se añadió al carrito', 'success-remove' => 'El artículo se eliminó del carrito', + 'success-all-remove' => 'All items is successfully removed from the cart.', 'error-add' => 'El artículo no se puede añadir al carrito, inténtelo más tarde', 'inactive' => 'Un artículo está inactivo y se eliminó del carrito.', 'inactive-add' => 'El artículo inactivo no se puede agregar al carrito', diff --git a/packages/Webkul/Shop/src/Resources/lang/fa/app.php b/packages/Webkul/Shop/src/Resources/lang/fa/app.php index c5d80ada9..eb7dcf76a 100644 --- a/packages/Webkul/Shop/src/Resources/lang/fa/app.php +++ b/packages/Webkul/Shop/src/Resources/lang/fa/app.php @@ -501,6 +501,8 @@ return [ 'proceed-to-checkout' => 'ادامه به پرداخت', 'remove' => 'برداشتن', 'remove-link' => 'برداشتن', + 'remove-all-items' => 'Remove all items', + 'confirm-action' => 'Confirm this action?', 'move-to-wishlist' => 'انتقال به لیست دلخواه', 'move-to-wishlist-success' => 'مورد به لیست دلخواه منتقل شد', 'move-to-wishlist-error' => 'نمی توان مورد را به لیست علاقه مندی ها انتقال داد ، لطفا بعداً دوباره امتحان کنید', @@ -517,6 +519,7 @@ return [ 'error_remove' => 'هیچ موردی برای حذف از سبد خرید وجود ندارد', 'success' => 'مورد با موفقیت به سبد خرید اضافه شد', 'success-remove' => 'مورد با موفقیت از سبد خرید حذف شد', + 'success-all-remove' => 'All items is successfully removed from the cart.', 'error-add' => 'لطفاً موردی را به سبد خرید اضافه نکرد ، لطفا بعداً دوباره امتحان کنید', 'inactive' => 'An item is inactive and was removed from cart', 'inactive-add' => 'Inactive item cannot be added to cart', diff --git a/packages/Webkul/Shop/src/Resources/lang/fr/app.php b/packages/Webkul/Shop/src/Resources/lang/fr/app.php index 205053110..235980746 100755 --- a/packages/Webkul/Shop/src/Resources/lang/fr/app.php +++ b/packages/Webkul/Shop/src/Resources/lang/fr/app.php @@ -500,6 +500,8 @@ return [ 'proceed-to-checkout' => 'Passer à la caisse', 'remove' => 'Supprimer', 'remove-link' => 'Supprimer', + 'remove-all-items' => 'Remove all items', + 'confirm-action' => 'Confirm this action?', 'move-to-wishlist' => 'Placer dans la liste de souhaits', 'move-to-wishlist-success' => 'L\'article a été déplacé vers la liste de souhaits avec succès.', 'move-to-wishlist-error' => 'Impossible de déplacer l\'élément vers la liste de souhaits, veuillez réessayer plus tard.', @@ -517,6 +519,7 @@ return [ 'error_remove' => 'Aucun article à retirer du panier.', 'success' => 'L\'article a été ajouté au panier avec succès.', 'success-remove' => 'L\'article a été supprimé avec succès du panier.', + 'remove-all-items' => 'Remove all items', 'error-add' => 'L\'article ne peut pas être ajouté au panier, veuillez réessayer plus tard.', 'inactive' => 'Un article est inactif et a été supprimé du panier.', 'inactive-add' => 'L\'article inactif ne peut pas être ajouté au panier.', diff --git a/packages/Webkul/Shop/src/Resources/lang/hi_IN/app.php b/packages/Webkul/Shop/src/Resources/lang/hi_IN/app.php index 032143b4b..7e2f011ce 100644 --- a/packages/Webkul/Shop/src/Resources/lang/hi_IN/app.php +++ b/packages/Webkul/Shop/src/Resources/lang/hi_IN/app.php @@ -503,6 +503,8 @@ return [ 'proceed-to-checkout' => 'चेक आउट करने के लिए आगे बढ़ें', 'remove' => 'निकालना', 'remove-link' => 'निकालना', + 'remove-all-items' => 'Remove all items', + 'confirm-action' => 'Confirm this action?', 'move-to-wishlist' => 'इच्छा सूची की ओर बदें', 'move-to-wishlist-success' => 'आइटम सफलतापूर्वक इच्छा सूची में ले जाया गया।', 'move-to-wishlist-error' => 'आइटम को इच्छा सूची में नहीं ले जाया जा सकता, कृपया बाद में पुन: प्रयास करें।', @@ -518,6 +520,7 @@ return [ 'error_remove' => 'कार्ट से निकालने के लिए कोई आइटम नहीं है।', 'success' => 'आइटम सफलतापूर्वक कार्ट में जोड़ा गया।', 'success-remove' => 'आइटम कार्ट से सफलतापूर्वक हटा दिया गया है।', + 'success-all-remove' => 'All items is successfully removed from the cart.', 'error-add' => 'आइटम कार्ट में नहीं जोड़ा जा सकता, कृपया बाद में पुन: प्रयास करें।', 'inactive' => 'एक आइटम निष्क्रिय है और उसे कार्ट से निकाल दिया गया था।', 'inactive-add' => 'निष्क्रिय आइटम कार्ट में नहीं जोड़ा जा सकता है।', diff --git a/packages/Webkul/Shop/src/Resources/lang/it/app.php b/packages/Webkul/Shop/src/Resources/lang/it/app.php index f45caf192..9372c36cc 100644 --- a/packages/Webkul/Shop/src/Resources/lang/it/app.php +++ b/packages/Webkul/Shop/src/Resources/lang/it/app.php @@ -498,6 +498,8 @@ return [ 'empty' => 'Il tuo carrello è ancora vuoto', 'update-cart' => 'Aggiorna Carrello', 'continue-shopping' => 'Continua con i tuoi acquisti', + 'remove-all-items' => 'Rimuovi tutti i prodotti', + 'confirm-action' => 'Confermi questa azione?', 'continue-registration' => 'Continua la registrazione', 'proceed-to-checkout' => 'Procedi alla Cassa', 'remove' => 'Rimuovi', @@ -518,6 +520,7 @@ return [ 'error_remove' => 'Nessun prodotto da rimuovere nel carrello.', 'success' => 'Prodotto aggiunto al carrello.', 'success-remove' => 'Prodotto rimosso dal carrello.', + 'success-all-remove' => 'Tutti i prodotti sono rimossi dal carrello', 'error-add' => 'Il prodotto non può essere aggiunto al carrello, prova ancora.', 'inactive' => 'An item is inactive and was removed from cart.', 'inactive-add' => 'Inactive item cannot be added to cart.', diff --git a/packages/Webkul/Shop/src/Resources/lang/ja/app.php b/packages/Webkul/Shop/src/Resources/lang/ja/app.php index 176933361..d79e17d23 100644 --- a/packages/Webkul/Shop/src/Resources/lang/ja/app.php +++ b/packages/Webkul/Shop/src/Resources/lang/ja/app.php @@ -467,6 +467,8 @@ return [ 'proceed-to-checkout' => '購入手続きに進む', 'remove' => '削除', 'remove-link' => '削除', + 'remove-all-items' => 'Remove all items', + 'confirm-action' => 'Confirm this action?', 'move-to-wishlist' => 'お気に入りに移動する', 'move-to-wishlist-success' => 'アイテムがお気に入りに追加されました。', 'move-to-wishlist-error' => 'アイテムをお気に入りに追加することができませんでした。しばらくしてから再度お試し下さい。', @@ -482,6 +484,7 @@ return [ 'error_remove' => 'カートに削除するアイテムがございません。', 'success' => 'アイテムがカートに追加されました。', 'success-remove' => 'アイテムがカートから削除されました。', + 'success-all-remove' => 'All items is successfully removed from the cart.', 'error-add' => 'アイテムをカートに追加できません。しばらくしてから再度お試し下さい。', 'inactive' => 'An item is inactive and was removed from cart', 'inactive-add' => 'Inactive item cannot be added to cart', diff --git a/packages/Webkul/Shop/src/Resources/lang/nl/app.php b/packages/Webkul/Shop/src/Resources/lang/nl/app.php index 983f1db83..8e6b28717 100644 --- a/packages/Webkul/Shop/src/Resources/lang/nl/app.php +++ b/packages/Webkul/Shop/src/Resources/lang/nl/app.php @@ -509,6 +509,8 @@ return [ 'proceed-to-checkout' => 'Ga naar de kassa', 'remove' => 'Verwijderen', 'remove-link' => 'Verwijderen', + 'remove-all-items' => 'Remove all items', + 'confirm-action' => 'Confirm this action?', 'move-to-wishlist' => 'Verplaats naar wens lijst', 'move-to-wishlist-success' => 'Item is succesvol naar de verlanglijst verplaatst.', 'move-to-wishlist-error' => 'Kan item niet naar verlanglijstje verplaatsen, probeer het later opnieuw.', @@ -525,6 +527,7 @@ return [ 'error_remove' => 'Geen items om uit de winkelwagen te verwijderen.', 'success' => 'Artikel is succesvol toegevoegd aan winkelwagen.', 'success-remove' => 'Item is met succes uit de winkelwagen verwijderd.', + 'success-all-remove' => 'All items is successfully removed from the cart.', 'error-add' => 'Item kan niet aan winkelwagen worden toegevoegd. Probeer het later opnieuw.', 'inactive' => 'An item is inactive and was removed from cart.', 'inactive-add' => 'Inactive item cannot be added to cart.', diff --git a/packages/Webkul/Shop/src/Resources/lang/pl/app.php b/packages/Webkul/Shop/src/Resources/lang/pl/app.php index 098ece739..1927e0741 100644 --- a/packages/Webkul/Shop/src/Resources/lang/pl/app.php +++ b/packages/Webkul/Shop/src/Resources/lang/pl/app.php @@ -502,6 +502,8 @@ return [ 'proceed-to-checkout' => 'Przejdź do kasy”', 'remove' => 'Usuń', 'remove-link' => 'Usuń', + 'remove-all-items' => 'Remove all items', + 'confirm-action' => 'Confirm this action?', 'move-to-wishlist' => 'Przenieś na listę wyboru', 'move-to-wishlist-success' => 'Produkt został pomyślnie przeniesiony na listę wyboru.', 'move-to-wishlist-error' => 'Nie można przenieść ptoduktu na listę życzeń, spróbuj ponownie później.', @@ -518,6 +520,7 @@ return [ 'error_remove' => 'Brak produktów do usunięcia z koszyka.', 'success' => 'Produkt został pomyślnie dodany do koszyka.', 'success-remove' => 'Produkt został pomyślnie usunięty z koszyka.', + 'success-all-remove' => 'All items is successfully removed from the cart.', 'error-add' => 'Nie można dodać produktu do koszyka, spróbuj ponownie później.', 'inactive' => 'An item is inactive and was removed from cart.', 'inactive-add' => 'Inactive item cannot be added to cart.', diff --git a/packages/Webkul/Shop/src/Resources/lang/pt_BR/app.php b/packages/Webkul/Shop/src/Resources/lang/pt_BR/app.php index 2cab605e4..0308e5833 100755 --- a/packages/Webkul/Shop/src/Resources/lang/pt_BR/app.php +++ b/packages/Webkul/Shop/src/Resources/lang/pt_BR/app.php @@ -493,6 +493,8 @@ return [ 'proceed-to-checkout' => 'Finalizar Compra', 'remove' => 'Remover', 'remove-link' => 'Remover', + 'remove-all-items' => 'Remove all items', + 'confirm-action' => 'Confirm this action?', 'move-to-wishlist' => 'Mover para Lista de Desejos', 'move-to-wishlist-success' => 'Item Movido para Lista de Desejos', 'move-to-wishlist-error' => 'Não foi possivel Mover Item para Lista de Desejos, Por favor, tente novamente mais tarde', @@ -509,6 +511,7 @@ return [ 'error_remove' => 'Nenhum item para remover do carrinho', 'success' => 'Item foi adicionado com sucesso ao carrinho', 'success-remove' => 'Item foi removido com sucesso do carrinho', + 'success-all-remove' => 'All items is successfully removed from the cart.', 'error-add' => 'Item não pode ser adicionado ao carrinho, por favor, tente novamente mais tarde', 'inactive' => 'An item is inactive and was removed from cart', 'inactive-add' => 'Inactive item cannot be added to cart', diff --git a/packages/Webkul/Shop/src/Resources/lang/tr/app.php b/packages/Webkul/Shop/src/Resources/lang/tr/app.php index dd48c4732..07dd64a8b 100644 --- a/packages/Webkul/Shop/src/Resources/lang/tr/app.php +++ b/packages/Webkul/Shop/src/Resources/lang/tr/app.php @@ -502,6 +502,8 @@ return [ 'proceed-to-checkout' => 'Satın Al', 'remove' => 'Kaldır', 'remove-link' => 'Kaldır', + 'remove-all-items' => 'Remove all items', + 'confirm-action' => 'Confirm this action?', 'move-to-wishlist' => 'Dilek Listesine Ekle', 'move-to-wishlist-success' => 'Dilek listesine başarıyla eklendi.', 'move-to-wishlist-error' => 'Dilek listesine eklenirken hata oluştu, lütfen tekrar deneyin.', @@ -518,6 +520,7 @@ return [ 'error_remove' => 'Sepetten kaldırılacak ürün bulunamadı.', 'success' => 'Ürün başarıyla sepete eklendi.', 'success-remove' => 'Ürün sepetten başarıyla kaldırıldı.', + 'success-all-remove' => 'All items is successfully removed from the cart.', 'error-add' => 'Ürün sepete eklenirken hata oluştu, lütfen tekrar deneyin.', 'inactive' => 'An item is inactive and was removed from cart.', 'inactive-add' => 'Inactive item cannot be added to cart.', diff --git a/packages/Webkul/Shop/src/Resources/lang/zh_CN/app.php b/packages/Webkul/Shop/src/Resources/lang/zh_CN/app.php index a768ef8c5..8d54ea264 100644 --- a/packages/Webkul/Shop/src/Resources/lang/zh_CN/app.php +++ b/packages/Webkul/Shop/src/Resources/lang/zh_CN/app.php @@ -502,6 +502,8 @@ return [ 'proceed-to-checkout' => '进行结算', 'remove' => '移除', 'remove-link' => '移除', + 'remove-all-items' => 'Remove all items', + 'confirm-action' => 'Confirm this action?', 'move-to-wishlist' => '移动到愿望清单', 'move-to-wishlist-success' => '项目已成功移至愿望清单.', 'move-to-wishlist-error' => '无法将商品移至愿望清单, 请稍后再试.', @@ -518,6 +520,7 @@ return [ 'error_remove' => '没有要从购物车中删除的物品.', 'success' => '商品已成功添加到购物车.', 'success-remove' => '物品已成功从购物车中移除.', + 'success-all-remove' => 'All items is successfully removed from the cart.', 'error-add' => '商品无法加入购物车, 请稍后再试.', 'inactive' => '商品处于非活动状态并已从购物车中移除.', 'inactive-add' => '不活跃商品无法添加到购物车.', diff --git a/packages/Webkul/Shop/src/Resources/views/checkout/cart/index.blade.php b/packages/Webkul/Shop/src/Resources/views/checkout/cart/index.blade.php index 4b7ca6e69..7ad158916 100755 --- a/packages/Webkul/Shop/src/Resources/views/checkout/cart/index.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/checkout/cart/index.blade.php @@ -13,6 +13,20 @@