Skip to content

Instantly share code, notes, and snippets.

@pablo-sg-pacheco
Last active November 24, 2017 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pablo-sg-pacheco/ec9f0b47fae5501efe4cece4b51b5f7f to your computer and use it in GitHub Desktop.
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
/**
* 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