From d13fb8f4823aca065c057bfa9f46a335d8fae728 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Mon, 11 Jan 2016 10:32:46 +0000 Subject: [PATCH] Let check_cart_item_validity remove multiple items during check Fixes #10050 --- includes/class-wc-cart.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/includes/class-wc-cart.php b/includes/class-wc-cart.php index 0cc821f0245..08be51303f4 100644 --- a/includes/class-wc-cart.php +++ b/includes/class-wc-cart.php @@ -477,18 +477,18 @@ class WC_Cart { * @return bool|WP_Error */ public function check_cart_item_validity() { - foreach ( $this->get_cart() as $cart_item_key => $values ) { + $return = true; + foreach ( $this->get_cart() as $cart_item_key => $values ) { $_product = $values['data']; - if ( ! $_product || ! $_product->exists() || $_product->post->post_status == 'trash' ) { + if ( ! $_product || ! $_product->exists() || 'trash' === $_product->post->post_status ) { $this->set_quantity( $cart_item_key, 0 ); - - return new WP_Error( 'invalid', __( 'An item which is no longer available was removed from your cart.', 'woocommerce' ) ); + $return = new WP_Error( 'invalid', __( 'An item which is no longer available was removed from your cart.', 'woocommerce' ) ); } } - return true; + return $return; } /**