We are working with add to cart hooks a lot in WooCommerce so we are able to add products to our carts via our own plugins without messing around in the functions.php
all too much.
But this time I think we came to our limits.
What we use is the WooCommerce Composite Products plugin and we have added multiple products into one composite product which ID is 123
.
By creating a link like this, we can add the composite product into our cart and select the components as we want:
The challenge now is that we want to add a different quantity for each component:
Working with the quantity
attribute didn't get us far here because it would only add the whole composite product into the cart x-times but not each of the components:
https://www.example.com/cart/?add-to-cart=123&wccp_component_selection[1593767685]=479&quantity=20...
So we're out of ideas now. How can we add a composite product into the cart 1 time but control the quantity of each component as we want?
After dealing with the customer support of the plugin, the solution is simple as this:
is the right link.
while wccps_cX
is the product ID and wccpq_cX
is the quantity. wccpmX
is the component ID and wccpl=X
marks the number of components you want to add.