Hide variation stock when manage stock is unchecked

closes #5935

@mikejolley
This commit is contained in:
claudiosmweb 2014-07-30 15:32:06 -03:00
parent 519de5be59
commit a0bd72b9f3
3 changed files with 23 additions and 7 deletions

View File

@ -52,6 +52,10 @@ jQuery( function ( $ ) {
$( 'input.variable_is_downloadable, input.variable_is_virtual, input.variable_manage_stock' ).change();
if ( ! $( 'input#_manage_stock' ).attr( 'checked' ) ) {
$( '.hide_if_parent_manage_stock_is_disabled' ).hide();
}
$( '.woocommerce_variations' ).unblock();
$( '#variable_product_options' ).trigger( 'woocommerce_variations_added' );
});
@ -60,6 +64,17 @@ jQuery( function ( $ ) {
});
$( 'body' ).on( 'change', 'input#_manage_stock', function () {
var fields = $( '.hide_if_parent_manage_stock_is_disabled' );
if ( $( this ).attr( 'checked' ) ) {
fields.show();
$( 'input.variable_manage_stock' ).change();
} else {
fields.hide();
}
}).change();
$( '#variable_product_options').on( 'click', 'button.link_all_variations', function () {
var answer = window.confirm( woocommerce_admin_meta_boxes_variations.i18n_link_all_variations );
@ -239,12 +254,13 @@ jQuery( function ( $ ) {
$( ':input[name^="' + edit_field + '"]' ).each( function() {
var current_value = accounting.unformat( $( this ).val(), woocommerce_admin.mon_decimal_point ),
new_value;
new_value,
mod_value;
if ( value.indexOf( '%' ) >= 0 ) {
var mod_value = ( current_value / 100 ) * accounting.unformat( value.replace(/\%/, '' ), woocommerce_admin.mon_decimal_point );
mod_value = ( current_value / 100 ) * accounting.unformat( value.replace( /\%/, '' ), woocommerce_admin.mon_decimal_point );
} else {
var mod_value = accounting.unformat( value, woocommerce_admin.mon_decimal_point );
mod_value = accounting.unformat( value, woocommerce_admin.mon_decimal_point );
}
if ( bulk_edit.indexOf( 'increase' ) !== -1 ) {

File diff suppressed because one or more lines are too long

View File

@ -81,7 +81,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
</tr>
<?php if ( get_option( 'woocommerce_manage_stock' ) == 'yes' ) : ?>
<tr class="show_if_variation_manage_stock">
<tr class="hide_if_parent_manage_stock_is_disabled show_if_variation_manage_stock">
<td>
<label><?php _e( 'Stock Qty:', 'woocommerce' ); ?> <a class="tips" data-tip="<?php _e( 'Enter a quantity to enable stock management at variation level, or leave blank to use the parent product\'s options.', 'woocommerce' ); ?>" href="#">[?]</a></label>
<input type="number" size="5" name="variable_stock[<?php echo $loop; ?>]" value="<?php if ( isset( $_stock ) ) echo esc_attr( $_stock ); ?>" step="any" />
@ -96,7 +96,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
?></select>
</td>
</tr>
<tr class="">
<tr class="hide_if_parent_manage_stock_is_disabled">
<td colspan="2">
<label><?php _e( 'Stock status', 'woocommerce' ); ?> <a class="tips" data-tip="<?php esc_attr_e( 'Controls whether or not the product is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce' ); ?>" href="#">[?]</a></label>
<select name="variable_stock_status[<?php echo $loop; ?>]">
@ -235,7 +235,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
<?php if ( get_option( 'woocommerce_manage_stock' ) == 'yes' ) : ?>
<label><input type="checkbox" class="checkbox variable_manage_stock" name="variable_manage_stock[<?php echo $loop; ?>]" <?php checked( isset( $_manage_stock ) ? $_manage_stock : '', 'yes' ); ?> /> <?php _e( 'Manage stock?', 'woocommerce' ); ?> <a class="tips" data-tip="<?php _e( 'Enable this option to enable stock management at variation level', 'woocommerce' ); ?>" href="#">[?]</a></label>
<label class="hide_if_parent_manage_stock_is_disabled"><input type="checkbox" class="checkbox variable_manage_stock" name="variable_manage_stock[<?php echo $loop; ?>]" <?php checked( isset( $_manage_stock ) ? $_manage_stock : '', 'yes' ); ?> /> <?php _e( 'Manage stock?', 'woocommerce' ); ?> <a class="tips" data-tip="<?php _e( 'Enable this option to enable stock management at variation level', 'woocommerce' ); ?>" href="#">[?]</a></label>
<?php endif; ?>