I need to alter the active checkout panes and pages based on some attributes of the current order. However, within hook_commerce_checkout_page_info_alter() there is no access to the current order. Attempting to load it with the following results in errors like so:

global $user;
$order = commerce_cart_order_load($user->uid);

Notice: Undefined index: name in commerce_checkout_commerce_order_status_info() (line 281 of profiles/concern/modules/contrib/commerce/modules/checkout/commerce_checkout.module).

commerce_checkout_commerce_order_status_info()
call_user_func_array('commerce_checkout_commerce_order_status_info', Array)
module_invoke_all('commerce_order_status_info')
commerce_order_statuses(Array)
commerce_cart_order_id(0)
commerce_cart_order_load(0)
cw_commerce_commerce_checkout_page_info_alter(Array, NULL, NULL)
drupal_alter('commerce_checkout_page_info', Array)
commerce_checkout_pages()
commerce_checkout_commerce_order_status_info()
call_user_func_array('commerce_checkout_commerce_order_status_info', Array)
module_invoke_all('commerce_order_status_info')
commerce_order_statuses(Array)
commerce_cart_order_is_cart(Object)
commerce_cart_commerce_order_load(Array)
call_user_func_array('commerce_cart_commerce_order_load', Array)
DrupalDefaultEntityController->attachLoad(Array, )
CommerceOrderEntityController->attachLoad(Array, )
DrupalDefaultEntityController->load(Array, Array)
entity_load('commerce_order', Array, Array, )
commerce_order_load_multiple(Array, Array)
commerce_order_load('48')
_menu_load_objects(Array, Array)
_menu_translate(Array, Array)
menu_get_item()
menu_get_custom_theme(1)
menu_set_custom_theme()
_drupal_bootstrap_full()
drupal_bootstrap(7)

Could we pass in the current order object as a paramater to hook_commerce_checkout_page_info_alter so thats its available for interrogation?

Comments

rszrama’s picture

Category: bug » support
Status: Active » Fixed

Since this is a simple info hook, there's no way for us to pass around additional contextual parameters that may be available on the page request. This would be akin to passing a specific $node to the function that returns valid node types or something. The problem appears to be a recursive loop... you may need to find some later hook in the execution process that you use to fetch the checkout page info from its static cache and alter it that way instead of through hook_commerce_checkout_page_info_alter(). That or just resist doing a full cart order load and query the database for the pertinent info directly.

Status: Fixed » Closed (fixed)

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

jcisio’s picture

Status: Closed (fixed) » Closed (duplicate)