WC_Cart::remove_cart_item PHP Method

remove_cart_item() public method

Remove a cart item.
Since: 2.3.0
public remove_cart_item ( string $cart_item_key ) : boolean
$cart_item_key string
return boolean
    public function remove_cart_item($cart_item_key)
    {
        if (isset($this->cart_contents[$cart_item_key])) {
            $this->removed_cart_contents[$cart_item_key] = $this->cart_contents[$cart_item_key];
            unset($this->removed_cart_contents[$cart_item_key]['data']);
            do_action('woocommerce_remove_cart_item', $cart_item_key, $this);
            unset($this->cart_contents[$cart_item_key]);
            do_action('woocommerce_cart_item_removed', $cart_item_key, $this);
            $this->calculate_totals();
            return true;
        }
        return false;
    }
WC_Cart