Add two diffrent Products in Cart with jQuery in WooCommerce
Hey everyone,im trying to add multiple products with just one Click to my WooCommerce Cart. This is my actually 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 im able to add one product, but i would like to add some more of the addToCart()-Functions like:
- addToCart(28,29,"Red");
- addToCart(28,30,"Black");
- addToCart(28,31,"Silver");
WooCommerce always only takes the last product in the cart. Has anyone an idea?