Documentation
Feedback
Guides
API Reference

Guides
CheckoutShopping Cart
Add a service (offering) to a shopping cart

A service, also known as an offering, is an item that may come with a product, optionally and with an additional cost. It is used to assign a value of an additional service to an SKU, as a gift packaging.

You can add a service to a shopping cart by using the Checkout API. To do so, follow the sections below.

Checking if a cart product has a service attached to it

First, you must check if a product has a service available attached to it. This way, you know the options of service you can add to the item in the shopping cart.

You must use the Cart simulation endpoint and send the skuId, seller and quantity in the request body, as the code example below.


_10
{ "items": [
_10
{
_10
"id": "30",
_10
"quantity": 1,
_10
"seller": "1"
_10
}
_10
]
_10
}

In the response body, you must check if the offerings object presents the following information, as in the example below:


_10
"offerings": [
_10
{
_10
"type": "Removal of additional old appliance",
_10
"id": "1",
_10
"name": "Removal of additional old appliance",
_10
"allowGiftMessage": false,
_10
"attachmentOfferings": ["Name", "Info"],
_10
"price": 2999
_10
}
_10
]

If the offerings array presents this information, the SKU has a service associated with it. You will use the id value in the next step.

If you have multiple services associated with the product, all of them will be returned in the offerings array.

Adding a service to a product

You can add a service to an item in the shopping cart by using the checkout orderForm.

To do so, you must add the item to the cart using the Add cart items endpoint.

Then, you must send the service id from the previous step in the desired item by using the request body of the POST https://{accountName}.{environment}.com/api/checkout/pub/orderForm/{orderFormId}/items/{itemPosition}/offerings request:


_10
{
_10
"id": "1"
_10
}

The expected response is the orderForm structure with the offerings array with the service information inside it, as the code below:


_10
"offerings": [
_10
{
_10
"type": "Removal of additional old appliance",
_10
"id": "1",
_10
"name": "Removal of additional old appliance",
_10
"allowGiftMessage": false,
_10
"attachmentOfferings": ["Name", "Info"],
_10
"price": 2999
_10
}
_10
]

Adding more than one service to a product

If you need to add more than a service to a specific product, you must add more units of the product that the service is attached to. To do so, you must follow the steps below:

  1. Update the product you want to add the service to have "quantity": 1. Use the Handle cart items endpoint with the following request body:

_10
{
_10
"orderItems": [
_10
{
_10
"index": 0,
_10
"quantity": 1
_10
}
_10
]
_10
}

  1. Attach the offering to the item in the shopping cart. Use the POST https://{accountName}.{environment}.com/api/checkout/pub/orderForm/{orderFormId}/items/{itemPosition}/offerings request as the previous section:

_10
{
_10
"id": "1"
_10
}

  1. Update the quantity back to the previous value, sending the noSplitItem field as true in the Handle cart items endpoint in the request body. This field will make sure the items do not split the configuration, making it possible to have the same quantity of products and services.

_10
"orderItems": [
_10
{
_10
"index": 0,
_10
"quantity": 4
_10
}
_10
],
_10
"noSplitItem": true

Removing a service (offering) from a shopping cart

In order to remove a service (offering), you must use the POST https://{accountName}.{environment}.com/api/checkout/pub/orderForm/{orderFormId}/items/{itemPosition}/offerings/remove endpoint with the service id in the request body:


_10
{
_10
"id": "1"
_10
}

The expected response is the orderForm structure with the offerings array empty, like the example below:


_10
"offerings": []

Contributors
1
Photo of the contributor
+ 1 contributors
Was this helpful?
Yes
No
Suggest edits (Github)
Contributors
1
Photo of the contributor
+ 1 contributors
On this page