diff --git a/packages/Webkul/Customer/src/Http/Controllers/WishlistController.php b/packages/Webkul/Customer/src/Http/Controllers/WishlistController.php index c7f1399f3..d49cf1db5 100755 --- a/packages/Webkul/Customer/src/Http/Controllers/WishlistController.php +++ b/packages/Webkul/Customer/src/Http/Controllers/WishlistController.php @@ -70,6 +70,7 @@ class WishlistController extends Controller return view($this->_config['view'], [ 'items' => $this->wishlistRepository->getCustomerWishlist(), + 'isSharingEnabled' => $this->isSharingEnabled(), 'isWishlistShared' => $this->currentCustomer->isWishlistShared(), 'wishlistSharedLink' => $this->currentCustomer->getWishlistSharedLink() ]); @@ -136,16 +137,18 @@ class WishlistController extends Controller */ public function share() { - $data = $this->validate(request(), [ - 'shared' => 'required|boolean' - ]); + if ($this->isSharingEnabled()) { + $data = $this->validate(request(), [ + 'shared' => 'required|boolean' + ]); - $updateCounts = $this->currentCustomer->wishlist_items()->update(['shared' => $data['shared']]); + $updateCounts = $this->currentCustomer->wishlist_items()->update(['shared' => $data['shared']]); - if ($updateCounts && $updateCounts > 0) { - session()->flash('success', 'Shared wishlist settings updated successfully'); + if ($updateCounts && $updateCounts > 0) { + session()->flash('success', 'Shared wishlist settings updated successfully'); - return redirect()->back(); + return redirect()->back(); + } } return redirect()->back(); @@ -159,7 +162,8 @@ class WishlistController extends Controller public function shared(CustomerRepository $customerRepository) { if ( - ! request()->hasValidSignature() + ! $this->isSharingEnabled() + || ! request()->hasValidSignature() || ! core()->getConfigData('general.content.shop.wishlist_option') ) { abort(404); @@ -261,4 +265,16 @@ class WishlistController extends Controller return redirect()->back(); } + + /** + * Is sharing enabled. + * + * @return bool + */ + public function isSharingEnabled(): bool + { + return (bool) core()->getConfigData('customer.settings.wishlist.share') + ? true + : false; + } } diff --git a/packages/Webkul/Shop/src/Resources/views/customers/account/wishlist/wishlist-product.blade.php b/packages/Webkul/Shop/src/Resources/views/customers/account/wishlist/wishlist-product.blade.php index b1d499274..4fffc84d4 100644 --- a/packages/Webkul/Shop/src/Resources/views/customers/account/wishlist/wishlist-product.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/customers/account/wishlist/wishlist-product.blade.php @@ -13,21 +13,24 @@ @if (isset($item->additional['attributes']))
{{ __('shop::app.customer.account.wishlist.enable-wishlist-info') }}
- @endif +{{ __('shop::app.customer.account.wishlist.enable-wishlist-info') }}
+ @endif +