From 07b1f9329df08c5d1f88facade9a838140d0d418 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Fri, 21 Aug 2015 16:48:25 +0100 Subject: [PATCH] Bulk update variation: Allow stock to be set to 0. --- includes/class-wc-ajax.php | 14 ++++++-------- readme.txt | 3 ++- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/includes/class-wc-ajax.php b/includes/class-wc-ajax.php index ff9b69d86f1..689107e45ec 100644 --- a/includes/class-wc-ajax.php +++ b/includes/class-wc-ajax.php @@ -2760,19 +2760,17 @@ class WC_AJAX { * @param array $data */ private static function variation_bulk_action_variable_stock( $variations, $data ) { - if ( empty( $data['value'] ) ) { + if ( ! isset( $data['value'] ) ) { return; } $value = wc_clean( $data['value'] ); - if ( $value ) { - foreach ( $variations as $variation_id ) { - if ( 'yes' === get_post_meta( $variation_id, '_manage_stock', true ) ) { - wc_update_product_stock( $variation_id, wc_stock_amount( $value ) ); - } else { - delete_post_meta( $variation_id, '_stock' ); - } + foreach ( $variations as $variation_id ) { + if ( 'yes' === get_post_meta( $variation_id, '_manage_stock', true ) ) { + wc_update_product_stock( $variation_id, wc_stock_amount( $value ) ); + } else { + delete_post_meta( $variation_id, '_stock' ); } } } diff --git a/readme.txt b/readme.txt index 40d33dfac6b..da63287c223 100644 --- a/readme.txt +++ b/readme.txt @@ -164,7 +164,8 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc * Fix - Subscriptions 2.0 (unreleased) compatibility. * Fix - Added BW compatibility for themes using 'uniform'. * Fix - Encode variation data in add_to_cart_url method. -* Fix - Bulk update variation manage stock when _manage_stock meta data is missing. +* Fix - Bulk update variation: Set manage stock when _manage_stock meta data is missing. +* Fix - Bulk update variation: Allow stock to be set to 0. * Tweak - Add tooltips for tax status and tax class options. * Tweak - WC Setup wizard: multi-line step styling. * Tweak - WC Setup wizard: site icon display on WP 4.3.