Answer the question
In order to leave comments, you need to log in
WooCommerce. How to add a product with multiple variations to the cart?
example: $woocommerce->cart->add_to_cart( $product_id = 2960, $quantity = 1, $variation_id = 2961, $variation = array(), $cart_item_data = array() );
There is a product it has a size variation. In this example, $variation_id. Everything is working. The item goes into the cart.
And if there is another color variation, then how to add the product to the cart in this case. I assume that you need to add something to this $variation array. But I can’t find what to add there, and what will be in the $variation_id variable then. Can you also tell me how to get the id of all variations on the product page?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question