Home Forums WoodMart support forum Implementing login trigger for « Add to Wishlist » button Reply To: Implementing login trigger for « Add to Wishlist » button

#540046

ggmaitre
Participant

I found a solution using a custom function :

function catch_clic_wishlist() {
?>
<script type=”text/javascript”>
jQuery(document).ready(function($) {
// Définir la fonction pour intercepter le clic sur le bouton de la wishlist
function catchClicWishlist(e) {
if (!woodmartThemeModule.$body.hasClass(‘logged-in’)) {

$(‘.login-side-opener’).trigger(‘click’);
}
}
$(‘body’).on(‘click’, ‘.wd-wishlist-btn a’, catchClicWishlist);
});
</script>
<?php
}

where I handle the click on the wishlist button and check if the client is logged in. So far, so good.

However, the heart icon still increments, whereas I would like this behavior not to occur until the user is logged in, perhaps through a method like: e.preventDefault() ?