• Hi! 

    I am using your super nice wishlist plugin, which has been working like a charm!
    Last week I implemented a new functionality on my webshop, where I show the total items in the wishlist in the navigation menu.
    However, there seems to be an issue, caused by my Redis Object Cache plugin, because it returns a cached value for the total amount of items. 

    The cache plugin offers a feature to ignore certain groups, but that doesn’t do the trick for me.
    I added this to my config:
    define(‘WP_REDIS_IGNORED_GROUPS’, array(
    ‘yith_wcwl’,
    ‘yith_wcwl_update_wishlist_count’,
    ));

    Is the group name incorrect or should I exclude this functionality from my cache in another way?
    Or is there a way to invalidate the cache when adding/removing something from the wishlist?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter stevejonk

    (@stevejonk)

    Some extra info.
    I added this to my functions.php to create the hook and update the totals on remove and add:

    <?php
    
    if (defined('YITH_WCWL') && !function_exists('yith_wcwl_get_items_count')) {
    
    function yith_wcwl_get_items_count()
    
    {
    
    return esc_html(yith_wcwl_count_all_products());
    
    }
    
    add_shortcode('yith_wcwl_items_count', 'yith_wcwl_get_items_count');
    
    }
    
    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');
    
    }
    
    if (defined('YITH_WCWL') && !function_exists('yith_wcwl_enqueue_custom_script')) {
    
    function yith_wcwl_enqueue_custom_script()
    
    {
    
    wp_add_inline_script(
    
    'jquery-yith-wcwl',
    
    "
    
    jQuery( function( $ ) {
    
    $( document ).on( 'added_to_wishlist removed_from_wishlist', function() {
    
    $.get( yith_wcwl_l10n.ajax_url, {
    
    action: 'yith_wcwl_update_wishlist_count'
    
    }, function( data ) {
    
    $('#wishlist-count').html( data.count );
    
    } );
    
    } );
    
    } );
    
    "
    
    );
    
    }
    
    add_action('wp_enqueue_scripts', 'yith_wcwl_enqueue_custom_script', 20);
    
    }
    Plugin Support Juan Coronel

    (@juaancmendez)

    Hello Steve,
    we hope you’re doing well!

    The only exclusions that we have from our cache-related plugin are the ones you can see at this link.

    Other types of exclusions are not possible at the moment.

    Try it and tell us about any news.

    Best regards.

    Thread Starter stevejonk

    (@stevejonk)

    Hi Juan,

    Thanks for your fast response. I added all varieties of the exclusions to my ignored groups and the result is still the same. I get old values back.

    Weird thing is, this only happens when removing from the wishlist, when adding all is fine.

    For example: I have 2 items in my wishlist. I add another one and it directly changes to 3 items (which is good). Then I delete an item from the wishlist. After that the number is still 3 (which is not good).

    Plugin Support Juan Coronel

    (@juaancmendez)

    Hello there,

    How did you add the item counter to the wishlist?

    If you didn’t do it like below, try it:

    https://support.yithemes.com/hc/en-us/articles/115001372967-Wishlist-How-to-count-number-of-products-wishlist-in-ajax

    Let us know any news.

    Best regards.

    Thread Starter stevejonk

    (@stevejonk)

    Hi Juan,

    Thanks for your quick reply!
    I added it in exactly that way (with another jquery selector, because my element is a little different).

    The problem hier is that (when looking at the network tab) the yith_wcwl_update_wishlist_count action responds with a count that is 1 to high, when removing an item. So the actual data seems cached.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Wishlist (Redis) Caching issue’ is closed to new replies.