F
F
Fesmer2018-05-31 12:34:17
WordPress
Fesmer, 2018-05-31 12:34:17

How to add size range to Woocommerce cart?

There is a product with variations in color and size.
5b0fbe26331e9050275687.jpeg
As in a variable product, when choosing a color and choosing a size range (PP) (or which additional button), send all sizes of the product of the selected color to the basket. In order not to go through each size in one color and add to the basket, but to add the entire size range of one color at once?
For example, when choosing blue and clicking on the PP button, sizes 32, 42 and 46 in blue are added to the basket.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Sharlaev, 2018-05-31
@entity1313

1. Collect all the variations - their IDs and attribute values ​​(probably, you can limit yourself to the variation ID, but here you need to figure it out at the code level)
2. Send it to the server with AJAX
3. Add it to the cart in a loop via WC()->cart ->add_to_cart
As an illustration link: https://businessbloomer.com/woocommerce-custom-add...
It describes adding via URL. In your case, it will not work, since there are several products, but the parameters that will be needed to add are explained very well.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question