Ajax Product filter - Attributes are no longer hierarchical than version 3.0.x of WooCommerce

Hierarchical attributes filter doesn't works with WooCommerce 3.0.x and to fix this you can add this code in functions.php of your theme:

 

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

if( ! function_exists( 'yith_woocommerce_register_taxonomies_hack' ) ){
function yith_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}", 'yith_woocommerce_taxonomy_product_attribute_args' );
}
}
}
}
}

if( ! function_exists( 'yith_woocommerce_taxonomy_product_attribute_args' ) ){
function yith_woocommerce_taxonomy_product_attribute_args( $taxonomy_data ){
$taxonomy_data['hierarchical'] = true;
return $taxonomy_data;
}
}
}
Was this article helpful?
0 out of 0 found this helpful

Back to Help Center

Powered by Zendesk