src/Cart/ShoppingCart.php
public function remove(Buyable $buyable, $quantity = null, $filter = [])
    {
        $order = $this->current();

        if (!$order) {
            return $this->error(_t(__CLASS__ . '.NoOrder', 'No current order.'));
        }

        // If an extension throws an exception, error out
        try {
            $order->extend('beforeRemove', $buyable, $quantity, $filter);
        } catch (Exception $exception) {
            return $this->error($exception->getMessage());
        }

        $item = $this->get($buyable, $filter);

        if (!$item || !$this->removeOrderItem($item, $quantity)) {
            return false;
        }

        // If an extension throws an exception, error out
        // TODO: There should be a rollback
        try {
            $order->extend('afterRemove', $item, $buyable, $quantity, $filter);
        } catch (Exception $exception) {
            return $this->error($exception->getMessage());
        }

        $this->message(_t(__CLASS__ . '.ItemRemoved', 'Item has been successfully removed.'));

        return true;
    }
public function remove(Buyable $buyable, $quantity = null, $filter = [])
    {
        $order = $this->current();

        if (!$order) {
            return $this->error(_t(__CLASS__ . '.NoOrder', 'No current order.'));
        }

        // If an extension throws an exception, error out
        try {
            $order->extend('beforeRemove', $buyable, $quantity, $filter);
        } catch (Exception $exception) {
            return $this->error($exception->getMessage());
        }

        $item = $this->get($buyable, $filter);

        if (!$item || !$this->removeOrderItem($item, $quantity)) {
            return false;
        }

        // If an extension throws an exception, error out
        // TODO: There should be a rollback
        try {
            $order->extend('afterRemove', $item, $buyable, $quantity, $filter);
        } catch (Exception $exception) {
            return $this->error($exception->getMessage());
        }

        $this->message(_t(__CLASS__ . '.ItemRemoved', 'Item has been successfully removed.'));

        return true;
    }
Remove an item from the cart.

@param Buyable $buyable
@param int     $quantity - number of items to remove, or leave null for all items (default)
@param array   $filter

@return boolean success/failure