Document how to add multiple items via batch request (https://github.com/woocommerce/woocommerce-blocks/pull/8266)
* Document how to add multiple items via batch request * Remove “Add Items” section title * Remove “data” part from JSON example payload
This commit is contained in:
parent
883d856c28
commit
dc283a0e0a
|
@ -14,11 +14,6 @@
|
|||
- [Update Customer](#update-customer)
|
||||
- [Select Shipping Rate](#select-shipping-rate)
|
||||
|
||||
Test:
|
||||
|
||||
- Hello
|
||||
- Hello 2
|
||||
|
||||
The cart API returns the current state of the cart for the current session or logged in user.
|
||||
|
||||
All POST endpoints require [Nonce Tokens](nonce-tokens.md) and return the updated state of the full cart once complete.
|
||||
|
@ -339,6 +334,45 @@ Returns the full [Cart Response](#cart-response) on success, or an [Error Respon
|
|||
|
||||
If you want to add supplemental cart item data before it is passed into `CartController::add_to_cart` use the [`woocommerce_store_api_add_to_cart_data`](https://github.com/woocommerce/woocommerce-blocks/blob/4d1c295a2bace9a4f6397cfd5469db31083d477a/docs/third-party-developers/extensibility/hooks/filters.md#woocommerce_store_api_add_to_cart_data) filter.
|
||||
|
||||
If you want to add multiple items at once, you need to use the batch endpoint:
|
||||
|
||||
```http
|
||||
POST /wc/store/v1/batch
|
||||
```
|
||||
|
||||
The JSON payload for adding multiple items to the cart would look like this:
|
||||
|
||||
```json
|
||||
{
|
||||
"requests": [
|
||||
{
|
||||
"path": "/wc/store/v1/cart/add-item",
|
||||
"method": "POST",
|
||||
"cache": "no-store",
|
||||
"body": {
|
||||
"id": 26,
|
||||
"quantity": 1
|
||||
},
|
||||
"headers": {
|
||||
"Nonce": "1db1d13784"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/wc/store/v1/cart/add-item",
|
||||
"method": "POST",
|
||||
"cache": "no-store",
|
||||
"body": {
|
||||
"id": 27,
|
||||
"quantity": 1
|
||||
},
|
||||
"headers": {
|
||||
"Nonce": "1db1d13784"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Remove Item
|
||||
|
||||
Remove an item from the cart and return the full cart response, or an error.
|
||||
|
|
Loading…
Reference in New Issue