From 1840b804db700cf6c704eea7bf0282b1fcbaf079 Mon Sep 17 00:00:00 2001 From: devansh bawari Date: Fri, 12 Feb 2021 17:37:53 +0530 Subject: [PATCH 1/2] Wishlist And Some Code Enhanced --- .../Webkul/Customer/src/Helpers/Wishlist.php | 4 ++-- .../views/shop/products/wishlist.blade.php | 22 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/Webkul/Customer/src/Helpers/Wishlist.php b/packages/Webkul/Customer/src/Helpers/Wishlist.php index 039b54c40..405417a1c 100644 --- a/packages/Webkul/Customer/src/Helpers/Wishlist.php +++ b/packages/Webkul/Customer/src/Helpers/Wishlist.php @@ -43,9 +43,9 @@ class Wishlist } if ($wishlist) { - return true; + return $wishlist; } - return false; + return null; } } \ No newline at end of file diff --git a/packages/Webkul/Velocity/src/Resources/views/shop/products/wishlist.blade.php b/packages/Webkul/Velocity/src/Resources/views/shop/products/wishlist.blade.php index acb9e4388..66573a0a1 100644 --- a/packages/Webkul/Velocity/src/Resources/views/shop/products/wishlist.blade.php +++ b/packages/Webkul/Velocity/src/Resources/views/shop/products/wishlist.blade.php @@ -4,22 +4,22 @@ @auth('customer') @php - $isWished = $wishListHelper->getWishlistProduct($product); + /* search wishlist on the basis of product's id so that wishlist id can be catched */ + $wishlist = $wishListHelper->getWishlistProduct($product); + + /* link making */ + $href = isset($route) ? $route : ($wishlist ? route('customer.wishlist.remove', $wishlist->id) : route('customer.wishlist.add', $product->product_id)); + + /* title */ + $title = $wishlist ? __('velocity::app.shop.wishlist.remove-wishlist-text') : __('velocity::app.shop.wishlist.add-wishlist-text'); @endphp + href="{{ $href }}" + title="{{ $title }}"> - + @if (isset($text)) {!! $text !!} From 6cd6b94af9e8c9b93664cd55b233c4cfe4ea23fe Mon Sep 17 00:00:00 2001 From: devansh bawari Date: Fri, 12 Feb 2021 17:53:17 +0530 Subject: [PATCH 2/2] Extra Usage Checks For The Support --- packages/Webkul/API/Http/Resources/Catalog/Product.php | 2 +- .../Shop/src/Resources/views/products/view/gallery.blade.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/Webkul/API/Http/Resources/Catalog/Product.php b/packages/Webkul/API/Http/Resources/Catalog/Product.php index cc1bbc18d..ef7e1ed74 100644 --- a/packages/Webkul/API/Http/Resources/Catalog/Product.php +++ b/packages/Webkul/API/Http/Resources/Catalog/Product.php @@ -61,7 +61,7 @@ class Product extends JsonResource /* product's checks */ 'in_stock' => $product->haveSufficientQuantity(1), 'is_saved' => false, - 'is_wishlisted' => $this->wishlistHelper->getWishlistProduct($product), + 'is_wishlisted' => $this->wishlistHelper->getWishlistProduct($product) ? true : false, 'is_item_in_cart' => \Cart::hasProduct($product), 'show_quantity_changer' => $this->when( $product->type !== 'grouped', diff --git a/packages/Webkul/Shop/src/Resources/views/products/view/gallery.blade.php b/packages/Webkul/Shop/src/Resources/views/products/view/gallery.blade.php index b87eb34d7..39a5c0c0b 100755 --- a/packages/Webkul/Shop/src/Resources/views/products/view/gallery.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/products/view/gallery.blade.php @@ -194,7 +194,7 @@ $('img#pro-img').data('zoom-image', $('img#pro-img').data('image')).ezPlus(); } - var wishlist = " getWishlistProduct($product); ?> "; + var wishlist = "{{ $wishListHelper->getWishlistProduct($product) ? 'true' : 'false' }}"; $(document).mousemove(function(event) { if ($('.add-to-wishlist').length || wishlist != 0) {