Repalced virtual product with template category
This commit is contained in:
@@ -109,6 +109,8 @@ jQuery(function ($) {
|
||||
var bundled_product_ids = search.val(),
|
||||
bundled_product_id = bundled_product_ids && bundled_product_ids.length > 0 ? bundled_product_ids.shift() : false;
|
||||
|
||||
var template_category_title =search.text();
|
||||
|
||||
if (!bundled_product_id) {
|
||||
return false;
|
||||
}
|
||||
@@ -123,6 +125,7 @@ jQuery(function ($) {
|
||||
action: 'wiaas_add_template_product',
|
||||
post_id: woocommerce_admin_meta_boxes.post_id,
|
||||
id: bundled_products_add_count,
|
||||
title: template_category_title,
|
||||
product_id: bundled_product_id,
|
||||
security: wc_bundles_admin_params.add_bundled_product_nonce,
|
||||
options: options,
|
||||
@@ -243,5 +246,86 @@ jQuery(function ($) {
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// Ajax product search box
|
||||
$( ':input.wiaas-term-search' ).filter( ':not(.enhanced)' ).each( function() {
|
||||
var select2_args = {
|
||||
allowClear: $( this ).data( 'allow_clear' ) ? true : false,
|
||||
placeholder: $( this ).data( 'placeholder' ),
|
||||
minimumInputLength: $( this ).data( 'minimum_input_length' ) ? $( this ).data( 'minimum_input_length' ) : '3',
|
||||
escapeMarkup: function( m ) {
|
||||
return m;
|
||||
},
|
||||
ajax: {
|
||||
url: wc_enhanced_select_params.ajax_url,
|
||||
dataType: 'json',
|
||||
delay: 250,
|
||||
data: function( params ) {
|
||||
return {
|
||||
term: params.term,
|
||||
action: 'wiaas_template_category_search',
|
||||
security: wc_enhanced_select_params.search_products_nonce,
|
||||
exclude: $( this ).data( 'exclude' ),
|
||||
include: $( this ).data( 'include' ),
|
||||
limit: $( this ).data( 'limit' )
|
||||
};
|
||||
},
|
||||
processResults: function( data ) {
|
||||
var terms = [];
|
||||
if ( data ) {
|
||||
$.each( data, function( id, text ) {
|
||||
terms.push( { id: id, text: text } );
|
||||
});
|
||||
}
|
||||
return {
|
||||
results: terms
|
||||
};
|
||||
},
|
||||
cache: true
|
||||
}
|
||||
};
|
||||
|
||||
// select2_args = $.extend( select2_args, getEnhancedSelectFormatString() );
|
||||
|
||||
$( this ).selectWoo( select2_args ).addClass( 'enhanced' );
|
||||
|
||||
if ( $( this ).data( 'sortable' ) ) {
|
||||
var $select = $(this);
|
||||
var $list = $( this ).next( '.select2-container' ).find( 'ul.select2-selection__rendered' );
|
||||
|
||||
$list.sortable({
|
||||
placeholder : 'ui-state-highlight select2-selection__choice',
|
||||
forcePlaceholderSize: true,
|
||||
items : 'li:not(.select2-search__field)',
|
||||
tolerance : 'pointer',
|
||||
stop: function() {
|
||||
$( $list.find( '.select2-selection__choice' ).get().reverse() ).each( function() {
|
||||
var id = $( this ).data( 'data' ).id;
|
||||
var option = $select.find( 'option[value="' + id + '"]' )[0];
|
||||
$select.prepend( option );
|
||||
} );
|
||||
}
|
||||
});
|
||||
// Keep multiselects ordered alphabetically if they are not sortable.
|
||||
} else if ( $( this ).prop( 'multiple' ) ) {
|
||||
$( this ).on( 'change', function(){
|
||||
var $children = $( this ).children();
|
||||
$children.sort(function(a, b){
|
||||
var atext = a.text.toLowerCase();
|
||||
var btext = b.text.toLowerCase();
|
||||
|
||||
if ( atext > btext ) {
|
||||
return 1;
|
||||
}
|
||||
if ( atext < btext ) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
$( this ).html( $children );
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user