public function setCartLineQuantity(
        CartLineInterface $cartLine,
        $quantity
    ) {
        $cart = $cartLine->getCart();

        if (!($cart instanceof CartInterface)) {
            return $this;
        }

        /**
         * If $quantity is an integer and is less or equal than 0, means that
         * full line must be removed.
         *
         * Otherwise, $quantity can have two values:
         * * null or false - Quantity is not affected
         * * integer higher than 0, quantity is edited and all changes are
         *   recalculated.
         */
        if (is_int($quantity) && $quantity <= 0) {
            $this->silentRemoveLine($cart, $cartLine);
        } elseif (is_int($quantity)) {
            $cartLine->setQuantity($quantity);

            $this
                ->cartLineEventDispatcher
                ->dispatchCartLineOnEditEvent(
                    $cart,
                    $cartLine
                );
        } else {

            /**
             * Nothing to do here. Quantity value is not an integer, so will not
             * be treated as such.
             */

            return $this;
        }

        $this
            ->cartEventDispatcher
            ->dispatchCartLoadEvents($cart);

        return $this;
    }
public function setCartLineQuantity(
        CartLineInterface $cartLine,
        $quantity
    ) {
        $cart = $cartLine->getCart();

        if (!($cart instanceof CartInterface)) {
            return $this;
        }

        /**
         * If $quantity is an integer and is less or equal than 0, means that
         * full line must be removed.
         *
         * Otherwise, $quantity can have two values:
         * * null or false - Quantity is not affected
         * * integer higher than 0, quantity is edited and all changes are
         *   recalculated.
         */
        if (is_int($quantity) && $quantity <= 0) {
            $this->silentRemoveLine($cart, $cartLine);
        } elseif (is_int($quantity)) {
            $cartLine->setQuantity($quantity);

            $this
                ->cartLineEventDispatcher
                ->dispatchCartLineOnEditEvent(
                    $cart,
                    $cartLine
                );
        } else {

            /**
             * Nothing to do here. Quantity value is not an integer, so will not
             * be treated as such.
             */

            return $this;
        }

        $this
            ->cartEventDispatcher
            ->dispatchCartLoadEvents($cart);

        return $this;
    }
public function setCartLineQuantity ( CartLineInterface $ cartLine , $ quantity ) { $ cart = $ cartLine -> getCart ( ) ; if ( ! ( $ cart instanceof CartInterface ) ) { return $ this ; } /**
         * If $quantity is an integer and is less or equal than 0, means that
         * full line must be removed.
         *
         * Otherwise, $quantity can have two values:
         * * null or false - Quantity is not affected
         * * integer higher than 0, quantity is edited and all changes are
         *   recalculated.
         */ if ( is_int ( $ quantity ) && $ quantity <= 0 ) { $ this -> silentRemoveLine ( $ cart , $ cartLine ) ; } elseif ( is_int ( $ quantity ) ) { $ cartLine -> setQuantity ( $ quantity ) ; $ this -> cartLineEventDispatcher -> dispatchCartLineOnEditEvent ( $ cart , $ cartLine ) ; } else { /**
             * Nothing to do here. Quantity value is not an integer, so will not
             * be treated as such.
             */ return $ this ; } $ this -> cartEventDispatcher -> dispatchCartLoadEvents ( $ cart ) ; return $ this ; }
Sets quantity to cartLine.

If quantity is higher than item stock, throw exception

This method dispatches all Cart Check and Load events

@param CartLineInterface $cartLine Cart line
@param int               $quantity CartLine quantity to set

@return $this Self object
Sets quantity to cartLine .