Answers for "Woocommerce Attribute Parent/Child Hierarchy"

PHP
0

Woocommerce Attribute Parent/Child Hierarchy

if( function_exists( 'WC' ) ){
    add_action( 'init', 'ag_woocommerce_register_taxonomies_hack', 4 );

    if( ! function_exists( 'ag_woocommerce_register_taxonomies_hack' ) ){
        function ag_woocommerce_register_taxonomies_hack(){
            if( $attribute_taxonomies = wc_get_attribute_taxonomies() ) {
                foreach ($attribute_taxonomies as $tax) {
                    if ($name = wc_attribute_taxonomy_name($tax->attribute_name)) {
                        add_filter( "woocommerce_taxonomy_args_{$name}", 'ag_woocommerce_taxonomy_product_attribute_args' );
                    }
                }
            }
        }
    }

    if( ! function_exists( 'ag_woocommerce_taxonomy_product_attribute_args' ) ){
        function ag_woocommerce_taxonomy_product_attribute_args( $taxonomy_data ){
            $taxonomy_data['hierarchical'] = true;
            return $taxonomy_data;
        }
    }
}
Posted by: Guest on August-30-2021

Browse Popular Code Answers by Language