Wishlist out of sync when logging in/out
-
When logging in and out and adding/removing products while between the two states it seems like the wishlist sometimes gets out of sync
Hello,
We checked the video and see that it works as expected. Logged-in and logged-out wishlists are separate. Could you please clarify what is wrong there?
Kind Regards
Yeah the wishlists are separate but at 2:00 you can see that the guest wishlist counter (the number in header) starts getting overwritten to 2 instead of 3 due to logged in wishlist count being 2
Try to add the following PHP code snippet to the child theme functions.php file to fix this
add_action('wp_logout', function () {
$cookie_storage = new XTS\WC_Wishlist\Cookies_Storage();
$cookie_products = $cookie_storage->get_all();
$cookie_name_count = 'woodmart_wishlist_count';
if ( is_multisite() ) {
$cookie_name_count .= '_' . get_current_blog_id();
}
if ( empty( $cookie_products ) ) {
woodmart_set_cookie( $cookie_name_count, 0 );
} else {
woodmart_set_cookie( $cookie_name_count, count( $cookie_products ) );
}
});