You are here

function uc_cart_form_alter in Ubercart 5

Same name and namespace in other branches
  1. 6.2 uc_cart/uc_cart.module \uc_cart_form_alter()

Implementation of hook_form_alter().

File

uc_cart/uc_cart.module, line 441

Code

function uc_cart_form_alter($form_id, &$form) {

  // Redirect shopper back to checkout page if they go to login from there.
  if ($form_id == 'user_login' || $form_id == 'user_edit' || $form_id == 'user_register') {
    if ($_SESSION['checkout-redirect'] == TRUE) {
      $form['#action'] = url($_GET['q'], "destination=cart/checkout");
    }
    else {

      // Compare the referer to checkout page URLs.
      if (uc_referer_check('cart/checkout') && uc_referer_uri() != '') {
        $form['#action'] = url($_GET['q'], "destination=cart/checkout");
      }
      elseif (uc_referer_check(array(
        'cart/checkout/review',
        'cart/checkout/complete',
      )) && uc_referer_uri() != '') {
        $form['#action'] = url($_GET['q'], "destination=user");
      }
    }
  }
  if ($form_id == 'user_login' || $form_id == 'user_login_block') {
    $form['#submit'] = array_merge(array(
      'uc_cart_user_login_form_submit' => array(),
    ), (array) $form['#submit']);
  }
}