woocommerce – Hide children categories from a plugin / shortcode

My theme comes with an addon plugin that include some visual constructor element.

They display the products on my homepage, with categories filter. But I want to exclude subcategories products (children).

I already tried to add “include_children => false” in what I suppose to be the query, but it has no incidence on the code.

Here is the code of the bloc :

function supro_products( $atts, $content ) {

    $atts = shortcode_atts(

        array(

            'title'            => '',

            'subtitle'         => '',

            'style'            => '1',

            'limit'            => 6,

            'columns'          => 3,

            'm_columns'        => 1,

            'orderby'          => 'title',

            'order'            => 'ASC',

            'filter'           => 'category',

            'show_all_product' => '1',

            'all_product_text' => esc_html__( 'All Products', 'supro' ),

            'tabs'             => '',

            'category'         => '',

            'link'             => '',

            'load_more'        => false,

            'btn_style'        => 'border-bottom',

            'css_animation'    => '',

            'el_class'         => '',

        ), $atts

    );



    if ( ! $this->wc_actived ) {

        return;

    }



    $css_class = array(

        'supro-products-grid supro-products',

        'style-' . $atts('style'),

        $atts('btn_style'),

        $this->get_css_animation( $atts('css_animation') ),

        'mobile-columns-' . $atts('m_columns'),

        $atts('el_class')

    );



    if ( $atts('load_more') ) {

        $css_class() = 'load-more-enabled';

    }



    $output = array();

    $title  = '';

    $filter = array();

    $type   = 'products';

    $attr   = array();



    $product_args = array(

        'limit'     => $atts('limit'),

        'columns'   => $atts('columns'),

        'page'      => 1,

        'orderby'   => $atts('orderby'),

        'order'     => $atts('order'),

        'category'  => '',

        'load_more' => $atts('load_more'),

    );



    $tabs = vc_param_group_parse_atts( $atts('tabs') );



    if ( $atts('title') ) {

        $title = sprintf( '<h3 class="title">%s</h3>', $atts('title') );

    }



    if ( $atts('subtitle') ) {

        $title .= sprintf( '<div class="subtitle">%s</div>', $atts('subtitle') );

    }



    if ( $title ) {

        $title = '<div class="section-title">' . $title . '</div>';

    }



    if ( $atts('filter') == 'category' ) {

        $attr = array(

            'limit'   => intval( $atts('limit') ),

            'columns' => intval( $atts('columns') ),

            'orderby' => $atts('orderby'),

            'order'   => $atts('order'),

        );



        if ( intval( $atts('show_all_product') ) ) {

            $filter() = sprintf(

                '<li class="active" data-filter="%s">%s</li>',

                $atts('category') ? $atts('category') : '',

                $atts('all_product_text')

            );

        } else {

            if ( $atts('category') ) {

                $cats                     = explode( ',', $atts('category') );

                $product_args('category') = $cats(0);



            } else {

                $terms                    = get_terms( 'product_cat' );

                $empty_terms              = array();

                $new_terms                = array_merge( $terms, $empty_terms );

                $product_args('category') = $new_terms(0)->slug;

            }

        }



        if ( $atts('category') ) {

            $cats = explode( ',', $atts('category') );



            foreach ( $cats as $cat ) {

                $cat      = get_term_by( 'slug', $cat, 'product_cat' );

                $filter() = sprintf( '<li class="" data-filter="%s">%s</li>', esc_attr( $cat->slug ), esc_html( $cat->name ) );

            }

        } else {

            $terms = get_terms( 'product_cat' );



            foreach ( $terms as $term ) {

                $filter() = sprintf( '<li class="" data-filter="%s">%s</li>', esc_attr( $term->slug ), esc_html( $term->name ) );

            }

        }



    } else {

        $product_args('category') = $atts('category');

        $css_class()              = 'filter-by-group';



        if ( $tabs ) {

            $type = $tabs(0)('products');



            $i = 0;

            foreach ( $tabs as $tab ) {

                $tab_attr = array(

                    'limit'   => intval( $atts('limit') ),

                    'columns' => intval( $atts('columns') ),

                    'orderby' => isset( $tab('orderby') ) ? $tab('orderby') : $atts('orderby'),

                    'order'   => isset( $tab('order') ) ? $tab('order') : $atts('order'),

                );

                if ( isset( $tab('title') ) ) {

                    $filter() = sprintf( '<li class="" data-filter="%s" data-attr="%s">%s</li>', esc_attr( $tab('products') ), esc_attr( json_encode( $tab_attr ) ), esc_html( $tab('title') ) );

                }



                if ( $i == 0 ) {

                    $atts('orderby') = isset( $tab('orderby') ) ? $tab('orderby') : $atts('orderby');

                    $atts('order')   = isset( $tab('order') ) ? $tab('order') : $atts('order');

                }



                $i ++;

            }

        }

    }



    $link = '';



    if ( $atts('link') && $atts('style') == '3' ) {

        $link = '<div class="product-btn">' . $this->get_vc_link( $atts, '' ) . '</div>';

    }



    $filter_html = '<ul class="nav-filter filter">' . implode( "n", $filter ) . '</ul>';



    $output() = $atts('style') == '3' ? $title : '';

    $output() = '<div class="product-header">';

    $output() = $atts('style') != '3' ? $title : '';

    $output() = $filter_html;

    $output() = $link;

    $output() = '</div>';

    $output() = '<div class="product-wrapper">';

    $output() = '<div class="product-loading"><span class="supro-loader"></span></div>';

    $output() = $this->get_wc_products( $product_args, $type );

    $output() = '</div>';



    return sprintf(

        '<div class="%s" data-attr="%s" data-load_more="%s" data-nonce="%s">%s</div>',

        esc_attr( implode( ' ', $css_class ) ),

        esc_attr( json_encode( $attr ) ),

        esc_attr( $atts('load_more') ),

        esc_attr( wp_create_nonce( 'supro_get_products' ) ),

        implode( '', $output )

    );

}

My two questions are :

  • how to hide all subcategory products
  • is it possible to make it thru functions.php ? Or should I overwrite the plugin Code ? Can I for example duplicate this bloc, with a new name in my child theme directly ?