Orders
Order Object
Not that you need the concept of an Order explained to you, but we're going to do it anyway. It is what is made when a User picks a bunch of things, or just one, that they want to buy.
The total_amount
is set by the items
and the resources
. See sections below for more details.
An order can include only one currency, which means you can not create an order containing two products with two different currencies. Otherwise, you will get the following error:
Error code 400, message: An order can not have products with different currencies
Attributes | Type | Description |
|
| The currency will be define by the Item(s). 3 letter ISO currency code as defined by ISO 4217. |
|
|
|
|
|
|
|
| See |
|
| Expected arrival time for delivery, |
|
| Expected arrival time for pickup, |
|
| See |
|
| List of |
|
| Human readable ID that identifies the order easily, e.g. |
|
| List of |
|
| The |
|
| Amount with two decimals. e.g., 12.34. The amount is automatically calculated based on the items in the order. |
|
| Total number of products in an order, e.g. 3 spoons and 2 forks = 5 products. |
|
| Number of product 'types' in an order, e.g. 3 spoons and 2 forks = 2 product units. |
|
| An accounting reference ID. |
|
| Associated |
|
| User associated with order (current user if order is created by a non-admin). |
|
| A note of the order. |
|
| See |
Total Amount Calculation
How we calculate the total_amount
is a little complicated due to the flexibility of our products' (and sub products') prices and discounts. However, we keep it simple for you. Just usesum(items.final_price)
to calculate total_amount
.
An item
is a product and any sub_products that are included with that product. When you get the final_price
for that item,
this is the equation:(item.price + sum(sub_products.price)) * (1 - item.discount) * item.quantity
To show you an example of an order that includes a product and a product along with its sub product, consider the following:
If we make an order for two Product As with a 10% discount and one Product B with Sub Product B1:
The total_amount
will be: 87 EUR
Product A's final price:
40 * (1 - 0.1) * 2 = 72
Product B's (with sub product B1) final price:
(10 + 5) * (1 - 0.0) * 1 = 15
Order Total Amount:
72 + 15 = 87
Order Items
Changes since API version 2019-02-01
2020-03-13 - New attribute `reserved_price`
Since we implemented a new Payment type, Reserved Payment
, we introduced this new attribute. It is used to calculate the amount of a Reserved Payment
when it is in an Order
.
We are deprecating the old image_url
and replacing it with Image
Object
The attribute items
in the Order Object is where you put the products
your user wants to buy. These items are stored in an array. Each item has the below attributes. See Updating Items in an Order for more details on how this is used.
All the followings attributes are not editable: name
, price
, final_price
, discount
, vat
, currency
.
The goal of these attributes it's to take a snapshot the product
at the moment the order
is created.
Updating a product later will not affect the orders containing it.
Attributes | Type | Description |
|
| A |
|
| The quantity of the product. |
|
| An array of sub-product ID’s associated in the order. |
|
| The |
|
| The |
|
| The |
|
| Calculated value: |
|
| The |
|
| The |
|
| The |
Percentages are calculated on your behalf when creating an Order Item through the Dashboard.
Order Arguments and Statuses
The table below shows possible values for the attributes date_filter
, order_status
, and delivery_status
used in the Order Object and various order methods.
Possible Values | Description |
| Shows orders by date of creation |
| Shows orders by delivery time |
User Role
Create an Order
Body Parameters | Type | Description |
|
|
|
|
| List of |
|
| Associated |
|
|
|
|
|
|
|
| See |
|
| Expected arrival time for delivery, |
|
| Expected arrival time for pickup, |
|
| Note field. |
|
| The |
|
| A |
Either theitems
or the subscription
parameter should be included in the request.
Update an Order*
Path Parameter | Type | Description |
|
| ID of the queried order. |
Body Parameters | Type | Description |
|
| An array of |
Important: Updating the list of items
overwrites the current list instead of adding additional items
to it.
Retrieve an Order*
Path Parameter | Type | Description |
|
| ID of the queried order. |
List all Orders*
Retrieves a list of all Orders associated with the current user (or all users if called from an Admin Role). It is also possible to filter the search using pagination.
Query Parameters | Type | Description |
|
| Start date, |
|
| End date, |
|
| Date field used to filter results. Default is |
|
| Number of items to retrieve. Default is 10. |
|
| Which page to retrieve. Default is 0. |
|
| Return orders with a specific |
|
| Return orders with a specific |
|
| Field used for sorting results. |
Search Orders*
Retrieves a list of all Orders associated with the search parameters for the current user. It is possible to search for _id
or human_id
associated with the current user's orders.
Query Parameters | Type | Description |
|
| The search query. One of human_id, user name or id |
|
| Start date, |
|
| End date, |
|
| Date field used to filter results. Default is |
|
| Number of items to retrieve. Default is 10. |
|
| Which page to retrieve. Default is 0. |
|
| Return orders with a specific |
|
| Return orders with a specific |
|
| Field used for sorting results. |
Cancel an Order*
Orders that haven't been completed or delivered can be cancelled.
Path Parameter | Type | Description |
|
| ID of the queried order. |
Admin Role
*Paths listed above and denoted with a star are accessible to both Users and Admins. Additional Admin Role paths are listed below.
Create an Order
In order to create a new Standard Order or Recurring Order as an Admin you must specify the User. This means that user
is required field.
Body Parameters | Type | Description |
|
| ID of the User associated with the order. |
|
|
|
|
| Address used for billing purposes |
|
|
|
|
| See delivery statuses. Default is |
|
| Expected arrival time for delivery, |
|
| Expected arrival time for pickup, |
|
| List of Items associated with an order. |
|
| Note field. |
|
| The Resources in the order. |
|
| Associated Subscription referenced by a Subscription ID |
|
| A |
Update Items in an Order*
Path Parameter | Type | Description |
|
| ID of the queried order. |
Body Parameters | Type | Description |
|
| ID of the User associated with the order. |
|
| List of |
Last updated