API
Plug-ins
Criterion
- class lfs.criteria.models.Criterion
Base class for all criteria.
Attributes:
- cart
The current cart of the current customer.
- content
The content object the criterion belongs to.
- operator
The current selected operator for the criterion.
- position
The position of the criterion within a list of criteria of the content object.
- product
The product, if the criterion is called from a product detail view. Otherwise this is None.
- request
The current request.
Constants:
- EQUAL, LESS_THAN, LESS_THAN_EQUAL, GREATER_THAN, GREATER_THAN_EQUAL, IS_SELECTED, IS_NOT_SELECTED, IS_VALID, IS_NOT_VALID, CONTAINS
Integers which represents certain operators.
- INPUT, SELECT, MULTIPLE_SELECT
Constants which represents the types of selectable values. One of these must be returned from
get_value_type.- NUMBER_OPERATORS
A list of operators which can be returned from
get_operators.[ [EQUAL, _(u"Equal to")], [LESS_THAN, _(u"Less than")], [LESS_THAN_EQUAL, _(u"Less than equal to")], [GREATER_THAN, _(u"Greater than")], [GREATER_THAN_EQUAL, _(u"Greater than equal to")], ]
- SELECTION_OPERATORS
A list of operators which can be returned from
get_operators.[ [IS_SELECTED, _(u"Is selected")], [IS_NOT_SELECTED, _(u"Is not selected")], ]
- VALID_OPERATORS
A list of operators which can be returned from
get_operators.[ [IS_VALID, _(u"Is valid")], [IS_NOT_VALID, _(u"Is not valid")], ]
- STRING_OPERATORS
A list of operators which can be return from
get_operators.[ [EQUAL, _(u"Equal to")], [CONTAINS, _(u"Contains")], ]
- get_operators()
Returns the selectable operators of the criterion which are displayed to the shop manager. This is a list of list, whereas the the first value is integer, which is stored within the criterion and the second value is the string which is displayed to the shop manager, e.g.:
[ [0, _(u"Equal to")], [1, _(u"Less than")], [2, _(u"Less than equal to")], [3, _(u"Greater than")], [4, _(u"Greater than equal to")], ]
Note
You can use one of the provided class attributes, see above.
NUMBER_OPERATORS
SELECTION_OPERATORS
VALID_OPERATORS
STRING_OPERATORS
- get_selectable_values(request)
Returns the selectable values as a list of dictionary, see below. This is only called when
get_value_typereturns SELECT or MULTIPLE_SELECT.[ { "id": 0, "name": "Name 0", "selected": False, }, { "id": 1, "name": "Name 1", "selected": True, }, ]
- get_template(request)
Returns the template to render the criterion.
- get_value_type()
Returns the type of the selectable values field. Must return one of:
self.INPUT
self.SELECT
self.MULTIPLE_SELECT
- get_value()
Returns the current value of the criterion.
- is_valid(request, product=None)
Returns
Trueif the criterion is valid otherwiseFalse.
- render(request, position)
Renders the criterion as html in order to displayed it within the management form.
- update(value)
Updates the value of the criterion.
Parameters:
- value
The value the shop user has entered for the criterion.
OrderNumberGenerator
- class lfs.plugins.OrderNumberGenerator
Base class from which all order number generators should inherit.
Attributes:
cart
The current cart of the customer.
customer
The customer of the order.
order
The order for which a new number is generated.
request
The current request
user
The user of the order.
- get_form(**kwargs)
Returns the form which is used within the shop preferences management interface.
All parameters are passed to the form.
- get_next(formatted=True)
Returns the next order number as string. Derived classes must implement this method.
Parameters:
- formatted
If True the number will be returned within the stored format, which is based on Python default string formatting operators, e.g.
%04d.
- exclude_form_fields()
Returns a list of fields, which are excluded from the model form, see also
get_form.
- init(request, order)
Initializes the order number generator. This method is called automatically from LFS.
PaymentMethodProcessor
- class lfs.plugins.PaymentMethodProcessor(request, cart=None, order=None)
Base class from which all 3rd-party payment method processors should inherit.
Attributes:
- cart
The current cart. This is only set, when create order time is ACCEPTED.
- order
The current order. This is only set, when create order time is IMMEDIATELY.
- request
The current request.
- get_create_order_time()
Returns the time when the order should be created. It is one of:
- PM_ORDER_IMMEDIATELY
The order is created immediately before the payment is processed.
- PM_ORDER_ACCEPTED
The order is created when the payment has been processed and accepted.
- get_pay_link()
Returns a link to the payment service to pay the current order, which is displayed on the thank-you page and the order confirmation mail. In this way the customer can pay the order again if something has gone wrong.
- process()
Implements the processing of the payment method. Returns a dictionary with several status codes, see below.
Return Values:
This values are returned within a dictionary.
- accepted (mandatory)
Indicates whether the payment is accepted or not. if this is
Falsethe customer keeps on the checkout page and getsmessage(if given) below. If this isTruethe customer will be redirected to next_url (if given).- message (optional)
This message is displayed on the checkout page, when the order is not accepted.
- message_location (optional)
The location, where the message is displayed.
- next_url (optional)
The url to which the user is redirect after the payment has been processed. if this is not given the customer is redirected to the default thank-you page.
- order_state (optional)
The state in which the order should be set. It’s just PAID. If it’s not given the state keeps in SUBMITTED.
PriceCalculator
- class lfs.plugins.PriceCalculator(request, product, **kwargs)
This is the base class that pricing calculators must inherit from.
Attributes:
- product
The product for which the price is calculated.
- request
The current request.
- get_base_price(with_properties=True)
Returns the base price of the product.
Parameters:
- with_properties
If the instance is a configurable product and with_properties is True the prices of the default properties are added to the price.
- get_base_price_net(with_properties=True)
Returns the net base price of the product.
Parameters:
- with_properties
If the instance is a configurable product and with_properties is True the prices of the default properties are added to the price.
- get_base_price_gross(with_properties=True)
Returns the gross base price of the product.
Parameters:
- with_properties
If the instance is a configurable product and with_properties is True the prices of the default properties are added to the price.
- get_base_packing_price(with_properties=True)
Returns the base packing price of the product.
Parameters:
- with_properties
If the instance is a configurable product and with_properties is True the prices of the default properties are added to the price.
- get_base_packing_price_net(with_properties=True)
Returns the base packing net price of the product.
Parameters:
- with_properties
If the instance is a configurable product and with_properties is True the prices of the default properties are added to the price.
- get_base_packing_price_gross(with_properties=True)
Returns the base packing gross price of the product.
Parameters:
- with_properties
If the instance is a configurable product and with_properties is True the prices of the default properties are added to the price.
- get_customer_tax(with_properties=True)
Returns the calculated tax for the current customer and product.
Parameters:
- with_properties
If the instance is a configurable product and with_properties is True the taxes of the default properties are added to the price.
- get_customer_tax_rate()
Returns the tax rate for the current customer and product.
- get_effective_price()
Effective price is used for sorting and filtering. Usually it is same as value from get_price but in some cases it might differ (eg. if we add eco tax to product price)
- get_for_sale_price(with_properties=True)
Returns the sale price for the product.
Parameters:
- with_properties
If the instance is a configurable product and with_properties is True the prices of the default properties are added to the price.
- get_for_sale_price_net(with_properties=True)
Returns the sale net price for the product.
Parameters:
- with_properties
If the instance is a configurable product and with_properties is True the prices of the default properties are added to the price.
- get_for_sale_price_gross(with_properties=True)
Returns the sale net price for the product.
Parameters:
- with_properties
If the instance is a configurable product and with_properties is True the prices of the default properties are added to the price.
- get_price(with_properties=True)
Returns the stored price of the product without any tax calculations. It takes variants, properties and sale prices into account, though.
Parameters:
- with_properties
If the instance is a configurable product and with_properties is True the prices of the default properties are added to the price.
- get_price_net(with_properties=True)
Returns the net price of the product.
Parameters:
- with_properties
If the instance is a configurable product and with_properties is True the prices of the default properties are added to the price.
- get_price_gross(with_properties=True)
Returns the real gross price of the product. This is the base of all price and tax calculations.
Parameters:
- with_properties
If the instance is a configurable product and with_properties is True the prices of the default properties are added to the price.
- get_standard_price(with_properties=True)
Returns always the stored standard price for the product. Independent whether the product is for sale or not. If you want the real price of the product use
get_priceinstead.Parameters:
- with_properties
If the instance is a configurable product and with_properties is True the prices of the default properties are added to the price.
- get_standard_price_net(with_properties=True)
Returns always the standard net price for the product. Independent whether the product is for sale or not. If you want the real net price of the product use
get_price_netinstead.Parameters:
- with_properties
If the instance is a configurable product and with_properties is True the prices of the default properties are added to the price.
- get_standard_price_gross(with_properties=True)
Returns always the gross standard price for the product. Independent whether the product is for sale or not. If you want the real gross price of the product use
get_price_grossinstead.Parameters:
- with_properties
If the instance is a configurable product and with_properties is True the prices of the default properties are added to the price.
- get_product_tax(with_properties=True)
Returns the calculated tax for the current product independent of the customer.
- get_product_tax_rate()
Returns the stored tax rate of the product. If the product is a variant it returns the parent’s tax rate.
- price_includes_tax()
Returns True if stored price includes tax. False if not.
ShippingMethodPriceCalculator
- class lfs.plugins.ShippingMethodPriceCalculator(request, shipping_method)
Base class from which all 3rd-party shipping method prices should inherit.
Attributes:
- request
The current request.
- shipping_method
The shipping method for which the price is calculated.
- get_price()
Returns the stored price without any calculations.
- get_price_gross()
Returns the gross price of the shipping method.
- get_price_net()
Returns the net price of the shipping method.
- get_tax()
Returns the total tax of the shipping method.
- get_tax_rate()
Returns the tax rate of the shipping method.