Merge pull request #27633 from woocommerce/fix/27618

Allow zero as variation attribute option
This commit is contained in:
Christopher Allford 2020-09-10 09:05:56 -07:00 committed by GitHub
commit 226225e0da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 3 deletions

View File

@ -1040,7 +1040,6 @@ class WC_Cart extends WC_Legacy_Cart {
// Gather posted attributes.
$posted_attributes = array();
foreach ( $parent_data->get_attributes() as $attribute ) {
if ( ! $attribute['is_variation'] ) {
continue;
@ -1056,7 +1055,7 @@ class WC_Cart extends WC_Legacy_Cart {
}
// Don't include if it's empty.
if ( ! empty( $value ) ) {
if ( ! empty( $value ) || '0' === $value ) {
$posted_attributes[ $attribute_key ] = $value;
}
}

View File

@ -2248,7 +2248,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
// Attempt adding variation with add_to_cart_action, without specifying attribute_pa_colour.
$_REQUEST['add-to-cart'] = $variation['variation_id'];
$_REQUEST['attribute_pa_number'] = '0';
$_REQUEST['attribute_pa_number'] = '';
WC_Form_Handler::add_to_cart_action( false );
$notices = WC()->session->get( 'wc_notices', array() );