Merge pull request #32743 from helgatheviking/fix/32741-wc-category-search-return-ids
Optionally switch the category search selects to return category IDs
This commit is contained in:
commit
1d7bbdbc04
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: tweak
|
||||
|
||||
Also allow getting category ID as option ID instead of term slug in wc-enhanced-select.
|
|
@ -264,6 +264,8 @@ jQuery( function( $ ) {
|
|||
|
||||
// Ajax category search boxes
|
||||
$( ':input.wc-category-search' ).filter( ':not(.enhanced)' ).each( function() {
|
||||
var return_format = $( this ).data( 'return_id' ) ? 'id' : 'slug';
|
||||
|
||||
var select2_args = $.extend( {
|
||||
allowClear : $( this ).data( 'allow_clear' ) ? true : false,
|
||||
placeholder : $( this ).data( 'placeholder' ),
|
||||
|
@ -287,7 +289,7 @@ jQuery( function( $ ) {
|
|||
if ( data ) {
|
||||
$.each( data, function( id, term ) {
|
||||
terms.push({
|
||||
id: term.slug,
|
||||
id: 'id' === return_format ? term.term_id : term.slug,
|
||||
text: term.formatted_name
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue