diff --git a/admin/post-types/writepanels/writepanel-product-type-variable.php b/admin/post-types/writepanels/writepanel-product-type-variable.php index 638684b30c4..3c8330c5630 100755 --- a/admin/post-types/writepanels/writepanel-product-type-variable.php +++ b/admin/post-types/writepanels/writepanel-product-type-variable.php @@ -382,137 +382,133 @@ 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' ) { - var checkbox = jQuery('input[name^="variable_enabled"]'); - checkbox.attr('checked', !checkbox.attr('checked')); - return false; - } - else if ( field_to_edit == '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' ) { - 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' ) { + switch( field_to_edit ) { - var answer = confirm(''); - if (answer){ + case 'toggle_enabled': + var checkbox = jQuery('input[name^="variable_enabled"]'); + checkbox.attr('checked', !checkbox.attr('checked')); + break; + case 'toggle_downloadable': + var checkbox = jQuery('input[name^="variable_is_downloadable"]'); + checkbox.attr('checked', !checkbox.attr('checked')); + jQuery('input.variable_is_downloadable').change(); + break; + case 'toggle_virtual': + var checkbox = jQuery('input[name^="variable_is_virtual"]'); + checkbox.attr('checked', !checkbox.attr('checked')); + jQuery('input.variable_is_virtual').change(); + break; + case 'delete_all': - var answer = confirm(''); + var answer = confirm(''); + if (answer){ - if (answer) { + var answer = confirm(''); - var variation_ids = []; + if (answer) { - jQuery('.woocommerce_variations .woocommerce_variation').block({ message: null, overlayCSS: { background: '#fff url(plugin_url(); ?>/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } }); + var variation_ids = []; - jQuery('.woocommerce_variations .woocommerce_variation .remove_variation').each(function(){ + jQuery('.woocommerce_variations .woocommerce_variation').block({ message: null, overlayCSS: { background: '#fff url(plugin_url(); ?>/assets/images/ajax-loader.gif) no-repeat center', opacity: 0.6 } }); - var variation = jQuery(this).attr('rel'); - if (variation>0) { - variation_ids.push(variation); - } - }); + jQuery('.woocommerce_variations .woocommerce_variation .remove_variation').each(function(){ - var data = { - action: 'woocommerce_remove_variations', - variation_ids: variation_ids, - security: '' - }; - - jQuery.post('', data, function(response) { - jQuery('.woocommerce_variations .woocommerce_variation').fadeOut('300', function(){ - jQuery('.woocommerce_variations .woocommerce_variation').remove(); + var variation = jQuery(this).attr('rel'); + if (variation>0) { + variation_ids.push(variation); + } }); - }); + + var data = { + action: 'woocommerce_remove_variations', + variation_ids: variation_ids, + security: '' + }; + + jQuery.post('', data, function(response) { + jQuery('.woocommerce_variations .woocommerce_variation').fadeOut('300', function(){ + jQuery('.woocommerce_variations .woocommerce_variation').remove(); + }); + }); + + } } + 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'; - } - return false; + var value = prompt(""); + jQuery(input_tag + '[name^="' + field_to_edit + '"]').each(function() { + var current_value = jQuery(this).val(); + + if ( value.indexOf("%") >= 0 ) { + var new_value = Number( current_value ) + ( ( Number( current_value ) / 100 ) * Number( value.replace(/\%/, "" ) ) ); + } else { + var new_value = Number( current_value ) + Number ( value ); + } + jQuery(this).val( new_value ).change(); + }); + 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'; + + var value = prompt(""); + jQuery(input_tag + '[name^="' + field_to_edit + '"]').each(function() { + var current_value = jQuery(this).val(); + + if ( value.indexOf("%") >= 0 ) { + var new_value = Number( current_value ) - ( ( Number( current_value ) / 100 ) * Number( value.replace(/\%/, "" ) ) ); + } else { + var new_value = Number( current_value ) - Number ( value ); + } + jQuery(this).val( new_value ).change(); + }); + 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'; + + var value = prompt(""); + jQuery(input_tag + '[name^="' + field_to_edit + '"]').each(function() { + var current_value = jQuery(this).val(); + + if ( value.indexOf("%") >= 0 ) { + var new_value = Number( current_value ) + ( ( Number( current_value ) / 100 ) * Number( value.replace(/\%/, "" ) ) ); + } else { + var new_value = Number( current_value ) + Number ( value ); + } + jQuery(this).val( new_value ).change(); + }); + 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'; + + var value = prompt(""); + jQuery(input_tag + '[name^="' + field_to_edit + '"]').each(function() { + var current_value = jQuery(this).val(); + + if ( value.indexOf("%") >= 0 ) { + var new_value = Number( current_value ) - ( ( Number( current_value ) / 100 ) * Number( value.replace(/\%/, "" ) ) ); + } else { + var new_value = Number( current_value ) - Number ( value ); + } + jQuery(this).val( new_value ).change(); + }); + break; + + default: + + var input_tag = jQuery('select#field_to_edit :selected').attr('rel') ? jQuery('select#field_to_edit :selected').attr('rel') : 'input'; + + var value = prompt(""); + jQuery(input_tag + '[name^="' + field_to_edit + '["]').val( value ).change(); + break; } - else if ( field_to_edit == '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'; - var value = prompt(""); - jQuery(input_tag + '[name^="' + field_to_edit + '"]').each(function() { - var current_value = jQuery(this).val(); - - if ( value.indexOf("%") >= 0 ) { - var new_value = Number( current_value ) + ( ( Number( current_value ) / 100 ) * Number( value.replace(/\%/, "" ) ) ); - } else { - var new_value = Number( current_value ) + Number ( value ); - } - jQuery(this).val( new_value ).change(); - }); - return false; - } - else if ( field_to_edit == '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'; - - var value = prompt(""); - jQuery(input_tag + '[name^="' + field_to_edit + '"]').each(function() { - var current_value = jQuery(this).val(); - - if ( value.indexOf("%") >= 0 ) { - var new_value = Number( current_value ) - ( ( Number( current_value ) / 100 ) * Number( value.replace(/\%/, "" ) ) ); - } else { - var new_value = Number( current_value ) - Number ( value ); - } - jQuery(this).val( new_value ).change(); - }); - return false; - } - else if ( field_to_edit == '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'; - - var value = prompt(""); - jQuery(input_tag + '[name^="' + field_to_edit + '"]').each(function() { - var current_value = jQuery(this).val(); - - if ( value.indexOf("%") >= 0 ) { - var new_value = Number( current_value ) + ( ( Number( current_value ) / 100 ) * Number( value.replace(/\%/, "" ) ) ); - } else { - var new_value = Number( current_value ) + Number ( value ); - } - jQuery(this).val( new_value ).change(); - }); - return false; - } - else if ( field_to_edit == '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'; - - var value = prompt(""); - jQuery(input_tag + '[name^="' + field_to_edit + '"]').each(function() { - var current_value = jQuery(this).val(); - - if ( value.indexOf("%") >= 0 ) { - var new_value = Number( current_value ) - ( ( Number( current_value ) / 100 ) * Number( value.replace(/\%/, "" ) ) ); - } else { - var new_value = Number( current_value ) - Number ( value ); - } - jQuery(this).val( new_value ).change(); - }); - return false; - } - else { - - var input_tag = jQuery('select#field_to_edit :selected').attr('rel') ? jQuery('select#field_to_edit :selected').attr('rel') : 'input'; - - var value = prompt(""); - jQuery(input_tag + '[name^="' + field_to_edit + '["]').val( value ).change(); - return false; - } }); jQuery('#variable_product_options').on('change', 'input.variable_is_downloadable', function(){