Allow layered nav to work with non pa_ prepended taxonomies

This commit is contained in:
Mike Jolley 2013-05-08 12:16:40 +01:00
parent 742cd3ae36
commit f49bd2cd77
3 changed files with 8 additions and 3 deletions

View File

@ -229,17 +229,20 @@ class WC_Widget_Layered_Nav extends WP_Widget {
foreach ( $_chosen_attributes as $name => $data ) { foreach ( $_chosen_attributes as $name => $data ) {
if ( $name !== $taxonomy ) { if ( $name !== $taxonomy ) {
//exclude query arg for current term archive term // Exclude query arg for current term archive term
while ( in_array( $current_term, $data['terms'] ) ) { while ( in_array( $current_term, $data['terms'] ) ) {
$key = array_search( $current_term, $data ); $key = array_search( $current_term, $data );
unset( $data['terms'][$key] ); unset( $data['terms'][$key] );
} }
// Remove pa_ and sanitize
$filter_name = sanitize_title( str_replace( 'pa_', '', $name ) );
if ( ! empty( $data['terms'] ) ) if ( ! empty( $data['terms'] ) )
$link = add_query_arg( sanitize_title( str_replace( 'pa_', 'filter_', $name ) ), implode(',', $data['terms']), $link ); $link = add_query_arg( 'filter_' . $filter_name, implode( ',', $data['terms'] ), $link );
if ( $data['query_type'] == 'or' ) if ( $data['query_type'] == 'or' )
$link = add_query_arg( sanitize_title( str_replace( 'pa_', 'query_type_', $name ) ), 'or', $link ); $link = add_query_arg( 'query_type_' . $filter_name, 'or', $link );
} }
} }
} }

View File

@ -174,6 +174,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
* Fix - Javascript escapes to stop breaking scripts when used with translations * Fix - Javascript escapes to stop breaking scripts when used with translations
* Fix - PayPal button should use classes 'button' and 'alt', not 'button-alt' * Fix - PayPal button should use classes 'button' and 'alt', not 'button-alt'
* Fix - Have the remove_taxes() method set subtotal to subtotal_ex_tax * Fix - Have the remove_taxes() method set subtotal to subtotal_ex_tax
* Fix - Allow layered nav to work with non pa_ prepended taxonomies
* Refactor - Taken out Piwik integration, use http://wordpress.org/extend/plugins/woocommerce-piwik-integration/ from now on * Refactor - Taken out Piwik integration, use http://wordpress.org/extend/plugins/woocommerce-piwik-integration/ from now on
* Refactor - Taken out ShareYourCart integration, use http://wordpress.org/extend/plugins/shareyourcart/ from now on * Refactor - Taken out ShareYourCart integration, use http://wordpress.org/extend/plugins/shareyourcart/ from now on
* Refactor - Moved woocommerce_get_formatted_product_name function into WC_Product class * Refactor - Moved woocommerce_get_formatted_product_name function into WC_Product class

View File

@ -75,6 +75,7 @@ if ( ! is_admin() || defined('DOING_AJAX') ) {
* @see woocommerce_template_loop_add_to_cart() * @see woocommerce_template_loop_add_to_cart()
* @see woocommerce_template_loop_product_thumbnail() * @see woocommerce_template_loop_product_thumbnail()
* @see woocommerce_template_loop_price() * @see woocommerce_template_loop_price()
* @see woocommerce_template_loop_rating()
*/ */
add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 ); add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 ); add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );