Skip to content

Commit

Permalink
Variation stock status handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejolley committed Mar 18, 2019
1 parent 9863758 commit 97f30e7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
9 changes: 7 additions & 2 deletions assets/js/admin/meta-boxes-product-variation.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,16 @@ jQuery( function( $ ) {
*/
variable_manage_stock: function() {
$( 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' ) ) {
$( 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();
}
},

Expand Down
2 changes: 2 additions & 0 deletions assets/js/admin/meta-boxes-product.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ jQuery( function( $ ) {
$( 'div.stock_fields' ).hide();
$( 'p.stock_status_field:not( .hide_if_' + product_type + ' )' ).show();
}

$( 'input.variable_manage_stock' ).change();
}).change();

// Date picker fields.
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/meta-boxes/views/html-variation-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
'options' => wc_get_product_stock_status_options(),
'desc_tip' => true,
'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',
)
);

Expand Down

0 comments on commit 97f30e7

Please sign in to comment.