Handling basket properties
This article will guide you through how to handle operations on your basket properties, using our headless API. The Postman collection will be used for all examples.
In order to show changes to the basket immediately, you have the option of enabling a mini basket view in all of the following requests. Find out more in the Available views section.
Prerequisites
accessTokenfrom Connect flow.basketIdfrom Creating a basket.cultureCode, e.g.en-US(string)priceGroupIdfrom Get price groups. (string)
Creating order properties on your basket
Additional prerequisites
key- basket property key (string)value- basket property value (string)
Create Basket Property
Open the Create Basket Property request.
Provide the basketId for the path variable and enter cultureCode, priceGroupId, key and value properties in appropriate places in the request body.
Request:
curl -D- -X POST {base_url}/api/v1/baskets/{basketId}/properties \
-H 'Authorization: Bearer <ACCESS_TOKEN>'
-H 'Content-Type: application/json' \
-d '{
"cultureCode": "{cultureCode}",
"priceGroupId": "{priceGroupId}",
"key": "{key}",
"value": "{value}"
}'
Response:
{
"miniBasket": null,
"success": true
}
Deleting order properties on your basket
Additional Prerequisites
propertyIdfrom the previous step
Delete basket property
Open the Delete Basket Property request.
Provide the basketId and propertyId for path variables and enter the cultureCode and priceGroupId properties in appropriate places in request body.
Request:
curl -D- -X DELETE {base_url}/api/v1/baskets/{basketId}/properties/{propertyId} \
-H 'Authorization: Bearer <ACCESS_TOKEN>'
-H 'Content-Type: application/json' \
-d '{
"cultureCode": "{cultureCode}",
"priceGroupId": "{priceGroupId}",
}'
Response:
{
"miniBasket": null,
"success": true
}
Getting the order properties on your basket
Get Basket Properties
Open the Get Basket Properties request.
Provide the basketId for the path variable.
Request:
curl -D- -X GET {base_url}/api/v1/baskets/{basketId}/properties \
-H 'Authorization: Bearer <ACCESS_TOKEN>'
-H 'Content-Type: application/json' \
Response:
{
"customProperties":
[
{
"_hasCustomPrice" : "120"
}
]
}
Updating order property on your basket
Additional Prerequisites
propertyIdfrom the previous stepvalue- new value for the property (string)
Update basket property
Open the Update Basket Property request.
Provide the basketId and propertyId for the path variables and enter the cultureCode, priceGroupId and value in appropriate places in the request body.
Request:
curl -D- -X PATCH {base_url}/api/v1/baskets/{basketId}/properties/{propertyId} \
-H 'Authorization: Bearer <ACCESS_TOKEN>'
-H 'Content-Type: application/json' \
-d '{
"cultureCode": "{cultureCode}",
"priceGroupId": "{priceGroupId}",
"value": "{value}"
}'
Response:
{
"miniBasket": null,
"success": true
}
Possible errors that may occur
| Error | Description |
|---|---|
| BadRequest (400) | Execution of the pipeline fails; Price group not found; AccessToken was not attached. |
| Unauthorized (401) | The token is expired. |
| Forbidden (403) | The token does not have access to this endpoint. |
| NotFound (404) | Basket or Property with the supplied id was not found. |
| Conflict (409) | Property already exists on the order. |
{
"errors": [
{
"error-description": "Basket with the supplied id basketId was not found",
"error": "NotFound"
}
]
}
See Handling failures for more info.