An object representing a discount.
Property | Type | Description |
---|---|---|
uid | integer | The unique identifier of the delivery method. |
name | object | Name of the discount, by language. |
active | boolean | If this discount is active and available to use. |
type | string | The type of discount e.g. Freight , BuyXPayY or Percentage . |
Takes a filter object and returns the number of discounts found, as an integer.
A filter object specifying which discounts to count. See Filter objects on the page List selection.
Discount.count({
"/active": true
})
Creates a new discount. This is shorthand for set with the unique identifier null
.
Parameter | Description |
---|---|
patch | An object containing the properties and values to set for the new discount. |
query | A query specifying what to return after article discount has been successful (optional). See Query language. |
Discount.create({
"name": {
"en": "Free shipping"
},
"active": true,
"type": "FreeDelivery"
})
Permanently delete a discount.
Parameter | Description |
---|---|
uid | The unique identifier of a discount. |
Discount.delete(6735)
Fetches information about a customer.
Parameter | Description |
---|---|
uid | The unique identifier of a customer. |
query | Which info to return. See Query language. |
Discount.get(6735, [
"active"
])
Fetches the JSON Schema which can be used for client-side validation.
The unique identifier of a discount or null
for a new instance.
Returns an array of objects representing dicsounts.
Parameter | Description |
---|---|
query | A query object specifying what to fetch from each discount. This is the same as for get. See Query language. |
selection | A list-selection object specifying which discounts to fetch. See List selection. |
Discount.list([
"uid",
"name"
], {
"/active": true
})
Fetches a normalized version of the patch. Uses the same parameters as set and validate. While set also normalizes the patch, before storing, normalize only returns the normalized patch. For all properties with number types, integers or floating-point values in strings are converted to number literals. A normalization error is thrown when we are unable to convert a string to a number literal.
Parameter | Description |
---|---|
uid | The unique identifier of a discount or null to create a new discount. |
patch | An object containing the properties and values to normalize. |
Customer.normalize(null, {
"active": "true"
})
Creates or updates a discount.
Parameter | Description |
---|---|
uid | The unique identifier of a customer or null to create a new customer. |
patch | An object containing the properties and values to set for the customer. |
query | A query specifying what to return after a successful set (optional). See Query language. |
Discount.set(6735, {
"active": false
}, [
"uid",
"active"
])
Validates the data to be set. The performed validation is the same as in set; it validates the resulting object and includes all the required properties. However, nothing is saved.
Parameter | Description |
---|---|
uid | The unique identifier of an existing discount or null . |
patch | An object containing the properties and values to set before validating. |
An array of validation-error objects, each containing the keys pointer
(a property referenced using a JSON Pointer) and message
(a readable text in the language of the context). An empty array is returned if there are no validation errors.