use switch case for variation bulk edit. add action hook for new cases
This commit is contained in:
parent
fc104fc84b
commit
04c071f855
|
@ -382,24 +382,23 @@ function variable_product_type_options() {
|
|||
jQuery('.wc-metaboxes-wrapper').on('click', 'a.bulk_edit', function(event){
|
||||
var field_to_edit = jQuery('select#field_to_edit').val();
|
||||
|
||||
if ( field_to_edit == 'toggle_enabled' ) {
|
||||
switch( field_to_edit ) {
|
||||
|
||||
case 'toggle_enabled':
|
||||
var checkbox = jQuery('input[name^="variable_enabled"]');
|
||||
checkbox.attr('checked', !checkbox.attr('checked'));
|
||||
return false;
|
||||
}
|
||||
else if ( field_to_edit == 'toggle_downloadable' ) {
|
||||
break;
|
||||
case 'toggle_downloadable':
|
||||
var checkbox = jQuery('input[name^="variable_is_downloadable"]');
|
||||
checkbox.attr('checked', !checkbox.attr('checked'));
|
||||
jQuery('input.variable_is_downloadable').change();
|
||||
return false;
|
||||
}
|
||||
else if ( field_to_edit == 'toggle_virtual' ) {
|
||||
break;
|
||||
case 'toggle_virtual':
|
||||
var checkbox = jQuery('input[name^="variable_is_virtual"]');
|
||||
checkbox.attr('checked', !checkbox.attr('checked'));
|
||||
jQuery('input.variable_is_virtual').change();
|
||||
return false;
|
||||
}
|
||||
else if ( field_to_edit == 'delete_all' ) {
|
||||
break;
|
||||
case 'delete_all':
|
||||
|
||||
var answer = confirm('<?php echo esc_js( __( 'Are you sure you want to delete all variations? This cannot be undone.', 'woocommerce' ) ); ?>');
|
||||
if (answer){
|
||||
|
@ -435,9 +434,8 @@ function variable_product_type_options() {
|
|||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if ( field_to_edit == 'variable_regular_price_increase' ) {
|
||||
break;
|
||||
case 'variable_regular_price_increase':
|
||||
field_to_edit = 'variable_regular_price';
|
||||
var input_tag = jQuery('select#field_to_edit :selected').attr('rel') ? jQuery('select#field_to_edit :selected').attr('rel') : 'input';
|
||||
|
||||
|
@ -452,9 +450,8 @@ function variable_product_type_options() {
|
|||
}
|
||||
jQuery(this).val( new_value ).change();
|
||||
});
|
||||
return false;
|
||||
}
|
||||
else if ( field_to_edit == 'variable_regular_price_decrease' ) {
|
||||
break;
|
||||
case 'variable_regular_price_decrease':
|
||||
field_to_edit = 'variable_regular_price';
|
||||
var input_tag = jQuery('select#field_to_edit :selected').attr('rel') ? jQuery('select#field_to_edit :selected').attr('rel') : 'input';
|
||||
|
||||
|
@ -469,9 +466,8 @@ function variable_product_type_options() {
|
|||
}
|
||||
jQuery(this).val( new_value ).change();
|
||||
});
|
||||
return false;
|
||||
}
|
||||
else if ( field_to_edit == 'variable_sale_price_increase' ) {
|
||||
break;
|
||||
case 'variable_sale_price_increase':
|
||||
field_to_edit = 'variable_sale_price';
|
||||
var input_tag = jQuery('select#field_to_edit :selected').attr('rel') ? jQuery('select#field_to_edit :selected').attr('rel') : 'input';
|
||||
|
||||
|
@ -486,9 +482,8 @@ function variable_product_type_options() {
|
|||
}
|
||||
jQuery(this).val( new_value ).change();
|
||||
});
|
||||
return false;
|
||||
}
|
||||
else if ( field_to_edit == 'variable_sale_price_decrease' ) {
|
||||
break;
|
||||
case 'variable_sale_price_decrease':
|
||||
field_to_edit = 'variable_sale_price';
|
||||
var input_tag = jQuery('select#field_to_edit :selected').attr('rel') ? jQuery('select#field_to_edit :selected').attr('rel') : 'input';
|
||||
|
||||
|
@ -503,16 +498,17 @@ function variable_product_type_options() {
|
|||
}
|
||||
jQuery(this).val( new_value ).change();
|
||||
});
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
<?php do_action( 'woocommerce_variable_product_bulk_edit_actions_js' ); ?>
|
||||
default:
|
||||
|
||||
var input_tag = jQuery('select#field_to_edit :selected').attr('rel') ? jQuery('select#field_to_edit :selected').attr('rel') : 'input';
|
||||
|
||||
var value = prompt("<?php echo esc_js( __( 'Enter a value', 'woocommerce' ) ); ?>");
|
||||
jQuery(input_tag + '[name^="' + field_to_edit + '["]').val( value ).change();
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
jQuery('#variable_product_options').on('change', 'input.variable_is_downloadable', function(){
|
||||
|
|
Loading…
Reference in New Issue