New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow adding multiple products to the cart via the add-to-cart query string #17477
Comments
Related #16742 |
|
A summary from #16742:
|
Feel free to submit a pull request for this! A new query param is probably the easiest solution, since it's a bonus feature not directly used in core. |
3.2 seems to have broken ability to add multiple variable products with this snippet as well. |
Ok, I'll add a use case for this: We have rewritten the looks of a variable product in the store so that two attributes ("Side" with left and right and "Color" with a list of colors as choices) are not displayed as a "Side" pulldown and a "Color" pulldown but as a fixed row "Left" and fixed row "Right" with a color pulldown for each. As it is currently implemented we have to add an order button to both lines and purchase two single items of the same product on one screen but the product is intended as a pair so only a single button would be nice - the basket still could and should have to single products. We call this a "matrix" product. Perhaps we are thinking too complicated here for this use case. If anyone has a suggestion for this, it would be very welcomed. |
@mikejolley How do you feel about the curie notation for defining the product ids/quantities? e.g.
(I'm envisioning doing a simple version of the same thing for varations: I think the alternative would possibly be multiple params, e.g.
|
I guess thats an option :) Did you see how grouped products do it? |
Yah, was working through that now actually. Appears to be an array with
But if we use a custom query var, I guess I we can make it a smaller query var for the ids/quantities, e.g.
|
(oops) |
Is the main goal to have a short url, or to just support it across product types? And query string only, or support post/forms too? |
…erce#17477 Adding multiple products: ``` ?items-to-cart=1&add[<product1-id>]=<product1-qty>&add[<product2-id>]=<product2-qty> ``` Adding multiple variable products looks the same as the above, except replace product-id with variation-id. Adding multiple grouped products looks like: ``` ?items-to-cart=1&add[<group-id>][<groupproduct1-id>]=<groupproduct1-qty>&add[<group-id>][<groupproduct2-id>]=<groupproduct2-qty> ```
@mikejolley ideally all of the above, I guess. #17855 ready for review. |
Let's continue discussion in #17855 Thanks |
I have written a tutorial for doing this (in a bit of hacky way, due to
WC_Form_Handler
's private methods), but this seems like prime territory for WC core. If this is considered blessed, I can start on a PR for it along the lines of the code in the tutorial.https://dsgnwrks.pro/snippets/woocommerce-allow-adding-multiple-products-to-the-cart-via-the-add-to-cart-query-string/
The text was updated successfully, but these errors were encountered: