Home › Forums › WoodMart support forum › Remove product from Wishlist on second click
Remove product from Wishlist on second click
- This topic has 1 reply, 2 voices, and was last updated 1 year, 4 months ago by Artem Temos.
-
AuthorPosts
-
July 8, 2023 at 11:10 pm #480135
mohsen.amra.70ParticipantHello
I would likne to remove product from Wishlist on second click On withlist icon. Based on woodmart theme when you click on wishlist icon the product has been added to wishlist list and after that when for second time you click on the whishlist icon you can see the whishlist page and redirect to the whishlist page.So we can only abale to remove the product from the wishlist when go to the whishlis page. In this way I want to remove product from whishlist without sending user to whishlist page and remove product from wishlist on second click. Is it possible?
Here is my code. But it does not working.
jQuery(document).ready(function($) { var clickCount = 0; var clickTimeout; $('.wd-wishlist-btn a').on('click', function(e) { e.preventDefault(); var $this = $(this); var productId = $this.data('product-id'); clickCount++; if (clickCount === 1) { clickTimeout = setTimeout(function() { clickCount = 0; addToWishlist(productId); }, 300); } else if (clickCount === 2) { clearTimeout(clickTimeout); clickCount = 0; removeProductFromWishlist(productId); } }); function addToWishlist(productId) { $.ajax({ url: woodmart_settings.ajaxurl, data: { action: 'woodmart_add_to_wishlist', product_id: productId }, dataType: 'json', method: 'GET', success: function(response) { if (response) { $('.wd-header-wishlist .wd-tools-count').text(response.count); $('.wd-wishlist-btn a[data-product-id="' + productId + '"]').addClass('added'); } else { console.log('Something went wrong while adding the product to the wishlist.'); } }, error: function() { console.log('Error: Unable to add the product to the wishlist.'); } }); } function removeProductFromWishlist(productId) { $.ajax({ url: woodmart_settings.ajaxurl, data: { action: 'woodmart_remove_from_wishlist', product_id: productId }, dataType: 'json', method: 'GET', success: function(response) { if (response) { $('.wd-header-wishlist .wd-tools-count').text(response.count); $('.wd-wishlist-btn a[data-product-id="' + productId + '"]').removeClass('added'); } else { console.log('Something went wrong while removing the product from the wishlist.'); } }, error: function() { console.log('Error: Unable to remove the product from the wishlist.'); } }); } });
- This topic was modified 1 year, 4 months ago by mohsen.amra.70.
July 9, 2023 at 7:33 pm #480188
Artem TemosKeymasterHello,
Thank you so much for purchasing our theme and contacting our support center.
Sorry, but additional code customizations like that are out of our theme support scope.
Kind Regards
XTemos Studio -
AuthorPosts
Tagged: whishlist
- You must be logged in to create new topics. Login / Register