Models¶
-
class
shopkit.stock.models.
StockedCartBase
¶ Bases:
object
Base class for shopping carts for which stock is kept.
-
add_item
(product, quantity=1, **kwargs)¶ Attempt to add item to cart.
This method will raise a
NoStockAvailableException
when no stock items are available.
-
-
class
shopkit.stock.models.
StockedCartItemBase
¶ Bases:
object
Base class for cart items for which the stock can be maintained. By default the is_available method returns True, this method can be overridden in subclassed to provide for more extended functionality.
Todo
Decide whether this bugger belongs into :module:shopkit.core or whether it is just fine at it’s place right here.
- Pro: We’ll have a generic API for determining the stock state of items.
- Con: It’s bad to have too much code in the core, it is better if modules within django-shopkit have the least possible knowledge about one another.
-
is_available
(quantity)¶ The is_available method can be used to determine whether a cart item is eligible to be saved or not.
-
class
shopkit.stock.models.
StockedItemBase
¶ Bases:
object
Generic base class for CartItem‘s or OrderItem‘s for which the stock is represented by a stocked item somehow.
-
get_stocked_item
()¶ Get the
StockedItemMixin
subclass instance whose is_available method should determine whether we are out of stock.This method should be overridden in order to be able to specify whether the cart item is available or not.
-
is_available
(quantity)¶ Determine whether or not this item is available.
-
-
class
shopkit.stock.models.
StockedOrderBase
¶ Bases:
object
Mixin base class for Order‘s with items for which stock is kept.
-
check_stock
()¶ Check the stock for all items in this order.
-
-
class
shopkit.stock.models.
StockedOrderItemBase
¶ Bases:
object
Mixin base class for OrderItem‘s containing items for which stock is kept.
-
check_stock
()¶ Check whether the stock for the current order item is available. This should be called right before register_confirmation.
-
confirm
()¶ Before registering confirmation, first make sure enough stock is available. This should have already been checked when adding the product to the shopping cart but who knows: somebody might have already bought the product in the meanwhile.
For this to work well, it is important that this register_confirmation function is called before that of discounts and other possible accounting functions.
-
prepare_confirm
()¶ Extend confirmation preparation by checking whether stock is available for this order.
Raises: NoStockAvailableException
-