You are here

function uc_cart_checkout_complete in Ubercart 7.3

Same name and namespace in other branches
  1. 5 uc_cart/uc_cart.module \uc_cart_checkout_complete()
  2. 6.2 uc_cart/uc_cart.pages.inc \uc_cart_checkout_complete()

Completes the sale and finishes checkout.

1 string reference to 'uc_cart_checkout_complete'
uc_cart_menu in uc_cart/uc_cart.module
Implements hook_menu().

File

uc_cart/uc_cart.pages.inc, line 594
Cart menu items.

Code

function uc_cart_checkout_complete() {
  if (empty($_SESSION['cart_order']) || empty($_SESSION['uc_checkout'][$_SESSION['cart_order']]['do_complete'])) {
    drupal_goto('cart');
  }
  $order = uc_order_load(intval($_SESSION['cart_order']));
  if (empty($order)) {

    // Display messages to customers and the administrator if the order was lost.
    drupal_set_message(t("We're sorry.  An error occurred while processing your order that prevents us from completing it at this time. Please contact us and we will resolve the issue as soon as possible."), 'error');
    watchdog('uc_cart', 'An empty order made it to checkout! Cart order ID: @cart_order', array(
      '@cart_order' => $_SESSION['cart_order'],
    ), WATCHDOG_ERROR);
    drupal_goto('cart');
  }
  $build = uc_cart_complete_sale($order, variable_get('uc_new_customer_login', FALSE));
  unset($_SESSION['uc_checkout'][$order->order_id], $_SESSION['cart_order']);

  // Add a comment to let sales team know this came in through the site.
  uc_order_comment_save($order->order_id, 0, t('Order created through website.'), 'admin');
  $page = variable_get('uc_cart_checkout_complete_page', '');
  if (!empty($page)) {
    drupal_goto($page);
  }
  return $build;
}