The shopping cart gathers information on the products the customer chooses while browsing a store, such as prices, shipping costs, payment methods, delivery methods, etc. This data may include item prices, shipping value, payment, and delivery methods, among others.
This guide will describe how to add relevant information related to a specific order to a shopping cart via API.
Getting shopping cart information
The first step is to get the orderFormId
of the shopping cart to which you want to add the merchant context information. For more information, read the Getting cart information by ID guide.
Adding merchant context information to the shopping cart
To add merchant context information to the shopping cart, you need to use the Add merchant context data endpoint. In this request, you must send the orderFormId
through the URL address, as in the example below:
https://{accountName}.{environment.com.br}/api/checkout/pub/orderForm/ede846222cd44046ba6c638442c3505a/attachments/merchantContextData
Additionally, you need to send the request with the merchant context information within the salesAssociateData
object. See a request body example containing the vendor (seller) identification code:
_10{_10 "salesAssociateData": {_10 "salesAssociateId": "seller123"_10 }_10}
After sending the request, the endpoint will return the response body containing the merchant context data in the shopping cart, as in the example below:
_10..._10"merchantContextData": {_10 "salesAssociateData": {_10 "salesAssociateId": "seller123"_10 }_10 }_10...
️ For more information about the meaning of each field available in the shopping cart, see the orderForm overview.
Error codes
The following errors may appear as a message in the response body.
400 - Bad Request
- Message error example (code ORD002):
"Invalid order form"
. TheorderFormId
information is not valid.
_10{_10 "fields": {},_10 "error": {_10 "code": "ORD002",_10 "message": "Invalid order form",_10 "exception": null_10 },_10 "operationId": "5d9f54e6-7db4-46d6-bca9-deeb278b8b98"_10}
404 - Not Found
Message error example: "The requested URL was not found on the server"
: Check if the URL is correct.
_10<body>_10 <h1>404 Not Found</h1>_10 <p>The requested URL was not found on this server.</p>_10</body>