Update a product quantity already in cart for a customer
| POST | cart/update-item |
|---|
Use this endpoint to obtain a comprehensive update a product quantity already in cart associated with a specific customer in your organization.
Header
Authorization
Example: Bearer {YOUR_AUTH_KEY}
Content-Type
Example: application/json
Accept
Example: application/json
Query Parameters
| Parameter | Datatype | Description |
|---|---|---|
| customer_id | Integer(required) | The customer's unique identifier. |
| cart_id | Integer(required) | The cart unique identifier. |
| quantity | Integer(required) | Number of quantity that you want to added to the cart. if you put the quantity is 0 then this item will be removed from cart |
Response Parameters
| Parameter | Datatype | Description |
|---|---|---|
| data | object | This object contains the entire resource. |
| cart_item_count | Integer | The number of cart items in cart. |
| total_cart_quantity | Integer | Sum of cart items quantity. |
| cart_total | Double | Total cart amount. |
| discount | Double | Total discount availed by the customer. |
| billable_amount | Double | Total amount payable by the customer. |
| items | Collection | The list of items associated with the cart. |
| items.id | Integer | The unique cart item identifier. |
| items.quantity | Integer | Number of quantity of the cart item. |
| items.product | Collection | The list of product associated with the cart item. |
| items.product.id | Integer | The unique identifier of the product. |
| items.product.name | String | The name of the product. |
| items.product.image | String (URL) | The URL of the product image. |
| items.product.sku | String | The SKU of the product and this also a unique identifier of the product. |
| items.product.hsn_code | String | The HSN code of the product. |
| items.product.description | String | The description of the product. |
| items.product.price_per_unit | Double | Price of the per unit product. |
| items.product.maximum_retail_price | Double | MRP of the product. |
| items.product.weight | Double | Per unit weight of the product. |
| items.product.vol | Double | Per unit volume of the product. |
| items.product.gst_percent | Double | GST percentage of the product. |
| items.product.measurementtype | Collection | Collection of product measurement type. |
| items.product.measurementtype.id | Integer | The unique identifier of the product measurement type. |
| items.product.measurementtype.name | String | The name of the product measurement type. |
| items.product.productcategory | Collection | Collection of product categories. |
| items.product.productcategory.id | Integer | The unique identifier of the product category. |
| items.product.productcategory.name | String | The name of the product category. |
| items.product.productcategory.image | String (URL) | The URL of the product category image. |
| items.product.productpricing | Collection | Collection of product pricing. |
| items.product.productpricing.id | Integer | Unique identifier or id of the product pricing or pricing set. Product pricings are pricing sets setup for specific buying quantities of the same product. Example - Tata Tea Gold is the product and Pack of 12, Pack of 18 or Pack of 24 are 3 product pricing sets of the product. |
| items.product.productpricing.product_id | Integer | ID of the product. |
| items.product.productpricing.buying_qty | Integer | Product Pricings are basically selling prices for a specific set of quantity or pricing set. Here buying_qty refers to the qty against the pricing set . |
| items.product.productpricing.price | Double | Selling price of the specific product pricing or pricing set against the specific buying quantity . |
Sample Request
curl --location --request POST 'https://testwebservices.sourcehub.in/api/cart/update-item?quantity=2&customer_id=9&cart_id=79532' \
--header 'Authorization: Bearer ************'
Sample Success Response
{
"data": {
"cart_item_count": 1,
"total_cart_quantity": 6,
"cart_total": 1200,
"discount": 0,
"billable_amount": 1200,
"items": [
{
"id": 79532,
"quantity": 6,
"product": {
"id": 4,
"name": "3 Roses Mrp 10 (408pc)",
"image": "https://sourcehub.in/public/images/product/1605342130.jpg",
"sku": "CP 2425 0046",
"hsn_code": "0902",
"description": "",
"price_per_unit": 10,
"maximum_retail_price": 4080,
"weight": 3000,
"vol": 0,
"gst_percent": 5,
"measurementtype": {
"id": 5,
"name": "bags"
},
"productcategory": {
"id": 3,
"name": "Tea ,Coffee and Beverages",
"image": "https://sourcehub.in/public/images/productcategory/1617180572.jpg"
},
"productpricing": {
"id": 1058,
"product_id": 4,
"buying_qty": 1,
"price": 200
}
}
}
]
},
"message": "Cart item quantity updated"
}
Sample 401 Faliure Response
{
"error": {
"code": "AUTHENTICATION_ERROR",
"description": "Invalid credential or token.",
"source": "https://webservices.sourcehub.in/api/items.product",
"status_code": 401
}
}
Sample 422 Faliure Response
{
"error": {
"code": "VALIDATION_ERROR",
"description": "The customer id field is required.",
"source": "http://testwebservices.sourcehub.in/api/carts/add-item",
"status_code": 422
}
}
Errors
1.The API key/secret provided is invalid. Error Status: 401
The API credentials passed in the API call differ from the ones generated on the Dashboard. Possible reasons are:
- Different keys for test mode and live modes.
- Expired API key.
Solution :
The API keys must be active and entered correctly with no whitespace before or after the keys.
2.VALIDATION_ERROR. Error Status: 422
Possible reasons are:
- Maybe you didn't provide customer ID.
- Maybe you Prodive incorrect customer ID.
Solution :
Provide a correct customer ID.