Add more than 1 Product to Cart with one Form ! Is this possible ?

Posts: 19
Joined: 05/22/2008

Hello Guys and Girls,

First Thanks to your fantastic work a 1.0 release. I think with 2.0 this plugin will be a killer application ;- )

I have a Problem.

I want to show a list of Products for an user ( no problem ).
Every Product has a Quantitiy field ( also no problem )
You have only 1 Button "Add to Cart", so the user can add more than one product with one click to cart ( my problem ;- ) )

Have anybody some suggestions for me ?

Posts: 15
Joined: 05/15/2008

I would like to do this too. We want to have an order form for bookstores who often know what they want. We will list every book on one page with a checkout button at the bottom.

Posts: 163
Joined: 08/07/2007
Uber DonorBug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Not Kulvik

We do this with a javascript that builds an add to cart button on the fly. if you put a hyphen between products they will all go into the cart using the cart_links module something like:

<?php
<a href=mysite.com/cart/add/p123_a101_q2-p456_a1o3_q3>ADD LOTS OF STUFF TO CART</a>
?>

This is totally off the top of my head but it should add 2 of product 123 with an option and 3 of product 456 with a different option using a single click.

Posts: 4747
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

I've also made some recommendations in this FAQ, but they involve custom code. Smiling

Posts: 13
Joined: 05/07/2008

Blessed_Steve has it mostly right. Check the help page for Cart Links under the Admin >> Store Administration >> Configuration >> Cart Links. The help page describes how to create links directly into the cart.

You'll probably want to make sure you pass "e" in which empties the existing cart if you only have one page. Otherwise you'll end up with extra product in the cart. Also, not only do you want to validate on the client side with JavaScript, but you'll want a PHP controller that actually passes the URL into the cart. Less prone to hacking.

Here is an example of our PHP controller. We use checkboxes on a separate hand-coded page.

<?php

//if (isset($_POST['p1']) || isset($_POST['p2'])) {
   
$url = "/cart/add/e-";
   
    if (isset(
$_POST['p2']))
       
$url .= "p2-q1";
       
    if (isset(
$_POST['p1']))
       
$url .= "-p1-q1";
       
   
$url .= "?destination=cart/checkout";
       
   
// /cart/add/e-p2_q1-p1_q1?destination=cart/checkout
   
header("Location: " . $url);
//}
?>

Posts: 4
Joined: 07/31/2008

Can you post the JS code too?

Posts: 2
Joined: 08/01/2008

How much would it cost.