Voucher
Oscar ships with broad support for vouchers, which are handled by this app.
Abstract models
-
class
oscar.apps.voucher.abstract_models.
AbstractVoucher
(*args, **kwargs)[source]
A voucher. This is simply a link to a collection of offers.
Note that there are three possible “usage” modes:
(a) Single use
(b) Multi-use
(c) Once per customer
Oscar enforces those modes by creating VoucherApplication
instances when a voucher is used for an order.
-
benefit
Returns the first offer’s benefit instance.
A voucher is commonly only linked to one offer. In that case,
this helper can be used for convenience.
-
is_active
(test_datetime=None)[source]
Test whether this voucher is currently active.
-
is_available_to_user
(user=None)[source]
Test whether this voucher is available to the passed user.
Returns a tuple of a boolean for whether it is successful, and a
availability message.
-
is_expired
()[source]
Test whether this voucher has passed its expiration date
-
record_discount
(discount)[source]
Record a discount that this offer has given
-
record_usage
(order, user)[source]
Records a usage of this voucher in an order.
-
class
oscar.apps.voucher.abstract_models.
AbstractVoucherApplication
(*args, **kwargs)[source]
For tracking how often a voucher has been used in an order.
This is used to enforce the voucher usage mode in
Voucher.is_available_to_user, and created in Voucher.record_usage.