Base models

shopkit.discounts.basemodels

class shopkit.discounts.basemodels.DiscountedCartBase(*args, **kwargs)

Bases: shopkit.discounts.basemodels.DiscountedItemBase

Base class for shopping carts which can have discounts applied to them.

get_order_discount(**kwargs)

Calculate the whole order discount, as distinct from discount that apply to specific order items. This method must be implemented elsewhere.

get_total_discount(**kwargs)

Return the total discount. This consists of the sum of discounts applicable to orders and the discounts applicable to items.

class shopkit.discounts.basemodels.DiscountedCartItemBase(*args, **kwargs)

Bases: shopkit.discounts.basemodels.DiscountedItemBase

Base class for shopping cart items which can have discounts applied to them.

get_item_discount(**kwargs)

Calculate the order item discount, as distinct from the whole order discount. This method must be implemented in elsewhere.

get_total_discount(**kwargs)

Return the total discount for the CartItem, which is simply a wrapper around get_item_discount.

class shopkit.discounts.basemodels.DiscountedItemBase(*args, **kwargs)

Bases: shopkit.core.basemodels.AbstractPricedItemBase

Mixin class for discounted items.

get_discount(**kwargs)

Return the most sensible discount related to this item. By default, it returns the total discount applicable as yielded by get_total_discount.

..todo::
The mechanism making sure the discount is never higher than the original price is implemented here as well as in get_total_discount of DiscountedCartBase and DiscountedOrderBase.
get_piece_discount(**kwargs)

Get the discount per piece. Must be implemented in subclasses.

get_piece_price_with_discount(**kwargs)

Get the piece price with the discount applied.

get_piece_price_without_discount(**kwargs)

The price per piece without discount. Wrapper around the get_piece_price method of the superclass.

get_price(**kwargs)

Get the price with the discount applied.

get_price_without_discount(**kwargs)

The price without discount. Wrapper around the get_price method of the superclass.

get_total_discount(**kwargs)

Return the total discount applicable for this item. Must be implemented in subclasses.

class shopkit.discounts.basemodels.DiscountedOrderBase(*args, **kwargs)

Bases: shopkit.discounts.basemodels.DiscountedItemBase

Base class for orders which can have discounts applied to them. This stores rather than calculates the discounts for order persistence.

get_order_discount()

Return the discount for this order. This basically returns the order_discount property. To recalculate/update this value, call the update_discount method.

get_total_discount(**kwargs)

Return the total discount. This consists of the sum of discounts applicable to orders and the discounts applicable to items.

update_discount()

Update discounts for order and order items

class shopkit.discounts.basemodels.DiscountedOrderItemBase(*args, **kwargs)

Bases: shopkit.discounts.basemodels.DiscountedItemBase

Base class for order items which can have discounts applied to them.

get_item_discount(**kwargs)

Return the discount for this item. This basically returns the discount property. To recalculate/update this value, call the update_discount method.

get_total_discount(**kwargs)

Return the total discount for the CartItem, which is simply a wrapper around get_item_discount.

update_discount()

Update the discount