Order Line
AddOrUpdateOrderLine
This method has multiple use cases, but common for all is that its updating the customer's current order. The most simple scenario is adding an order line. The other uses are updating the quantity of an existing order line, add unique order lines, add bundled products etc.
Arguments
Name | Type | Description |
storeId | long | Id of the store. |
productIdentifier | string? | A unique identifier of the product. E.g. the node id from Umbraco. |
orderLineId | long? | Id of the order line. |
quantity | decimal? | The quantity of the order line. Default behavior will add the quantity to the existing order line's quantity. This can be changed using the overwriteQuantity parameter. |
properties | | A list of key/value pairs identifying the property alias and name of a html input to deliver the value. |
overwriteQuantity | bool? | If true - the parameter will overwrite the current quantity of the order line. |
bundleIdentifier | string? | Use to be able to create product bundles. This identifier is used when adding sub order lines to this order line. |
parentBundleIdentifier | string? | The bundleIdentifier of the order line you want to add this product to. |
Example - Add order line - 1
Adding an order line in its most simple form.
Example - Add order line - 2
The example extends the first example by adding custom properties to the added order line. These properties can be any key/value pair that you desire. The properties can be updated after the order line has been added by submitting new values.
Example - Overwrite quantity
This example shows how to overwrite the quantity for an existing order line.
Example - Product bundle
This example demonstrates how to add product bundles. A computer is added as the main product bundle item. Another product - it could be a RAM module - is added, specifying the computer as its bundle parent.
Arguments
Name | Type | Default | Description |
productIdentifier | string? | | A unique identifier of the product. E.g. the node id from Umbraco. |
orderLineId | long? | | Id of the order line. |
quantity | decimal? | | The quantity of the order line. Default behavior will add the quantity to the existing order line's quantity. This can be changed using the overwriteQuantity parameter. |
properties | property object? | | A property object containing keys and values of the properties to be added. |
overwriteQuantity | boolean | false | If true - the parameter will overwrite the current quantity of the order line. |
bundleIdentifier | string? | | Use to be able to create product bundles. This identifier is used when adding sub order lines to this order line. |
parentBundleIdentifier | string? | | The bundleIdentifier of the order line you want to add this product to. |
storeId | long | _storeId | Id of the store. |
async | boolean | true | Specifies if a request should be asynchronously. |
successfn | function(json[, jQForm]) | | A function to be called if the request succeeds. |
errorfn | function(json) | | A function to be called if the request fails. |
Return values
Type | Description |
methodsCalled | An object containing information about the methods called, related data to the methods and the order object if present.
Will only be returned if you use async = false |
Example - Add order line - 1
Adding an order line in its most simple form.
Example - Add order line - 2
The example extends the first example by adding custom properties to the added order line. These properties can be any key/value pair that you desire. The properties can be updated after the order line has been added by submitting new values.
Example - Overwrite quantity
This example shows how to overwrite the quantity for an existing order line.
Example - Product bundle
This example demonstrates how to add product bundles. A computer is added as the main product bundle item. Another product - it could be a RAM module - is added, specifying the computer as its bundle parent.
Arguments
Name | Type | Description |
storeId | long | Id of the store. |
productIdentifier | string | A unique identifier of the product. E.g. the node id from Umbraco. |
quantity | decimal? | The quantity of the order line. Default behavior will add the quantity to the existing order line's quantity. This can be changed using the overwriteQuantity parameter. |
properties | Dictionary<string, string> | A dictionary containing the property aliases and their values. |
overwriteQuantity | bool? | If true - the parameter will overwrite the current quantity of the order line. |
bundleIdentifier | string? | Use to be able to create product bundles. This identifier is used when adding sub order lines to this order line. |
parentBundleIdentifier | string? | The bundleIdentifier of the order line you want to add this product to. |
Return values
Type | Description |
OrderLine | The order line just created or updated. |
Example - Add order line - 1
Adding an order line in its most simple form.
Example - Add order line - 2
The example extends the first example by adding custom properties to the added order line. These properties can be any key/value pair that you desire. The properties can be updated after the order line has been added by submitting new values.
Example - Overwrite quantity
This example shows how to overwrite the quantity for an existing order line.
Example - Product bundle
This example demonstrates how to add product bundles. A computer is added as the main product bundle item. Another product - it could be a RAM module - is added, specifying the computer as its bundle parent.
UpdateOrderLine
Updates a single order line on the current order. If the customer does not have a current order a new one will be created.
Arguments
Name | Type | Description |
storeId | long | Id of the store. |
orderLineId | long | If of the order line. |
quantity | decimal? | The quantity of the order line. Default behavior will add the quantity to the existing order line's quantity. This can be changed using the overwriteQuantity parameter. |
properties | Dictionary<string, string>? | A dictionary containing the property aliases and their values. |
overwriteQuantity | bool? | If true - the parameter will overwrite the current quantity of the order line. |
Return values
Type | Description |
OrderLine | The order line updated. |
Example
RemoveOrderLine
Removes a single order line from the customer's current order.
Arguments
Name | Type | Description |
storeId | long | Id of the store. |
orderLineId | long | Id of the order line. |
Example
Arguments
Name | Type | Default | Description |
orderLineId | long | | Id of the order line. |
storeId | long | _storeId | Id of the store. |
async | boolean | true | Specifies if a request should be asynchronously. |
successfn | function(json[, jQForm]) | | A function to be called if the request succeeds. |
errorfn | function(json) | | A function to be called if the request fails. |
Return values
Type | Description |
methodsCalled | An object containing information about the methods called, related data to the methods and the order object if present.
Will only be returned if you use async = false |
Example
Arguments
Name | Type | Description |
storeId | long | Id of the store. |
orderLineId | long | Id of the order line. |
Return values
Type | Description |
OrderLine | The removed order line. |
Example
RemoveAllOrderLines
Removes all order lines from the customer's current order.
Arguments
Name | Type | Description |
storeId | long | Id of the store. |
Example
Arguments
Name | Type | Default | Description |
storeId | long | _storeId | Id of the store. |
async | boolean | true | Specifies if a request should be asynchronously. |
successfn | function(json[, jQForm]) | | A function to be called if the request succeeds. |
errorfn | function(json) | | A function to be called if the request fails. |
Return values
Type | Description |
methodsCalled | An object containing information about the methods called, related data to the methods and the order object if present.
Will only be returned if you use async = false |
Example
Arguments
Name | Type | Description |
storeId | long | Id of the store. |
Return values
Type | Description |
IEnumerable<OrderLine> | A collection of all removed order lines. |
Example
Automatic Properties
When adding an item to an order, you can provide extra information to add to an OrderLine by passing a properties
collection through to either of the AddOrUpdateOrderLine
or UpdateOrderLine
methods documented above.
However, you can also configure Tea Commerce to automatically copy across certain product information for you automatically. This can be useful if you have information you constantly want to display next to an OrderLine item but don't want to have to perform a node lookup every time.
To automatically copy node fields to an OrderLine, these can be configured by entering a comma separated list of property aliases into the Product property aliases field found on the Store editor, under the Product tab.
Product Uniqueness Properties
When adding an item to an Order, you may want to allow different configurations of the same product to be added to an order as distinct order lines rather than having them all seen as the same order line. To achieve this you can configure which properties of a product node should be used to identify the "uniqueness" of a product. These can be configured by entering a comma separated list of property aliases into the Product uniqueness property aliases field found on the Store editor, under the Product tab.
With this field populated, when an item is added to an order, Tea Commerce will check the value of the product nodes uniqueness properties and create distinct order lines for each unique combination.
System Properties
When adding an item to an order, as well as the properties passed via the AddOrUpdateOrderLine
or UpdateOrderLine
methods properties
collection as documented above, Tea Commerce will also add some system defined properties to the OrderLine who's values will be automatically extracted from the product node. In order for these properties to work, you must have fields on your product node with the documented property aliases defined below.
Name | Property Alias | Description |
SKU | sku | A product SKU code. |
NB These fields are extracted via a Product Information Extractor, if you need to extract these fields from alternative sources, you can do so by overriding the default Product Information Extractor with your own.
Last Updated: 2/6/2019, 8:40:54 AM