Changing the Wishlist button status?

  • Posts: 2
  • Thank you received: 0
4 years 10 months ago #306454

-- HikaShop version -- : 4.0.0
-- Joomla version -- : 3.8.12
-- PHP version -- : 5.6.40

cl.ly/70ee6fda395d - image of the button...

On the page I gave, there is a little grey heart that acts as wishlist button. But this question applies to all wishlist buttons.

Is there a way for the wishlist button to change status (or css class) depending on whether the user has added that item to their wishlist? We want to let the user know they already have it in their wishlist.

Thanks!

Please Log in or Create an account to join the conversation.

  • Posts: 81363
  • Thank you received: 13037
  • MODERATOR
4 years 10 months ago #306467

Hi,

There is no option for that.
As you can have quantity for products in wishlists, clicking several times on the wishlist button will increase the quantity of the product in the wishlist.

Now you could add such class with a bit of customization on the view file displaying the wishlist button.
You can activate the "Display view files" setting of the HikaShop configuration to know which view file is used there.
Then, in the view, you can load the cart and loop through the products in it to see if one match with the current product. It should be some simple code like that:

$cartClass = hikashop_get('class.cart');
$cart_id = $cartClass->getCurrentCartId('cart');
$cart = $cartClass->getFullCart($cart_id);
foreach($cart->products as $product) {
 if($product->product_id == $this->row->product_id) {
echo 'product already in the cart';
}
}
To do the same for the wishlist instead of the cart, just replace 'cart' by 'wishlist' in the getCurrentCartId function call.

Please Log in or Create an account to join the conversation.

Time to create page: 0.056 seconds
Powered by Kunena Forum