Categories
Core

Grouped Products now accepted

If you been wanting to add grouped products to the cart, well now you can in CoCart v3.

Bare in mind this is not the same as adding products in bulk. You are required to pass the product ID of the container product that is a grouped product along with the items it contains you wish to add to the cart.

Simply adding the container product to the cart will not automatically assume you want to add one of every item in the grouped product to the cart.

Adding a grouped product to the cart via CoCart acts exactly the same as you would on a normal WooCommerce store setup.

You need a minimum of one item in the grouped product along with the quantity of that item in order to successfully add the product to the cart.

curl -X POST https://example.com/wp-json/cocart/v2/add-items \
  -H "Content-Type: application/json" \
  -d '{
	"id": "91", /* Grouped product container. */
	"quantity": {
		"71": 2, /* Product ID: Quantity. */
		"72": 1
	}
}'

Each item from the grouped product added is validated. Any item that has restrictions from stock to quantity limits gone over will return an error response detailing which products could not be added.

So that is grouped products.

What about other bundled product types?

Support for developers have also been added to the API in order for extensions to add support for their product bundle types.

More product types will be supported in CoCart Pro in the future.