Adding items to a Cart
Adding an item to a Cart is the first step of the Checkout process. You can do this either during Cart creation or through a dedicated API during the checkout process.
Violet recommends adding SKUs during cart creation. This is because any call that changes a cart also makes an underlying call to relevant merchant stores and impacts your rate limits.
Create Cart + Add Item to Cart
In addition to other inputs, the Create Cart endpoint also takes in a list of SKUs along with their quantity as seen below:
If provided, the Cart
created will include these these items. In the example response below, an item was added from The Violet Garden
, one of the stores we have available in sandbox to place orders against.
Add Item to Cart
The Add SKU to Cart API lets you add items to a cart at any point up until a Cart
has been submitted.
In this scenario, only one SKU can be added at a time. A sample body can be seen below:
The response for this call will be similar to the one above.
When adding a Sku
to a cart, a line item entity called an OrderSku
is created. When making modifications to a line item in a cart, you will be interacting with the OrderSku
, which has a different id
to the original Sku
. You can find the id
of the original Sku
in the sku_id
property of the OrderSku
.
Custom Properties
Custom properties, also commonly referred to as “metadata”, can be applied to any new line item or existing line in in a cart.
- Any endpoint that allows for the addition or modification of an
OrderSku
will accept a list of one or more custom properties. - Custom properties can be removed from an
OrderSku
by setting the value ofcustom_properties
tonull
or[]
.
Custom properties have the following structure.
The following example shows how custom properties can be applied to a new OrderSku
while it’s being added to a cart.
POST /v1/checkout/cart/{cart_id}/skus
Some commerce platforms do not support the concept of custom properties on a line item. For these platforms, the data will persist on the Violet OrderSku, but will not be forwarded to the commerce platform. Because these platforms do not support custom properties, there will be no merchants on these platforms with requirements for custom properties. These platforms currently include BIGCOMMERCE
, WIX
, and DEMANDWARE
(also known as Salesforce Commerce Cloud).
Was this page helpful?