I have tried to disable the Billing information checkout pane from UI or in a custom module with 2 ways

function mymodule_commerce_checkout_pane_info_alter(&$checkout_pane) {
    global $user;
    foreach ($checkout_pane as $pane_name => & $pane_data) {
        if ($pane_name == 'customer_profile_billing') {
            $order = commerce_cart_order_load($user->uid);
            if ($user->uid > 0) {
                    unset($checkout_pane['customer_profile_billing']);
}}}}
function mymodule_commerce_checkout_pane_info_alter(&$checkout_pane) {
    global $user;  
    foreach ($checkout_pane as $pane_name => & $pane_data) {
        if ($pane_name == 'customer_profile_billing') {
            $order = commerce_cart_order_load($user->uid);
            if (!empty($order->data)) {
                    unset($checkout_pane['customer_profile_billing']);
}}}}

none of them seems to work as the user still must press the 'continue to next step' button
(I have set not required the address field in admin/commerce/customer-profiles/types/billing/fields/commerce_customer_address )

any ideas what else should I try?

Comments

redhatusr created an issue. See original summary.

rszrama’s picture

Status: Active » Closed (works as designed)

Sounds to me like you're confusing issues - unsetting a checkout pane is different from disabling a checkout page. In reality, if you are wanting to skip a checkout page, I recommend hooking into the checkout router, not attempting to unset checkout panes.

redhatusr’s picture

rszrama thanks for your reply. I have searched the internet for examples about checkout router and I think there are only 4, all of them seem to work like this:

function mymodule_commerce_checkout_router($order, $checkout_page) {
  if ($checkout_page['page_id'] == 'customer_profile_billing') {

    // shows nothing
    dpm($order); 

  }
}
function mymodule_commerce_checkout_router($order, $checkout_page) {
  if ($checkout_page['page_id'] == 'customer_profile_billing') {

    // does nothing
    $order = commerce_order_status_update($order, 'checkout_' . $checkout_page['next_page'], FALSE, TRUE, t('Billing Page was skipped'));
    drupal_goto('checkout/' . $order->order_id . '/' . $checkout_page['next_page']);

  }
}

but the above code does nothing to my site. I have run out of examples. Can you give me a hint about what to search for?

thanks

yaach’s picture

Any update on this.

I also have the need to disable a checkout page (in my case is the registration page). I have different product types, some of them do not require registration.