Discounts¶
Resource description¶
Discounts provide a way to automatically reduce the price of a cart if it matches a given set of conditions. Discounts are available to everyone. If you want to give a discount just to specific persons, look at vouchers instead. If you are interested in the behind-the-scenes details of how discounts are calculated for a specific order, have a look at our algorithm documentation.
Field |
Type |
Description |
|---|---|---|
id |
integer |
Internal ID of the discount rule |
active |
boolean |
The discount will be ignored if this is |
internal_name |
string |
A name for the rule used in the backend |
position |
integer |
An integer, used for sorting the rules which are applied in order |
all_sales_channels |
boolean |
If |
limit_sales_channels |
list of strings |
List of sales channel identifiers the discount is available on
if |
sales_channels |
list of strings |
DEPRECATED. Legacy interface, use |
available_from |
datetime |
The first date time at which this discount can be applied
(or |
available_until |
datetime |
The last date time at which this discount can be applied
(or |
subevent_mode |
strings |
Determines how the discount is handled when used in an
event series. Can be |
subevent_date_from |
datetime |
The first date time of a subevent to which this discount can be applied
(or |
subevent_date_until |
datetime |
The last date time of a subevent to which this discount can be applied
(or |
condition_all_products |
boolean |
If |
condition_limit_products |
list of integers |
If |
condition_apply_to_addons |
boolean |
If |
condition_ignore_voucher_discounted |
boolean |
If |
condition_min_count |
integer |
The minimum number of matching products for the discount to be activated. |
condition_min_value |
money (string) |
The minimum value of matching products for the discount
to be activated. Cannot be combined with |
benefit_discount_matching_percent |
decimal (string) |
The percentage of price reduction for matching products. |
benefit_only_apply_to_cheapest_n_matches |
integer |
If set higher than 0, the discount will only be applied to
the cheapest matches. Useful for a “3 for 2”-style discount.
Cannot be combined with |
benefit_same_products |
boolean |
If |
benefit_limit_products |
list of integers |
If |
benefit_apply_to_addons |
boolean |
(Only used if |
benefit_ignore_voucher_discounted |
boolean |
(Only used if |
Endpoints¶
- GET /api/v1/organizers/(organizer)/events/(event)/discounts/¶
Returns a list of all discounts within a given event.
Example request:
GET /api/v1/organizers/bigevents/events/sampleconf/discounts/ HTTP/1.1 Host: pretix.eu Accept: application/json, text/javascript
Example response:
HTTP/1.1 200 OK Vary: Accept Content-Type: application/json { "count": 1, "next": null, "previous": null, "results": [ { "id": 1, "active": true, "internal_name": "3 for 2", "position": 1, "all_sales_channels": false, "limit_sales_channels": ["web"], "sales_channels": ["web"], "available_from": null, "available_until": null, "subevent_mode": "mixed", "subevent_date_from": null, "subevent_date_until": null, "condition_all_products": true, "condition_limit_products": [], "condition_apply_to_addons": true, "condition_ignore_voucher_discounted": false, "condition_min_count": 3, "condition_min_value": "0.00", "benefit_same_products": true, "benefit_limit_products": [], "benefit_apply_to_addons": true, "benefit_ignore_voucher_discounted": false, "benefit_discount_matching_percent": "100.00", "benefit_only_apply_to_cheapest_n_matches": 1 } ] }
- Query Parameters:
page (integer) – The page number in case of a multi-page result set, default is 1
active (boolean) – If set to
trueorfalse, only discounts with this value for the fieldactivewill be returned.ordering (string) – Manually set the ordering of results. Valid fields to be used are
idandposition. Default:position
- Parameters:
organizer – The
slugfield of the organizer to fetchevent – The
slugfield of the event to fetch
- Status Codes:
200 OK – no error
401 Unauthorized – Authentication failure
403 Forbidden – The requested organizer/event does not exist or you have no permission to view this resource.
- GET /api/v1/organizers/(organizer)/events/(event)/discounts/(id)/¶
Returns information on one discount, identified by its ID.
Example request:
GET /api/v1/organizers/bigevents/events/sampleconf/discounts/1/ HTTP/1.1 Host: pretix.eu Accept: application/json, text/javascript
Example response:
HTTP/1.1 200 OK Vary: Accept Content-Type: application/json { "id": 1, "active": true, "internal_name": "3 for 2", "position": 1, "all_sales_channels": false, "limit_sales_channels": ["web"], "sales_channels": ["web"], "available_from": null, "available_until": null, "subevent_mode": "mixed", "subevent_date_from": null, "subevent_date_until": null, "condition_all_products": true, "condition_limit_products": [], "condition_apply_to_addons": true, "condition_ignore_voucher_discounted": false, "condition_min_count": 3, "condition_min_value": "0.00", "benefit_same_products": true, "benefit_limit_products": [], "benefit_apply_to_addons": true, "benefit_ignore_voucher_discounted": false, "benefit_discount_matching_percent": "100.00", "benefit_only_apply_to_cheapest_n_matches": 1 }
- Parameters:
organizer – The
slugfield of the organizer to fetchevent – The
slugfield of the event to fetchid – The
idfield of the discount to fetch
- Status Codes:
200 OK – no error
401 Unauthorized – Authentication failure
403 Forbidden – The requested organizer/event does not exist or you have no permission to view this resource.
- POST /api/v1/organizers/(organizer)/events/(event)/discounts/¶
Creates a new discount
Example request:
POST /api/v1/organizers/bigevents/events/sampleconf/discounts/ HTTP/1.1 Host: pretix.eu Accept: application/json, text/javascript Content-Type: application/json { "active": true, "internal_name": "3 for 2", "position": 1, "all_sales_channels": false, "limit_sales_channels": ["web"], "sales_channels": ["web"], "available_from": null, "available_until": null, "subevent_mode": "mixed", "subevent_date_from": null, "subevent_date_until": null, "condition_all_products": true, "condition_limit_products": [], "condition_apply_to_addons": true, "condition_ignore_voucher_discounted": false, "condition_min_count": 3, "condition_min_value": "0.00", "benefit_same_products": true, "benefit_limit_products": [], "benefit_apply_to_addons": true, "benefit_ignore_voucher_discounted": false, "benefit_discount_matching_percent": "100.00", "benefit_only_apply_to_cheapest_n_matches": 1 }
Example response:
HTTP/1.1 201 Created Vary: Accept Content-Type: application/json { "id": 1, "active": true, "internal_name": "3 for 2", "position": 1, "all_sales_channels": false, "limit_sales_channels": ["web"], "sales_channels": ["web"], "available_from": null, "available_until": null, "subevent_mode": "mixed", "subevent_date_from": null, "subevent_date_until": null, "condition_all_products": true, "condition_limit_products": [], "condition_apply_to_addons": true, "condition_ignore_voucher_discounted": false, "condition_min_count": 3, "condition_min_value": "0.00", "benefit_same_products": true, "benefit_limit_products": [], "benefit_apply_to_addons": true, "benefit_ignore_voucher_discounted": false, "benefit_discount_matching_percent": "100.00", "benefit_only_apply_to_cheapest_n_matches": 1 }
- Parameters:
organizer – The
slugfield of the organizer of the event to create a discount forevent – The
slugfield of the event to create a discount for
- Status Codes:
201 Created – no error
400 Bad Request – The discount could not be created due to invalid submitted data.
401 Unauthorized – Authentication failure
403 Forbidden – The requested organizer/event does not exist or you have no permission to create this resource.
- PATCH /api/v1/organizers/(organizer)/events/(event)/discounts/(id)/¶
Update a discount. You can also use
PUTinstead ofPATCH. WithPUT, you have to provide all fields of the resource, other fields will be reset to default. WithPATCH, you only need to provide the fields that you want to change.You can change all fields of the resource except the
idfield.Example request:
PATCH /api/v1/organizers/bigevents/events/sampleconf/discounts/1/ HTTP/1.1 Host: pretix.eu Accept: application/json, text/javascript Content-Type: application/json Content-Length: 94 { "active": false }
Example response:
HTTP/1.1 200 OK Vary: Accept Content-Type: application/json { "id": 1, "active": false, "internal_name": "3 for 2", "position": 1, "all_sales_channels": false, "limit_sales_channels": ["web"], "sales_channels": ["web"], "available_from": null, "available_until": null, "subevent_mode": "mixed", "subevent_date_from": null, "subevent_date_until": null, "condition_all_products": true, "condition_limit_products": [], "condition_apply_to_addons": true, "condition_ignore_voucher_discounted": false, "condition_min_count": 3, "condition_min_value": "0.00", "benefit_same_products": true, "benefit_limit_products": [], "benefit_apply_to_addons": true, "benefit_ignore_voucher_discounted": false, "benefit_discount_matching_percent": "100.00", "benefit_only_apply_to_cheapest_n_matches": 1 }
- Parameters:
organizer – The
slugfield of the organizer to modifyevent – The
slugfield of the event to modifyid – The
idfield of the discount to modify
- Status Codes:
200 OK – no error
400 Bad Request – The discount could not be modified due to invalid submitted data
401 Unauthorized – Authentication failure
403 Forbidden – The requested organizer/event does not exist or you have no permission to change this resource.
- DELETE /api/v1/organizers/(organizer)/events/(event)/discount/(id)/¶
Delete a discount.
Example request:
DELETE /api/v1/organizers/bigevents/events/sampleconf/discount/1/ HTTP/1.1 Host: pretix.eu Accept: application/json, text/javascript
Example response:
HTTP/1.1 204 No Content Vary: Accept
- Parameters:
organizer – The
slugfield of the organizer to modifyevent – The
slugfield of the event to modifyid – The
idfield of the discount to delete
- Status Codes:
204 No Content – no error
401 Unauthorized – Authentication failure
403 Forbidden – The requested organizer/event does not exist or you have no permission to delete this resource.