OrderItem

An object representing a row in an Order. Order items are not created with this API; they are always created by Order.addArticle.

Properties

Property Decription
article The unique identifier of an article.
articleNumber An optional identifier of the article modifiable by an adminstrator. May contain letters, hyphens, numbers and other characters.
articleName The article name the in language the order was place in
choices The ArticleChoices that were made when ordering the article, e.g. {"1324567": "789456123", "quantity": 2}.
costs The cost details of the order item. See Costs below.
discountInfo The discount details of the order item, if any. See discountInfo below.
download The download URL of the order item, if any.
order The order number associated with the order item.
revenueShare Revenue-share details of the order item, if any. See revenueShare below.
uid The unique identifier of the order item.

costs

These are the properties for the costs object:

Property Description
total The total amount of the order item influenced by, e.g., the quantity added to cart. See the example below.
unit The unit cost of the order item.

In turn, the above objects have the following properties:

Property Description
currency The currency of the order item.
exVat The amount excluding value-added tax.
incVat The amount including value-added tax.
vat Value-added tax of the order item.
vatRate Value-added tax rate of the order item as a decimal number, e.g. 0.12 for 12%.

delete

Deletes an order item.

Parameters

The unique identifier of the order item.

Errors

Code Message Description
1006 Forbidden The request is forbidden. This may be because you don't have the required permissions.

Returns

If the request is successful, then an empty response (null) is returned.

Example

API Console
OrderItem.delete(123456)
Response
null

discountInfo

These are the properties for the discountInfo object:

Property Description
discount The unique identifier of the discount.
exVat The discount amount excluding value-added tax.
incVat The discount amount including value-added tax.
name Name of the discount, e.g. "Students and teachers".
rate The discount rate of the order item as a decimal number, e.g. 0.2 for 20%.
vat Value-added tax of the discount.
vatRate Value-added tax rate of the discount as a decimal number, e.g. 0.12 for 12%.

revenueShare

These are the properties for the revenueShare object:

Property Description
exVat The revenue-share amount excluding value-added tax.
incVat The revenue-share amount including value-added tax.
suborder The unique identifier of the sub order, if any.
supplier The unique identifier of the supplier, if any.
vat Value-added tax of the revenue share.
vatRate Value-added tax rate of the revenue share as a decimal number, e.g. 0.12 for 12%.

Methods

get

Parameters

Parameter Description
uid The unique identifier of an order item.
query Which info to return. See Query language.

Example

API Console
OrderItem.get(999999)
Response
{
  "uid": 23456,
  "article": 1234,
  "articleNumber": "999",
  "choices": {
    "1324567": "789456123",
    "quantity": 2
  },
  "costs": {
    "total": {
      "exVat":   160,
      "incVat":  200,
      "vatRate": 0.25,
      "vat":     40
    },
    "unit": {
      "currency": "SEK",
      "exVat":   80,
      "incVat":  100,
      "vatRate": 0.25,
      "vat":     20
    }
  }
}

getSchema

Fetches the JSON Schema which can be used for client-side validation.

Parameters

The unique identifier of an order item.

set

Creates or updates an order item. At present, the only property that can be set is choices/quantity.

Parameters

Parameter Description
uid The unique identifier of an article or null to create a new order item.
patch An object containing the properties and values to set for the order item.
query A query specifying what to return after a successful set (optional).

Returns

If the request is successful, then either the unique identifier of the order item is returned or what had been specified in the query.

Errors

Code Message Description
-32003 Bad call The request is formally correct but the operation can still not be performed.
1006 Forbidden The request is forbidden. This may be because you don't have the required permissions.
9001 Validation error The parameters contents failed JSON-Schema validation. The data is an array of objects with the properies message (readable text) and pointer (a JSON Poiter to the property where the validation failed).

Example

The request below sets quantity to 3 for the order item 999999 and returns the choices and unique identifiers of the order item as well as the unique identifier of the order.

API Console
OrderItem.set(999999, {"choices": {"quantity": 3}}, ["choices", "order", "uid"])
Response
{
  "choices": {
    "quantity": 3,
    "1324567": "789456123"
  },
  "order": "456456",
  "uid": 23456
}