woocommerce attribute parent 2fchild hierarchy

Solutions on MaxInterview for woocommerce attribute parent 2fchild hierarchy by the best coders in the world

showing results for - "woocommerce attribute parent 2fchild hierarchy"
Royce
08 Sep 2019
1if( function_exists( 'WC' ) ){
2    add_action( 'init', 'ag_woocommerce_register_taxonomies_hack', 4 );
3
4    if( ! function_exists( 'ag_woocommerce_register_taxonomies_hack' ) ){
5        function ag_woocommerce_register_taxonomies_hack(){
6            if( $attribute_taxonomies = wc_get_attribute_taxonomies() ) {
7                foreach ($attribute_taxonomies as $tax) {
8                    if ($name = wc_attribute_taxonomy_name($tax->attribute_name)) {
9                        add_filter( "woocommerce_taxonomy_args_{$name}", 'ag_woocommerce_taxonomy_product_attribute_args' );
10                    }
11                }
12            }
13        }
14    }
15
16    if( ! function_exists( 'ag_woocommerce_taxonomy_product_attribute_args' ) ){
17        function ag_woocommerce_taxonomy_product_attribute_args( $taxonomy_data ){
18            $taxonomy_data['hierarchical'] = true;
19            return $taxonomy_data;
20        }
21    }
22}
23