• Hi there,

    I am experience this admin issue when in published products trying to add a category to filter.

    The ‘count’ for category shows the number of products for published products.

    Even if I am in Private products the category counts and show, from published products.

    Is this a bug or it’s just me ?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator threadi

    (@threadi)

    What kind of products are we talking about? Do you use a plugin for them?

    If I understand you mean to say category are showing count of only published products then it is default woocommerce feature .
    In case you want to show all products not only published please add the below code into your themes functions.php

    // Show total product count (all statuses) in WooCommerce categories
    add_filter( 'woocommerce_subcategory_count_html', 'custom_total_product_count', 10, 2 );

    function custom_total_product_count( $markup, $category ) {
    global $wpdb;

    // Get product count for all post statuses
    $count = $wpdb->get_var( $wpdb->prepare("
    SELECT COUNT(p.ID)
    FROM $wpdb->posts p
    INNER JOIN $wpdb->term_relationships tr ON (p.ID = tr.object_id)
    INNER JOIN $wpdb->term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id)
    WHERE tt.taxonomy = 'product_cat'
    AND tt.term_id = %d
    AND p.post_type = 'product'
    ", $category->term_id ) );

    return ' <mark class="count">(' . $count . ')</mark>';
    }

    hope this helps to solve your query

    Thread Starter aalve

    (@aalve)

    Hi thank you for your reply. I was expecting, when in private products that the category will count only products listed in “private products”. Not from published products such I am listing private products. But when I am in published products thats fine!

    Moderator threadi

    (@threadi)

    What kind of products are we talking about? Do you use a plugin for them?

    It would be great to have an answer to this. At the moment, I don’t know what you’re planning to do. That would make it much easier to help you. WordPress itself doesn’t recognize any products.

    If you’re really using WooCommerce as a plugin for your products, I would recommend contacting their support forum here: https://wordpress.org/support/plugin/woocommerce/

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

The topic ‘Categories count bug ?’ is closed to new replies.