Home Forums WoodMart support forum Favorites top bar issue

Favorites top bar issue

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #714651

    John
    Participant

    When adding something to the favorites you can see the top account heart icon to change the counter, so if you had “0” it will change to “1” or similar.

    So far so good if you stay in the same browser.

    When swapping browser with the same account, if you go to the favorites page you will see your favorites, but whatever you do e.g. clear caches or make refreshes it will still stay to “0”.

    Am I doing something wrong ?

    #714686

    Aizaz Imtiaz Awan
    Keymaster
    Xtemos team

    Hello,

    Please deactivate all the 3rd party plugins and activate only theme-required plugins on the site and then check the issue. I am sure your issue will be solved. Then Activate the 3rd party plugins one by one and check which plugin is creating the issue for you.

    Otherwise, if the issue still exists then keep the 3rd party plugins deactivated and share the WP admin login details of your site so I will check and give you a possible solution.

    Best Regards

    #714692

    John
    Participant

    None plugin was responsible. The issue is that you read the top bar favorite count from cookie.
    If you swap browser the count is lost, because it is within the cookie.
    If you add a favorite from a browser and go to another and add a favorite from there the number will become from 0->2 and that confirms it.

    You should have an option “Enable fragment updating” but didn’t find one in your settings.

    Anyway, this PHP code fixes it:

    add_action( 'template_redirect', 'woodmart_safe_sync_wishlist_cookie' );
    
    function woodmart_safe_sync_wishlist_cookie() {
        if ( is_admin() || ! is_user_logged_in() ) {
            return;
        }
    
        if ( function_exists( 'woodmart_get_wishlist_count' ) ) {
            
            $count = woodmart_get_wishlist_count();
            
            $current_cookie = isset( $_COOKIE['woodmart_wishlist_count'] ) ? intval( $_COOKIE['woodmart_wishlist_count'] ) : -1;
            
            if ( $current_cookie !== intval( $count ) ) {
                setcookie( 'woodmart_wishlist_count', $count, time() + 7 * DAY_IN_SECONDS, '/' );
                $_COOKIE['woodmart_wishlist_count'] = $count;
            }
        }
    }
    #714744

    Aizaz Imtiaz Awan
    Keymaster
    Xtemos team

    Hello,

    Thank you for the detailed explanation and for sharing your solution

    At the moment, there is no built-in option like “Enable fragment updating” for the wishlist counter, but we appreciate you sharing this workaround — it can be helpful for similar cases.

    If you notice any side effects or need further improvements, feel free to let us know.

    Best Regards

Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)