We are trying to build a simple subscription workflow.
Our spec calls for a one page workflow where the purchaser can choose a subscription level (only one), put in all their user/address/payment info and then click "purchase".
No cart, no review, no multiple steps, oh and a different URL then /checkout.

My current thoughts are as follows:

1. create a node showing all the products (subscription levels), create an empty order in code, and include the checkout form on the node display.
2. choosing a subscription level uses js to set a hidden field to the sku for that option
3. alter the checkout submit to my own function which would grab the sku and create/save/add a line item to the order and then "just" proceed with the rest of the checkout submit.

I am currently struggling with the best way to include the checkout form in my node display. I am able to create the form, but only by doing an include_once on the commerce_checkout.pages.inc file. This feels like a mistake! Is there a smarter way that I am missing to build my own version of the form, short of recreating all the code in the checkout module?

I looked at hook_commerce_checkout_router() but it requires that there be line items in the order before it is willing to return a form.

Thanks for any advice!

Comments

rszrama’s picture

Status: Active » Fixed

What you're doing is correct, actually. You should also mention it in your form state's build info array like I do for our various UI forms:

  $form_state['build_info']['files']['form'] = drupal_get_path('module', 'commerce_checkout') . '/includes/commerce_checkout.pages.inc';

Is there perhaps any way for you to tie the checkout form inclusion to the selection of a subscription level? If you did that, then you could add an AJAX refresh to the level selection widget that refreshes the page to include the checkout form. The advantage here is that you could create an order on refresh and add a line item to it representing the level selected. Then if they changed their mind, you can just update the line item you've created for them.

There are various other options... for something like this I probably wouldn't use a product display node at all.

jkopel’s picture

Thanks for the followup Ryan!
I did end up getting it working, and I did not use a display node, and it really was pretty straight forward.
Then the client decided they wanted to use Recurly.

rszrama’s picture

lol So it goes. Were you able to use my Recurly module for that?

jkopel’s picture

Indeed I was/am (http://drupal.org/node/1190686) :-)

It turns out I need to use the Recurly API instead of hosted pages, but I am still using some of what you have in there.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

queenvictoria’s picture

Hi there @jkopel. I'm looking at implementing this and have been looking at older ideas from here. Can you share some of your (sadly unused) work or ideas?

giorgosk’s picture

@jkopel
I would love any details you give us on simplification of checkout process

starsinmypockets’s picture

Ditto - I'm working on a similar workflow with a one-page-checkout... would love to look at your implementation(s)

jkopel’s picture

I abandoned my investigations back in June, and have not done anything further with it since then. I have put the code I have in a sandbox, but I can't provide any support for it, and to be honest I am not sure it will even run against the current version of commerce.

One other major caveat is that I intended my checkout form to run in a panels module page (as an easy way to handle paths and such). I wrote a simple Ctools content type plugin which will also go in the sandbox, but if you are not running panels you are on your own.
Here it is, and I hope it helps someone!

http://drupal.org/sandbox/jkopel/1341870

rj’s picture

Hi, responding to an old issue in-case anyone comes along this post like I did when I was doing research. I created a single-page checkout module similar to what's being requested in this thread; it basically adds a checkout_page with duplicate address/billing/cart/etc. panes to a node that has products referenced to it.