Merge pull request #23069 from woocommerce/fix/23061

Variation stock status field handling (displaying/hiding when needed)
This commit is contained in:
Rodrigo Primo 2019-03-27 14:51:26 -03:00 committed by GitHub
commit cbf6149cb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 3 deletions

View File

@ -62,11 +62,16 @@ jQuery( function( $ ) {
*/ */
variable_manage_stock: function() { variable_manage_stock: function() {
$( this ).closest( '.woocommerce_variation' ).find( '.show_if_variation_manage_stock' ).hide(); $( this ).closest( '.woocommerce_variation' ).find( '.show_if_variation_manage_stock' ).hide();
$( this ).closest( '.woocommerce_variation' ).find( '.hide_if_variation_manage_stock' ).show(); $( this ).closest( '.woocommerce_variation' ).find( '.variable_stock_status' ).show();
if ( $( this ).is( ':checked' ) ) { if ( $( this ).is( ':checked' ) ) {
$( this ).closest( '.woocommerce_variation' ).find( '.show_if_variation_manage_stock' ).show(); $( this ).closest( '.woocommerce_variation' ).find( '.show_if_variation_manage_stock' ).show();
$( this ).closest( '.woocommerce_variation' ).find( '.hide_if_variation_manage_stock' ).hide(); $( this ).closest( '.woocommerce_variation' ).find( '.variable_stock_status' ).hide();
}
// Parent level.
if ( $( 'input#_manage_stock:checked' ).length ) {
$( this ).closest( '.woocommerce_variation' ).find( '.variable_stock_status' ).hide();
} }
}, },

View File

@ -240,6 +240,8 @@ jQuery( function( $ ) {
$( 'div.stock_fields' ).hide(); $( 'div.stock_fields' ).hide();
$( 'p.stock_status_field:not( .hide_if_' + product_type + ' )' ).show(); $( 'p.stock_status_field:not( .hide_if_' + product_type + ' )' ).show();
} }
$( 'input.variable_manage_stock' ).change();
}).change(); }).change();
// Date picker fields. // Date picker fields.

View File

@ -235,7 +235,7 @@ defined( 'ABSPATH' ) || exit;
'options' => wc_get_product_stock_status_options(), 'options' => wc_get_product_stock_status_options(),
'desc_tip' => true, 'desc_tip' => true,
'description' => __( 'Controls whether or not the product is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce' ), 'description' => __( 'Controls whether or not the product is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce' ),
'wrapper_class' => 'form-row form-row-full hide_if_variation_manage_stock', 'wrapper_class' => 'form-row form-row-full variable_stock_status',
) )
); );