The checkout module provides a default status for the Checkout order state. This is done by building the checkout pages and returning the first page ID key. The consequence of this involves building the checkout page info definitions, which also involves the alters for this. It then builds all checkout panes and their alters as well. That's a lot for just wanting to know the default status.
$order_states['checkout'] = array(
'name' => 'checkout',
'title' => t('Checkout'),
'description' => t('Orders in this state have begun but not completed the checkout process.'),
'weight' => -3,
'default_status' => 'checkout_' . commerce_checkout_first_checkout_page(),
);
I'm proposing a variable called "commerce_checkout_first_checkout_page" that can be set to programmatically define the first checkout page ID in commerce_checkout_first_checkout_page()
. I don't think we need an invoke or alter here. It's just a performance item for implementations that require a lot of alter logic for the checkout pages and it's being called when not needed to just to built order state and status info.
Comment | File | Size | Author |
---|---|---|---|
#18 | provide_a_way_to_define-2633648-18.patch | 1.79 KB | joelpittet |
| |||
#13 | provide_a_way_to_define-2633648-13.patch | 1.76 KB | mglaman |
#11 | provide_a_way_to_define-2633648-11.patch | 1.56 KB | mglaman |
#9 | provide_a_way_to_define-2633648-9.patch | 1.56 KB | mglaman |
#9 | interdiff-2633648-9-5.txt | 2.12 KB | mglaman |
Comments
Comment #2
mglamanHere's the patch. If the variable is not set it defaults to
key(commerce_checkout_pages()
. Maybe we could expose this on the checkout settings form, though. It could be a select list of "Automatic based on first page" or a specific page. It's more of an advanced item that might just deserve developer documentation.Comment #4
mglamanHere's an updated patch with a test added.
Comment #5
mglamanWhoops, synxtax error.
Comment #8
mglamanTalked it over with rszrama. The idea will be to change commerce_checkout_first_checkout_page() to invoke page info and alter and get the key, bypassing the checkout pane logic and sorting.
Comment #9
mglamanHere's a shot at idea from #8. Also updated test to make sure the static cache of panes is empty, showing we bypassed their init for just checking order state info.
Comment #11
mglamanThis is what I get for trying to write a patch quick. Fix syntax.
Comment #12
mglamanThis doesn't work because there might not be a weight.
Comment #13
mglamanHere is a new approach that provides a hook to define the default page key.
The above code would allow me to ensure an order ends up on Checkout: Payment immediately and no need to fiddle with the checkout router, either. So this is a bonus option beyond performance!
Comment #14
mglamanComment #15
joelpittetyes please, this has a nice rabbit hole.
Comment #16
joelpittetComment #17
rszrama CreditAttribution: rszrama at Centarro commentedAhh, shoot. This actually needs a re-roll b/c of #2430337: HHVM incompatibility, but it'll let us make sure we preserve the HHVM compatibility.
Comment #18
joelpittetRe-rolled.
Comment #19
mglamanI say, back to RTBC! Test pass, nothing changed in patch.
Comment #21
rszrama CreditAttribution: rszrama at Centarro commentedTouched up the comments and changed "page key" to "page ID" to keep in line with the rest of the module.