Support » Plugin: WooCommerce » Use add-to-cart-URL to add more than one product

  • Resolved doopie


    I would like to use a URL for button that adds more than just one product to the cart.

    The standard format is /?add-to-cart=11195
    This works.

    I tried
    and /?add-to-cart=11195&add-to-cart=11379

    but it only adds the second product ID to the cart, not the first one.

    Does anyone know a solution?

Viewing 9 replies - 1 through 9 (of 9 total)
  • You won’t be able to do that because the “add-to-cart” url only take one product or variation id.

    What you can do is to use the $_GET and the foreach loop

    You can make a grouped product consisting of one or several simple products. The quantity of each simple product in a group is 0 by default so the quantity of each simple product needs to be set in the query string.

    For example, if I have two simple products with ids 1593 and 1801, and my grouped product is id 3111, then my add-to-cart query string is:

    Works for me, your experience may differ.

    For simple product works but the first product was ignored(“add-to-cart=3111” or it just min)but not with variable product.

    Yes, I don’t think its possible to have a variable product or a variation as part of a grouped product. The grouped product is not added to the cart since its not a product in its own right, its a collection of other products. The quantity array ensures each component simple product is added to the cart.

    However the above technique will also work if a variation id is used in the quantity array. So in my example, the url:


    will add the two simple products 1593 and 1801 and variation_id 2668 to the cart in one go, even though 2668 is not part of the grouped product.

    Thank you very much for your suggestions.

    I’m currently only offering these two products (it’s a subscription site), so I solved it by having one item automatically added to the cart from the beginning.

    @lorro so in a grouped product we can add the variable product but how can we decide which variation id with attribute slug should be loaded for each in a grouped product 🙂

    variation_ids can be seen on the product edit page > Product Data section > Variations tab.

    I mean to say how to pass the variation id with attribute slug in query args 🙂

    I don’t think add-to-cart needs to know the attribute slug. The variation id is sufficient for add-to-cart to know which product to add. Anyway, I don’t know how to pass the attribuute.

    The query string would include something like:
    where in this example, 2668 is the variation id.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Use add-to-cart-URL to add more than one product’ is closed to new replies.