Add a new cart item
359414
protected function addAddCart()
    {
        if (!$this->isError()) {
            $id = $this->cart->add($this->getSubmitted());
            if (empty($id)) {
                $this->errorAndExit($this->text('Unexpected result'));
            }
            $this->line($id);
        }
    }
929762
def append(self, item):
    
    if self.should_flush():
      self.flush()
    self.items.append(item)
674493
def push(self, cart, env=None, callback=None):
        
        juicer.utils.Log.log_debug("Initializing push of cart '%s'" % cart.cart_name)

        if not env:
            env = self._defaults['start_in']

        cart.current_env = env
        self.sign_cart_for_env_maybe(cart, env)
        self.upload(env, cart, callback)
        return True
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;
    }
488705
def change_item(self, item_id, operation):
        

        product = Products().get_one(item_id)
        if product:
            if operation == 'add':
                self.items.append(product)
            elif operation == 'remove':
                cart_p = [x for x in self.items if x['id'] == product['id']]
                self.items.remove(cart_p[0])
            self.update()
            return True
        else:
            return False
1187002
def add_item(self, item):
        """"""

        if not isinstance(item, JsonRpcResponse):
            raise TypeError(
                "Expected JsonRpcResponse but got {} instead".format(type(item).__name__))

        self.items.append(item)
864655
def addMenuItem( self, newItem, atItem ):
        
        tree = self.uiMenuTREE
        
        if ( not atItem ):
            tree.addTopLevelItem(newItem)
            
        elif ( atItem.data(0, Qt.UserRole) == 'menu' ):
            atItem.addChild(newItem)
        
        elif ( atItem.parent() ):
            index = atItem.parent().indexOfChild(atItem)
            atItem.parent().insertChild(index + 1, newItem)
        
        else:
            index = tree.indexOfTopLevelItem(atItem)
            tree.insertTopLevelItem(index + 1, newItem)
1295495
def insert(self, item, safe=None): # pragma: nocover
		''' '''
		warnings.warn('Insert will be deprecated soon and removed in 1.0. Please use insert',
					  PendingDeprecationWarning)
		self.add(item, safe=safe)
993042
def insert_after(self, key, new_item, instance=0):
        """"""
        self._insert_item(key, new_item, instance, True)
943094
def new(self, **dict):
        ''''''
        if not self._item_new_path:
            raise AttributeError('new is not available for %s' % self._item_name)

        # Remap various tag to tag_id
        for tag in self._object._remap_to_id:
            self._object._remap_tag_to_tag_id(tag, dict)

        target = self._item_new_path
        payload = json.dumps({self._item_type:dict})
        json_data = self._redmine.post(target, payload)
        data = self._redmine.unwrap_json(self._item_type, json_data)
        data['_source_path'] = target
        return self._objectify(data=data)
1167424
def add_item(self, item):
        """"""
        _idx = len(self.items)
        self.items.update({"item_" + str(_idx + 1): item})
931446
def add_item(self, item):
        
        if item.get_type() == ebooklib.ITEM_STYLE:
            self.add_link(href=item.get_name(), rel='stylesheet', type='text/css')

        if item.get_type() == ebooklib.ITEM_SCRIPT:
            self.add_link(src=item.get_name(), type='text/javascript')
1260168
public function updateCart($cartId, $cartData)
    {
        $cartData = $this->arraySnakeCase($cartData);

        Cart::where('id', $cartId)->update($cartData);
    }
234087
def add(self, quantity):
        
        newvalue = self._value + quantity
        self.set(newvalue.deg)
1266095
public function addToCart($cart_action_model)
    {
        $errors = $this->error();

        if (empty($errors)) {
            $submitted = $this->getSubmitted();
            $result = $cart_action_model->add($submitted['product'], $submitted);
        } else {

            $result = array(
                'redirect' => '',
                'severity' => 'warning',
                'message' => $this->format($errors)
            );
        }

        if ($this->isAjax()) {
            $result['modal'] = $this->getCartPreview();
            $this->outputJson($result);
        }

        $this->redirect($result['redirect'], $result['message'], $result['severity']);
    }
1316727
def update(self, cart_name, cart_description, manifests):
        
        if cart_description is None:
            juicer.utils.Log.log_debug("No cart_description provided.")
            cart_description = []

        if manifests is None:
            juicer.utils.Log.log_debug("No manifests provided.")
            manifests = []

        juicer.utils.Log.log_debug("Loading cart '%s'." % cart_name)
        cart = juicer.common.Cart.Cart(cart_name, autoload=True)

        for repo_items in cart_description:
            (repo, items) = (repo_items[0], repo_items[1:])
            juicer.utils.Log.log_debug("Processing %s input items for repo '%s'." % (len(items), repo))

            if repo not in cart.keys():
                cart[repo] = items
            else:
                for item in items:
                    cart[repo].append(juicer.common.CartItem.CartItem(os.path.expanduser(item)))

        for manifest in manifests:
            cart.add_from_manifest(manifest, self.connectors)

        cart.save()
        return cart
1257507
public function add($item, $attributes = [], $quantity = 1, $quantityReset = false)
    {
        if (!is_array($item) && !$item->isShoppable) return;

        $attributesHash = sha1(serialize($attributes));
        $cartItem = $this->getItem(is_array($item) ? $item['sku'] : $item->sku, $attributesHash);


        // Add new or sum quantity
        if (empty($cartItem)) {

            $arrAttributeObjects = [];
            if (!empty($attributes) && is_array($attributes)) {
                foreach ($attributes as $attributeType => $attributeValues) {
                    if ($type = Config::get('shop.attribute_models.' . $attributeType)) {
                        if (is_array($attributeValues)) {
                            foreach ($attributeValues as $cgr => $cAttr) {
                                $attr = new $type();
                                $attr->fillAttr($cgr, $cAttr);

                                $class = Config::get('shop.item_attributes');
                                $itemAttribute = new $class();

                                $itemAttribute->attributeObject()->associate($attr);

                                $arrAttributeObjects[] = $itemAttribute;

                            }
                        }
                    }
                }
            }

            $class = Config::get('shop.item');
            $cartItem = new $class();
            $cartItem->user_id = !empty($this->user->shopId) ? $this->user->shopId : 0;
            $cartItem->session_id = session('visitor_id');
            $cartItem->cart_id = $this->id;
            $cartItem->sku = is_array($item) ? $item['sku'] : $item->sku;
            $cartItem->price = is_array($item) ? $item['price'] : $item->getSpecificBasePrice($quantity, $arrAttributeObjects, $this);
            $cartItem->tax = is_array($item)
                                        ? (array_key_exists('tax', $item)
                                            ?   $item['tax']
                                            :   0
                                        )
                                        : (isset($item->tax) && !empty($item->tax)
                                            ?   $item->tax
                                            :   0
                                        );
            $cartItem->shipping = is_array($item)
                                        ? (array_key_exists('shipping', $item)
                                            ?   $item['shipping']
                                            :   0
                                        )
                                        : (isset($item->shipping) && !empty($item->shipping)
                                            ?   $item->shipping
                                            :   0
                                        );
            $cartItem->discount = $item->calculateDiscount();
            $cartItem->currency = Config::get('shop.currency');
            $cartItem->quantity = $quantity;
            $cartItem->attributes_hash = $attributesHash;

            // This looks a bit backwards but this is the proper way of storing the relation
            $item->shoppables()->save($cartItem);

            // Save the attributes
            $cartItem->itemAttributes()->saveMany($arrAttributeObjects);

            $this->resetCalculations();
        } else {
            $this->increase($cartItem, $quantity, $quantityReset);
        }

        return $this;
    }