# Discount API Reference
Cart resource object:
{
"type": "discounts",
"id": "(string)",
"attributes": {
"status": "string",
"code": "string",
"description": "string",
"usage_limit": {Integer},
"min_amount": {Float|precision:2},
"min_quantity": {Integer},
"rules": Array,
"starts_at": "string|datetime",
"expires_at": "string|datetime",
"created_at": "string|datetime",
"updated_at": "string|datetime"
}
}
# Writable fields
| Field name | Creating | Updating |
|---|---|---|
| status | string|in:active,inactive | string|in:active,inactive |
| code | required|string|min:1|max:255 | string|min:1|max:255 |
| description | string|max:255 | string|max:255 |
| rules | array | array |
| usage_limit | integer|>= 0 | integer|>= 0 |
| starts_at | string|datetime | string|datetime |
| expires_at | string|datetime | string|datetime |
# Rule format
- 3 rule types available: percentage, fixed-amount, buy-x-get-y.
- Maximum 5 rules / discount.
- Maximum 10 collection ids / discount.
- Maximum 100 product ids / rule data.
- Maximum 100 variant ids / rule data.
Percentage discount rule format:
{
"type": "percentage",
"value": (float),
"allocation_limit": (integer),
"exclude_collection_ids": [
...
],
"exclude_product_ids": [
...
],
"exclude_variant_ids": [
...
],
"entitled_collection_ids": [
...
],
"entitled_product_ids": [
...
],
"entitled_variant_ids": [
...
],
"once_per_customer": (boolean),
"is_free_shipping": (boolean),
"shipping_discount_value": (float,precision:2)
}
Fixed amount discount rule format:
{
"type": "fixed-amount",
"value": (float),
"allocation_limit": (integer),
"exclude_collection_ids": [
...
],
"exclude_product_ids": [
...
],
"exclude_variant_ids": [
...
],
"entitled_collection_ids": [
...
],
"entitled_product_ids": [
...
],
"entitled_variant_ids": [
...
],
"once_per_customer": (boolean),
"is_free_shipping": (boolean),
"shipping_discount_value": (float,precision:2)
}
Buy X get Y discount rule format:
{
"type": "buy-x-get-y",
"value": (float),
"allocation_limit": (integer),
"prerequisite_quantity": (integer),
"entitled_quantity": (integer),
"prerequisite_collection_ids": [
...
],
"prerequisite_product_ids": [
...
],
"prerequisite_variant_ids": [
...
],
"exclude_collection_ids": [
...
],
"exclude_product_ids": [
...
],
"exclude_variant_ids": [
...
],
"entitled_collection_ids": [
...
],
"entitled_product_ids": [
...
],
"entitled_variant_ids": [
...
],
"once_per_customer": (boolean),
"is_free_shipping": (boolean),
"shipping_discount_value": (float,precision:2)
}
# Filters
| Filter name | Detail |
|---|---|
| status | string |
| code | string |
| usage_limit | integer |
| cart_count | integer |
| order_count | integer |
| starts_at | string|datetime |
| expires_at | string|datetime |
# Sortable
| Field name |
|---|
| code |
| cart_count |
| order_count |
| starts_at |
| expires_at |
| created_at |
← Cart Items Orders →