• Hi,
    I am trying to hide empty terms and it is not working. I am using following shortcode:
    [a-z-listing display="terms" taxonomy="product_brand" alphabet="Dd,Ee,Ff" hide-empty-terms="true"]

    You can check in the header, click Banky > Dinafem Seeds. This entry (product brand) contains no posts (products). Products are out of stock and doesn’t display in frontend.

    Thanks for any suggestions how to exclude empty terms.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Dani Llewellyn

    (@diddledani)

    Hi,

    The plugin doesn’t have any code to handle “out of stock” products. The plugin thinks the terms are not empty because the products are still published.

    Can you note which commerce plugin you’re using so that I may investigate?

    Thread Starter squatter1

    (@squatter1)

    Hi,
    I am using Woocommerce plugin. “product_brand” is custom taxonomy.

    I tried to modify the plugin myself by modifying the template. It is working, but this way is ineffective and causes long page load.

     $term = get_term($a_z_query->get_the_item_id(), 'product_brand');
                                    
           echo get_instock_products_count($a_z_query->get_the_item_id());
                                   
                                   $args = array(
                                    'post_type' => 'product',
                                    'posts_per_page' => -1,
                                    'post_status' => 'publish',
                                    'meta_query' => array(
                                        array(
                                            'key' => '_stock_status',
                                            'value' => 'instock',
                                        )
                                    ),
                                    'tax_query' => array(
                                        array(
                                        'taxonomy' => 'product_brand',
                                        'field' => 'term_id',
                                        'terms' => $term->term_id
                                        )
                                    )
                                );
                        
                                $query = new WP_Query($args);
                                echo $query->found_posts;
    

    It would be perfect if there was an option in shortcode to exclude terms which contain only products out of stock. Is there a chance you would implement it in next update?

    Thanks.

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hide empty terms not working’ is closed to new replies.