Order discount
POST /order-discount
Applies a discount to an order. The discount can be applied to the whole order, to specific order items, or to both.
You can either send the discount amount directly or send the ID of a discount defined in Adisyo. When a defined discount is used, the amount is calculated by Adisyo. See Discount list for the available defined discounts.
Where the discount is applied
The discountId, discountAmount and discountRate fields at the root of the request apply to the whole order.
The fields inside the orderDetails list apply to the corresponding order item.
Whichever side is not sent is preserved: sending only orderDetails keeps the order's existing general discount, and sending only the root fields keeps the existing item discounts.
Sample request
Discount on the whole order
curl -X POST 'https://ext.adisyo.com/api/External/v2/order-discount' \
--header "x-api-key: ..." \
--header "x-api-secret: ..." \
--header "x-api-consumer: ..." \
--header 'Content-Type: application/json' \
--data '{
"orderId": 4815162342,
"discountAmount": 50
}'Using a defined discount
curl -X POST 'https://ext.adisyo.com/api/External/v2/order-discount' \
--header "x-api-key: ..." \
--header "x-api-secret: ..." \
--header "x-api-consumer: ..." \
--header 'Content-Type: application/json' \
--data '{
"orderId": 4815162342,
"discountId": 34
}'Per-item discount
curl -X POST 'https://ext.adisyo.com/api/External/v2/order-discount' \
--header "x-api-key: ..." \
--header "x-api-secret: ..." \
--header "x-api-consumer: ..." \
--header 'Content-Type: application/json' \
--data '{
"orderId": 4815162342,
"orderDetails": [
{ "orderDetailId": 671962, "discountId": 77 },
{ "orderDetailId": 671963, "discountAmount": 25 }
]
}'Request parameters
| Parameter | Data Type | Description |
|---|---|---|
orderId | Number | Adisyo ID of the order the discount is applied to |
discountId | Number? | ID of the defined discount applied to the whole order. When sent, the amount/rate is taken from the definition |
discountAmount | Decimal? | Discount amount applied to the whole order |
discountRate | Decimal? | Discount rate applied to the whole order (0-100) |
orderDetails | Array? | Per-item discounts |
orderDetails parameters
| Parameter | Data Type | Description |
|---|---|---|
orderDetailId | Number | Adisyo ID of the order item. Taken from the products[].id field of the Order details response |
discountId | Number? | ID of the defined discount applied to the item |
discountAmount | Decimal? | Discount amount applied to the item |
discountRate | Decimal? | Discount rate applied to the item (0-100) |
Rules
- The request must contain at least one discount: either for the whole order or for at least one item.
- When
discountIdis sent together withdiscountAmountordiscountRate,discountIdtakes precedence and the others are ignored. - When
discountIdis not sent,discountAmountanddiscountRatecannot be sent at the same time. - The same
orderDetailIdcannot appear more than once in the list. - An item discount cannot exceed the item total.
- The total discount (item discounts + order discount) cannot exceed the order total.
Sample response
Discount applied response
{
"status": 100,
"message": "Discount applied successfully."
}