Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Why is there no route that allows an array of products to be added to the cart? #9775

Discussion options

You must be logged in to vote

Hi @multiplehats - please take a look at this document

https://github.com/woocommerce/woocommerce-blocks/blob/trunk/src/StoreApi/docs/cart.md#add-item

Specifically the "Batching" section of the Add Item route.

You can add multiple items by making a batch request containing multiple cart/add-item requests.

The JSON payload for adding multiple items would look like this:

{
	"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,…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@multiplehats
Comment options

@opr
Comment options

@multiplehats
Comment options

Answer selected by multiplehats
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants