The shopping cart is where the information on the products chosen by the customer while browsing a store is gathered. This data may include item prices, shipping value, payment, and delivery methods, among others.
This guide will describe how to change the price of an SKU (item) in a cart by the API.
️ Before starting to manually change prices on an item, make sure the Manual Price feature is already enabled in your store.
Getting and accessing shopping cart information
The first step is to get the orderFormId
and access the shopping cart information that you want to change the item price. For more information, access the Get cart information by ID guide.
Below is an example of pricing details for items contained in a shopping cart:
_11"items": [_11 {_11 ..._11 "price": 1200000,_11 "listPrice": 1200000,_11 "manualPrice": null,_11 "manualPriceAppliedBy": null,_11 ..._11 }_11..._11]
️ For more information about the meaning of each of the fields available in the shopping cart, access the orderForm overview.
Changing the price of a shopping cart item
With the orderFormId
information available, you must use the Change price endpoint to send the path parameters information through the URL:
- orderFormId: value.
- itemIndex: a string indicating the index of the item in the cart. Each cart item is identified by an index, starting with
0
.
See a URL example below:
https://{accountname}.{environment.com.br}/api/checkout/pub/orderForm/36a1646105f243e1a9012c915631344b/items/0/price
Additionally, you need to send the request body containing the new price to be applied to the item:
_10{"price":850000}
After sending the request, the endpoint will return the response body with the new item price indicated by the manualPrice
property. The identification of the user responsible for the price change is available in the manualPriceAppliedBy
property.
_11"items": [_11 {_11 ..._11 "price": 1200000,_11 "listPrice": 1200000,_11 "manualPrice": 850000,_11 "manualPriceAppliedBy": “99e09db4-fc3b-4c8e-a15b-5194516”,_11 ..._11 }_11..._11]
Error codes
The following errors may appear as a message in the response body.
400 - Bad Request
- Message error example (code CHK0041):
"Índice de item inválido"
(invalid item index). This message indicates that theitemIndex
used in the request does not exist or is incorrect.
_10{_10 "fields": {},_10 "error": {_10 "code": "CHK0041",_10 "message": "Índice de item inválido",_10 "exception": null_10 },_10 "operationId": "8b1c2f39-641a-4ec1-ba91-b8a9d5b1cd19"_10}
403 - Forbidden
- Message error example (code CHK003):
"Access Denied"
. The feature Manual Price is not activated on your store. See how to enable it on Enable the Manual Price.
_10{_10 "fields": {},_10 "error": {_10 "code": "CHK003",_10 "message": "Access Denied",_10 "exception": null_10 },_10 "operationId": "4ae9e8e4-0fd1-469a-99b1-71705cbe036f"_10}
404 - Not Found
- Message error example:
"The requested URL was not found on the server"
. Check that the URL data is correct.
_10<body>_10 <h1>404 Not Found</h1>_10 <p>The requested URL was not found on this server.</p>_10</body>