(function( $ ) {
|
|
'use strict';
|
|
|
|
$(function() {
|
|
|
|
$(document.body).on('change', '._wc_cdp_bundle_product_select', function() {
|
|
console.debug('select triggered');
|
|
if ( ! $( this ).closest( '._wc_cdp_bundle_product' ).is( ':last-child' ) ) {
|
|
return;
|
|
}
|
|
console.debug('after return check');
|
|
var container = $( this ).closest( '._wc_cdp_products_container' ),
|
|
index = container.find( '._wc_cdp_bundle_product' ).length,
|
|
row = container.data( 'row' ).replace( /\[99999\]/g, '[' + index + ']' );
|
|
|
|
container.append(row);
|
|
$( document.body ).trigger( 'wc-enhanced-select-init' );
|
|
});
|
|
|
|
$('._wc_cdp_bundle_product_remove').click(function(event) {
|
|
event.preventDefault();
|
|
$(this).closest('._wc_cdp_bundle_product').remove();
|
|
});
|
|
});
|
|
|
|
|
|
})( jQuery );
|