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
offeringsarray.
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:
- 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}
- Attach the
offeringto theitemin the shopping cart. Use thePOSThttps://{accountName}.{environment}.com/api/checkout/pub/orderForm/{orderFormId}/items/{itemPosition}/offeringsrequest as the previous section:
_10{_10 "id": "1"_10}
- Update the
quantityback to the previous value, sending thenoSplitItemfield astruein 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 samequantityof 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": []