When updating the cart a quantity input of zero should remove the product from the cart

This commit is contained in:
Geert De Deckere 2012-03-01 09:14:33 +01:00
parent f0c312213f
commit 13978a196d
1 changed files with 8 additions and 4 deletions

View File

@ -215,10 +215,14 @@ function woocommerce_update_cart_action() {
foreach ($woocommerce->cart->get_cart() as $cart_item_key => $values) :
$_product = $values['data'];
$quantity = (isset($cart_totals[$cart_item_key]['qty'])) ? $cart_totals[$cart_item_key]['qty'] : '';
if (!$quantity) continue;
// Skip product if no updated quantity was posted
if ( ! isset( $cart_totals[$cart_item_key]['qty'] ) )
continue;
// Clean the quantity input
$quantity = absint( $cart_totals[$cart_item_key]['qty'] );
// Update cart validation
$passed_validation = apply_filters('woocommerce_update_cart_validation', true, $cart_item_key, $values, $quantity);