Fix cat dropdown URL

Because a filter is not a fix :)

Closes #8412
This commit is contained in:
Mike Jolley 2015-06-22 10:22:15 +01:00
parent 0d6ec24a83
commit 5937a08696
1 changed files with 10 additions and 3 deletions

View File

@ -207,9 +207,16 @@ class WC_Widget_Product_Categories extends WC_Widget {
wc_product_dropdown_categories( apply_filters( 'woocommerce_product_categories_widget_dropdown_args', $dropdown_args ) );
wc_enqueue_js( "
jQuery('.dropdown_product_cat').change(function(){
if(jQuery(this).val() != '') {
location.href = '" . home_url() . "/?product_cat=' + jQuery(this).val();
jQuery( '.dropdown_product_cat' ).change( function() {
if ( jQuery(this).val() != '' ) {
var this_page = location.href.toString();
var home_url = '" . esc_js( home_url( '/' ) ) . "';
if ( this_page.indexOf( '?' ) > 0 ) {
this_page = home_url + '&product_cat=' + jQuery(this).val();
} else {
this_page = home_url + '?product_cat=' + jQuery(this).val();
}
location.href = this_page;
}
});
" );