Basket¶
The basket app handles shopping baskets, which essentially are a collection of products that hopefully end up being ordered.
Abstract models¶
- class oscar.apps.basket.abstract_models.AbstractBasket(*args, **kwargs)[source]¶
Basket object
- add(product, quantity=1, options=None)¶
Add a product to the basket
‘stock_info’ is the price and availability data returned from a partner strategy class.
The ‘options’ list should contains dicts with keys ‘option’ and ‘value’ which link the relevant product.Option model and string value respectively.
- Returns (line, created).
- line: the matching basket line created: whether the line was created or updated
- add_product(product, quantity=1, options=None)[source]¶
Add a product to the basket
‘stock_info’ is the price and availability data returned from a partner strategy class.
The ‘options’ list should contains dicts with keys ‘option’ and ‘value’ which link the relevant product.Option model and string value respectively.
- Returns (line, created).
- line: the matching basket line created: whether the line was created or updated
- all_lines()[source]¶
Return a cached set of basket lines.
This is important for offers as they alter the line models and you don’t want to reload them from the DB as that information would be lost.
- applied_offers()[source]¶
Return a dict of offers successfully applied to the basket.
This is used to compare offers before and after a basket change to see if there is a difference.
- grouped_voucher_discounts[source]¶
Return discounts from vouchers but grouped so that a voucher which links to multiple offers is aggregated into one object.
- is_quantity_allowed(qty)[source]¶
Test whether the passed quantity of items can be added to the basket
- is_shipping_required()[source]¶
Test whether the basket contains physical products that require shipping.
- line_quantity(product, stockrecord, options=None)[source]¶
Return the current quantity of a specific product and options
- merge(basket, add_quantities=True)[source]¶
Merges another basket with this one.
Basket: The basket to merge into this one. Add_quantities: Whether to add line quantities when they are merged.
- merge_line(line, add_quantities=True)[source]¶
For transferring a line from another basket to this one.
This is used with the “Saved” basket functionality.
- offer_discounts[source]¶
Return basket discounts from non-voucher sources. Does not include shipping discounts.
- product_quantity(product)[source]¶
Return the quantity of a product in the basket
The basket can contain multiple lines with the same product, but different options and stockrecords. Those quantities are summed up.
- set_as_submitted()¶
Mark this basket as submitted
- class oscar.apps.basket.abstract_models.AbstractLine(*args, **kwargs)[source]¶
A line of a basket (product and a quantity)
- consume(quantity)[source]¶
Mark all or part of the line as ‘consumed’
Consumed items are no longer available to be used in offers.
- get_price_breakdown()[source]¶
Return a breakdown of line prices after discounts have been applied.
Returns a list of (unit_price_incl_tax, unit_price_excl_tax, quantity) tuples.
Views¶
- class oscar.apps.basket.views.BasketAddView(**kwargs)[source]¶
Handles the add-to-basket submissions, which are triggered from various parts of the site. The add-to-basket form is loaded into templates using a templatetag from module basket_tags.py.
- product_model¶
alias of Product