How to alter checkout panes based on order contents I want to remove billing and payment for free orders. Currently, I have the code below.

Am I safe to user global $user in this case? Is there any better way to get the user account &amp; order involved when this hook runs?

I ask because, after installing this hook, I've seen payment and billing panes hidden under admin/commerce/config/checkout, but I didn't hide them there. This seems to be intermittent.

function MODULE_commerce_checkout_pane_info_alter(&amp;$checkout_pane) {

  global $user;
  $order = commerce_cart_order_load($user-&gt;uid);
  if (!empty($order)) {

    //get the order wrapper and order total
    $order_wrapper = entity_metadata_wrapper('commerce_order', $order);
    $order_total = $order_wrapper-&gt;commerce_order_total-&gt;amount-&gt;value();

    // hide payment and billing info if the order total is &lt;= 0
    if ((int) $order_total &lt;= 0) {
      $checkout_pane['customer_profile_billing']['enabled'] = FALSE;
      $checkout_pane['commerce_payment']['enabled'] = FALSE;
    }
  }
}
You're seeing them hidden on the admin page because you're making no differentiation here in your code that would restrict the checkout pane info altering to only occur on checkout pages for customers, not administrators.

I'm divided. I recently created a checkout experience with an optional checkout pane, and I ultimately decided to alter the form directly instead of altering the checkout pane info. Part of it was that desire to ensure I had an identical definition on the front end / back end for all customers, but I'm not sure it was strictly necessary.

If you do end up altering the form instead, you need to supply new custom validate / submit handlers for the conditional checkout panes that wrap their default handlers and only invoke them if the pane was actually presented on a checkout form.