def add(self, pk, quantity=<NUM_LIT:1>, **kwargs):
pk = str(pk)<EOL>if pk in self.items:<EOL><INDENT>existing_item = self.items[pk]<EOL>existing_item.quantity += _clean_quantity(quantity)<EOL><DEDENT>else:<EOL><INDENT>queryset = self.get_queryset([pk])<EOL>try:<EOL><INDENT>obj = queryset[<NUM_LIT:0>]<EOL><DEDENT>except IndexError:<EOL><INDENT>raise ItemNotInDatabase(pk=pk)<EOL><DEDENT>obj = self.process_object(obj)<EOL>self.items[pk] = self.item_class(obj, quantity, **kwargs)<EOL><DEDENT>self.update()<EOL>
Add an item to the cart.

        If the item is already in the cart, then its quantity will be
        increased by `quantity` units.

        Parameters
        ----------
        pk : str or int
            The primary key of the item.
        quantity : int-convertible
            A number of units of to add.
        **kwargs
            Extra keyword arguments to pass to the item class
            constructor.

        Raises
        ------
        ItemNotInDatabase
        NegativeItemQuantity
        NonConvertibleItemQuantity
        TooLargeItemQuantity
        ZeroItemQuantity