Currently the code is as follows

    $checkout_pages = module_invoke_all('commerce_checkout_page_info');
    drupal_alter('commerce_checkout_page_info', $checkout_pages);

    $count = 0;
    foreach ($checkout_pages as $page_id => $checkout_page) {
      $defaults = array(
        'page_id' => $page_id,
        'name' => $checkout_page['title'],
        'title' => '',
        'help' => '',
        'status_cart' => TRUE,
        'buttons' => TRUE,
        'back_value' => t('Go back'),
        'submit_value' => t('Continue to next step'),
        'prev_page' => NULL,
        'next_page' => NULL,
      );

      $checkout_pages[$page_id] += $defaults;

      // Set a weight that preserves the order of 0 weighted pages.
      if (empty($checkout_page['weight'])) {
        $checkout_pages[$page_id]['weight'] = $count++ / count($checkout_pages);
      }
    }

A problem occurs that when commerce_checkout_pages() is called from within a hook implementation that's triggered by the drupal_alter call. A solution is to move the call to drupal_alter right after the for-loop.

Comments

cvangysel’s picture

Status: Active » Needs review
StatusFileSize
new848 bytes

Patch.

JulienD’s picture

Status: Needs review » Reviewed & tested by the community

Nice catch @cvangysel, It's perfectly make sens to run drupal_alter() after the default implementation.

The patch is working fine.

rszrama’s picture

Category: bug » task

I'll need to cross-reference the change with our notes in #1357376: Resolve order of info alter hooks in relation to UI settings. Previously we had decided to table this change until Commerce 2.x.

rszrama’s picture

Status: Reviewed & tested by the community » Closed (duplicate)

As this patch turned out to be unnecessary for the Express Checkout integration, I'm going to mark it as a duplicate of the other and make a note in there that the same discussion applies to checkout page alteration. In the case of PayPal EC, I actually changed the module to alter the checkout router as opposed to simply trying to alter checkout pages to make the multiple checkout flows work.

rszrama’s picture

Issue summary: View changes

spell check