diff --git a/sites/all/modules/commerce_wishlist/commerce_wishlist.admin.inc b/sites/all/modules/commerce_wishlist/commerce_wishlist.admin.inc
index a4783ed..9579596 100644
--- a/sites/all/modules/commerce_wishlist/commerce_wishlist.admin.inc
+++ b/sites/all/modules/commerce_wishlist/commerce_wishlist.admin.inc
@@ -19,10 +19,33 @@ function commerce_wishlist_admin_form($form, &$form_state) {
   $form['commerce_wishlist_element'] = array(
     '#type' => 'select',
     '#title' => t('"Add to wishlist" element'),
-    '#options' => array('link' => t('Ajax link'), 'button' => t('Button')),
+    '#options' => array('link' => t('Link'), 'button' => t('Button')),
     '#description' => t('The way "Add to wishlist" element will be displayed. Either as a button or link.'),
     '#default_value' => variable_get('commerce_wishlist_element', 'button'),
   );
+  $form['commerce_wishlist_use_ajax'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Use Ajax'),
+    '#description' => t('Use ajax for add/remove from wishlist.'),
+    '#default_value' => variable_get('commerce_wishlist_use_ajax', 0),
+    '#states' => array(
+      'visible' => array(
+        ':input[name="commerce_wishlist_element"]' => array('value' => 'link'),
+      ),
+    ),
+  );
+  $form['commerce_wishlist_show_login'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Display "Add to Wishlist" for anonymous users'),
+    '#description' => t('This will display the "Add to Wishlist" for anonymous, but will show a "Login Required" message if not proper permissions are set.'),
+    '#default_value' => variable_get('commerce_wishlist_show_login', 0),
+  );
+  $form['commerce_wishlist_show_remove'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Show "Remove from Wishlist"'),
+    '#description' => t('Show the Remove from Wishlist, instead of already in wishlist'),
+    '#default_value' => variable_get('commerce_wishlist_show_remove', 0),
+  );
   $form['commerce_wishlist_product_types'] = array(
     '#type' => 'checkboxes',
     '#title' => t('Product types'),
diff --git a/sites/all/modules/commerce_wishlist/commerce_wishlist.module b/sites/all/modules/commerce_wishlist/commerce_wishlist.module
index f18d842..10da63f 100644
--- a/sites/all/modules/commerce_wishlist/commerce_wishlist.module
+++ b/sites/all/modules/commerce_wishlist/commerce_wishlist.module
@@ -1,3 +1,5 @@
+<!--  if (!empty($form_state['uid'])) {-->
+<!--    $url = 'wishlist/nojs/add/' . $_GET['product_id'];-->
 <?php
 
 /**
@@ -23,32 +25,28 @@ define('COMMERCE_WISHLIST_VISIBILITY_PUBLIC', 2);
 function commerce_wishlist_menu() {
   $items = array();
 
-  $items['user/%user/wishlist/nojs/remove/%commerce_line_item'] = array(
+  $items['wishlist/nojs/remove/%commerce_product'] = array(
     'page callback' => 'commerce_wishlist_product_remove_page',
-    'page arguments' => array(5, 1),
-    'access callback' => 'commerce_wishlist_user_access',
-    'access arguments' => array(1, 'update'),
+    'page arguments' => array(3),
+    'access arguments' => array('manage own wish list'),
     'type' => MENU_CALLBACK,
   );
-  $items['user/%user/wishlist/ajax/remove/%commerce_line_item'] = array(
+  $items['wishlist/ajax/remove/%commerce_product'] = array(
     'page callback' => 'commerce_wishlist_product_remove_ajax',
-    'page arguments' => array(5, 1),
-    'access callback' => 'commerce_wishlist_user_access',
-    'access arguments' => array(1, 'update'),
+    'page arguments' => array(3),
+    'access arguments' => array('manage own wish list'),
     'type' => MENU_CALLBACK,
   );
-  $items['user/%user/wishlist/nojs/add/%commerce_product'] = array(
+  $items['wishlist/nojs/add/%commerce_product'] = array(
     'page callback' => 'commerce_wishlist_product_add_page',
-    'page arguments' => array(5, 1),
-    'access callback' => 'commerce_wishlist_user_access',
-    'access arguments' => array(1, 'update'),
+    'page arguments' => array(3),
+    'access arguments' => array('manage own wish list'),
     'type' => MENU_CALLBACK,
   );
-  $items['user/%user/wishlist/ajax/add/%commerce_product'] = array(
+  $items['wishlist/ajax/add/%commerce_product'] = array(
     'page callback' => 'commerce_wishlist_product_add_ajax',
-    'page arguments' => array(5, 1),
-    'access callback' => 'commerce_wishlist_user_access',
-    'access arguments' => array(1, 'update'),
+    'page arguments' => array(3),
+    'access arguments' => array('manage own wish list'),
     'type' => MENU_CALLBACK,
   );
   $items['user/%user/wishlist'] = array(
@@ -82,6 +80,11 @@ function commerce_wishlist_menu() {
     'access arguments' => array('access content'),
   );
 
+  $items['wishlist'] = array(
+    'title' => 'Wishlist',
+    'page callback' => 'commerce_wishlist_view',
+    'access arguments' => array('manage own wish list'),
+  );
   return $items;
 }
 
@@ -183,6 +186,24 @@ function commerce_wishlist_is_public($wishlist) {
   return FALSE;
 }
 
+function commerce_wishlist_view() {
+  global $user;
+  // Default to displaying an empty message.
+  $content = theme('commerce_wishlist_empty_page');
+
+  // First check to make sure we have a valid order.
+  if ($order = commerce_wishlist_order_load($user->uid)) {
+    $wrapper = entity_metadata_wrapper('commerce_order', $order);
+    // Only show the wishlist form if we found product line items.
+    if (commerce_line_items_quantity($wrapper->commerce_line_items, commerce_product_line_item_types()) > 0) {
+
+      // Add the form for editing the cart contents.
+      $content = commerce_embed_view('wishlist', 'default', array($order->order_id), 'wishlist');
+    }
+  }
+  return $content;
+}
+
 /**
  * Implements hook_permission().
  */
@@ -233,6 +254,9 @@ function commerce_wishlist_theme($existing, $type, $theme, $path) {
     'commerce_wishlist_product_add_link' => array(
       'variables' => array('product_id' => NULL, 'user' => NULL),
     ),
+    'commerce_wishlist_remove_from_wishlist_link' => array(
+      'variables' => array('line_item_id' => NULL, 'text' => t('Remove'), 'destination' => ''),
+    ),
     'commerce_wishlist_already_in_wishlist_link' => array(
       'variables' => array('user_id' => NULL),
     ),
@@ -256,6 +280,9 @@ function commerce_wishlist_theme($existing, $type, $theme, $path) {
         'account' => NULL,
       ),
     ),
+    'commerce_wishlist_empty_page' => array(
+      'variables' => array(),
+    ),
   );
 }
 
@@ -278,7 +305,8 @@ function commerce_wishlist_form_alter(&$form, &$form_state, $form_id) {
     }
 
     // Make sure that this product is allowed.
-    if (!in_array($form_state['default_product']->type, array_filter(variable_get('commerce_wishlist_product_types', array())))) {
+    $allowed_types = array_filter(variable_get('commerce_wishlist_product_types', array()));
+    if (!empty($allowed_types) && (!in_array($form_state['default_product']->type, $allowed_types))) {
       return;
     }
 
@@ -297,27 +325,40 @@ function commerce_wishlist_form_alter(&$form, &$form_state, $form_id) {
       }
       return;
     }
-
-    // If it's already in the wishlist, show the already in wishlist link.
-    // Otherwise, show the button or link as configured.
-    if (commerce_wishlist_user_has_product_in_wishlist($product_id)) {
-      $form['add_to_wishlist'] = array(
-        '#markup' => theme('commerce_wishlist_already_in_wishlist_link', array('user_id' => $user->uid)),
-        '#weight' => variable_get('commerce_wishlist_weight', 0),
-      );
-    }
-    elseif (variable_get('commerce_wishlist_element', 'button') == 'button') {
-      $form += commerce_wishlist_add_form();
-    }
-    else {
-      // Add the "Add to wishlist" link to the form.
-      $form['add_to_wishlist'] = array(
-        '#markup' => theme('commerce_wishlist_product_add_link', array('product_id' => $product_id, 'user' => $user)),
-        '#weight' => variable_get('commerce_wishlist_weight', 0),
-      );
+    //show the wishlist widget if you have permission or show for anonymous with login functionality
+
+    if (user_access('manage own wish list') || (($user->uid == 0) && variable_get('commerce_wishlist_show_login', 0))) {
+      // If it's already in the wishlist, show the already in wishlist link.
+      //Otherwise, show the button or link as configured.
+      if (commerce_wishlist_user_has_product_in_wishlist($product_id)) {
+        if (variable_get('commerce_wishlist_show_remove', 0)) {
+          if (variable_get('commerce_wishlist_element', 'button') == 'button') {
+            $form += commerce_wishlist_remove_form();
+          } else {
+            $form['add_to_wishlist'] = array(
+              '#markup' => theme('commerce_wishlist_remove_from_wishlist_link', array('product_id' => $product_id)),
+              '#weight' => variable_get('commerce_wishlist_weight', 0),
+            );
+          }
+        } else {
+          $form['add_to_wishlist'] = array(
+            '#markup' => theme('commerce_wishlist_already_in_wishlist_link', array('user_id' => $user->uid)),
+            '#weight' => variable_get('commerce_wishlist_weight', 0),
+          );
+        }
+      } elseif (variable_get('commerce_wishlist_element', 'button') == 'button') {
+        $form += commerce_wishlist_add_form();
+      } else {
+        // Add the "Add to wishlist" link to the form.
+        $form['add_to_wishlist'] = array(
+          '#markup' => theme('commerce_wishlist_product_add_link', array('product_id' => $product_id, 'user' => $user)),
+          '#weight' => variable_get('commerce_wishlist_weight', 0),
+        );
+      }
     }
   }
 
+
   if ($form_id == 'user_login' && !empty($_GET['wishlist_product'])) {
     $_SESSION['commerce_wishlist']['product_id'] = check_plain($_GET['wishlist_product']);
   }
@@ -423,7 +464,8 @@ function commerce_wishlist_block_view($delta = '') {
 /**
  * Form callback: Wishlist sharing.
  */
-function commerce_wishlist_share($form, &$form_state, $wishlist) {
+function commerce_wishlist_share($form, &$form_state, $wishlist)
+{
   $form_state['wishlist'] = $wishlist;
 
   $state = empty($wishlist->commerce_wishlist_visibility[LANGUAGE_NONE][0]['value']) ? 0 : $wishlist->commerce_wishlist_visibility[LANGUAGE_NONE][0]['value'];;
@@ -474,807 +516,1098 @@ function commerce_wishlist_share($form, &$form_state, $wishlist) {
     '#value' => t('Save'),
   );
 
-  return $form;
-}
-
-/**
- * Submit handler: sharing options.
- */
-function commerce_wishlist_share_submit($form, &$form_state) {
-  $wishlist = &$form_state['wishlist'];
-
-  $previous_state = $wishlist->commerce_wishlist_visibility[LANGUAGE_NONE][0]['value'];
-  field_attach_submit('commerce_order', $wishlist, $form, $form_state);
-  $new_state = $wishlist->commerce_wishlist_visibility[LANGUAGE_NONE][0]['value'];
-
-  // If the state has changed, we need to update the URL.
-  if ($previous_state != $new_state) {
-    switch ($new_state) {
-      // Private visibility. Note that we're not removing the "Protected" if the
-      // visibility transitions to public, since we wouldn't want to break it.
-      case COMMERCE_WISHLIST_VISIBILITY_PRIVATE:
-        // Remove the existing wishlist URL.
-        commerce_wishlist_remove_wishlist_url($wishlist);
-        break;
-
-      case COMMERCE_WISHLIST_VISIBILITY_PROTECTED:
-        // Create or replace the existing URL.
-        commerce_wishlist_add_wishlist_url($wishlist);
-
-    }
+  function commerce_wishlist_remove_form()
+  {
+    $form['remove_from_wishlist'] = array(
+      '#type' => 'submit',
+      '#value' => t('Remove'),
+      '#weight' => variable_get('commerce_wishlist_weight', 0),
+      '#name' => 'commerce-wishlist-remove-product',
+      '#attributes' => array('class' => array('commerce-wishlist')),
+      '#validate' => array('commerce_wishlist_remove_form_validate'),
+      '#submit' => array('commerce_wishlist_remove_form_submit'),
+    );
+    return $form;
   }
 
-  commerce_order_save($form_state['wishlist']);
-}
-
-/**
- * Already in cart link theme callback.
- */
-function theme_commerce_wishlist_already_in_wishlist_link(&$variables) {
-  return t('Already in <a class="in-wishlist" href="@url">your wish list</a>.', array(
-    '@url' => url('user/' . $variables['user_id'] . '/wishlist'),
-  ));
-}
+  /**
+   * Submit handler: sharing options.
+   */
+  function commerce_wishlist_share_submit($form, &$form_state)
+  {
+    $wishlist = &$form_state['wishlist'];
+
+    $previous_state = $wishlist->commerce_wishlist_visibility[LANGUAGE_NONE][0]['value'];
+    field_attach_submit('commerce_order', $wishlist, $form, $form_state);
+    $new_state = $wishlist->commerce_wishlist_visibility[LANGUAGE_NONE][0]['value'];
+
+    // If the state has changed, we need to update the URL.
+    if ($previous_state != $new_state) {
+      switch ($new_state) {
+        // Private visibility. Note that we're not removing the "Protected" if the
+        // visibility transitions to public, since we wouldn't want to break it.
+        case COMMERCE_WISHLIST_VISIBILITY_PRIVATE:
+          // Remove the existing wishlist URL.
+          commerce_wishlist_remove_wishlist_url($wishlist);
+          break;
+
+        case COMMERCE_WISHLIST_VISIBILITY_PROTECTED:
+          // Create or replace the existing URL.
+          commerce_wishlist_add_wishlist_url($wishlist);
 
-/**
- * Added to cart link theme callback.
- */
-function theme_commerce_wishlist_added_to_wishlist_link(&$variables) {
-  return t('Added to <a class="in-wishlist" href="@url">your wish list</a>.', array(
-    '@title' => $variables['product']->title,
-    '@url' => url('user/' . $variables['user_id'] . '/wishlist'),
-  ));
-}
-
-/**
- * Add to wishlist theme callback.
- */
-function theme_commerce_wishlist_product_add_link($variables) {
-  $user = $variables['user'];
-  $product_id = $variables['product_id'];
-
-  $url = 'user/' . $user->uid . '/wishlist/nojs/add/' . $product_id;
-  $params = array(
-    'attributes' => array(
-      'class' => array('ajax' => 'use-ajax', 'add-to-wishlist'),
-      'id' => 'add-wishlist-' . $product_id,
-    ),
-    'query' => array(
-      'destination' => $_GET['q'],
-      'token' => drupal_get_token(),
-    ),
-  );
+      }
+    }
 
-  // If the current user is not logged in, build a different link that
-  // points to the login page and lists all other relevant details
-  // (product ID, node ID and original URL) in query string.
-  if ($user->uid == 0) {
-    unset($params['attributes']['class']['ajax'], $params['query']);
-    $params['query']['wishlist_product'] = $product_id;
-    $params['query']['destination'] = $_GET['q'];
-    $url = 'user/login';
+    commerce_order_save($form_state['wishlist']);
   }
-  return l(t('Add to Wishlist'), $url, $params);
-}
 
-/**
- * Theme callback for page title on user's wishlist page.
- *
- * The reason this is created as a separate themeable function is that depending
- * on the site configuration and the way user profiles are set, it would make
- * more sense to use user's first or first + last names, or even full name saved
- * in commerce customer profile. This way even themes can override the output.
- */
-function theme_commerce_wishlist_user_wishlist_page_title(&$variables) {
-  global $user;
-  if ($user->uid == $variables['account']->uid) {
-    return t('My Wish list');
+  /**
+   * Already in cart link theme callback.
+   */
+  function theme_commerce_wishlist_already_in_wishlist_link(&$variables)
+  {
+    return t('Already in <a class="in-wishlist" href="@url">your wish list</a>.', array(
+      '@url' => url('wishlist'),
+    ));
   }
-  return t("@name's Wish list", array('@name' => $variables['account']->name));
-}
 
-/**
- * Determine whether the user has a privilege to manage a wish list.
- *
- * @param object $account
- *   The account whose wishlist will be affected by some action. (e.g. viewed or
- *   updated).
- * @param string $operation
- *   One of "view" or "update" based on the action.
- * @param object|null $wishlist
- *   The wishlist to be affected. If the param is null, the default wishlist for
- *   a user will be loaded.
- *
- * @return bool
- *   TRUE if allowed, FALSE if not.
- */
-function commerce_wishlist_user_access($account, $operation, $wishlist = NULL) {
-  global $user;
-  // Allow administrators to edit any wishlist on the site.
-  if (user_access('administer wish lists')) {
-    return TRUE;
+  /**
+   * Added to cart link theme callback.
+   */
+  function theme_commerce_wishlist_added_to_wishlist_link(&$variables)
+  {
+    return t('Added to <a class="in-wishlist" href="@url">your wish list</a>.', array(
+      '@title' => $variables['product']->title,
+      '@url' => url('user/' . $variables['user_id'] . '/wishlist'),
+    ));
   }
 
-  // Before we perform checks on view/update operations, we will load the
-  // default wishlist order for the user account, if there is none provided.
-  // This will be the case on "/user/%user/wishlist" page.
-  if (!is_object($wishlist)) {
-    $wishlist = commerce_wishlist_order_load($account->uid);
-    if (!$wishlist) {
-      return user_access('manage any wish list');
+  /**
+   * Add to wishlist theme callback.
+   */
+  function theme_commerce_wishlist_product_add_link($variables)
+  {
+    $user = $variables['user'];
+    $product_id = $variables['product_id'];
+    if (variable_get('commerce_wishlist_use_ajax', 0)) {
+      drupal_add_library('system', 'drupal.ajax');
+      $url = 'wishlist/ajax/add/' . $product_id;
+      $params = array(
+        'attributes' => array(
+          'class' => array('ajax' => 'use-ajax', 'add-to-wishlist'),
+          'id' => 'add-wishlist-' . $product_id,
+        ),
+      );
+    } else {
+      $url = 'wishlist/nojs/add/' . $product_id;
+      $params = array(
+        'attributes' => array(
+          'id' => 'add-wishlist-' . $product_id,
+        ),
+        'query' => array(
+          'destination' => $_GET['q'],
+        ),
+      );
     }
-  }
 
-  // Users can always view their own wish list. Or, a user can view any wish
-  // list if they have the correct permission.
-  if ($operation == 'view') {
-    if ((!empty($wishlist->uid) && $account->uid == $wishlist->uid) || (empty($wishlist) && $account->uid == $user->uid) || user_access('view any wish list', $user) || user_access('administer wish lists', $user) || commerce_wishlist_is_public($wishlist)) {
-      return TRUE;
+    // If the current user is not logged in, build a different link that
+    // points to the login page and lists all other relevant details
+    // (product ID, node ID and original URL) in query string.
+    if (($user->uid == 0) && variable_get('commerce_wishlist_show_login', 0)) {
+      unset($params['attributes']['class']['ajax'], $params['query']);
+      $params['query']['wishlist_product'] = $product_id;
+      $params['query']['destination'] = $_GET['q'];
+      $url = 'user/login';
     }
-    return FALSE;
+    return l(t('Add to Wishlist'), $url, $params);
   }
 
-  if ($operation == 'update') {
-    if ($account->uid == $user->uid && user_access('manage own wish list')) {
-      return TRUE;
+  /**
+   * Remove From Wishlist theme callback
+   */
+  function theme_commerce_wishlist_remove_from_wishlist_link($variables)
+  {
+    //no-ajax is used to remove ajax from views list
+    if (empty($variables['no-ajax']) && (variable_get('commerce_wishlist_use_ajax', 0))) {
+      drupal_add_library('system', 'drupal.ajax');
+      $url = 'wishlist/ajax/remove/' . $variables['product_id'];
+      $params = array(
+        'attributes' => array(
+          'class' => array('use-ajax', 'remove-from-wishlist'),
+          'id' => 'remove-wishlist-' . $variables['product_id'],
+        )
+      );
+    } else {
+      $url = 'wishlist/nojs/remove/' . $variables['product_id'];
+      $params = array(
+        'attributes' => array(
+          'id' => 'remove-wishlist-' . $variables['product_id'],
+        ),
+        'query' => array(
+          'destination' => $_GET['q'],
+        ),
+      );
     }
-    // Check if the wish list owner and the user who is trying to edit the wish
-    // list are the same, and if they have permission to manage own wish list.
-    return ($account->uid == $user->uid
-      && user_access('manage own wish list')
-      && $wishlist->uid == $account->uid);
-  }
 
-  return FALSE;
-}
+    return l($variables['text'], $url, $params);
+  }
 
-/**
- * Determine whether the user has a privilege to view a wish list.
- */
-function commerce_wishlist_user_wishlist_access($acting_user, $view) {
-  if (!is_object($acting_user)) {
+  /**
+   * Theme callback for page title on user's wishlist page.
+   * @param int $product
+   * The reason this is created as a separate themeable function is that depending
+   * on the site configuration and the way user profiles are set, it would make
+   * more sense to use user's first or first + last names, or even full name saved
+   * in commerce customer profile. This way even themes can override the output.
+   */
+  function theme_commerce_wishlist_user_wishlist_page_title(&$variables)
+  {
     global $user;
-    $acting_user = user_load($user->uid);
-  }
-  // Get the wishlist owner.
-  if (arg(1) && is_numeric(arg(1))) {
-    $wishlist_owner = user_load(arg(1));
+    if ($user->uid == $variables['account']->uid) {
+      return t('My Wish list');
+    }
+    return t("@name's Wish list", array('@name' => $variables['account']->name));
   }
-  if ($wishlist_owner) {
-    // Wishlist administrators.
+
+  /**
+   * Determine whether the user has a privilege to manage a wish list.
+   *
+   * @param object $account
+   *   The account whose wishlist will be affected by some action. (e.g. viewed or
+   *   updated).
+   * @param string $operation
+   *   One of "view" or "update" based on the action.
+   * @param object|null $wishlist
+   *   The wishlist to be affected. If the param is null, the default wishlist for
+   *   a user will be loaded.
+   *
+   * @return bool
+   *   TRUE if allowed, FALSE if not.
+   */
+  function commerce_wishlist_user_access($account, $operation, $wishlist = NULL)
+  {
+    global $user;
+    // Allow administrators to edit any wishlist on the site.
     if (user_access('administer wish lists')) {
       return TRUE;
     }
-    // If the user can view any active wishlist, stop here and grant access.
-    if (user_access('view active wish lists', $acting_user)) {
-      return TRUE;
+
+    // Before we perform checks on view/update operations, we will load the
+    // default wishlist order for the user account, if there is none provided.
+    // This will be the case on "/user/%user/wishlist" page.
+    if (!is_object($wishlist)) {
+      $wishlist = commerce_wishlist_order_load($account->uid);
+      if (!$wishlist) {
+        return user_access('manage any wish list');
+      }
     }
-    // Check if the user can manage own wishlist AND if he is on the page of his
-    // own wish list.
-    if (user_access('manage own wish list', $acting_user)) {
-      return ($acting_user->uid == $wishlist_owner->uid);
+
+    // Users can always view their own wish list. Or, a user can view any wish
+    // list if they have the correct permission.
+    if ($operation == 'view') {
+      if ((!empty($wishlist->uid) && $account->uid == $wishlist->uid) || (empty($wishlist) && $account->uid == $user->uid) || user_access('view any wish list', $user) || user_access('administer wish lists', $user) || commerce_wishlist_is_public($wishlist)) {
+        return TRUE;
+      }
+      return FALSE;
     }
+
+    if ($operation == 'update') {
+      if ($account->uid == $user->uid && user_access('manage own wish list')) {
+        return TRUE;
+      }
+      // Check if the wish list owner and the user who is trying to edit the wish
+      // list are the same, and if they have permission to manage own wish list.
+      return ($account->uid == $user->uid
+        && user_access('manage own wish list')
+        && $wishlist->uid == $account->uid);
+    }
+
+    return FALSE;
   }
 
-  return FALSE;
-}
+  /**
+   * Determine whether the user has a privilege to view a wish list.
+   */
+  function commerce_wishlist_user_wishlist_access($acting_user, $view)
+  {
+    if (!is_object($acting_user)) {
+      global $user;
+      $acting_user = user_load($user->uid);
+    }
+    // Get the wishlist owner.
+    if (arg(1) && is_numeric(arg(1))) {
+      $wishlist_owner = user_load(arg(1));
+    }
+    if ($wishlist_owner) {
+      // Wishlist administrators.
+      if (user_access('administer wish lists')) {
+        return TRUE;
+      }
+      // If the user can view any active wishlist, stop here and grant access.
+      if (user_access('view active wish lists', $acting_user)) {
+        return TRUE;
+      }
+      // Check if the user can manage own wishlist AND if he is on the page of his
+      // own wish list.
+      if (user_access('manage own wish list', $acting_user)) {
+        return ($acting_user->uid == $wishlist_owner->uid);
+      }
+    }
 
-/**
- * Form submit handler: wishlist product added to the cart.
- */
-function commerce_wishlist_product_added_to_cart($form, &$form_state) {
-  // Load the line item, add wishlist user ID in additional data, and then save
-  // back the changes.
-  $line_item = commerce_line_item_load($form_state['line_item']->line_item_id);
-  $line_item->data['wishlist_products'][] = array(
-    'node_id'    => $form_state['values']['wishlist_nid'],
-    'user_id'    => $form_state['values']['wishlist_uid'],
-    'product_id' => $form_state['values']['product_id'],
-  );
+    return FALSE;
+  }
 
-  commerce_line_item_save($line_item);
 
-  $account = user_load($form_state['values']['wishlist_uid']);
-  $product = commerce_product_load($form_state['values']['product_id']);
-  $wishlist = commerce_wishlist_order_load($account->uid);
+  function _commerce_wishlist_user_login_submit($form, &$form_state)
+  {
+    if (!empty($form_state['uid'])) {
 
-  rules_invoke_event('commerce_wishlist_product_add_to_cart', $account, $product, $wishlist);
-}
+    }
+  }
 
-/**
- * Form callback for adding a new button to an add to cart form.
- */
-function commerce_wishlist_add_form() {
 
-  $form['add_to_wishlist'] = array(
-    '#type' => 'submit',
-    '#value' => t('Add to Wishlist'),
-    '#weight' => variable_get('commerce_wishlist_weight', 0),
-    '#name' => 'commerce-wishlist-add-product',
-    '#attributes' => array('class' => array('commerce-wishlist')),
-    '#validate' => array('commerce_wishlist_add_form_validate'),
-    '#submit' => array('commerce_wishlist_add_form_submit'),
-  );
+  /**
+   * Form submit handler: wishlist product added to the cart.
+   */
+  function commerce_wishlist_product_added_to_cart($form, &$form_state)
+  {
+    // Load the line item, add wishlist user ID in additional data, and then save
+    // back the changes.
+    $line_item = commerce_line_item_load($form_state['line_item']->line_item_id);
+    $line_item->data['wishlist_products'][] = array(
+      'node_id' => $form_state['values']['wishlist_nid'],
+      'user_id' => $form_state['values']['wishlist_uid'],
+      'product_id' => $form_state['values']['product_id'],
+    );
+
+    commerce_line_item_save($line_item);
+
+    $account = user_load($form_state['values']['wishlist_uid']);
+    $product = commerce_product_load($form_state['values']['product_id']);
+    $wishlist = commerce_wishlist_order_load($account->uid);
 
-  return $form;
-}
+    rules_invoke_event('commerce_wishlist_product_add_to_cart', $account, $product, $wishlist);
+  }
 
-/**
- * Validate callback for commerce_cart_add_to_cart_form().
- */
-function commerce_wishlist_add_form_validate($form, &$form_state) {
-  global $user;
-  if ($form_state['triggering_element']['#name'] == 'commerce-wishlist-add-product') {
-    // Verify if the user is logged in.
-    if (!$user->uid) {
-      $_SESSION['commerce_wishlist']['product_id'] = $form_state['values']['product_id'];
-      form_set_error('add_to_wishlist',
-        t('Please <a href="@login">log in</a> or <a href="@register">register</a> to add this product to your wish list.',
-          array(
-            '@login' => url('user/login', array('query' => drupal_get_destination())),
-            '@register' => url('user/register'),
+  /**
+   * Form callback for adding a new button to an add to cart form.
+   */
+  function commerce_wishlist_add_form()
+  {
+    global $user;
+    $form['add_to_wishlist'] = array(
+      '#type' => 'submit',
+      '#value' => t('Add to Wishlist'),
+      '#weight' => variable_get('commerce_wishlist_weight', 0),
+      '#name' => 'commerce-wishlist-add-product',
+      '#attributes' => array('class' => array('commerce-wishlist')),
+      '#validate' => array('commerce_wishlist_add_form_validate'),
+      '#submit' => array('commerce_wishlist_add_form_submit'),
+    );
+    return $form;
+  }
+
+  /**
+   * Validate callback for commerce_wishlist_add_form().
+   */
+  function commerce_wishlist_add_form_validate($form, &$form_state)
+  {
+    global $user;
+    if ($form_state['triggering_element']['#name'] == 'commerce-wishlist-add-product') {
+      // Verify if the user is logged in.
+      if (!user_access('manage own wish list') && (!$user->uid) && variable_get('commerce_wishlist_show_login', 0)) {
+        $_SESSION['commerce_wishlist']['product_id'] = $form_state['values']['product_id'];
+        form_set_error('add_to_wishlist',
+          t('Please <a href="@login">log in</a> or <a href="@register">register</a> to add this product to your wish list.',
+            array(
+              '@login' => url('user/login', array('query' => drupal_get_destination())),
+              '@register' => url('user/register'),
+            )
           )
-        )
-      );
+        );
+      }
+
+      if (commerce_wishlist_user_has_product_in_wishlist($form_state['values']['product_id'])) {
+        form_set_error('add_to_wishlist', t('This product is already in your wish list.'));
+      }
     }
+  }
 
-    if (commerce_wishlist_user_has_product_in_wishlist($form_state['values']['product_id'])) {
-      form_set_error('add_to_wishlist', t('This product is already in your wish list.'));
+  /**
+   * Implements hook_user_login().
+   */
+  function commerce_wishlist_user_login(&$edit, $account)
+  {
+    // If someone has a product ID in their session, go ahead and add it to their
+    // wish list when the log in.
+    if (!empty($_SESSION['commerce_wishlist']['product_id'])) {
+      $product_id = $_SESSION['commerce_wishlist']['product_id'];
+      $product = commerce_product_load($product_id);
+      if (!commerce_wishlist_user_has_product_in_wishlist($product_id, $account->uid)) {
+        commerce_wishlist_product_add($product, NULL, $account->uid);
+        drupal_set_message(t('Product <em>@product</em> has been added to <a href="@url">your wish list</a>.', array(
+          '@product' => $product->title,
+          '@url' => url('user/' . $account->uid . '/wishlist', array('absolute' => TRUE)),
+        )));
+      } else {
+        drupal_set_message(t('Product <em>@product</em> was already in <a href="@url">your wish list</a>.', array(
+          '@product' => $product->title,
+          '@url' => url('user/' . $account->uid . '/wishlist', array('absolute' => TRUE)),
+        )), 'error');
+      }
     }
+    unset($_SESSION['commerce_wishlist']);
   }
-}
 
-/**
- * Implements hook_user_login().
- */
-function commerce_wishlist_user_login(&$edit, $account) {
-  // If someone has a product ID in their session, go ahead and add it to their
-  // wish list when the log in.
-  if (!empty($_SESSION['commerce_wishlist']['product_id'])) {
-    $product_id = $_SESSION['commerce_wishlist']['product_id'];
-    $product = commerce_product_load($product_id);
-    if (!commerce_wishlist_user_has_product_in_wishlist($product_id, $account->uid)) {
-      commerce_wishlist_product_add($product, NULL, $account->uid);
-      drupal_set_message(t('Product <em>@product</em> has been added to <a href="@url">your wish list</a>.', array(
-        '@product' => $product->title,
-        '@url' => url('user/' . $account->uid . '/wishlist', array('absolute' => TRUE)),
-      )));
+  /**
+   * Validate callback for commerce_wishlist_remove_form().
+   */
+  function commerce_wishlist_remove_form_validate($form, &$form_state)
+  {
+    if ($form_state['triggering_element']['#name'] == 'commerce-wishlist-remove-product') {
+      if (!commerce_wishlist_user_has_product_in_wishlist($form_state['values']['product_id'])) {
+        form_set_error('remove_from_wishlist', t('This product is not in your wishlist.'));
+      }
     }
-    else {
-      drupal_set_message(t('Product <em>@product</em> was already in <a href="@url">your wish list</a>.', array(
-        '@product' => $product->title,
-        '@url' => url('user/' . $account->uid . '/wishlist', array('absolute' => TRUE)),
-      )), 'error');
+  }
+
+  /**
+   * Submit callback for commerce_cart_add_to_cart_form().
+   *
+   * Override of commerce_cart_add_to_cart_form_submit to add wishlist additional
+   * functionality.
+   */
+  function commerce_wishlist_remove_form_submit($form, &$form_state)
+  {
+    $product = commerce_product_load($form_state['values']['product_id']);
+    if ($line_item = commerce_wishlist_user_has_product_in_wishlist($product->product_id)) {
+      commerce_wishlist_product_remove_line_item($line_item);
     }
+    drupal_set_message(t('Product <em>@product</em> has been removed from <a href="@url">your wishlist</a>.', array(
+      '@product' => $product->title,
+      '@url' => url('wishlist', array('absolute' => TRUE)),
+    )));
   }
-  unset($_SESSION['commerce_wishlist']);
-}
 
-/**
- * Implements hook_contextual_links_view_alter().
- */
-function commerce_wishlist_menu_contextual_links_alter(&$links, $router_item, $root_path) {
-  if ($router_item['path'] == 'admin/commerce/orders/%') {
-    if (commerce_wishlist_order_is_wishlist($router_item['page_arguments'][0])) {
-      unset($links['commerce-order-payment']);
+  /**
+   * Implements hook_contextual_links_view_alter().
+   */
+  function commerce_wishlist_menu_contextual_links_alter(&$links, $router_item, $root_path)
+  {
+    if ($router_item['path'] == 'admin/commerce/orders/%') {
+      if (commerce_wishlist_order_is_wishlist($router_item['page_arguments'][0])) {
+        unset($links['commerce-order-payment']);
+      }
     }
   }
-}
 
-/**
- * Submit callback for commerce_cart_add_to_cart_form().
- *
- * Override of commerce_cart_add_to_cart_form_submit to add wishlist additional
- * functionality.
- */
-function commerce_wishlist_add_form_submit($form, &$form_state) {
-  global $user;
+  /**
+   * Submit callback for commerce_cart_add_to_cart_form().
+   *
+   * Override of commerce_cart_add_to_cart_form_submit to add wishlist additional
+   * functionality.
+   */
+  function commerce_wishlist_add_form_submit($form, &$form_state)
+  {
+    global $user;
 
-  $product = commerce_product_load($form_state['values']['product_id']);
-  commerce_wishlist_product_add($product, NULL, NULL, $form_state['line_item']->data['context']['display_path']);
+    $product = commerce_product_load($form_state['values']['product_id']);
+    commerce_wishlist_product_add($product, NULL, NULL, $form_state['line_item']->data['context']['display_path']);
 
-  drupal_set_message(t('Product <em>@product</em> has been added to <a href="@url">your wish list</a>.', array(
-    '@product' => $product->title,
-    '@url' => url('user/' . $user->uid . '/wishlist', array('absolute' => TRUE)),
-  )));
-}
+    drupal_set_message(t('Product <em>@product</em> has been added to <a href="@url">your wish list</a>.', array(
+      '@product' => $product->title,
+      '@url' => url('wishlist', array('absolute' => TRUE)),
+    )));
+  }
 
-/**
- * Page callback: handle deletion of a wish list item.
- *
- * @param object $line_item
- *   The wish list product line item.
- * @param object $account
- *   The account.
- */
-function commerce_wishlist_product_remove_page($line_item, $account) {
-  commerce_wishlist_product_remove_line_item($line_item, $account);
-  drupal_goto();
-}
+  /**
+   * Page callback: handle deletion of a wish list item.
+   *
+   * @param object $line_item
+   *   The wish list product line item.
+   * @param object $account
+   *   The account.
+   */
+  function commerce_wishlist_product_remove_page($product)
+  {
+    if ($line_item = commerce_wishlist_user_has_product_in_wishlist($product->product_id)) {
+      commerce_wishlist_product_remove_line_item($line_item);
+    }
+    drupal_goto();
+  }
 
-/**
- * Ajax callback to handle deletion of wish list item.
- *
- * @param object $line_item
- *   The wish list product line item.
- * @param object $account
- *   The account.
- */
-function commerce_wishlist_product_remove_ajax($line_item, $account) {
-  $product_id = commerce_product_load($line_item->commerce_product[LANGUAGE_NONE][0]['product_id']);
-  commerce_wishlist_product_remove_line_item($line_item, $account);
-  $link = theme('commerce_wishlist_product_add_link', array('product_id' => $product_id, 'user' => $account));
-  $commands = array(ajax_command_replace('a#add-wishlist-' . $product_id, $link));
-  ajax_deliver(array('#type' => 'ajax', '#commands' => $commands));
-}
+  /**
+   * Page callback: Ajax product remove
+   *
+   * @param $product
+   */
+  function commerce_wishlist_product_remove_ajax($product, $account)
+  {
+    if ($line_item = commerce_wishlist_user_has_product_in_wishlist($product->product_id)) {
+      commerce_wishlist_product_remove_line_item($line_item, $account);
+    }
+    $link = theme('commerce_wishlist_product_add_link', array('product_id' => $product->product_id, 'user' => $account));
+    $commands = array(ajax_command_replace('a#remove-wishlist-' . $product->product_id, $link));
+    ajax_deliver(array('#type' => 'ajax', '#commands' => $commands));
+  }
 
-/**
- * Menu callback: Perform various actions (add to wishlist etc).
- */
-function commerce_wishlist_product_add_page($product, $user) {
-  if (isset($_GET['token']) && drupal_valid_token($_GET['token'])) {
-    if (!commerce_wishlist_user_has_product_in_wishlist($product->product_id, $user->uid)) {
+  /**
+   * Menu callback: Perform various actions (add to wishlist etc).
+   */
+  function commerce_wishlist_product_add_page($product)
+  {
+    global $user;
+    if (!commerce_wishlist_user_has_product_in_wishlist($product->product_id)) {
       $display_path = '';
       if ($_GET['destination'] != '') {
         $display_path = $_GET['destination'];
       }
       commerce_wishlist_product_add($product, NULL, $user->uid, $display_path);
     }
+    drupal_goto();
   }
-  drupal_goto();
-}
 
-/**
- * Page callback: Ajax product add.
- */
-function commerce_wishlist_product_add_ajax($product, $user) {
-  if (!commerce_wishlist_user_has_product_in_wishlist($product->product_id, $user->uid)) {
+  /**
+   * Page callback: Ajax product add.
+   */
+  function commerce_wishlist_product_add_ajax($product)
+  {
+    global $user;
     $display_path = '';
     if ($_GET['destination'] != '') {
       $display_path = $_GET['destination'];
     }
-    commerce_wishlist_product_add($product, NULL, $user->uid, $display_path);
-  }
-
-  $link = theme('commerce_wishlist_added_to_wishlist_link', array('user_id' => $user->uid));
-  $commands = array(ajax_command_replace('a#add-wishlist-' . $product->product_id, $link));
-  ajax_deliver(array('#type' => 'ajax', '#commands' => $commands));
-}
+    if (!commerce_wishlist_user_has_product_in_wishlist($product->product_id)) {
+      commerce_wishlist_product_add($product, NULL, $user->uid, $display_path);
+    }
 
-/**
- * Loads the default wishlist order for the specified user.
- *
- * @param int $uid
- *   The uid of the customer whose wishlist to load.
- *
- * @return bool|object
- *   The fully loaded shopping cart order or FALSE if nonexistent.
- */
-function commerce_wishlist_order_load($uid = 0) {
-  if ($uid == 0) {
-    global $user;
-    $uid = $user->uid;
+    $link = variable_get('commerce_wishlist_show_remove', 0) ? theme('commerce_wishlist_remove_from_wishlist_link', array('product_id' => $product->product_id)) : theme('commerce_wishlist_already_in_wishlist_link', array('user_id' => $user->uid));
+    $commands = array(ajax_command_replace('a#add-wishlist-' . $product->product_id, $link));
+    ajax_deliver(array('#type' => 'ajax', '#commands' => $commands));
   }
 
-  if ($uid == 0) {
+  /**
+   * Loads the default wishlist order for the specified user.
+   *
+   * @param int $uid
+   *   The uid of the customer whose wishlist to load.
+   *
+   * @return bool|object
+   *   The fully loaded shopping cart order or FALSE if nonexistent.
+   */
+  function commerce_wishlist_order_load($uid = 0)
+  {
+
+    // Retrieve the order ID for the specified user's current shopping cart.
+    $order_id = commerce_wishlist_order_id($uid);
+
+    // If a valid cart order ID exists for the user, return it now.
+    if (!empty($order_id)) {
+      return commerce_order_load($order_id);
+    }
+
     return FALSE;
   }
 
-  // Retrieve the order ID for the specified user's current shopping cart.
-  $order_id = commerce_wishlist_order_id($uid);
-
-  // If a valid cart order ID exists for the user, return it now.
-  if (!empty($order_id)) {
-    return commerce_order_load($order_id);
-  }
+  /**
+   * Returns the current wish list order ID for the given user.
+   *
+   * @param int $uid
+   *   The uid of the customer whose wishlist to load. If left 0, attempts to load
+   *   an anonymous order from the session.
+   *
+   * @return int
+   *   The requested cart order ID or FALSE if none was found.
+   */
+  function commerce_wishlist_order_id($uid = 0)
+  {
+    // Cart order IDs will be cached keyed by $uid.
+    $cart_order_ids = &drupal_static(__FUNCTION__);
+
+    // Cache the user's cart order ID if it hasn't been set already.
+    if (isset($cart_order_ids[$uid])) {
+      return $cart_order_ids[$uid];
+    }
 
-  return FALSE;
-}
+    // First let other modules attempt to provide a valid order ID for the given
+    // uid. Instead of invoking hook_commerce_cart_order_id() directly, we invoke
+    // it in each module implementing the hook and return the first valid order ID
+    // returned (if any).
+    foreach (module_implements('commerce_wishlist_order_id') as $module) {
+      $order_id = module_invoke($module, 'commerce_wishlist_order_id', $uid);
+
+      // If a hook said the user should not have a cart, that overrides any other
+      // potentially valid order ID. Return FALSE now.
+      if ($order_id === FALSE) {
+        $cart_order_ids[$uid] = FALSE;
+        return FALSE;
+      }
 
-/**
- * Returns the current wish list order ID for the given user.
- *
- * @param int $uid
- *   The uid of the customer whose wishlist to load. If left 0, attempts to load
- *   an anonymous order from the session.
- *
- * @return int
- *   The requested cart order ID or FALSE if none was found.
- */
-function commerce_wishlist_order_id($uid = 0) {
-  // Cart order IDs will be cached keyed by $uid.
-  $cart_order_ids = &drupal_static(__FUNCTION__);
+      // Otherwise only return a valid order ID.
+      if (!empty($order_id) && is_int($order_id)) {
+        $cart_order_ids[$uid] = $order_id;
+        return $order_id;
+      }
+    }
 
-  // Cache the user's cart order ID if it hasn't been set already.
-  if (isset($cart_order_ids[$uid])) {
+    // Create an array of valid shopping cart order statuses.
+    $status_ids = array('wishlist');
+
+    // If a customer uid was specified...
+    if ($uid) {
+      // Look for the user's most recent shopping cart order, although they
+      // should never really have more than one.
+      $cart_order_ids[$uid] = db_query('SELECT order_id FROM {commerce_order} WHERE uid = :uid AND status IN (:status_ids) ORDER BY order_id DESC', array(':uid' => $uid, ':status_ids' => $status_ids))->fetchField();
+    } else {
+      // Otherwise look for a shopping cart order ID in the session.
+      if (commerce_wishlist_order_session_exists()) {
+        // We can't trust a user's IP address to remain the same, especially since
+        // it may be derived from a proxy server and not the actual client. As of
+        // Commerce 1.4, this query no longer restricts order IDs based on IP
+        // address, instead trusting Drupal to prevent session hijacking.
+        $cart_order_ids[$uid] = db_query('SELECT order_id FROM {commerce_order} WHERE order_id IN (:order_ids) AND uid = 0 AND status IN (:status_ids) ORDER BY order_id DESC', array(':order_ids' => commerce_wishlist_order_session_order_ids(), ':status_ids' => $status_ids))->fetchField();
+      } else {
+        $cart_order_ids[$uid] = FALSE;
+      }
+    }
     return $cart_order_ids[$uid];
   }
 
-  // First let other modules attempt to provide a valid order ID for the given
-  // uid. Instead of invoking hook_commerce_cart_order_id() directly, we invoke
-  // it in each module implementing the hook and return the first valid order ID
-  // returned (if any).
-  foreach (module_implements('commerce_wishlist_order_id') as $module) {
-    $order_id = module_invoke($module, 'commerce_wishlist_order_id', $uid);
-
-    // If a hook said the user should not have a cart, that overrides any other
-    // potentially valid order ID. Return FALSE now.
-    if ($order_id === FALSE) {
-      $cart_order_ids[$uid] = FALSE;
-      return FALSE;
+  /**
+   * Add a product to a wish list.
+   *
+   * @param object $product
+   *   The product entity being added to the wish list.
+   * @param object|null $wishlist
+   *   The wishlist it is being added to. Defaults to the user's primary wish
+   *   list.
+   * @param int|null $uid
+   *   The UID of the owner of the wish list. Defaults to the current user.
+   * @param string $display_path
+   *   The display path to attach to the new line item. This can be used for
+   *   linking the item to the original node that was shown when it was added.
+   *
+   * @return bool|object
+   *   FALSE if the product was not added, otherwise the new line item.
+   */
+  function commerce_wishlist_product_add($product, $wishlist = NULL, $uid = NULL, $display_path = '')
+  {
+    $line_item = commerce_product_line_item_new($product, 1);
+    $line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
+    $line_item_wrapper->commerce_display_path->set($display_path);
+
+    if ($uid === NULL) {
+      global $user;
+      $uid = $user->uid;
     }
 
-    // Otherwise only return a valid order ID.
-    if (!empty($order_id) && is_int($order_id)) {
-      $cart_order_ids[$uid] = $order_id;
-      return $order_id;
+    $wishlist = commerce_wishlist_order_load($uid);
+    if ($wishlist === NULL) {
+      $wishlist = commerce_wishlist_order_load($uid);
     }
-  }
 
-  // Create an array of valid shopping cart order statuses.
-  $status_ids = array('wishlist');
+    // If no wish list exists, create one now.
+    if (empty($wishlist)) {
+      $wishlist = commerce_wishlist_order_new($uid);
+    }
 
-  // If a customer uid was specified...
-  if ($uid) {
-    // Look for the user's most recent shopping cart order, although they
-    // should never really have more than one.
-    $cart_order_ids[$uid] = db_query('SELECT order_id FROM {commerce_order} WHERE uid = :uid AND status IN (:status_ids) ORDER BY order_id DESC', array(':uid' => $uid, ':status_ids' => $status_ids))->fetchField();
-  }
+    // Return if it's already in there.
+    if (commerce_wishlist_user_has_product_in_wishlist($product->product_id)) {
+      return FALSE;
+    } elseif (!is_array($wishlist)) {
+      $wishlist = array($wishlist);
+    }
 
-  return $cart_order_ids[$uid];
-}
 
-/**
- * Add a product to a wish list.
- *
- * @param object $product
- *   The product entity being added to the wish list.
- * @param object|null $wishlist
- *   The wishlist it is being added to. Defaults to the user's primary wish
- *   list.
- * @param int|null $uid
- *   The UID of the owner of the wish list. Defaults to the current user.
- * @param string $display_path
- *   The display path to attach to the new line item. This can be used for
- *   linking the item to the original node that was shown when it was added.
- *
- * @return bool|object
- *   FALSE if the product was not added, otherwise the new line item.
- */
-function commerce_wishlist_product_add($product, $wishlist = NULL, $uid = NULL, $display_path = '') {
-  $line_item = commerce_product_line_item_new($product, 1);
-  $line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
-  $line_item_wrapper->commerce_display_path->set($display_path);
+    // Set the incoming line item's order_id.
+    $line_item->order_id = $wishlist->order_id;
 
-  if ($uid === NULL) {
-    global $user;
-    $uid = $user->uid;
-  }
+    // Wrap the order for easy access to field data.
+    $wishlist_wrapper = entity_metadata_wrapper('commerce_order', $wishlist);
 
-  // First attempt to load the customer's shopping cart order.
-  if ($wishlist === NULL) {
-    $wishlist = commerce_wishlist_order_load($uid);
-  }
+    // Save the incoming line item now so we get its ID.
+    commerce_line_item_save($line_item);
 
-  // If no wish list exists, create one now.
-  if (empty($wishlist)) {
-    $wishlist = commerce_wishlist_order_new($uid);
-  }
+    // Add it to the order's line item reference value.
+    $wishlist_wrapper->commerce_line_items[] = $line_item;
 
-  // Return if it's already in there.
-  if (commerce_wishlist_user_has_product_in_wishlist($product->product_id, $uid)) {
-    return FALSE;
-  }
+    // Save the updated order.
+    commerce_order_save($wishlist);
+    // Invoke the product add event with the newly saved or updated line item.
+    rules_invoke_all('commerce_wishlist_product_add', $wishlist, $product, $line_item);
 
-  // Set the incoming line item's order_id.
-  $line_item->order_id = $wishlist->order_id;
+    // Return the line item.
+    return $line_item;
+  }
 
-  // Wrap the order for easy access to field data.
-  $wishlist_wrapper = entity_metadata_wrapper('commerce_order', $wishlist);
+  /**
+   * Creates a new wishlist order.
+   *
+   * @param int $uid
+   *   The UID of the owner of the new wish list.
+   * @param string $type
+   *   The order type to create. Defaults to 'commerce_order'.
+   *
+   * @return object
+   *   The new commerce order. It's visibility will be set to private.
+   */
+  function commerce_wishlist_order_new($uid, $type = 'commerce_order')
+  {
+    // Create the new order with the customer's uid and the cart order status.
+    global $user;
+    $order = commerce_order_new($uid, 'wishlist', $type);
+    $order->log = t('Created a new wishlist order.');
 
-  // Save the incoming line item now so we get its ID.
-  commerce_line_item_save($line_item);
+    // Save all wishlist as private by default.
+    $order->commerce_wishlist_visibility[LANGUAGE_NONE][0]['value'] = COMMERCE_WISHLIST_VISIBILITY_PRIVATE;
 
-  // Add it to the order's line item reference value.
-  $wishlist_wrapper->commerce_line_items[] = $line_item;
+    // Save it so it gets an order ID and return the full object.
+    commerce_order_save($order);
 
-  // Save the updated order.
-  commerce_order_save($wishlist);
-  // Invoke the product add event with the newly saved or updated line item.
-  rules_invoke_all('commerce_wishlist_product_add', $wishlist, $product, $line_item);
+    // If the user is not logged in, ensure the order ID is stored in the session.
+    if (!$uid && empty($user->uid)) {
+      commerce_wishlist_order_session_save($order->order_id);
+    }
 
-  // Return the line item.
-  return $line_item;
-}
+    return $order;
+  }
 
-/**
- * Creates a new wishlist order.
- *
- * @param int $uid
- *   The UID of the owner of the new wish list.
- * @param string $type
- *   The order type to create. Defaults to 'commerce_order'.
- *
- * @return object
- *   The new commerce order. It's visibility will be set to private.
- */
-function commerce_wishlist_order_new($uid, $type = 'commerce_order') {
-  // Create the new order with the customer's uid and the cart order status.
-  $order = commerce_order_new($uid, 'wishlist', $type);
-  $order->log = t('Created a new wishlist order.');
+  /**
+   * Implements hook_commerce_cart_order_is_cart().
+   */
+  function commerce_wishlist_commerce_cart_order_is_cart($order, &$is_cart)
+  {
+    if (commerce_wishlist_order_is_wishlist($order)) {
+      return FALSE;
+    }
+  }
 
-  // Save all wishlist as private by default.
-  $order->commerce_wishlist_visibility[LANGUAGE_NONE][0]['value'] = COMMERCE_WISHLIST_VISIBILITY_PRIVATE;
+  /**
+   * Returns whether or not a product is in a user's wish list.
+   *
+   * This module looks to see if a product exists in any of the user's wishlists.
+   * It does this by loading all of the orders that are a user has and looping
+   * through the line items.
+   *
+   * @param int $product_id
+   *   The product ID.
+   * @param int|null $uid
+   *   The UID of the user or NULL for the current user.
+   *
+   * @return bool
+   *   TRUE if the product exists, FALSE otherwise.
+   */
+  function commerce_wishlist_user_has_product_in_wishlist($product_id)
+  {
+    global $user;
+    $uid = $user->uid;
+    // Load all wish lists.
+    $a = new EntityFieldQuery();
+    $a->entityCondition('entity_type', 'commerce_order', '=')
+      ->propertyCondition('status', array('wishlist'), 'IN')
+      ->propertyCondition('uid', $uid, '=');
 
-  // Save it so it gets an order ID and return the full object.
-  commerce_order_save($order);
+    $wishlist = commerce_wishlist_order_id($uid);
 
-  return $order;
-}
+    if (empty($wishlist)) {
+      return FALSE;
+    } elseif (!is_array($wishlist)) {
+      $wishlist = array($wishlist);
+    }
 
-/**
- * Implements hook_commerce_cart_order_is_cart().
- */
-function commerce_wishlist_commerce_cart_order_is_cart($order, &$is_cart) {
-  if (commerce_wishlist_order_is_wishlist($order)) {
+    foreach (commerce_order_load_multiple($wishlist) as $order) {
+      $order_wrapper = entity_metadata_wrapper('commerce_order', $order);
+      foreach ($order_wrapper->commerce_line_items as $wrapper_line_item) {
+        if (in_array('commerce_product', array_keys($wrapper_line_item->getPropertyInfo()))) {
+          if ($wrapper_line_item->commerce_product->product_id->value() == $product_id) {
+            return $wrapper_line_item->value();
+          }
+        }
+      }
+    }
     return FALSE;
   }
-}
 
-/**
- * Returns whether or not a product is in a user's wish list.
- *
- * This module looks to see if a product exists in any of the user's wishlists.
- * It does this by loading all of the orders that are a user has and looping
- * through the line items.
- *
- * @param int $product_id
- *   The product ID.
- * @param int|null $uid
- *   The UID of the user or NULL for the current user.
- *
- * @return bool
- *   TRUE if the product exists, FALSE otherwise.
- */
-function commerce_wishlist_user_has_product_in_wishlist($product_id, $uid = NULL, $wishlist = NULL) {
-  if ($uid === NULL) {
-    global $user;
-    $uid = $user->uid;
-  }
+  /**
+   * Removes a product from a user's wish list.
+   *
+   * If no wishlist is provided, it will grab the default wish list using
+   * commerce_wishlist_order_load(). If no account is provided, it will default to
+   * the logged in user.
+   *
+   * @param object $line_item
+   *   The product (line_item) to remove.
+   * @param object|null $account
+   *   The user object of the owner of the wish list.
+   * @param object|null $wishlist
+   *   The wishlist to remove the product from.
+   */
+  function commerce_wishlist_product_remove_line_item($line_item, $account = NULL, $wishlist = NULL)
+  {
+    if ($account === NULL) {
+      global $user;
+      $account = $user;
+    }
 
-  if ($uid === 0) {
-    return FALSE;
-  }
+    if ($wishlist === NULL) {
+      // Get the default wish list.
+      $wishlist = commerce_wishlist_order_load($account->uid);
+    }
 
-  // Load all wish lists.
-  $a = new EntityFieldQuery();
-  $a->entityCondition('entity_type', 'commerce_order', '=')
-    ->propertyCondition('status', array('wishlist'), 'IN')
-    ->propertyCondition('uid', $uid, '=');
+    if ($line_item->order_id != $wishlist->order_id) {
+      return;
+    }
 
-  $results = $a->execute();
+    $line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
 
-  if (!isset($results['commerce_order'])) {
-    return FALSE;
-  }
+    rules_invoke_all('commerce_wishlist_product_remove', $line_item_wrapper->commerce_product->value(), $account, $wishlist);
 
-  foreach (commerce_order_load_multiple(array_keys($results['commerce_order'])) as $order) {
-    $order_wrapper = entity_metadata_wrapper('commerce_order', $order);
-    foreach ($order_wrapper->commerce_line_items as $wrapper_line_item) {
-      if (in_array('commerce_product', array_keys($wrapper_line_item->getPropertyInfo()))) {
-        if ($wrapper_line_item->commerce_product->product_id->value() == $product_id) {
-          return TRUE;
-        }
-      }
-    }
+    // Remove the line item from the line item reference field.
+    commerce_entity_reference_delete($wishlist, 'commerce_line_items', 'line_item_id', $line_item->line_item_id);
+    commerce_line_item_delete($line_item->line_item_id);
+    commerce_order_save($wishlist);
   }
-  return FALSE;
-}
 
-/**
- * Removes a product from a user's wish list.
- *
- * If no wishlist is provided, it will grab the default wish list using
- * commerce_wishlist_order_load(). If no account is provided, it will default to
- * the logged in user.
- *
- * @param object $line_item
- *   The product (line_item) to remove.
- * @param object|null $account
- *   The user object of the owner of the wish list.
- * @param object|null $wishlist
- *   The wishlist to remove the product from.
- */
-function commerce_wishlist_product_remove_line_item($line_item, $account = NULL, $wishlist = NULL) {
-  if ($account === NULL) {
-    global $user;
-    $account = $user;
-  }
+  /**
+   * Implements hook_commerce_entity_access_condition_commerce_order_alter().
+   *
+   * This alter hook allows the Commerce Wishlist module to add conditions to the query used to
+   * determine if a user has view access to a given order. The Commerce Wishlist module will
+   * always grant users access to view their own carts (independent of any
+   * permission settings) and also grants anonymous users access to view their
+   * completed orders if they've been given the permission.
+   */
+  function commerce_wishlist_commerce_entity_access_condition_commerce_order_alter(&$conditions, $context)
+  {
+    // Find the user's cart order ID and anonymous user's completed orders.
+    $current_order_id = commerce_wishlist_order_id($context['account']->uid);
+    $completed_order_ids = commerce_cart_order_session_order_ids(TRUE);
+
+    // Always give the current user access to their own wishlist regardless of order
+    // view permissions.
+    if (!empty($current_order_id)) {
+      $conditions->condition($context['base_table'] . '.order_id', $current_order_id);
+    }
 
-  if ($account->uid === 0) {
     return;
   }
 
-  if ($wishlist === NULL) {
-    // Get the default wish list.
-    $wishlist = commerce_wishlist_order_load($account->uid);
+  /**
+   * Saves an order ID to the appropriate wishlist orders session variable.
+   *
+   * @param $order_id
+   *   The order ID to save to the array.
+   */
+  function commerce_wishlist_order_session_save($order_id)
+  {
+
+    if (empty($_SESSION['commerce_wishlist_orders'])) {
+      $_SESSION['commerce_wishlist_orders'] = array($order_id);
+    } elseif (!in_array($order_id, $_SESSION['commerce_wishlist_orders'])) {
+      $_SESSION['commerce_wishlist_orders'][] = $order_id;
+    }
   }
 
-  if ($line_item->order_id != $wishlist->order_id) {
-    return;
+  /**
+   * Checks to see if any order ID or a specific order ID exists in the session.
+   *
+   * @param $order_id
+   *   Optionally specify an order ID to look for in the commerce_cart_orders
+   *     session variable; defaults to NULL.
+   * @return
+   *   Boolean indicating whether or not any cart order ID exists in the session
+   *     or if the specified order ID exists in the session.
+   */
+  function commerce_wishlist_order_session_exists($order_id = NULL)
+  {
+
+    // If an order was specified, look for it in the array.
+    if (!empty($order_id)) {
+      return !empty($_SESSION['commerce_wishlist_orders']) && in_array($order_id, $_SESSION['commerce_wishlist_orders']);
+    } else {
+      // Otherwise look for any value.
+      return !empty($_SESSION['commerce_wishlist_orders']);
+    }
   }
 
-  $line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
+  /**
+   * Deletes all order IDs or a specific order ID from the cart orders session
+   *   variable.
+   *
+   * @param $order_id
+   *   The order ID to remove from the array or NULL to delete the variable.
+   */
+  function commerce_wishlist_order_session_delete($order_id = NULL)
+  {
+
+    if (!empty($_SESSION['commerce_wishlist_orders'])) {
+      if (!empty($order_id)) {
+        $_SESSION['commerce_wishlist_orders'] = array_diff($_SESSION['commerce_wishlist_orders'], array($order_id));
+      } else {
+        unset($_SESSION['commerce_wishlist_orders']);
+      }
+    }
+  }
 
-  rules_invoke_all('commerce_wishlist_product_remove', $line_item_wrapper->commerce_product->value(), $account, $wishlist);
+  /**
+   * Returns an array of cart order IDs stored in the session.
+   *
+   * @return
+   *   An array of applicable cart order IDs or an empty array if none exist.
+   */
+  function commerce_wishlist_order_session_order_ids()
+  {
+    return empty($_SESSION['commerce_wishlist_orders']) ? array() : $_SESSION['commerce_wishlist_orders'];
+  }
 
-  // Remove the line item from the line item reference field.
-  commerce_entity_reference_delete($wishlist, 'commerce_line_items', 'line_item_id', $line_item->line_item_id);
-  commerce_line_item_delete($line_item->line_item_id);
-  commerce_order_save($wishlist);
-}
+  /**
+   * Themes an empty wishlist page.
+   */
+  function theme_commerce_wishlist_empty_page()
+  {
+    return '<div class="wishlist-empty-page">' . t('Your wishlist is empty.') . '</div>';
+  }
 
-/**
- * Removes a product from a user's wish list.
- *
- * If no wishlist is provided, it will grab the default wish list using
- * commerce_wishlist_order_load(). If no account is provided, it will default to
- * the logged in user.
- *
- * @param object $product
- *   The product to remove.
- * @param int|null $account
- *   The account of the owner of the wish list.
- * @param object|null $wishlist
- *   The wishlist to remove the product from.
- */
-function commerce_wishlist_product_remove($product, $account = NULL, $wishlist = NULL) {
-  if ($account === NULL) {
+  /**
+   * Implements hook_user_login().
+   *
+   * When a user logs into the site, if they have a wishlist order it should
+   * be merged ito the user account wishlist.
+   */
+  function commerce_wishlist_user_login(&$edit, $account)
+  {
+    // Get the user's anonymous wishlist order if it exists.
     global $user;
-    $account = $user;
-  }
 
-  if ($account->uid === 0) {
-    return;
+    if ($wishlist = commerce_wishlist_order_load()) {
+      // Convert it to an authenticated cart.
+      commerce_wishlist_order_convert($wishlist, $account);
+    }
   }
 
-  if ($wishlist === NULL) {
-    // Get the default wish list.
-    $wishlist = commerce_wishlist_order_load($account->uid);
-  }
+  /**
+   * Converts an anonymous commerce wishlist order to an authenticated wishlist.
+   *
+   * @param $order
+   *   The anonymous wishlist to convert to an authenticated wishlist.
+   * @param $account
+   *   The user account the wishlist will belong to.
+   *
+   * @return
+   *   The updated order's wrapper or FALSE if the order was not converted,
+   *     meaning it was not an anonymous wishlist order to begin with.
+   */
+  function commerce_wishlist_order_convert($anonymous_wishlist_order, $account)
+  {
+    // Only convert wishlists that are currently anonmyous wishlists.
+    if ($anonymous_wishlist_order->uid == 0) {
+      //get account wishlist if exists
+      if ($account_wishlist = commerce_wishlist_order_load($account->uid)) {
+        //wrap orders
+        $anonymous_wishlist_wrapper = entity_metadata_wrapper('commerce_order', $anonymous_wishlist_order);
+        $acount_wishlist_wrapper = entity_metadata_wrapper('commerce_order', $account_wishlist);
+
+        $existing_prods = array();
+        // Get existing products from the account wishlist
+        foreach ($acount_wishlist_wrapper->commerce_line_items as $line_item) {
+          $existing_prods[] = $line_item->commerce_product->product_id->value();
+        }
 
-  $wishlist_wrapper = entity_metadata_wrapper('commerce_order', $wishlist);
+        //Move all products in account wishlist which are not there already
+        foreach ($anonymous_wishlist_wrapper->commerce_line_items as $line_item) {
+          // If not in array, the account wishlist didn have the product
+          if (!in_array($line_item->commerce_product->product_id->value(), $existing_prods)) {
+
+            // change the order id for the line item
+            $line_item->order_id = $acount_wishlist_wrapper->order_id->value();
+            // Not sure if this was needed but it didnt hurt
+            $line_item->save();
+            // add the line item to the new order
+            $acount_wishlist_wrapper->commerce_line_items[] = $line_item;
+          }
+        }
+        //delete anonymous order
+        $anonymous_wishlist_wrapper->commerce_line_items = array();
+        $anonymous_wishlist_wrapper->delete();
+      } else {
+        // Update the uid and e-mail address to match the current account since
+        // there currently is no way to specify a custom e-mail address per order.
+        $anonymous_wishlist_order->uid = $account->uid;
+        $anonymous_wishlist_order->mail = $account->mail;
+        $acount_wishlist_wrapper = entity_metadata_wrapper('commerce_order', $anonymous_wishlist_order);
 
-  foreach ($wishlist_wrapper->commerce_line_items as $delta => $line_item_wrapper) {
-    if ($line_item_wrapper->commerce_product->product_id->value() === $product->product_id) {
-      $line_item = $line_item_wrapper->value();
-      break;
+      }
+      // Allow other modules to operate on the converted order and then save.
+      module_invoke_all('commerce_wishlist_order_convert', $acount_wishlist_wrapper, $account);
+      $acount_wishlist_wrapper->save();
+      return $acount_wishlist_wrapper;
     }
-    // No item was found.
-    return;
+
+    return FALSE;
   }
 
-  rules_invoke_all('commerce_wishlist_product_remove', $product, $account, $wishlist);
+  /**
+   * Removes a product from a user's wish list.
+   *
+   * If no wishlist is provided, it will grab the default wish list using
+   * commerce_wishlist_order_load(). If no account is provided, it will default to
+   * the logged in user.
+   *
+   * @param object $product
+   *   The product to remove.
+   * @param int|null $account
+   *   The account of the owner of the wish list.
+   * @param object|null $wishlist
+   *   The wishlist to remove the product from.
+   */
+  function commerce_wishlist_product_remove($product, $account = NULL, $wishlist = NULL)
+  {
+    if ($account === NULL) {
+      global $user;
+      $account = $user;
+    }
 
-  // Remove the line item from the line item reference field.
-  commerce_entity_reference_delete($wishlist, 'commerce_line_items', 'line_item_id', $line_item->line_item_id);
-  commerce_line_item_delete($line_item->line_item_id);
-  commerce_order_save($wishlist);
-}
+    if ($wishlist === NULL) {
+      // Get the default wish list.
+      $wishlist = commerce_wishlist_order_load($account->uid);
+    }
 
-/**
- * Return a wish list for a given hash.
- *
- * @param string $hash
- *   The hash to load.
- *
- * @return bool|mixed
- *   FALSE if no wish list was found, otherwise the commerce order object.
- */
-function commerce_wishlist_hash_load($hash) {
-  $wishlist_id = db_select('commerce_wishlist_share', 'cws')
-    ->fields('cws', array('order_id'))
-    ->condition('url_hash', $hash)
-    ->execute()
-    ->fetchField();
-
-  if (!empty($wishlist_id)) {
-    return commerce_order_load($wishlist_id);
-  }
+    $wishlist_wrapper = entity_metadata_wrapper('commerce_order', $wishlist);
 
-  return FALSE;
-}
+    foreach ($wishlist_wrapper->commerce_line_items as $delta => $line_item_wrapper) {
+      if ($line_item_wrapper->commerce_product->product_id->value() === $product->product_id) {
+        $line_item = $line_item_wrapper->value();
+        break;
+      }
+      // No item was found.
+      return;
+    }
 
-/**
- * Create and store a shareable URL for a given wish list.
- *
- * This function will create and store a wish list for a given wish list. It
- * technically guarantees to create a unique URL for a given wish list with
- * roughly 2 trillion possibilities.
- *
- * @param object $wishlist
- *   The wish list object.
- */
-function commerce_wishlist_add_wishlist_url($wishlist) {
-  // Remove if there already is one.
-  commerce_wishlist_remove_wishlist_url($wishlist);
-
-  // Avoid collisions.
-  do {
-    $hash_to_use = commerce_wishlist_generate_url_hash($wishlist);
-  } while (commerce_wishlist_hash_load($hash_to_use) !== FALSE);
-
-  db_insert('commerce_wishlist_share')
-    ->fields(array(
-      'order_id' => $wishlist->order_id,
-      'url_hash' => $hash_to_use,
-    ))
-    ->execute();
-
-  $url_hashes = &drupal_static('commerce_wishlist_order_hashes', array());
-  $url_hashes[$wishlist->order_id] = $hash_to_use;
-}
+    rules_invoke_all('commerce_wishlist_product_remove', $product, $account, $wishlist);
 
-/**
- * Remove a wish list's shareable hash.
- *
- * @param object $wishlist
- *   The wish list to have it's URL removed.
- */
-function commerce_wishlist_remove_wishlist_url($wishlist) {
-  db_delete('commerce_wishlist_share')
-    ->condition('order_id', $wishlist->order_id)
-    ->execute();
-}
+    // Remove the line item from the line item reference field.
+    commerce_entity_reference_delete($wishlist, 'commerce_line_items', 'line_item_id', $line_item->line_item_id);
+    commerce_line_item_delete($line_item->line_item_id);
+    commerce_order_save($wishlist);
+  }
 
-/**
- * Returns a shareable URL for a given wish list.
- *
- * @param object $wishlist
- *   The wish list object.
- *
- * @return string
- *   The shareable URL for the wishlist which uses the hash.
- */
-function commerce_wishlist_get_wishlist_url($wishlist) {
-  $url_hashes = &drupal_static('commerce_wishlist_order_hashes', array());
+  /**
+   * Return a wish list for a given hash.
+   *
+   * @param string $hash
+   *   The hash to load.
+   *
+   * @return bool|mixed
+   *   FALSE if no wish list was found, otherwise the commerce order object.
+   */
+  function commerce_wishlist_hash_load($hash)
+  {
+    $wishlist_id = db_select('commerce_wishlist_share', 'cws')
+      ->fields('cws', array('order_id'))
+      ->condition('url_hash', $hash)
+      ->execute()
+      ->fetchField();
+
+    if (!empty($wishlist_id)) {
+      return commerce_order_load($wishlist_id);
+    }
 
-  if (empty($url_hashes[$wishlist->order_id])) {
-    $result = db_select('commerce_wishlist_share', 'cws')
-      ->fields('cws', array('url_hash'))
-      ->condition('order_id', $wishlist->order_id)
+    return FALSE;
+  }
+
+  /**
+   * Create and store a shareable URL for a given wish list.
+   *
+   * This function will create and store a wish list for a given wish list. It
+   * technically guarantees to create a unique URL for a given wish list with
+   * roughly 2 trillion possibilities.
+   *
+   * @param object $wishlist
+   *   The wish list object.
+   */
+  function commerce_wishlist_add_wishlist_url($wishlist)
+  {
+    // Remove if there already is one.
+    commerce_wishlist_remove_wishlist_url($wishlist);
+
+    // Avoid collisions.
+    do {
+      $hash_to_use = commerce_wishlist_generate_url_hash($wishlist);
+    } while (commerce_wishlist_hash_load($hash_to_use) !== FALSE);
+
+    db_insert('commerce_wishlist_share')
+      ->fields(array(
+        'order_id' => $wishlist->order_id,
+        'url_hash' => $hash_to_use,
+      ))
       ->execute();
 
-    $url_hash = $result->fetchField(0);
-    $url_hashes[$wishlist->order_id] = $url_hash;
-  }
-  else {
-    $url_hash = $url_hashes[$wishlist->order_id];
+    $url_hashes = &drupal_static('commerce_wishlist_order_hashes', array());
+    $url_hashes[$wishlist->order_id] = $hash_to_use;
   }
 
-  if ($url_hash == '') {
-    return '';
+  /**
+   * Remove a wish list's shareable hash.
+   *
+   * @param object $wishlist
+   *   The wish list to have it's URL removed.
+   */
+  function commerce_wishlist_remove_wishlist_url($wishlist)
+  {
+    db_delete('commerce_wishlist_share')
+      ->condition('order_id', $wishlist->order_id)
+      ->execute();
   }
 
-  $wishlist_url = str_replace('%', '%commerce_wishlist_hash', variable_get('commerce_wishlist_share_prefix', 'shared-wishlist/%'));
-  return url(str_replace('%commerce_wishlist_hash', $url_hash, $wishlist_url));
-}
+  /**
+   * Returns a shareable URL for a given wish list.
+   *
+   * @param object $wishlist
+   *   The wish list object.
+   *
+   * @return string
+   *   The shareable URL for the wishlist which uses the hash.
+   */
+  function commerce_wishlist_get_wishlist_url($wishlist)
+  {
+    $url_hashes = &drupal_static('commerce_wishlist_order_hashes', array());
+
+    if (empty($url_hashes[$wishlist->order_id])) {
+      $result = db_select('commerce_wishlist_share', 'cws')
+        ->fields('cws', array('url_hash'))
+        ->condition('order_id', $wishlist->order_id)
+        ->execute();
+
+      $url_hash = $result->fetchField(0);
+      $url_hashes[$wishlist->order_id] = $url_hash;
+    } else {
+      $url_hash = $url_hashes[$wishlist->order_id];
+    }
 
-/**
- * Generate a short URL "hash" for a given wish list.
- *
- * @param object $wishlist
- *   The wish list object.
- *
- * @return string
- *   A hash of 8 characters, in base36. Not guaranteed to be unique.
- */
-function commerce_wishlist_generate_url_hash($wishlist) {
-  return substr(base_convert(hash('sha256', serialize(array(
-    $wishlist->order_id,
-    $wishlist->mail,
-    $wishlist->created,
-    $wishlist->changed,
-    time(),
-  ))), 16, 36), 0, COMMERCE_WISHLIST_HASH_LENGTH);
+    if ($url_hash == '') {
+      return '';
+    }
+
+    $wishlist_url = str_replace('%', '%commerce_wishlist_hash', variable_get('commerce_wishlist_share_prefix', 'shared-wishlist/%'));
+    return url(str_replace('%commerce_wishlist_hash', $url_hash, $wishlist_url));
+  }
+
+  /**
+   * Generate a short URL "hash" for a given wish list.
+   *
+   * @param object $wishlist
+   *   The wish list object.
+   *
+   * @return string
+   *   A hash of 8 characters, in base36. Not guaranteed to be unique.
+   */
+  function commerce_wishlist_generate_url_hash($wishlist) {
+    return substr(base_convert(hash('sha256', serialize(array(
+      $wishlist->order_id,
+      $wishlist->mail,
+      $wishlist->created,
+      $wishlist->changed,
+      time(),
+    ))), 16, 36), 0, COMMERCE_WISHLIST_HASH_LENGTH);
+  }
 }
diff --git a/sites/all/modules/commerce_wishlist/includes/views/commerce_wishlist.views_default.inc b/sites/all/modules/commerce_wishlist/includes/views/commerce_wishlist.views_default.inc
index ec49ea2..ebf5609 100644
--- a/sites/all/modules/commerce_wishlist/includes/views/commerce_wishlist.views_default.inc
+++ b/sites/all/modules/commerce_wishlist/includes/views/commerce_wishlist.views_default.inc
@@ -45,15 +45,14 @@ function commerce_wishlist_views_default_views() {
   $view->name = 'commerce_wishlist_page';
   $view->description = '';
   $view->tag = 'default';
-  $view->base_table = 'commerce_line_item';
-  $view->human_name = 'User wish list';
+  $view->base_table = 'commerce_order';
+  $view->human_name = 'User Wishlist';
   $view->core = 7;
   $view->api_version = '3.0';
   $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
 
   /* Display: Master */
   $handler = $view->new_display('default', 'Master', 'default');
-  $handler->display->display_options['title'] = 'User wish list';
   $handler->display->display_options['use_more_always'] = FALSE;
   $handler->display->display_options['access']['type'] = 'none';
   $handler->display->display_options['cache']['type'] = 'none';
@@ -61,85 +60,101 @@ function commerce_wishlist_views_default_views() {
   $handler->display->display_options['query']['options']['disable_sql_rewrite'] = TRUE;
   $handler->display->display_options['exposed_form']['type'] = 'basic';
   $handler->display->display_options['pager']['type'] = 'full';
-  $handler->display->display_options['pager']['options']['items_per_page'] = '25';
   $handler->display->display_options['style_plugin'] = 'table';
   $handler->display->display_options['style_options']['columns'] = array(
-    'line_item_id' => 'line_item_id',
+    'order_id' => 'order_id',
+    'commerce_display_path' => 'commerce_display_path',
+    'line_item_title' => 'line_item_title',
+    'wishlist_remove' => 'wishlist_remove',
+    'wishlist_add_to_cart' => 'wishlist_add_to_cart',
   );
   $handler->display->display_options['style_options']['default'] = '-1';
   $handler->display->display_options['style_options']['info'] = array(
-    'line_item_id' => array(
+    'order_id' => array(
       'sortable' => 0,
       'default_sort_order' => 'asc',
       'align' => '',
       'separator' => '',
       'empty_column' => 0,
     ),
+    'commerce_display_path' => array(
+      'sortable' => 0,
+      'default_sort_order' => 'asc',
+      'align' => '',
+      'separator' => '',
+      'empty_column' => 0,
+    ),
+    'line_item_title' => array(
+      'align' => '',
+      'separator' => '',
+      'empty_column' => 0,
+    ),
+    'wishlist_remove' => array(
+      'align' => '',
+      'separator' => '',
+      'empty_column' => 0,
+    ),
+    'wishlist_add_to_cart' => array(
+      'align' => '',
+      'separator' => '',
+      'empty_column' => 0,
+    ),
   );
-  /* No results behavior: Global: Text area */
-  $handler->display->display_options['empty']['area']['id'] = 'area';
-  $handler->display->display_options['empty']['area']['table'] = 'views';
-  $handler->display->display_options['empty']['area']['field'] = 'area';
-  $handler->display->display_options['empty']['area']['label'] = 'No items in wish list';
-  $handler->display->display_options['empty']['area']['empty'] = TRUE;
-  $handler->display->display_options['empty']['area']['content'] = 'There are no items in your wish list.';
-  $handler->display->display_options['empty']['area']['format'] = 'plain_text';
-  /* Relationship: Commerce Line Item: Order ID */
-  $handler->display->display_options['relationships']['order_id']['id'] = 'order_id';
-  $handler->display->display_options['relationships']['order_id']['table'] = 'commerce_line_item';
-  $handler->display->display_options['relationships']['order_id']['field'] = 'order_id';
-  $handler->display->display_options['relationships']['order_id']['required'] = TRUE;
+  /* Relationship: Commerce Order: Referenced line items */
+  $handler->display->display_options['relationships']['commerce_line_items_line_item_id']['id'] = 'commerce_line_items_line_item_id';
+  $handler->display->display_options['relationships']['commerce_line_items_line_item_id']['table'] = 'field_data_commerce_line_items';
+  $handler->display->display_options['relationships']['commerce_line_items_line_item_id']['field'] = 'commerce_line_items_line_item_id';
+  $handler->display->display_options['relationships']['commerce_line_items_line_item_id']['required'] = TRUE;
   /* Field: Commerce Line item: Display path */
   $handler->display->display_options['fields']['commerce_display_path']['id'] = 'commerce_display_path';
   $handler->display->display_options['fields']['commerce_display_path']['table'] = 'field_data_commerce_display_path';
   $handler->display->display_options['fields']['commerce_display_path']['field'] = 'commerce_display_path';
+  $handler->display->display_options['fields']['commerce_display_path']['relationship'] = 'commerce_line_items_line_item_id';
   $handler->display->display_options['fields']['commerce_display_path']['exclude'] = TRUE;
   /* Field: Commerce Line Item: Title */
   $handler->display->display_options['fields']['line_item_title']['id'] = 'line_item_title';
   $handler->display->display_options['fields']['line_item_title']['table'] = 'commerce_line_item';
   $handler->display->display_options['fields']['line_item_title']['field'] = 'line_item_title';
-  $handler->display->display_options['fields']['line_item_title']['alter']['make_link'] = TRUE;
-  $handler->display->display_options['fields']['line_item_title']['alter']['path'] = '[commerce_display_path]';
-  /* Field: Commerce Line Item: Created date */
-  $handler->display->display_options['fields']['created']['id'] = 'created';
-  $handler->display->display_options['fields']['created']['table'] = 'commerce_line_item';
-  $handler->display->display_options['fields']['created']['field'] = 'created';
-  $handler->display->display_options['fields']['created']['label'] = 'Added';
-  $handler->display->display_options['fields']['created']['date_format'] = 'medium';
-  $handler->display->display_options['fields']['created']['second_date_format'] = 'long';
+  $handler->display->display_options['fields']['line_item_title']['relationship'] = 'commerce_line_items_line_item_id';
   /* Field: Commerce Line Item: Remove */
   $handler->display->display_options['fields']['wishlist_remove']['id'] = 'wishlist_remove';
   $handler->display->display_options['fields']['wishlist_remove']['table'] = 'commerce_line_item';
   $handler->display->display_options['fields']['wishlist_remove']['field'] = 'wishlist_remove';
-  $handler->display->display_options['fields']['wishlist_remove']['label'] = '';
-  $handler->display->display_options['fields']['wishlist_remove']['element_label_colon'] = FALSE;
+  $handler->display->display_options['fields']['wishlist_remove']['relationship'] = 'commerce_line_items_line_item_id';
   /* Field: Commerce Line Item: Add to Cart */
   $handler->display->display_options['fields']['wishlist_add_to_cart']['id'] = 'wishlist_add_to_cart';
   $handler->display->display_options['fields']['wishlist_add_to_cart']['table'] = 'commerce_line_item';
   $handler->display->display_options['fields']['wishlist_add_to_cart']['field'] = 'wishlist_add_to_cart';
-  $handler->display->display_options['fields']['wishlist_add_to_cart']['label'] = '';
-  $handler->display->display_options['fields']['wishlist_add_to_cart']['element_label_colon'] = FALSE;
+  $handler->display->display_options['fields']['wishlist_add_to_cart']['relationship'] = 'commerce_line_items_line_item_id';
+  $handler->display->display_options['fields']['wishlist_add_to_cart']['show_quantity'] = 1;
+  $handler->display->display_options['fields']['wishlist_add_to_cart']['default_quantity'] = '1';
+  $handler->display->display_options['fields']['wishlist_add_to_cart']['combine'] = 1;
+  $handler->display->display_options['fields']['wishlist_add_to_cart']['display_path'] = 0;
+  $handler->display->display_options['fields']['wishlist_add_to_cart']['line_item_type'] = 0;
+  $handler->display->display_options['fields']['wishlist_add_to_cart']['remove_from_wishlist'] = 0;
   /* Contextual filter: Commerce Order: Order ID */
   $handler->display->display_options['arguments']['order_id']['id'] = 'order_id';
   $handler->display->display_options['arguments']['order_id']['table'] = 'commerce_order';
   $handler->display->display_options['arguments']['order_id']['field'] = 'order_id';
-  $handler->display->display_options['arguments']['order_id']['relationship'] = 'order_id';
+  $handler->display->display_options['arguments']['order_id']['default_action'] = 'empty';
   $handler->display->display_options['arguments']['order_id']['default_argument_type'] = 'fixed';
   $handler->display->display_options['arguments']['order_id']['summary']['number_of_records'] = '0';
   $handler->display->display_options['arguments']['order_id']['summary']['format'] = 'default_summary';
   $handler->display->display_options['arguments']['order_id']['summary_options']['items_per_page'] = '25';
-  /* Filter criterion: Commerce Order: Order state */
-  $handler->display->display_options['filters']['state']['id'] = 'state';
-  $handler->display->display_options['filters']['state']['table'] = 'commerce_order';
-  $handler->display->display_options['filters']['state']['field'] = 'state';
-  $handler->display->display_options['filters']['state']['relationship'] = 'order_id';
-  $handler->display->display_options['filters']['state']['value'] = array(
+  /* Filter criterion: Commerce Order: Order type */
+  $handler->display->display_options['filters']['type']['id'] = 'type';
+  $handler->display->display_options['filters']['type']['table'] = 'commerce_order';
+  $handler->display->display_options['filters']['type']['field'] = 'type';
+  $handler->display->display_options['filters']['type']['value'] = array(
+    'commerce_order' => 'commerce_order',
+  );
+  /* Filter criterion: Commerce Order: Order status */
+  $handler->display->display_options['filters']['status']['id'] = 'status';
+  $handler->display->display_options['filters']['status']['table'] = 'commerce_order';
+  $handler->display->display_options['filters']['status']['field'] = 'status';
+  $handler->display->display_options['filters']['status']['value'] = array(
     'wishlist' => 'wishlist',
   );
-  $handler->display->display_options['filters']['state']['expose']['operator_id'] = 'state_op';
-  $handler->display->display_options['filters']['state']['expose']['label'] = 'Order state';
-  $handler->display->display_options['filters']['state']['expose']['operator'] = 'state_op';
-  $handler->display->display_options['filters']['state']['expose']['identifier'] = 'state';
   $views[$view->name] = $view;
 
   // Administrative views.
@@ -240,6 +255,7 @@ function commerce_wishlist_views_default_views() {
   $handler->display->display_options['relationships']['commerce_line_items_line_item_id']['id'] = 'commerce_line_items_line_item_id';
   $handler->display->display_options['relationships']['commerce_line_items_line_item_id']['table'] = 'field_data_commerce_line_items';
   $handler->display->display_options['relationships']['commerce_line_items_line_item_id']['field'] = 'commerce_line_items_line_item_id';
+  $handler->display->display_options['relationships']['commerce_line_items_line_item_id']['required'] = TRUE;
   /* Field: Commerce Order: Order number */
   $handler->display->display_options['fields']['order_number']['id'] = 'order_number';
   $handler->display->display_options['fields']['order_number']['table'] = 'commerce_order';
diff --git a/sites/all/modules/commerce_wishlist/includes/views/handlers/commerce_wishlist_handler_field_remove.inc b/sites/all/modules/commerce_wishlist/includes/views/handlers/commerce_wishlist_handler_field_remove.inc
index 6a5bc19..91272e4 100644
--- a/sites/all/modules/commerce_wishlist/includes/views/handlers/commerce_wishlist_handler_field_remove.inc
+++ b/sites/all/modules/commerce_wishlist/includes/views/handlers/commerce_wishlist_handler_field_remove.inc
@@ -27,22 +27,14 @@ class commerce_wishlist_handler_field_remove extends views_handler_field {
 
   function render($values) {
     // Ensure the user has access to remove this product from wishlist.
-    global $user;
     $line_item_id = $this->get_value($values);
     $line_item = commerce_line_item_load($line_item_id);
+    $product_id = $line_item->commerce_product['und'][0]['product_id'];
 
-    $account = user_load($user->uid);
-    $wishlist_id = $line_item->order_id;
-    $wishlist = commerce_order_load($wishlist_id);
-
-    if (commerce_wishlist_user_access($account, 'update', $wishlist)) {
+    if (user_access('manage own wish list')) {
       $text = !empty($this->options['text']) ? $this->options['text'] : t('Remove');
 
-      $destination = drupal_get_destination();
-
-      return l($text, 'user/' . $wishlist->uid . '/wishlist/nojs/remove/' . $line_item_id, (array(
-        'query' => $destination,
-      )));
+      return theme('commerce_wishlist_remove_from_wishlist_link', array('product_id' => $product_id, 'text' => $text, 'no-ajax' => TRUE));
     }
 
     return '';
