Convert product categories widget to use selectWoo.

This commit is contained in:
Gerhard Potgieter 2018-06-25 12:25:16 +02:00
parent e6c1ab38a8
commit 664abe2015
1 changed files with 24 additions and 0 deletions

View File

@ -201,6 +201,30 @@ function wc_product_dropdown_categories( $args = array() ) {
$args['orderby'] = 'name'; $args['orderby'] = 'name';
} }
wp_enqueue_script( 'selectWoo' );
wp_enqueue_style( 'select2' );
wc_enqueue_js(
"
if ( jQuery().selectWoo ) {
var wc_product_cat_select = function() {
jQuery( '.dropdown_product_cat' ).selectWoo( {
placeholder: '" . esc_js( __( 'Select a category', 'woocommerce' ) ) . "',
minimumResultsForSearch: 5,
width: '100%',
allowClear: true,
language: {
noResults: function() {
return '" . esc_js( _x( 'No matches found', 'enhanced select', 'woocommerce' ) ) . "';
}
}
} );
};
wc_product_cat_select();
}
"
);
wp_dropdown_categories( $args ); wp_dropdown_categories( $args );
} }