Wishlist not adding products

  • Posts: 46
  • Thank you received: 1
  • Hikashop Business
5 months 1 week ago #282508

-- HikaShop version -- : 3.2.1
-- Joomla version -- : 3.8.1
-- PHP version -- : 7.0.25
-- Browser(s) name and version -- : Any

I'm workin in catalog mode for a site and the wishlist does not seem to work as expected.

As a logged in user, when I try to add a product to the wishlist it says that product is not available.

I have customized a bit the add to wishlist button to use this code in product view:

<a class="swan-heart-icon" href="<?php echo hikashop_completeLink($classical_url); ?>" rel="nofollow" onclick="if(window.hikashop.addToWishlist) { return window.hikashop.addToWishlist(this); }" data-addToWishlist="<?php echo $this->element->product_id ?>" data-addTo-div="hikashop_product_form" data-addTo-class="add_in_progress">

Which looks ok to me as far as I can see in your Demo.

I have checked that the products have stock and even setting stock to "Unlimited", they cannot be added.

Can you please let me know where I should look next? I cannot find why the products are not being added to the wishlist.

Thanks!!

Carlos

Attachments:

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

  • Posts: 61874
  • Thank you received: 8804
  • MODERATOR
5 months 1 week ago #282516

Hi,

It would be great if you could provide a test user account in such cases so that we can directly analyze the situation.

Right now, I can only provide some vague guidance. If you activate the display of the add to wishlist button (so that HikaShop displays its own button) do you see the button and does it work ?

Also, you're using the variable $this->element, but on a products listing, the data of the product is available in $this->row and not $this->element. Maybe that would explain why you get that error as the id you give is not the correct one ?

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

  • Posts: 46
  • Thank you received: 1
  • Hikashop Business
5 months 4 days ago #282938

Hi Nicolas,
thank you very much for your reply!

I'm afraid it didn't help that much:

Right now, I can only provide some vague guidance. If you activate the display of the add to wishlist button (so that HikaShop displays its own button) do you see the button and does it work ?


No, it has exactly the same behaviour.

Also, you're using the variable $this->element, but on a products listing,


No, I'm using the code shown for Product View, for Product DETAIL view ;)


This message contains confidential information

Last Edit: 5 months 4 days ago by karendunne.

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

  • Posts: 61874
  • Thank you received: 8804
  • MODERATOR
5 months 3 days ago #282978

Hi,

From hat I can see, the issue is that you've deactivated the "Display 'add to cart' button for free products" setting in the HikaShop configuration, and that you didn't configure any price in the prices listing of the product (which you've actually removed from the product edition screen).
If I turn on that option, then it works fine.

The following user(s) said Thank You: karendunne

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

  • Posts: 46
  • Thank you received: 1
  • Hikashop Business
5 months 3 days ago #283015

Thank you very much!!

And just in case you can provide a quick answer. Do you estore in the item object any information to show that the product is already in a wishlist? I want to change the button accordingly ;)

Thanks!!

Carlos Cámara

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

  • Posts: 61874
  • Thank you received: 8804
  • MODERATOR
5 months 2 days ago #283016

Hi,

No, there is no such data in the product object that you have access to in the views. You would have to load the wishlist, go through the products in it and see if one is a match with some custom coding.
It's only a few lines of code so it's not that hard.
Something like that:

$cartClass = hikashop_get('class.cart');
$wishlist = $cartClass->getFullCart($cartClass->getCurrentCartId('wishlist'));
foreach($wishlist->products as $product){
 if($product->product_id == $this->row->product_id){
  // my process 
}
}

The following user(s) said Thank You: karendunne

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

  • Posts: 46
  • Thank you received: 1
  • Hikashop Business
4 months 4 weeks ago #283218

Thank you very much!! It's an easy solution indeed ;)

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

Time to create page: 0.089 seconds
Powered by Kunena Forum