Hi
are you running version 3.0.x of the plugin?
In this case, cookie name changed, and now you should use yith_wcwl_session_* for exception (the actual name will contain cookiehash as the end of the name)
Apart from disabling cache when cookies are set, I suggest you to use ajax loading of wishlist elements: you can find dedicated option under WP Dashboard -> YITH -> Wishlist -> General
Thank you for the fast reply,
Ohhh I will stick with ajax loading then,
otherwise it doesn’t work, due to the fact that the wishlist is on every page so it excludes the Cache on every page.
How to achieve that the counter is loaded with Ajax in the beginning too ? This code I copied from another post, does the Ajax loading only on update…
The code:
PHP
if( defined( 'YITH_WCWL' ) && ! function_exists( 'yith_wcwl_ajax_update_count' ) ){
function yith_wcwl_ajax_update_count(){
wp_send_json( array(
'count' => yith_wcwl_count_all_products()
) );}
add_action( 'wp_ajax_yith_wcwl_update_wishlist_count', 'yith_wcwl_ajax_update_count' );
add_action( 'wp_ajax_nopriv_yith_wcwl_update_wishlist_count', 'yith_wcwl_ajax_update_count' );}
JS
$(document).on( 'added_to_wishlist removed_from_wishlist', function(){
var counter = $('.wishlist-counter');
$.ajax({
url: yith_wcwl_l10n.ajax_url,
data: {
action: 'yith_wcwl_update_wishlist_count'
},
dataType: 'json',
success: function( data ){
counter.html( data.count );
},
beforeSend: function(){
},
complete: function(){
counter.unblock();
}
})
})
Thanks in advance,
Marko
Hi Marko
You can change the js code to trigger ajax loading on document ready as follows
$(document).on( 'added_to_wishlist removed_from_wishlist', function(){
var counter = $('.wishlist-counter');
$.ajax({
url: yith_wcwl_l10n.ajax_url,
data: {
action: 'yith_wcwl_update_wishlist_count'
},
dataType: 'json',
success: function( data ){
counter.html( data.count );
},
beforeSend: function(){
},
complete: function(){
counter.unblock();
}
})
}).trigger( 'added_to_wishlist' );
Hi,
Thank you very much for you answer.
Appriciate the support! I will buy your plugin for my customers in the future!
Last question how to get the wishlist hearts, if I have another ajax call.
Products Load More –> Receive hearts again via Ajax?
Best,
Marko
Hi again Marko
I’m sorry, but I’m not sure if I correctly understand your question
Do you want to reload Add to Wishlist buttons via ajax after a new set of products is loaded in the page?
Currently there is no proper way of doing this using Fragment loading routine of the plugin
Anyway, I will include a dedicated trigger in next version of the plugin, that will allow you to execute Fragment refresh whenever you need
Trigger will be the following: yith_wcwl_reload_fragments
You should use it as follows
jQuery(document).trigger('yith_wcwl_reload_fragments')
If you want to perform tests, I’m going to attach to this answer two patched files; just download them, and use them to replace default files of the plugin, as follows:
File 1 -> wp-content/plugins/yith-woocommerce-wishlist-premium/assets/js/unminified/
File 2 -> wp-content/plugins/yith-woocommerce-wishlist-premium/assets/js/