=== modified file 'uc_cart/uc_cart.admin.inc'
--- uc_cart/uc_cart.admin.inc	2008-11-13 03:04:35 +0000
+++ uc_cart/uc_cart.admin.inc	2009-01-13 14:59:03 +0000
@@ -120,52 +120,61 @@
 
   $form['continue_shopping'] = array(
     '#type' => 'fieldset',
-    '#title' => t('Continue shopping link'),
+    '#title' => t('Continue shopping element'),
+    '#description' => t('Ubercart will add a continue shopping to the cart page based on the settings below.'),
     '#summary' => t('Continue shopping !type is: <br />!link', array('!type' => variable_get('uc_continue_shopping_type', 'link') == 'link' ? t('link') : t('button'), '!link' => l(variable_get('uc_continue_shopping_text', t('Continue shopping')), variable_get('uc_cart_continue_shopping', '')))),
   );
   $form['continue_shopping']['uc_continue_shopping_type'] = array(
     '#type' => 'radios',
-    '#title' => t('Display the continue shopping link as'),
+    '#title' => t('Continue shopping element display'),
     '#options' => array(
-      'link' => t('A text link'),
-      'button' => t('A button link'),
+      'link' => t('Text link'),
+      'button' => t('Button'),
+      'none' => t('None'),
     ),
     '#default_value' => variable_get('uc_continue_shopping_type', 'link'),
   );
+  $form['continue_shopping']['uc_continue_shopping_use_last_url'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Make the continue shopping link send customers back to product pages after adding items to the cart.'),
+    '#description' => t('If this is disabled, the URL specified below will always be used.'),
+    '#default_value' => variable_get('uc_continue_shopping_use_last_url', TRUE),
+  );
   $form['continue_shopping']['uc_continue_shopping_url'] = array(
     '#type' => 'textfield',
-    '#title' => t('Continue shopping link URL'),
-    '#description' => t('Enter the Drupal page for the link to continue shopping from the cart view page.<br />Enter &lt;none&gt; for no link to appear.'),
+    '#title' => t('Default continue shopping link URL'),
+    '#description' => t('Enter the Drupal page for the link to continue shopping from the cart view page.'),
     '#default_value' => variable_get('uc_continue_shopping_url', ''),
     '#size' => 32,
     '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
   );
   $form['continue_shopping']['uc_continue_shopping_text'] = array(
     '#type' => 'textfield',
-    '#title' => t('Continue shopping link text'),
-    '#description' => t('Enter the text for the continue shopping link.'),
-    '#default_value' => variable_get('uc_continue_shopping_text', t('Continue shopping')),
+    '#title' => t('Custom continue shopping link text'),
+    '#description' => t('Enter custom text for the continue shopping link.'),
+    '#default_value' => variable_get('uc_continue_shopping_text', ''),
   );
 
   $form['breadcrumb'] = array(
     '#type' => 'fieldset',
     '#title' => t('Cart breadcrumb'),
-    '#summary' => t('Default cart breadcrumb is: <br />!breadcrumb', array('!breadcrumb' => l(variable_get('uc_cart_breadcrumb_text', t('Home')), variable_get('uc_cart_breadcrumb_url', '')))),
+    '#description' => t('Drupal automatically adds a Home breadcrumb to the cart page.  You can use these settings to specify a custom breadcrumb to use on the cart page instead.  If a custom text is not supplied, the default Home breadcrumb will be displayed.'),
+    '#summary' => variable_get('uc_cart_breadcrumb_text', '') ? t('Custom cart breadcrumb is: <br />!breadcrumb', array('!breadcrumb' => l(variable_get('uc_cart_breadcrumb_text', ''), variable_get('uc_cart_breadcrumb_url', '')))) : t('Not using a custom cart breadcrumb.'),
+  );
+  $form['breadcrumb']['uc_cart_breadcrumb_text'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Custom cart breadcrumb text'),
+    '#description' => t('Enter the text for the custom breadcrumb on the cart page.'),
+    '#default_value' => variable_get('uc_cart_breadcrumb_text', ''),
   );
   $form['breadcrumb']['uc_cart_breadcrumb_url'] = array(
     '#type' => 'textfield',
-    '#title' => t('Default cart breadcrumb URL'),
-    '#description' => t('Enter the Drupal page linked to in the default breadcrumb on the cart view page.'),
+    '#title' => t('Custom cart breadcrumb URL'),
+    '#description' => t('Enter the Drupal page linked to in the custom breadcrumb on the cart view page.'),
     '#default_value' => variable_get('uc_cart_breadcrumb_url', ''),
     '#size' => 32,
     '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
   );
-  $form['breadcrumb']['uc_cart_breadcrumb_text'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Default cart breadcrumb text'),
-    '#description' => t('Enter the text for the default breadcrumb on the cart page.'),
-    '#default_value' => variable_get('uc_cart_breadcrumb_text', t('Home')),
-  );
 
   return system_settings_form($form);
 }

=== modified file 'uc_cart/uc_cart.module'
--- uc_cart/uc_cart.module	2008-12-31 13:50:42 +0000
+++ uc_cart/uc_cart.module	2009-01-13 16:16:49 +0000
@@ -672,30 +672,79 @@
 
   $form['items'] = uc_cart_view_table($form['items']);
 
-  if (($page = variable_get('uc_continue_shopping_url', '')) != '<none>' &&
-      variable_get('uc_continue_shopping_type', 'link') == 'button') {
-    $form['continue_shopping'] = array(
-      '#type' => 'submit',
-      '#submit' => array('uc_cart_view_form_continue_submit'),
-      '#value' => variable_get('uc_continue_shopping_text', t('Continue shopping')),
-    );
+  // If the continue shopping element is enabled...
+  if (($cs_type = variable_get('uc_continue_shopping_type', 'link')) !== 'none') {
+    // Setup the text used for the element.
+    $cs_text = variable_get('uc_continue_shopping_text', '') ? variable_get('uc_continue_shopping_text', '') : t('Continue shopping');
+
+    // Add the element to the form based on the element type.
+    if (variable_get('uc_continue_shopping_type', 'link') == 'link') {
+      $form['continue_shopping'] = array(
+        '#value' => l($cs_text, uc_cart_continue_shopping_url()),
+      );
+    }
+    elseif (variable_get('uc_continue_shopping_type', 'link') == 'button') {
+      $form['continue_shopping'] = array(
+        '#type' => 'submit',
+        '#value' => $cs_text,
+        '#submit' => array('uc_cart_view_form_submit'),
+      );
+      $form['continue_shopping_text'] = array(
+        '#type' => 'hidden',
+        '#value' => $cs_text,
+      );
+    }
   }
 
+  // Add the control buttons for updating and proceeding to checkout.
   $form['update'] = array(
     '#type' => 'submit',
-    '#submit' => array('uc_cart_view_form_update_submit'),
     '#value' => t('Update cart'),
+    '#submit' => array('uc_cart_view_form_submit'),
   );
   if (variable_get('uc_checkout_enabled', TRUE)) {
     $form['checkout'] = array(
       '#type' => 'submit',
       '#value' => t('Checkout'),
+      '#submit' => array('uc_cart_view_form_submit'),
     );
   }
 
   return $form;
 }
 
+function uc_cart_view_form_submit($form, &$form_state) {
+  // Remove the cart order variable if the customer came here during checkout.
+  if (isset($_SESSION['cart_order'])) {
+    unset($_SESSION['cart_order']);
+  }
+
+  // TODO: Review use of cache_clear_all().  Empties temporary cached pages.
+  cache_clear_all();
+
+  // Update the items in the shopping cart based on the form values.
+  uc_cart_update_item_object((object)$form_state['values']);
+
+  // Specify the appropriate redirect based on the button used to submit.
+  switch ($form_state['values']['op']) {
+    // Continue shopping button.
+    case $form_state['values']['continue_shopping_text']:
+      $form_state['redirect'] = uc_cart_continue_shopping_url();
+      break;
+
+    // Update cart button.
+    case t('Update cart'):
+      // No redirect.  Just display a message and preserve the last URL.
+      drupal_set_message(t('Your cart has been updated.'));
+      break;
+
+    // Checkout button.
+    case t('Checkout'):
+      $form_state['redirect'] = variable_get('uc_checkout_enabled', TRUE) ? 'cart/checkout' : 'cart';
+      break;
+  }
+}
+
 function theme_uc_cart_view_form($form) {
   drupal_add_css(drupal_get_path('module', 'uc_cart') .'/uc_cart.css');
 
@@ -709,17 +758,20 @@
     $form['items'][$i]['#printed'] = TRUE;
   }
 
-  if (($page = variable_get('uc_continue_shopping_url', '')) != '<none>') {
-    if (variable_get('uc_continue_shopping_type', 'link') == 'link') {
+  // Add the continue shopping element and cart submit buttons.
+  if (($type = variable_get('uc_continue_shopping_type', 'link')) != 'none') {
+    // Render the continue shopping element into a variable.
+    $cs_element = drupal_render($form['continue_shopping']);
+
+    // Add the element with the appropriate markup based on the display type.
+    if ($type == 'link') {
       $output .= '<div id="cart-form-buttons"><div id="continue-shopping-link">'
-               . l(variable_get('uc_continue_shopping_text', t('Continue shopping')), $page) .'</div>'
-               . drupal_render($form) .'</div>';
+               . $cs_element .'</div>'. drupal_render($form) .'</div>';
     }
-    else {
-      $button = drupal_render($form['continue_shopping']);
+    elseif ($type == 'button') {
       $output .= '<div id="cart-form-buttons"><div id="update-checkout-buttons">'
                . drupal_render($form) .'</div><div id="continue-shopping-button">'
-               . $button .'</div></div>';
+               . $cs_element .'</div></div>';
     }
   }
   else {
@@ -784,45 +836,41 @@
   return $table;
 }
 
-function uc_cart_view_form_continue_submit($form, &$form_state) {
-  // Instead of using $_SESSION, can we use $form_state?
-  if (isset($_SESSION['cart_order'])) {
-    unset($_SESSION['cart_order']);
-  }
-
-  $form_state['redirect'] = variable_get('uc_continue_shopping_url', '');
-}
-
-function uc_cart_view_form_update_submit($form, &$form_state) {
-  // Instead of using $_SESSION, can we use $form_state?
-  if (isset($_SESSION['cart_order'])) {
-    unset($_SESSION['cart_order']);
-  }
-
-  cache_clear_all();
-  uc_cart_update_item_object((object)$form_state['values']);
-  drupal_set_message(t('Your cart has been updated.'));
-  $form_state['redirect'] = 'cart';
-}
-
-function uc_cart_view_form_submit($form, &$form_state) {
-  // Instead of using $_SESSION, can we use $form_state?
-  if (isset($_SESSION['cart_order'])) {
-    unset($_SESSION['cart_order']);
-  }
-
-  cache_clear_all();
-  if (!variable_get('uc_checkout_enabled', TRUE)) {
-    $form_state['redirect'] = 'cart';
-  }
-  uc_cart_update_item_object((object)$form_state['values']);
-  $form_state['redirect'] = 'cart/checkout';
-}
 
 /*******************************************************************************
  * Module and Helper Functions
  ******************************************************************************/
 
+
+/**
+ * Returns the URL redirect for the continue shopping element on the cart page.
+ *
+ * @param $unset
+ *   TRUE or FALSE indicating whether or not to unset the last URL variable.
+ * @return
+ *   The URL or Drupal path that will be used for the continue shopping element.
+ */
+function uc_cart_continue_shopping_url($unset = TRUE) {
+  $url = '';
+
+  // Use the last URL if enabled and available.
+  if (variable_get('uc_continue_shopping_use_last_url', TRUE)) {
+    $url = $_SESSION['uc_cart_last_url'];
+  }
+
+  // If the URL is still empty, fall back to the default.
+  if (empty($url)) {
+    $url = variable_get('uc_continue_shopping_url', '');
+  }
+
+  // Unset the last URL if specified.
+  if ($unset) {
+    unset($_SESSION['uc_cart_last_url']);
+  }
+
+  return $url;
+}
+
 /**
  * Completes a sale, including adjusting order status and creating user account.
  *
@@ -1044,7 +1092,7 @@
             }
             $redirect = variable_get('uc_add_item_redirect', 'cart');
             if ($redirect != '<none>') {
-              $_SESSION['last_url'] = uc_referer_uri();
+              $_SESSION['uc_cart_last_url'] = uc_referer_uri();
               return $redirect;
             }
             else {
@@ -1087,7 +1135,7 @@
 
     $redirect = variable_get('uc_add_item_redirect', 'cart');
     if ($redirect != '<none>') {
-      $_SESSION['last_url'] = uc_referer_uri();
+      $_SESSION['uc_cart_last_url'] = uc_referer_uri();
       return $redirect;
     }
     else {

=== modified file 'uc_cart/uc_cart.pages.inc'
--- uc_cart/uc_cart.pages.inc	2008-11-06 15:00:37 +0000
+++ uc_cart/uc_cart.pages.inc	2009-01-13 14:44:35 +0000
@@ -11,36 +11,36 @@
 function uc_cart_view() {
   // Failsafe so that this function only works when called with no arguments.
   // This prevents the accidental wiping of the cart_order session variable.
-  if ((func_num_args() > 0)) {
+  if (func_num_args() > 0) {
     return drupal_not_found();
   }
 
+  // Clear the cart order session variable if it exists.
   if (!empty($_SESSION['cart_order'])) {
     unset($_SESSION['cart_order']);
   }
 
+  // Load the array of shopping cart items.
   $items = uc_cart_get_contents();
 
+  // Display the empty cart page if there are no items in the cart.
   if (empty($items)) {
     return theme('uc_empty_cart');
   }
 
-  $panes = uc_cart_cart_pane_list($items);
-  foreach ($panes as $pane) {
+  // Load through the cart panes...
+  foreach (uc_cart_cart_pane_list($items) as $pane) {
+    // If the pane is enabled...
     if ($pane['enabled']) {
+      // Add its output to the cart view.
       $output .= $pane['body'];
     }
   }
 
-  if (isset($_SESSION['last_url'])) {
-    drupal_set_breadcrumb(array(l(t('Back'), check_plain($_SESSION['last_url']))));
-    unset($_SESSION['last_url']);
-  }
-  else {
-    if (($text = variable_get('uc_cart_breadcrumb_text', t('Home'))) !== '') {
-      $link = l($text, variable_get('uc_cart_breadcrumb_url', '<front>'));
-      drupal_set_breadcrumb(array($link));
-    }
+  // Add a custom cart breadcrumb if specified.
+  if (($text = variable_get('uc_cart_breadcrumb_text', '')) !== '') {
+    $link = l($text, variable_get('uc_cart_breadcrumb_url', '<front>'));
+    drupal_set_breadcrumb(array($link));
   }
 
   return $output;

