Multipage Checkout

Issue tracker: view

Contrib type: 
Module
Status: 
Work in progress
Compatibility: 
Ubercart 1.x

Here's my initial shot at a multipage cart module (actually it's my second, but my first was a complete custom rewrite, doesn't use the panes system and is quite separate from ubercart).

Basically what I've done is used the form_alter hook to render the checkout form, but depending on the page you are on, only a subset of the panes are visible.
This way, all Javascript used in the panes still works, and hopefully the majority of panes won't even realise that they're in a multipage checkout.

The checkout is constructed by specifying pages which have panes on them. I've sort of started doing an admin interface for this, using drag and drop. But I figured it's more important to have the multipage checkout actual be complete-able, rather than having a shiney backend.

The main problem I have had is that the current checkout form only allowed the referrers 'cart' and 'cart/checkout/review' (a few lines into uc_cart_checkout_form() )
This was a problem, as the multipage checkout has urls like 'cart/checkout/billing_details' etc, and I didn't really want to have the current page determined by session or post variables or anything.
So I've included a patch that basically defines a hook that allows other modules to extend the set of valid referrers for the checkout. I'm not really familiar with the contribution process for ubercart (or any OpenSource projects, I've previously been a bit of a lurker Smiling ), so if someone could review it and let me know how I can submit it for inclusion that'd be great.

This module is by no means complete, but I thought I'd just get it out there for review and comments.

In particular I'd like comments on the need for the patch, as well as ways of making sure that the 'cart_order' session variable is persisted throughout the checkout process, as many panes have a freakin' annoying habit of messing with it in their processing function.

Cheers,
Toby

** UPDATE **

v.1 was broken I believe.

v.2 works for me, in that I can get through a checkout successfully. I've started work on a version of the quotes and payment panes that work with this multipage approach, because the default ubercart ones are so heavily reliant on JS that they don't really work in the multipage way.
The old JS from the checkout page is doing a bunch of request in the background too. They need to be weeded out somehow.

v.3 Implemented the current page via session rather than URL, so patch is no longer necessary. Seems to work well. Problems with Paypal doing queries in the background. I anticipate that a few of those payment modules will need to be dealt with, as they seem to be doing so much crazy JS stuff.

v.4 Works fine for me now, needs testing though. Created nice AJAX GUI for messing around with pages and panes at: admin/store/settings/checkout/edit/pages

Related threads: 
AttachmentSize
uc_multipage_checkout_v.1.zip15.11 KB
uc_multipage_checkout_v.2.zip18.47 KB
uc_multipage_checkout_v.3.zip17.46 KB
uc_multipage_checkout_v.4.zip20.55 KB
uc_multipage_checkout_v.5.zip20.71 KB

Hi, Awesome works,

Hi,

Awesome works, congratulation. I'was not sure about the possibilites to do that without tweaking core... very nice.

Re: Multipage Checkout

I'd say this is almost feature complete (the main things work). I'll be doing testing from now on.
If anyone wants to test that'd be great.
The latest version has a drag and drop interface for changing page and pane order (try it out, it's shiney Smiling )

Module dependancies

Hello!

I was about to try your module, but I've found that it dependes on free_order module. I can not find anywhere the module called free_order... The only one I've found thath matches is uc_free_order, is this the one you meant?

Additionaly I'm getting some javascript error while trying to use your module. Some sugestions on how I can got it works?

Regards,
Adam

Re: Module dependancies

the module is locatede here http://www.ubercart.org/forum/announcements/4091/new_module_0_orders
and you have to go in and rename the dependency to "uc_free_order"

/morten.dk

Re: Re: Module dependancies

Yep, mortendk's got it. That'll be fixed in the next release. I'm just integrating this module into a production site at the moment, once that goes live and is tested I'll take this module out of alpha/beta.
But for now, what can I say "shrug" Smiling "shrug" It's a work in progress.

detecting stage?

To give the user an idea of where hes at in the checkout process i modified the THEME_uc_cart_checkout_form() and used
$form['#submit']['uc_multipage_checkout_checkout_page_submit']['0']
Is that the "correct" way to detect a stage - or is there somewhere a $var that I havent seen?

<?php
THEME_uc_cart_checkout_form
(){
 
//1
 
if($form['#submit']['uc_multipage_checkout_checkout_page_submit']['0']=="billing_details"){}
 
//2
 
if($form['#submit']['uc_multipage_checkout_checkout_page_submit']['0']=="shipping"){}
 
//3
 
if($form['#submit']['uc_multipage_checkout_checkout_page_submit']['0']=="payment_details"){
 
//4 checks the previous
 
if($form['#submit']['uc_multipage_checkout_checkout_page_submit']['1']=="shipping"){}
?>

- it would be cool with some kind of generic $form[#stage] though Eye-wink

/morten.dk

Error...

Hi! I'm trying to use to use this module, first thanks a lot ! I needed that feature. But I can't have it working fine... I always get "Invalid option selected. Recalculate shipping quotes to continue." and then "You must select a shipping option before continuing."
When I try to use the special panes provided by the module ("Shipping Method" and "Payment Method"), the shipping method is well calculated, by the radio button is disabled !

I'm confused and do not see where the issue comes from...

I'm running ubercart 1.3 on Drupal 5.9.

Re: detecting stage?

You could actually just query the session variable "multipage_cart_page" or similar, I can't remember off the top of my head and don't have the source in front of me.
You could also grab the variable that holds the cart pages and get the actual cart title from there (again, I can't remember it off the top of my head)

Re: Error...

Hi primo, I think I may have fixed that problem recently, I'll do an upload tomorrow when I get to work.
I probably wouldn't be using this on production (unless you can debug it yourself) until I've used on our next production site and uploaded a non beta version.

Cheers,
Toby

Thanks !

Thanks a lot, that corrected the bug ! I will still make a few changes and submit it here:
- In the Shipping pane, when there is only one option, it still appears as an unchecked radio button. I will transform it into a simple display.
- In the Payment method pane, I see the fieldsets for each payment method uncollapsed by default. I will try to make it look the most like the default übercart pane.
Thanks again Smiling

Re: Thanks !

Well, I don't understand how to make each payment method fieldset collapsed by default without breaking the whole thing...