Add two different Products with Custom Add-To-Cart() in WooCommerce

I’m trying to add multiple products with just one Click to my WooCommerce Cart.
This is my actual code:

jQuery("#button").click(function(e){
    e.preventDefault();
    addToCart(28,29,"Red");
    return false;
});

function addToCart(p_id,v_id,a_name) {
    jQuery.get('/wp/?post_type=product&add-to-cart='+p_id+'&variation_id='+v_id+'&attribute_color='+a_name, function() {
    });
}

At least I’m able to add one product, but I would like to add some more addToCart()-functions like:

Read More
addToCart(28,29,"Red");
addToCart(28,30,"Black");
addToCart(28,31,"Silver");

WooCommerce always only takes the last one.

Related posts

1 comment

Comments are closed.