shuup.core.order_creator package
Submodules
shuup.core.order_creator.constants module
shuup.core.order_creator.signals module
Module contents
- shuup.core.order_creator.get_order_source_modifier_modules()
Get a list of configured order source modifier module instances.
- Return type:
- shuup.core.order_creator.is_code_usable(order_source, code)
- class shuup.core.order_creator.OrderCreator(request=None)
Bases:
OrderProcessor
Initialize order creator.
- Parameters:
request (django.http.HttpRequest|None) – Optional request object for backward compatibility. Passing non-None value is DEPRECATED.
- __init__(request=None)[source]
Initialize order creator.
- Parameters:
request (django.http.HttpRequest|None) – Optional request object for backward compatibility. Passing non-None value is DEPRECATED.
- class shuup.core.order_creator.OrderModifier
Bases:
OrderProcessor
- class shuup.core.order_creator.OrderSource(shop)
Bases:
object
A “provisional order” object.
Contains data that is not strictly about a basket’s contents, but is useful for things that need to calculate something based on the basket’s contents and extra data, such as shipping/billing addresses.
The core API of
OrderCreator
reads anOrderSource
.No objects held here need to be saved, but they may be.
- add_code(code)[source]
Add a code to this OrderSource.
At this point it is expected that the customers permission to use the code has already been checked by the caller.
The code will be converted to text.
- clear_codes()[source]
Remove all codes from this OrderSource.
- Returns:
True if there were any codes before clearing.
- Return type:
- property codes
- count_products(supplier=None)[source]
The same as
smart_product_count`
, but accepts a supplier as a filter.- Return type:
- property creator
- property customer
- get_final_lines(with_taxes=False)[source]
Get lines with processed lines added.
This implementation includes all lines returned by
get_lines
. In addition, lines from shipping and payment methods are also returned. These latter lines can be extended, deleted or replaced by a subclass (by overriding_compute_processed_lines
method) and with thepost_compute_source_lines
signal. Lines returned are not validated.Note
By default, taxes for the returned lines are not calculated when
self.calculate_taxes_automatically
is false. Pass inTrue
towith_taxes
argument or usecalculate_taxes
method to force tax calculation.
- get_lines()[source]
Get unprocessed lines in this OrderSource.
See also
get_final_lines
.
- get_product_lines()[source]
Get lines with a product.
This does not use
get_final_lines
because it will be called when final lines are being computed (for example to determine shipping discounts based on the total price of all products).
- property is_empty
- property language
- property modified_by
- property orderer
- property payment_method
- property product_count
Get the sum of product quantities in this order source.
Note: It is a bit silly to sum different units together. Check
smart_product_count
andproduct_line_count
for other options.- Return type:
- property product_ids
- property product_line_count
Get the total number of product lines in this order source.
- Return type:
- property shipping_method
- property smart_product_count
Get the total number of separate products in this order source.
Quantities of lines, which have countable products, will be summed and then number of lines with non-countable product units will be added to that. E.g. smart product count for a basket containing 5 chocolate bars, 2 t-shirts and 2.5 kg of cocoa beans would be 5 + 2 + 1 = 8.
Definition of “countable” here: If product has an unit that allows presenting its quantities as a bare number (see
allow_bare_number
) and its quantity is an integral number, we assume that the unit is similar to “Pieces” unit and those products being countable. Other units are assumed to be non-countable.- Return type:
- property status
- taxful_total_discount
Property that calculates a sum of prices.
Used to implement various total price properties to
OrderSource
.Calculate the totals same way as for orders which is from rounded line prices.
- taxful_total_discount_or_none
Property that turns
TaxesNotCalculated
exception to None.Used to implement the
OrderSource
taxful/taxless total price properties with the “_or_none” suffix.
- taxful_total_price
Property that calculates a sum of prices.
Used to implement various total price properties to
OrderSource
.Calculate the totals same way as for orders which is from rounded line prices.
- taxful_total_price_of_products
Property that calculates a sum of prices.
Used to implement various total price properties to
OrderSource
.Calculate the totals same way as for orders which is from rounded line prices.
- taxful_total_price_or_none
Property that turns
TaxesNotCalculated
exception to None.Used to implement the
OrderSource
taxful/taxless total price properties with the “_or_none” suffix.
- taxless_total_discount
Property that calculates a sum of prices.
Used to implement various total price properties to
OrderSource
.Calculate the totals same way as for orders which is from rounded line prices.
- taxless_total_discount_or_none
Property that turns
TaxesNotCalculated
exception to None.Used to implement the
OrderSource
taxful/taxless total price properties with the “_or_none” suffix.
- taxless_total_price
Property that calculates a sum of prices.
Used to implement various total price properties to
OrderSource
.Calculate the totals same way as for orders which is from rounded line prices.
- taxless_total_price_of_products
Property that calculates a sum of prices.
Used to implement various total price properties to
OrderSource
.Calculate the totals same way as for orders which is from rounded line prices.
- taxless_total_price_or_none
Property that turns
TaxesNotCalculated
exception to None.Used to implement the
OrderSource
taxful/taxless total price properties with the “_or_none” suffix.
- total_discount
Property that calculates a sum of prices.
Used to implement various total price properties to
OrderSource
.Calculate the totals same way as for orders which is from rounded line prices.
- property total_gross_weight
- total_price
Property that calculates a sum of prices.
Used to implement various total price properties to
OrderSource
.Calculate the totals same way as for orders which is from rounded line prices.
- total_price_of_products
Property that calculates a sum of prices.
Used to implement various total price properties to
OrderSource
.Calculate the totals same way as for orders which is from rounded line prices.
- uncache()[source]
Uncache processed lines.
Should be called after changing the contents and before (re)accessing lines with
get_final_lines
.
- class shuup.core.order_creator.OrderSourceModifierModule
Bases:
object
- get_new_lines(order_source, lines)[source]
Get new lines to be added to order source.
- Return type:
Iterable[shuup.core.order_creator.SourceLine]
Bases:
object
- class shuup.core.order_creator.SourceLine(source, **kwargs)
Bases:
TaxableItem
,Priceful
,LineWithUnit
Line of OrderSource.
Note: Properties like price, taxful_price, tax_rate, etc. are inherited from the
Priceful
mixin.Initialize SourceLine with a given source and data.
- Parameters:
source (OrderSource) – The
OrderSource
thisSourceLine
belongs to.kwargs – Data for the
SourceLine
.
- __init__(source, **kwargs)[source]
Initialize SourceLine with a given source and data.
- Parameters:
source (OrderSource) – The
OrderSource
thisSourceLine
belongs to.kwargs – Data for the
SourceLine
.
- base_unit_price = None
- property data
- discount_amount = None
- classmethod from_dict(source, data)[source]
Create SourceLine from a given OrderSource and dict.
- Return type:
cls
- on_parent_change_behavior = 1
- property parent_line
- quantity = None
- property tax_amount
shuup.utils.money.Money
- Type:
rtype
- property tax_class
shuup.core.models.TaxClass
- Type:
rtype
- property taxes
Taxes of this line.
Determined by a TaxModule in
OrderSource.calculate_taxes
.- Return type: