@param CartItem $cartItem
@param int      $qty

@return $this
551153
private function addItemToCart(CartItem $cartItem, $qty = 1)
    {
        $cartItem->setQuantity($qty);
        $cartItem->setTaxRate(config('shoppingcart.tax'));

        $content = $this->getContent();

        if ($content->has($cartItem->rowId)) {
            $cartItem->setQuantity($cartItem->getQuantity() + $content->get($cartItem->rowId)->qty);
        }

        $content->put($cartItem->rowId, $cartItem);

        $this->content = serialize($content);

        $this->save();

        return $this;
    }
808463
public function add($id, $name = null, $qty = null, $price = null, array $options = [])
    {
        if ($this->isMulti($id)) {
            return array_map(function ($item) {
                return $this->add($item);
            }, $id);
        }

        $cartItem = $this->createCartItem($id, $name, $qty, $price, $options);

        $content = $this->getContent();

        if ($content->has($cartItem->rowId)) {
            $cartItem->qty += $content->get($cartItem->rowId)->qty;
        }

        $content->put($cartItem->rowId, $cartItem);
        
        $this->events->fire('cart.added', $cartItem);

        $this->session->put($this->instance, $content);

        return $cartItem;
    }
93518
public function update(CartItem $cartitem, UpdateCartItemRequest $request)
    {
        $errors = '';
        try {

            $this->cart->update($cartitem->id, $request->quantity);

            return response()->json([
                'errors' => false,
                'data' => $this->cart->items()
            ]);

        } catch (\Exception $e) {
            $errors = $e->getMessage();
        }

        return response()->json([
            'errors' => true,
            'message' => $errors,
            'data' => $this->cart->items()
        ]);
    }
984658
public function destroy(CartItem $cartitem)
    {
        $this->cart->remove($cartitem->id);

        return response()->json([
            'errors' => false,
            'data' => $this->cart->items()
        ]);
    }
1080385
public function update($itemId, $quantity)
    {
        if ($cartItem = $this->get($itemId)) {
            $cartItem->canChangeQuantity($quantity);
            $cartItem->quantity = $quantity;
            $cartItem->save();
        }

        return $cartItem;
    }
323928
public function withProductRequest($sku, $qty = 1, $request = []) : CartBuilder
    {
        $result = clone $this;
        $requestInfo = array_merge(['qty'=> $qty], $request);
        $result->addToCartRequests[$sku][] = new DataObject($requestInfo);
        return $result;
    }
1238059
public function checkStockLevel($qty)
    {
        $stock_param = $this->config()->get("stock_param");
        $item = $this->Match();
        $stock = ($item->$stock_param) ? $item->$stock_param : 0;
        $return = $stock - $qty;

        $this->extend("updateCheckStockLevel", $return);
        
        return $return;
    }
33276
public function addItem(\Flowcode\ShopBundle\Entity\StockTransferItem $item)
    {
        $this->items[] = $item;

        return $this;
    }
409032
public function createFromCartItem( $order, $cartItem, $config = [] ) {

		$model	= $this->getModelObject();

		// Set Attributes
		$model->orderId		= $order->id;
		$model->createdBy	= $order->creator->id;

		// Copy from Cart Item
		$model->copyForUpdateFrom( $cartItem, [ 'primaryUnitId', 'purchasingUnitId', 'quantityUnitId', 'weightUnitId', 'volumeUnitId', 'lengthUnitId', 'parentId', 'parentType', 'name', 'price', 'primary', 'purchase', 'quantity', 'total', 'weight', 'volume', 'length', 'width', 'height', 'radius' ] );

		$model->save();

		// Return OrderItem
		return $model;
	}
57243
protected function updateQty($rawId, $qty)
    {
        if ($qty <= 0) {
            return $this->remove($rawId);
        }

        return $this->updateRow($rawId, ['qty' => $qty]);
    }
465488
public function updateCart($cartId, $cartData)
    {
        $items = session($this->itemsKey);

        session([
            $this->sessionKey => array_merge($cartData, ['items' => $items]),
        ]);
    }
1065368
public function addCartProduct($cartProduct) {
    if ($this->orderCartContent == null || !is_array($this->orderCartContent)) {
      $this->orderCartContent = array();
    }

    if ($cartProduct instanceof CartProduct) {
      $this->orderCartContent[] = $cartProduct;
    }

    return $this;
  }
681378
public function decreasedBy(UomQty $qty)
    {
        $convertedValue = $qty->convertValueTo($this->uom);

        if ($convertedValue > $this->value) {
            throw new \InvalidArgumentException(
                'A quantity cannot be negative');
        }

        $newValue = $this->value - $convertedValue;

        return new self($this->uom, $newValue);
    }
524270
public function setMenuItem(\Amulen\PageBundle\Entity\MenuItem $menuItem = null) {
        $this->menuItem = $menuItem;

        return $this;
    }
517654
public function dispatchCartLineOnRemoveEvent(
        CartInterface $cart,
        CartLineInterface $cartLine
    ) {
        $this->eventDispatcher->dispatch(
            ElcodiCartEvents::CARTLINE_ONREMOVE,
            new CartLineOnAddEvent(
                $cart,
                $cartLine
            )
        );

        return $this;
    }
835082
public function add(
        $itemID,
        $name = null,
        $qty = 1,
        $price = '0.00',
        $options = [],
        $taxable = true,
        $lineItem = false
    ) {
        if (!empty(config('laracart.item_model'))) {
            $itemModel = $itemID;

            if (!$this->isItemModel($itemModel)) {
                $itemModel = (new $this->itemModel())->with($this->itemModelRelations)->find($itemID);
            }

            if (empty($itemModel)) {
                throw new ModelNotFound('Could not find the item '.$itemID);
            }

            $bindings = config('laracart.item_model_bindings');

            $itemID = $itemModel->{$bindings[\LukePOLO\LaraCart\CartItem::ITEM_ID]};

            if (is_int($name)) {
                $qty = $name;
            }

            $name = $itemModel->{$bindings[\LukePOLO\LaraCart\CartItem::ITEM_NAME]};
            $price = $itemModel->{$bindings[\LukePOLO\LaraCart\CartItem::ITEM_PRICE]};

            $options['model'] = $itemModel;

            $options = array_merge($options, $this->getItemModelOptions($itemModel, $bindings[\LukePOLO\LaraCart\CartItem::ITEM_OPTIONS]));

            $taxable = $itemModel->{$bindings[\LukePOLO\LaraCart\CartItem::ITEM_TAXABLE]} ? true : false;
        }

        $item = $this->addItem(new CartItem(
            $itemID,
            $name,
            $qty,
            $price,
            $options,
            $taxable,
            $lineItem
        ));

        $this->update();

        return $this->getItem($item->getHash());
    }
502372
public function moveItemsTo(Cart $cart){

        \DB::transaction(function () use(&$cart){
            $current_items = $cart->items()->pluck('product_id');
            $items_to_move = $this->items()->whereNotIn('product_id', $current_items->toArray())->get();
            if($items_to_move->count() === 0){
                return;
            }
            $this->items()->whereNotIn('product_id', $current_items->toArray())->update([
                'cart_id' => $cart->id
            ]);
            foreach($items_to_move as $item) {
                $this->item_count -= $item->quantity;
                $this->total_price -= $item->getPrice();
                $cart->item_count += $item->quantity;
                $cart->total_price += $item->getPrice();
            }
            $this->relations = [];
            $cart->relations = [];
            $this->save();
            $cart->save();
        });
        return $cart;
    }