Ajax to "Remove from wishlist"

  • Posts: 99
  • Thank you received: 6
  • Hikashop Business
7 years 5 hours ago #283248

-- HikaShop version -- : 3.2.1
-- Joomla version -- : 3.8.2
-- PHP version -- : 7.0.25
-- Browser(s) name and version -- : Fiefox Quantum

Hi guys,
is there any javascript that removes items from wishlist? Basically I want the method that does the opposite than the add_to_wishlist ... Can you please point us in the right direction?

Best!!
Carlos

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

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
6 years 11 months ago #283289

Hi,

Yes.
A typical add to cart/wishlist URL looks like that:

http://yourwebsite.com/component/hikashop/product/updatecart/add-1/quantity-XXX/cart_type-YYY/cid-ZZZ
where XXX is the quantity to add, YYY is either "cart" or "wishlist" and ZZZ is the product ID to add.
When the parameter "add" is set to 1, the quantity XXX will be added to the quantity of the product in the cart/wishlist.
When that parameter is set to 0, the quantity XXX will replace the quantity of the product in the cart.
So in short, you can use that URL:
http://yourwebsite.com/component/hikashop/product/updatecart/add-0/quantity-0/cart_type-wishlist/cid-ZZZ
and that will remove the product with the id ZZZ from the current wishlist.

The following user(s) said Thank You: karendunne

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

  • Posts: 99
  • Thank you received: 6
  • Hikashop Business
6 years 11 months ago #283311

Thank you very much Nicolas!!

Your reply set me on the correct track and I have managed to use this code:

<a rel="nofollow" href="<?php echo hikashop_completeLink($remove_url.'&cart_type=wishlist'); ?>"  title="Remove From Wishlist" onclick="{jQuery(this).children('svg').removeClass('swan-heart-icon-filled'); return window.hikashop.deleteFromCart(this,'wishlist',''); }">

Which pretty much does what I want. Nevertheless I'm not getting a message saying the item has been removed from the wishlist. Is that something that can be done adding some data attributes or do I need to code my own Javascript messages?

Thank you!!

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

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
6 years 11 months ago #283317

Hi,

If you call the hikashop javascript deleteFromCart function, it triggers the event cart.updated or wishlist.updated
And if you look at the plugins/hikashop/cartnotify/media/notify.min.js, you'll see that the plugin which displays the notification boxes is triggered by that plugin.
However, it will only display the notification box when the notify parameter of the trigger is set to true, but in the deleteFromCart function of HikaShop, that parameter is set to false as we usually don't want to display the notification box when something is removed from the cart/wishlist.

So you could potentially redefine the deleteFromCart function to change that parameter, or add you own javascript function after that process to trigger the display of the notification box which code like that:

jQuery.notify({title:title,text:text,image:"<img src=\""+img_url+"\" alt=\"\"/>"},{style:"metro",className:class_name});

The following user(s) said Thank You: karendunne

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

Time to create page: 0.060 seconds
Powered by Kunena Forum