'Exclude the variable products from the get_categories() -woocommerce

i am getting the list of woocommerce product categories using get_categories($args);

$args = array(
                'hide_empty' => 0,
                'taxonomy' => 'product_cat',
                'hierarchical' => 1,
                'orderby' => 'name',
                'order' => 'ASC',
                'child_of' => 0,
                'product_type' => 'simple'
            );

and the returned array is

[1] => WP_Term Object
        (
            [term_id] => 15
            [name] => Uncategorized
            [slug] => uncategorized
            [term_group] => 0
            [term_taxonomy_id] => 15
            [taxonomy] => product_cat
            [description] => 
            [parent] => 0
            [count] => 12
            [filter] => raw
            [cat_ID] => 15
            [category_count] => 12
            [category_description] => 
            [cat_name] => Uncategorized
            [category_nicename] => uncategorized
            [category_parent] => 0
        )

here the count include both the simple and variable product count, i want to restrict the variable product from here. how can i achieve this? if i pass the product_type simple to the arg list it is not working.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source