The text in the customer checkout pane presented to anonymous users reads as follows:

"Enter a valid email address for this order or click here to login with an existing account and return to checkout."

This is a lie; the token "!url" is a simple "user/login" link, and does not return the user to the checkout after they have logged in. In order to return the user to the checkout, the link needs a query string of "destination=cart/checkout" - which can be derived using the drupal_get_destination() function. To be precise, the array('!url' => url('user/login')) argument in the t() function should be changed to array('!url' => url('user/login', array('query' => drupal_get_destination()))).

Find attached a patch that .... does ... this thing. Above. Yeah.

CommentFileSizeAuthor
#2 975394.patch1.72 KBtr
uc_cart_checkout_pane.inc_.txt811 byteskingandy

Comments

tomw’s picture

Thanks for supplying the patch, worked great.
Would be great to get this fix into the next release of ubercart.

tr’s picture

Version: 6.x-2.4 » 6.x-2.x-dev
Status: Needs review » Fixed
StatusFileSize
new1.72 KB

Attached is the patch as committed.

longwave’s picture

Status: Fixed » Needs work

Reopening, because I think most of this code can be removed as well:

/**
 * Implementation of hook_form_alter().
 */
function uc_cart_form_alter(&$form, $form_state, $form_id) {
  global $language;

  // 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') {

    // Figure out the destination.
    if (empty($_SESSION['checkout-redirect'])) {
      // Compare the referer to checkout page URLs.
      if (uc_referer_check('cart/checkout') && uc_referer_uri() != '') {
        $_SESSION['checkout-redirect'] = TRUE;
      }
      elseif (uc_referer_check(array('cart/checkout/review', 'cart/checkout/complete')) && uc_referer_uri() != '') {
        unset($_SESSION['checkout-redirect']);
      }
    }

    if (!empty($_SESSION['checkout-redirect'])) {
      $form['#redirect'] = 'cart/checkout';
    }
  }

  if ($form_id == 'user_login' || $form_id == 'user_login_block') {
    $form['#submit'] = array_merge(array('uc_cart_user_login_form_submit'), (array) $form['#submit']);
  }
}

The last three lines handle merging carts when a user logs in (although hook_user also has code for this?) but the first part seems useless now.

longwave’s picture

The patch in #2 also needs porting to 7.x.

longwave’s picture

Status: Needs work » Fixed

The code I quoted in #3 dates back to D5! I removed it, and also fixed the use of drupal_get_destination() when forcing users to log in before going to checkout, in both 6.x and 7.x branches.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.