You are here

function commerce_paypal_checkout_commerce_checkout_router in Commerce PayPal 7.2

Implements hook_commerce_checkout_router().

File

modules/checkout/commerce_paypal_checkout.module, line 183
Implements PayPal Checkout in Drupal Commerce checkout.

Code

function commerce_paypal_checkout_commerce_checkout_router($order, $checkout_page) {

  // If the current page is the PayPal Checkout page but the current order did
  // not use the shortcut Checkout flow...
  if ($checkout_page['page_id'] == 'paypal_checkout' && (empty($order->data['commerce_paypal_checkout']['flow']) || $order->data['commerce_paypal_checkout']['flow'] != 'shortcut')) {

    // Update the order status to the next checkout page.
    $next_page = $checkout_page['next_page'];
    $order = commerce_order_status_update($order, 'checkout_' . $next_page, FALSE, FALSE);

    // Inform modules of checkout completion if the next page is Completed.
    if ($next_page == 'complete') {
      commerce_checkout_complete($order);
    }

    // Redirect to the URL for the new checkout page.
    $target_uri = commerce_checkout_order_uri($order);
    return drupal_goto($target_uri);
  }
}