WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What I am trying to achieve is to have one add-to-cart button that will add the selected quantity of multiple products, featured on the catalog page, into the basket.

Here is an image of what I aim to have:


I've found the code that outputs the existing button has the following code:

echo apply_filters(
    sprintf('<a href="%s" rel="nofollow" data-product_id="%s" data-product_sku="%s" class="%s button product_type_%s">%s</a>',
        esc_url( $link['url'] ),
        esc_attr( $product->id ),
        esc_attr( $product->get_sku() ),
        esc_attr( $link['class'] ),
        esc_attr( $product->product_type ),
        esc_html( $link['label'] ) ),

I'm aware that there could be a way to use jQuery to submit each individual form, via a loop, at once but due to my limited knowledge, I don't think I could implement it.

Alternatively, if there is a way to have a custom button that can submit multiple forms for each product and its corresponding quantity that may make things easier in the long run.

share|improve this question

Maybe the Grouped product type is for what you want.

You can create a Grouped product and then add child products to it. A grouped product (with the child products) can be added by one click.

See WooThemes docs.


If it's not what you're looking for, try to search for submitting multiple forms with jQuery (maybe this one), and have a look at this question about AJAX add-to-cart:

Woocommerce - Add a product to cart programmatically via JS or PHP

share|improve this answer
Thanks, I'll take a look into that and report back. – Ashley D Apr 17 '13 at 11:09
Unfortunately, this has not solved my original question, as it simply provides an alternative method of listing products. If I am going wrong somewhere, let me know. – Ashley D Apr 17 '13 at 12:37
Sorry to hear that, updated my answer, maybe you can use one of the links. – generousdesigner Apr 18 '13 at 14:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.