Customize check out, allow adding multiple products to the cart at one time

Posts: 24
Joined: 02/28/2008

I need a feature. If it's not already available, I may work on it. If I finish it and people think it's useful, I can contribute it back. But before I start, I want to make sure that I'm not re-inventing the wheel. I also want to hear opinions about this feature.

Here is what I need:

1. to have multiple products listed on the same page, each with a check box next to it,
2. do not display 'add to cart' next to these products on this page (or other pages)
3. show a single 'add to cart' button on the page
4. user selects multiple items, then click the single 'add to cart' button
5. this behavior is applicable to selected product class only (so it won't mess up other product classes)
6. additional features: sorting, grouping of selected products

Thanks in advance.

Posts: 80
Joined: 12/28/2007
Bug FinderGetting busy with the Ubercode.

Hi,

I think this would probably be easily accomplished by creating a custom form with the checkboxes and a submit button. The submit function could then call the uc_cart_add_item($node_id, $quantity) function for each checked product to add it to the cart.

Chad

Posts: 24
Joined: 02/28/2008

Chad,

thanks for your response.

Any suggestions on how to hide the 'add to cart' button for the special product class?

I can think of:

1. hack it where the button shows up (bad choice)
2. some sort of theming hook (I don't know where, some pointers would be appreciated)
3. through some existing ubercart or Drupal features that I don't know

Posts: 45
Joined: 09/03/2007

If I understand what you are trying to do, the cart links contribution should work.

This cont allows you to use a url string to bypass any add to cart button and takes you straight to the filled cart.

Posts: 24
Joined: 02/28/2008

What I want is a page like:

x prod1 attr1 attr2 ... price1
x prod2 attr2 attr2 ... price2
...
x prodn attrn attrn ... pricen

'add to cart'
(x stands for check box)
user can select multiple check boxes, hit 'add to cart' once.

I think Chad is right that custom form is the way to go for this page, please let me know if otherwise.

In addition, I'd like user NOT to see 'add to cart' button, if he browses the individual product. Essentially, force user only to use this page to purchase these products.

Posts: 1217
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

Hiding the Add to Cart button you can do using Contemplate and creating a new Template for the Product node type.

For the page to buy multiple items, I like this idea - but I think it'll require some custom coding. You'll probably need to use CCK also, to add a Checkbox to your Product edit forms - something like "Purchase via multiple" or something to that effect, so you can flag which products to include on this page. (There are other ways but I think that's easiest).

Then, in the custom module create a form which contains a loop that finds all flagged products and adds the checkboxes to the page. You'll probably need to use TAPIr for that, or just outputting a themed table, whatever suits you best. (You can really use any layout you like).

So utilizing hook_form_alter in your custom code, loop through all the products and add them to the form, and then when they are done looping, add your Submit button which during hook_form_submit uses the hook_add_to_cart to add those items.

Sounds more complicated than it is, I think. I know what you're trying to do and more questions might be "do you want multiple pages to allow different categories, or just one page listing all products?" etc which might bring you into more complex territory.

Hope this helps!

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 24
Joined: 02/28/2008

Thanks for your response. Thanks for providing so many pointers.

You mentioned "a loop that finds all flagged products", which requires some query to build a product list first.

Are you aware of some drupal function can do the 'query' (or search) for products (nodes)? node_search() don't look like it.

I hate to use sql query to search the node table in db directly, if I happen to bypass any existing drupal functions, it may make the module less portable. However, if db query is THE way to go, I'll do it.

Posts: 1217
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

Unfortunately not. I agree something like drupal_get_nodes would be spectacular - they have a get_node_types function, and I'm pretty sure that there will almost always be less node types than actual nodes themselves. I wonder if this is something going into version 6.

But db_query will be portable as long as you keep the node types it searches for flexible and make sure you use curly braces to retain table prefixing.

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 24
Joined: 02/28/2008

I generated the form the hard way using forms api. Inside my_form() function I used brutal sql select to retrieve the nodes, filled in all form variables.

I didn't see where I can use hook_form_alter() function. I suspect I didn't do it right.

In my case, I have a new content type, added new cck fields. Then I added a table view with these fields. It looks something like:

col1 col2 col3
*************
V11 V12 V13
V21 V22 V23
...
Vn1 Vn2 Vn3

The form basically looks identical as the view, except one more column of check boxes and a submit button. It should look like

id col1 col2 col3
****************
x V11 V12 V13
x V21 V22 V23
...
x Vn1 Vn2 Vn3
"submit button"

where 'x' stands for a check box.

I felt like there got be a better way to take advantage of the view , which already contains all the contents for the form, except the check boxes and a submit button. I am playing with theme_views_view_table(), so far, it has not got me anywhere.

Posts: 24
Joined: 02/28/2008

someone pointed me to this http://drupal.org/node/103171, i'm going to check it out...

Posts: 1
Joined: 03/05/2008

I've run into the same requirement for our site. Do you have any snippets from your solution available?

Thanks,
T

Posts: 24
Joined: 02/28/2008

I'm in the uncharted territory now. My case may not apply to you.

For the part that I need the multiple products checkout, I decided not to use shopping cart. I just used view_bulk_operations module which is configured thru the views GUI. Then I provided my own action callback. So far the callback is only a stub.

The true test is going to be next part, which I haven't started yet.

I don't know if bulk operations can work with ubert cart, you can check out the view_bulk_operations module. It's very good for what it supposed to do.

Posts: 64
Joined: 02/13/2008

Have you had a look at the product kit Contrib?

Posts: 24
Joined: 02/28/2008

The reason I am skipping shopping cart is not entirely because multiple check out. It's due to my special needs. I am developing an education site that allows people to register for courses, and buy other regular products as well. The shopping cart fits the regular products well.

For the course registration and payment, I found out I need to twist everywhere (screens and processes) to treat a course as a product. Once a course is paid, I still need the registration record. Refund is also tricky. I also need special report.

I am not sure if I making the right decision. Since I am skipping the shopping cart, I think I also have to code my own credit card payment module.

Posts: 28
Joined: 04/04/2008

Hmmm, maybe you could use workflow-ng for this? The user could put courses in the cart along with other products. Then at checkout create a workflow that takes the user through whatever process they need to go through for registration if the cart contains any products that are in the product class "course".

I built an e-commerce platform (not ubercart) for a client that does class registrations. They have courses for registration and shippable products from the school store. I treated the course itself as a type of product that is simply added to the cart. Upon checkout, if course products are in the cart, the user has to register an account or login. Then it goes through a verification process (is the class full, is the user banned from registration, has the user already taken the course, has the user taken the required prerequisite courses, etc). Then the user has to fill out registration information which gets saved as part of the user record. After payment, the course is added to the user record. Basically, everything is associated with the user record. The user's role is "student".

In Drupal, you could use profile to store extra information in the user record.

Hope that helps.

--

Chisholm Technologies, Inc.
Custom software development since 1999!
www.chisholmtech.com

Posts: 15
Joined: 02/22/2008

Hello ubuntu,

Just wondering if you ever managed to get your bulk_operations action callback to work? I'm looking for something similiar as well.

Thanks

Nathan

Posts: 89
Joined: 11/06/2007
Bug FinderGetting busy with the Ubercode.

I'm wondering if this is the kind of thing you are looking for but instead of textfield's you would want checkboxes. http://www.itiswritten.com/give/donate

Posts: 4
Joined: 07/31/2008

This would be a nice feature. Any news?