Spree Commerce

Try It Now

Checkout Process More Extensible

Posted on April 09, 2009 by Sean Schofield

The edge version now includes some additional refactoring to make it
easier to customize the one page checkout process to suit your needs.
Some of the HTML elements have been renamed and the checkout.js has
been simplified to work with a configurable array of sections for your
checkout page. The checkout method of OrdersController has been
moved to a new Checkout module which you can easily
override in your own site extension. This means that in most cases you
will not need to override the OrdersController, nor need to provide a
giant class_eval statement to patch it.

A quick test last night showed that it was a trivial task to
completely omit the payment step from the checkout process. You start
off by creating a lib\spree\checkout.rb module in your site extension. Copy in the original contents of the Spree version of this file. Then you simply change two lines of code as follows.

Change this line:

<p>@checkout_steps = %w{billing shipping shipping_method payment confirmation}</p>

and remove the payment step like so:

<p>@checkout_steps = %w{billing shipping shipping_method confirmation}</p>

This single change will fix all of the client side issues. The user will no longer have a payment step and they can step through the process without any problems until its time to submit the final order. The final submit will fail though because the controller is still expecting to authorize the creditcard.

So you need to comment out or remove the following line:


That’s it! You could also use this apporach to change the default behavior and capture the creditcard (instead of authorizing it.) It should be pretty simple now to add extra steps or to remove a step (maybe shipping?) from the checkout process. Ultimately we will also be adding some configuration options that would allow you to do some of these things without having to write a single line of code.