Automate steps up to checkout

Posts: 2
Joined: 05/12/2008

I've set up ubercart, and got it working with my merchant. I am a developer, but this is my first experience with ubercart, and I've found it to be reasonably straightforward for beta software.

Besides standard products, I'm going to use it to process event fees. I'd like to create an event registration form with my own module, which will already capture address info.

I'm looking for pointers on the calls I need to make to skip the user steps of adding the product to the cart and filling in the billing info, so that I'm going from my form to the review order stage. I'll want to make sure there's no other cart entries, so it would be a new order at that time.

Thanks in advance,

Roger

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

Hey Roger, thanks for giving us a shot. Smiling

If you're going to bypass the checkout form at /cart/checkout, you're going to need to do 3 basic things to get to the Review page:

1) Validate the customer's input yourself.
2) Create a new order with the customer and product info in the in_checkout order state and set $_SESSION['cart_order'] to the order ID.
3) Set $_SESSION['do_review'] = TRUE and redirect to /cart/checkout/review.

In your own module, these things can happen in your form's validate handler (#1) and submit handler (#2-3). Simply return the URL from your form's submit function and it should take care of the redirect for you.

You'll need to account for payment with this setup somehow. At the moment, there are a couple payment systems (PayPal WPS, 2Checkout.com) integrated that work by redirecting from the review page to the gateway's payment page... if you're not using either of those, be aware that payment info is normally collected through the checkout form.

Posts: 2
Joined: 05/12/2008

Thanks Ryan,

That's basically what I was looking for, although I'm using a contrib payment module for myVirtualMerchant, which is bare bones (in fact, I've extended it myself and will post that when I've finished testing things out).

I also discovered the cartlink addon, which is very cool and useful here.

I guess I don't care if I totally bypass the checkout form itself, as long as I can pre-populate the fields there so the user doesn't have to re-enter info. They could just verify and follow the rest of the process. Is there anything existing to allow that (besides just hook_form_alter-ing the form)?

-Roger

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

The checkout form gets populated with data from the order that you specify in $_SESSION['cart_order'], so if they go back using the form button it will be filled without you having to do anything.