Models

shopkit.shipping.advanced.models

class shopkit.shipping.advanced.models.shipping_models.ItemShippingMethodMixin(*args, **kwargs)

Bases: django.db.models.base.Model

Mixin for shipping methods which process individual items and not whole orders.

classmethod get_cheapest(**kwargs)

Return the cheapest shipping method or None.

If item_cost is not specified, an attempt will be made to call get_cheapest on the superclass. If this method does not exist in the superclass, None is returned.

classmethod get_valid_methods(item_methods=None, **kwargs)

We want to be able to discriminate between methods valid for the whole item and those valid for item items.

Parameters:item_methods – When True, only items for which item_cost has been specified are valid. When False, only items which have no item_cost specified are let through.
class shopkit.shipping.advanced.models.shipping_models.MinimumItemAmountShippingMixin(*args, **kwargs)

Bases: django.db.models.base.Model

Shipping mixin for methods valid only from a specified order amount.

classmethod get_valid_methods(item_price=None, **kwargs)

Return shipping methods for which the item price is above a minimum price or ones for which no minimal item price has been specified.

Parameters:item_price – Price for the current OrderItem, used to determine valid shipping methods.
class shopkit.shipping.advanced.models.shipping_models.MinimumOrderAmountShippingMixin(*args, **kwargs)

Bases: django.db.models.base.Model

Shipping mixin for methods valid only from a specified order amount.

classmethod get_valid_methods(order_price=None, **kwargs)

Return shipping methods for which the order price is above the minimal order price or ones for which no minimal order price has been specified.

Parameters:order_price – Price for the current order, used to determine valid shipping methods.
class shopkit.shipping.advanced.models.shipping_models.OrderShippingMethodMixin(*args, **kwargs)

Bases: django.db.models.base.Model

Mixin for shipping methods which process whole orders and not individual items.

classmethod get_cheapest(**kwargs)

Return the cheapest order shipping method if order_methods is specified. Return whatever it is the superclass returns otherwise.

classmethod get_valid_methods(order_methods=None, **kwargs)

We want to be able to discriminate between methods valid for the whole order and those valid for order items.

Parameters:order_methods – When True, only items for which order_cost has been specified are valid. When False, only items which have no order_cost specified are let through.
class shopkit.shipping.advanced.models.shipping_models.ShippingMethodBase(*args, **kwargs)

Bases: django.db.models.base.Model

Base class for shipping methods.

get_cost(**kwargs)

Get the total shipping costs resulting from this ShippingMethod. This method should be implemented by subclasses of :class:ShippingMethodBase.

classmethod get_valid_methods(**kwargs)

Get all valid shipping methods for a given kwargs. By default, all methods are valid.

is_valid(**kwargs)

Check to see whether an individual method is valid under the given circumstances.

class shopkit.shipping.advanced.models.order_models.AutomaticShippingMixin

Bases: object

Mixin class for shippable items for which the choice of method is automatic.

get_shipping_method(**kwargs)

Return the shipping method used for the current item. This method should be overridden in subclasses. It should return None if shipping is not applicable for this item and hence, the shipping costs should be 0.

class shopkit.shipping.advanced.models.order_models.CheapestShippingMixin

Bases: shopkit.shipping.advanced.models.order_models.AutomaticShippingMixin

Shippable item which defaults to using the

get_shipping_method(**kwargs)

Return the cheapest shipping method or an order or item.

Todo

This code is probably a bit too low-level.

class shopkit.shipping.advanced.models.order_models.PersistentShippedItemBase(*args, **kwargs)

Bases: django.db.models.base.Model

Mixin class for Order‘s and OrderItem‘s for which the shipping method is stored persistently upon calling the update_shipping method.

update_shipping()

Call update_shipping on the superclass and get the shipping method, store the resulting ShippingMethod on the shipping_method property.

class shopkit.shipping.advanced.models.order_models.ShippedCartItemMixin(*args, **kwargs)

Bases: shopkit.shipping.advanced.models.order_models.CalculatedShippingItemMixin, shopkit.shipping.advanced.models.order_models.CheapestShippingMixin, shopkit.shipping.basemodels.ShippedCartItemBase

Base class for shopping cart items which are shippable.

class shopkit.shipping.advanced.models.order_models.ShippedCartMixin(*args, **kwargs)

Bases: shopkit.shipping.advanced.models.order_models.CalculatedShippingOrderMixin, shopkit.shipping.advanced.models.order_models.CheapestShippingMixin, shopkit.shipping.basemodels.ShippedCartBase

Base class for shopping carts with shippable items.

class shopkit.shipping.advanced.models.order_models.ShippedOrderItemMixin(*args, **kwargs)

Bases: shopkit.shipping.advanced.models.order_models.PersistentShippedItemBase, shopkit.shipping.advanced.models.order_models.CalculatedShippingItemMixin, shopkit.shipping.advanced.models.order_models.CheapestShippingMixin, shopkit.shipping.basemodels.ShippedOrderItemBase

Base class for orderitems which can have individual shipping costs applied to them.

class shopkit.shipping.advanced.models.order_models.ShippedOrderMixin(*args, **kwargs)

Bases: shopkit.shipping.advanced.models.order_models.PersistentShippedItemBase, shopkit.shipping.basemodels.ShippedOrderBase, shopkit.shipping.advanced.models.order_models.CalculatedShippingOrderMixin, shopkit.shipping.advanced.models.order_models.CheapestShippingMixin

Base class for orders with a shipping_method.