Update a discount
Updates a discount; fields not supplied keep their current values. Buy-X-get-Y and tiered-quantity discounts are validated for their required settings. The response is the bare object, without the standard {status, message, data} envelope.
How to use it
- Take the discount id from List discounts.
- Send name, discountType and rate, plus the type's settings (buy/get quantities for type 3, tierMinQuantity for type 4).
- Send status too: if it is omitted the discount is saved as active. Other omitted optional fields keep their current values.
BearerAuthAuthorizationBearer <JWT>id*integerID of the record.
int64application/json- body
id*integerUnique ID of the discount. Set by the server; use it as discountId on items.
int64name*stringDiscount name, up to 100 characters. Required and unique for the merchant.
discountType*integerKind of discount: 1 = fixed amount, 2 = percentage, 3 = buy X get Y, 4 = tiered quantity. Any other value is rejected.
int32rate*numberDiscount value: an amount in the merchant's currency for type 1, a percentage for type 2; for type 4 it applies once the tier quantity is reached.
modifiedTime*stringWhen the discount was last saved. Set by the server.
date-timestatus*stringStatus text, for example active (the default when omitted).
buyQuantity?|Buy X get Y only (type 3): number of units the customer must buy. Required and greater than zero for that type.
int32getQuantity?|Buy X get Y only (type 3): number of units that then get the discount. Required and greater than zero for that type.
int32getDiscountPercent?|Buy X get Y only (type 3): discount on the get units, above 0 and up to 100 (100 = free).
tierMinQuantity?|Tiered quantity only (type 4): line quantity at which rate starts to apply. Required and greater than zero for that type.
int32OK
*/*- response
id*integerUnique ID of the discount. Set by the server; use it as discountId on items.
int64name*stringDiscount name, up to 100 characters. Required and unique for the merchant.
discountType*integerKind of discount: 1 = fixed amount, 2 = percentage, 3 = buy X get Y, 4 = tiered quantity. Any other value is rejected.
int32rate*numberDiscount value: an amount in the merchant's currency for type 1, a percentage for type 2; for type 4 it applies once the tier quantity is reached.
modifiedTime*stringWhen the discount was last saved. Set by the server.
date-timestatus*stringStatus text, for example active (the default when omitted).
buyQuantity?|Buy X get Y only (type 3): number of units the customer must buy. Required and greater than zero for that type.
int32getQuantity?|Buy X get Y only (type 3): number of units that then get the discount. Required and greater than zero for that type.
int32getDiscountPercent?|Buy X get Y only (type 3): discount on the get units, above 0 and up to 100 (100 = free).
tierMinQuantity?|Tiered quantity only (type 4): line quantity at which rate starts to apply. Required and greater than zero for that type.
int32curl -X PUT 'https://beta.iotoms.com/api/v1/catalog/attributes/discounts/0' \ -H 'Content-Type: application/json' \ -d '{ "id": 0, "name": "string", "discountType": 0, "rate": 0, "modifiedTime": "2019-08-24T14:15:22Z", "status": "string"}'{ "id": 0, "name": "string", "discountType": 0, "rate": 0, "modifiedTime": "2019-08-24T14:15:22Z", "status": "string", "buyQuantity": 0, "getQuantity": 0, "getDiscountPercent": 0, "tierMinQuantity": 0}