• Resolved konsument

    (@konsument)


    Hi

    Im using YITH_WCWL()->count_all_products(); in my header.php to show the number of products on my wishlist next to my menu-item. This works on my wishlist page or single product page. On my category or shop-home the function counts all products on my page.

    So on wishlist and single the output is numeric only.

    On my home or cat-pages the output is: “<span class=”total”>23</span> products”.

    Whats wrong here?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author YITHEMES

    (@yithemes)

    Hi there

    that’s really strange, since count that comes from count_all_products() method isn’t affected in any way by product loop; it simply counts items stored in wishlist table for current user

    I tried to add the same method in the header of my test site, and I was able to consistently see wishlist count across all pages of my site

    Could this be a cache problem? Maybe you’re viewing wishlist count for another user that happened to be stored in page cache?

    Thread Starter konsument

    (@konsument)

    Hi and thanks for your response.

    Im querying my items with a custom template and wc_get_products() instead of choosing my page in woocommerce shop-page settings. If I use the page-settings the counter works. Maybe you could test again with an custom product-query?

    Plugin Author YITHEMES

    (@yithemes)

    Hi there

    sure, but I’m afraid the result won’t change (as I said, I double checked the code and I cannot find any evidence that product query would affect wishlist items count)

    Anyway, here you go: I created a page containing [products] shortcode (it will retrieve products using custom WP_Query, as you can see here: wp-content/plugins/woocommerce/includes/shortcodes/class-wc-shortcode-products.php:572)
    This is page configuration, and this is the page appearance

    As you can see im the header, count matches the number of wishlist items, and isn’t affected by how many products I show in the page
    Besides, there is the fact that ->count_all_products() method always returns an integer, and never prints formtted text

    Unfortunately I don’t know what is happening on your installation, but I have the feeling this is something outside of plugin code

    Thread Starter konsument

    (@konsument)

    Hey,

    thanks again for your reply. In the meantime I found the problem. I had two elements with class “counter” in my theme. One for the items on my wishlist and the other I used for filtering products to show the amount after filter-action. This of course also wrote the numbers in my wishlist-counter element. Im so sorry that I wasted your time just because I was too stupid to give proper classes.

    Thanks anyway for your great support.

    Plugin Author YITHEMES

    (@yithemes)

    Hi again

    don’t worry, it is a pleasure for us to help ??
    And by the way, thank you for your effort on supporting other people of the community, we really appreciate it ??

    May I aslo ask you to review our plugin? A good review would really help us, and support our work

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Count items on wishlist’ is closed to new replies.