The browse wishlist page (commerce_wishlist_page_browse_wishlists() in .pages.inc) assumes the following fields to be attached to a user:

  • field_user_first_name
  • field_user_last_name

When these are not present the user is presented with a fatal error when visiting the /browse-wishlists page.

These fields are used to generate the username on the browse wishlist page, which can be done using format_username(). The other use for them is to allow searching wishlists by username.

I will provide a patch this evening.

Comments

neograph734’s picture

I came quite far with this, but got stuck on the search filter. There are off course possibilities for detecting realname and joining that table to the search, but that would only detect one module. Though I am not aware of others, there is possibly another module providing similar functionality.

While writing #2485725: Allow multiple (nameable) wishlists per user I thought of searching on the wishlist name rather then the username, where a default wishlist can be named after it's owner's name. We can even write an update hook to convert existing wishlists to this new format.

And finally I came to the conclusion this page could be replaced by a default view. It would allow the site builder to add additional data to the table and the search query (exposed filters) and it has full support for any field the site builder wants to filter on.

This as simple as building a view of commerce_orders, adding the default filters (orderstatus = wishlist, user status = 1, uid > 0), adding an exposed filter for the user/wishlistname and pasting the export in hook_views_default_views().

neograph734’s picture

I suppse a view like this would work:

$view = new view();
$view->name = 'view_wishlists';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'commerce_order';
$view->human_name = 'View wishlists';
$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'] = 'Browse wishlists';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'commerce_wishlist';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$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';
/* 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']['empty'] = TRUE;
$handler->display->display_options['empty']['area']['content'] = 'No wishlists were found.';
$handler->display->display_options['empty']['area']['format'] = 'filtered_html';
/* Relationship: Commerce Order: Owner */
$handler->display->display_options['relationships']['uid']['id'] = 'uid';
$handler->display->display_options['relationships']['uid']['table'] = 'commerce_order';
$handler->display->display_options['relationships']['uid']['field'] = 'uid';
$handler->display->display_options['relationships']['uid']['label'] = 'Wishlist owner';
$handler->display->display_options['relationships']['uid']['required'] = TRUE;
/* Field: User: Name */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'users';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['relationship'] = 'uid';
/* Field: Commerce Order: Created date */
$handler->display->display_options['fields']['created']['id'] = 'created';
$handler->display->display_options['fields']['created']['table'] = 'commerce_order';
$handler->display->display_options['fields']['created']['field'] = 'created';
$handler->display->display_options['fields']['created']['label'] = 'Created on';
$handler->display->display_options['fields']['created']['date_format'] = 'custom';
$handler->display->display_options['fields']['created']['custom_date_format'] = 'F d, Y';
$handler->display->display_options['fields']['created']['second_date_format'] = 'long';
/* Field: Commerce Order: Order ID */
$handler->display->display_options['fields']['order_id']['id'] = 'order_id';
$handler->display->display_options['fields']['order_id']['table'] = 'commerce_order';
$handler->display->display_options['fields']['order_id']['field'] = 'order_id';
$handler->display->display_options['fields']['order_id']['label'] = 'Wishlist';
$handler->display->display_options['fields']['order_id']['alter']['alter_text'] = TRUE;
$handler->display->display_options['fields']['order_id']['alter']['text'] = 'View wishlist';
$handler->display->display_options['fields']['order_id']['alter']['make_link'] = TRUE;
$handler->display->display_options['fields']['order_id']['alter']['path'] = 'wishlist/[order_id]';
/* 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']['value'] = array(
  'wishlist' => 'wishlist',
);
$handler->display->display_options['filters']['state']['group'] = 1;
/* Filter criterion: User: Active */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'users';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['relationship'] = 'uid';
$handler->display->display_options['filters']['status']['value'] = '1';
$handler->display->display_options['filters']['status']['group'] = 1;
/* Filter criterion: User: The user ID */
$handler->display->display_options['filters']['uid_raw']['id'] = 'uid_raw';
$handler->display->display_options['filters']['uid_raw']['table'] = 'users';
$handler->display->display_options['filters']['uid_raw']['field'] = 'uid_raw';
$handler->display->display_options['filters']['uid_raw']['relationship'] = 'uid';
$handler->display->display_options['filters']['uid_raw']['operator'] = '>';
$handler->display->display_options['filters']['uid_raw']['value']['value'] = '1';
$handler->display->display_options['filters']['uid_raw']['group'] = 1;

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'browse-wishlists';
$handler->display->display_options['menu']['type'] = 'normal';
$handler->display->display_options['menu']['title'] = 'Browse wishlists';
$handler->display->display_options['menu']['name'] = 'main-menu';
$translatables['view_wishlists'] = array(
  t('Master'),
  t('Browse wishlists'),
  t('more'),
  t('Apply'),
  t('Reset'),
  t('Sort by'),
  t('Asc'),
  t('Desc'),
  t('Items per page'),
  t('- All -'),
  t('Offset'),
  t('« first'),
  t('‹ previous'),
  t('next ›'),
  t('last »'),
  t('No wishlists were found.'),
  t('Wishlist owner'),
  t('Name'),
  t('Created on'),
  t('Wishlist'),
  t('View wishlist'),
  t('Page'),
);
neograph734’s picture

Status: Active » Needs review
StatusFileSize
new11.68 KB

Patch added

aramboyajyan’s picture

I'll check this these days and let you know my comments. If everything is okay, I'll just commit it.

Thanks!

neograph734’s picture

Status: Needs review » Closed (fixed)

This has been merged in with #2485725: Allow multiple (nameable) wishlists per user and is already patched there.