Last active
November 24, 2017 18:06
-
-
Save pablo-sg-pacheco/ec9f0b47fae5501efe4cece4b51b5f7f to your computer and use it in GitHub Desktop.
Update the whole wishlist every time an item is added or removed, considering the wishlist is always present in all pages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Update the whole wishlist every time an item is added or removed, considering the wishlist is always present in all pages | |
* Plugin: Wish list for WooCommerce | |
*/ | |
jQuery(document).ready(function($){ | |
//Get your wish list element first (Replace it by your wish list css class) | |
var wish_list_div = '.wish-list'; | |
//Every time an item is toggled (i.e added or removed) | |
$("body").on('alg_wc_wl_toggle_wl_item', function (e) { | |
//Call a ajax function that gets the wish list shortcode | |
$.post(alg_wc_wl.ajaxurl, {action:alg_wc_wl_pro_get_wl_shortcode_ajax_action}, function (response) { | |
// Replace your wish list content by the updated one that comes through ajax | |
if (response.success) { | |
wish_list_div.replaceWith($(response.data.shortcode)); | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment