1 Answers Vote up! 0 Vote down! Display recently bought items by loged in user Hi. Is there a way to display ( maybe as a block ), i. e. ten recently bought product by logged in user? Thank You for any sugestions. Asked by: blwoo on July 8, 2012 Log in or register to post a comment.
Vote up! 0 Vote down! You could create a view with a default argument on the user, relationship to order based on that user id, relationship to products based on the order, list the products. Answer by: Josh Miller Posted: Aug 10, 2012 Comments Or you could import this view and it will work (though I think it will show items that are in a shopping cart as well)... $view = new view;$view->name = 'recent_purchased_products';$view->description = '';$view->tag = 'default';$view->base_table = 'commerce_order';$view->human_name = 'Recent purchased products';$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'] = 'Recent purchased products';$handler->display->display_options['access']['type'] = 'none';$handler->display->display_options['cache']['type'] = 'none';$handler->display->display_options['query']['type'] = 'views_query';$handler->display->display_options['query']['options']['query_comment'] = FALSE;$handler->display->display_options['exposed_form']['type'] = 'basic';$handler->display->display_options['pager']['type'] = 'some';$handler->display->display_options['pager']['options']['items_per_page'] = '5';$handler->display->display_options['style_plugin'] = 'default';$handler->display->display_options['row_plugin'] = 'fields';/* Relationship: Commerce Order: Referenced line item */$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'] = 1;/* Relationship: Commerce Line item: Referenced product */$handler->display->display_options['relationships']['commerce_product_product_id']['id'] = 'commerce_product_product_id';$handler->display->display_options['relationships']['commerce_product_product_id']['table'] = 'field_data_commerce_product';$handler->display->display_options['relationships']['commerce_product_product_id']['field'] = 'commerce_product_product_id';$handler->display->display_options['relationships']['commerce_product_product_id']['relationship'] = 'commerce_line_items_line_item_id';$handler->display->display_options['relationships']['commerce_product_product_id']['required'] = 0;/* Field: Commerce Product: SKU */$handler->display->display_options['fields']['sku']['id'] = 'sku';$handler->display->display_options['fields']['sku']['table'] = 'commerce_product';$handler->display->display_options['fields']['sku']['field'] = 'sku';$handler->display->display_options['fields']['sku']['relationship'] = 'commerce_product_product_id';$handler->display->display_options['fields']['sku']['alter']['alter_text'] = 0;$handler->display->display_options['fields']['sku']['alter']['make_link'] = 0;$handler->display->display_options['fields']['sku']['alter']['absolute'] = 0;$handler->display->display_options['fields']['sku']['alter']['external'] = 0;$handler->display->display_options['fields']['sku']['alter']['replace_spaces'] = 0;$handler->display->display_options['fields']['sku']['alter']['trim_whitespace'] = 0;$handler->display->display_options['fields']['sku']['alter']['nl2br'] = 0;$handler->display->display_options['fields']['sku']['alter']['word_boundary'] = 1;$handler->display->display_options['fields']['sku']['alter']['ellipsis'] = 1;$handler->display->display_options['fields']['sku']['alter']['more_link'] = 0;$handler->display->display_options['fields']['sku']['alter']['strip_tags'] = 0;$handler->display->display_options['fields']['sku']['alter']['trim'] = 0;$handler->display->display_options['fields']['sku']['alter']['html'] = 0;$handler->display->display_options['fields']['sku']['element_label_colon'] = 1;$handler->display->display_options['fields']['sku']['element_default_classes'] = 1;$handler->display->display_options['fields']['sku']['hide_empty'] = 0;$handler->display->display_options['fields']['sku']['empty_zero'] = 0;$handler->display->display_options['fields']['sku']['hide_alter_empty'] = 1;$handler->display->display_options['fields']['sku']['link_to_product'] = 0;/* Field: Commerce Product: Title */$handler->display->display_options['fields']['title']['id'] = 'title';$handler->display->display_options['fields']['title']['table'] = 'commerce_product';$handler->display->display_options['fields']['title']['field'] = 'title';$handler->display->display_options['fields']['title']['relationship'] = 'commerce_product_product_id';$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;$handler->display->display_options['fields']['title']['alter']['external'] = 0;$handler->display->display_options['fields']['title']['alter']['replace_spaces'] = 0;$handler->display->display_options['fields']['title']['alter']['trim_whitespace'] = 0;$handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 1;$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 1;$handler->display->display_options['fields']['title']['alter']['more_link'] = 0;$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;$handler->display->display_options['fields']['title']['alter']['trim'] = 0;$handler->display->display_options['fields']['title']['alter']['html'] = 0;$handler->display->display_options['fields']['title']['element_label_colon'] = 1;$handler->display->display_options['fields']['title']['element_default_classes'] = 1;$handler->display->display_options['fields']['title']['hide_empty'] = 0;$handler->display->display_options['fields']['title']['empty_zero'] = 0;$handler->display->display_options['fields']['title']['hide_alter_empty'] = 1;$handler->display->display_options['fields']['title']['link_to_product'] = 0;/* Contextual filter: Commerce Order: Uid */$handler->display->display_options['arguments']['uid']['id'] = 'uid';$handler->display->display_options['arguments']['uid']['table'] = 'commerce_order';$handler->display->display_options['arguments']['uid']['field'] = 'uid';$handler->display->display_options['arguments']['uid']['default_action'] = 'default';$handler->display->display_options['arguments']['uid']['default_argument_type'] = 'current_user';$handler->display->display_options['arguments']['uid']['default_argument_skip_url'] = 0;$handler->display->display_options['arguments']['uid']['summary']['number_of_records'] = '0';$handler->display->display_options['arguments']['uid']['summary']['format'] = 'default_summary';$handler->display->display_options['arguments']['uid']['summary_options']['items_per_page'] = '25';$handler->display->display_options['arguments']['uid']['break_phrase'] = 0;$handler->display->display_options['arguments']['uid']['not'] = 0;/* 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',);/* Display: Block */$handler = $view->new_display('block', 'Block', 'block'); - Josh Miller on August 10, 2012 Log in or register to post a comment. Link Log in or register to post a comment.
Or you could import this view and it will work (though I think it will show items that are in a shopping cart as well)... $view = new view;$view->name = 'recent_purchased_products';$view->description = '';$view->tag = 'default';$view->base_table = 'commerce_order';$view->human_name = 'Recent purchased products';$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'] = 'Recent purchased products';$handler->display->display_options['access']['type'] = 'none';$handler->display->display_options['cache']['type'] = 'none';$handler->display->display_options['query']['type'] = 'views_query';$handler->display->display_options['query']['options']['query_comment'] = FALSE;$handler->display->display_options['exposed_form']['type'] = 'basic';$handler->display->display_options['pager']['type'] = 'some';$handler->display->display_options['pager']['options']['items_per_page'] = '5';$handler->display->display_options['style_plugin'] = 'default';$handler->display->display_options['row_plugin'] = 'fields';/* Relationship: Commerce Order: Referenced line item */$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'] = 1;/* Relationship: Commerce Line item: Referenced product */$handler->display->display_options['relationships']['commerce_product_product_id']['id'] = 'commerce_product_product_id';$handler->display->display_options['relationships']['commerce_product_product_id']['table'] = 'field_data_commerce_product';$handler->display->display_options['relationships']['commerce_product_product_id']['field'] = 'commerce_product_product_id';$handler->display->display_options['relationships']['commerce_product_product_id']['relationship'] = 'commerce_line_items_line_item_id';$handler->display->display_options['relationships']['commerce_product_product_id']['required'] = 0;/* Field: Commerce Product: SKU */$handler->display->display_options['fields']['sku']['id'] = 'sku';$handler->display->display_options['fields']['sku']['table'] = 'commerce_product';$handler->display->display_options['fields']['sku']['field'] = 'sku';$handler->display->display_options['fields']['sku']['relationship'] = 'commerce_product_product_id';$handler->display->display_options['fields']['sku']['alter']['alter_text'] = 0;$handler->display->display_options['fields']['sku']['alter']['make_link'] = 0;$handler->display->display_options['fields']['sku']['alter']['absolute'] = 0;$handler->display->display_options['fields']['sku']['alter']['external'] = 0;$handler->display->display_options['fields']['sku']['alter']['replace_spaces'] = 0;$handler->display->display_options['fields']['sku']['alter']['trim_whitespace'] = 0;$handler->display->display_options['fields']['sku']['alter']['nl2br'] = 0;$handler->display->display_options['fields']['sku']['alter']['word_boundary'] = 1;$handler->display->display_options['fields']['sku']['alter']['ellipsis'] = 1;$handler->display->display_options['fields']['sku']['alter']['more_link'] = 0;$handler->display->display_options['fields']['sku']['alter']['strip_tags'] = 0;$handler->display->display_options['fields']['sku']['alter']['trim'] = 0;$handler->display->display_options['fields']['sku']['alter']['html'] = 0;$handler->display->display_options['fields']['sku']['element_label_colon'] = 1;$handler->display->display_options['fields']['sku']['element_default_classes'] = 1;$handler->display->display_options['fields']['sku']['hide_empty'] = 0;$handler->display->display_options['fields']['sku']['empty_zero'] = 0;$handler->display->display_options['fields']['sku']['hide_alter_empty'] = 1;$handler->display->display_options['fields']['sku']['link_to_product'] = 0;/* Field: Commerce Product: Title */$handler->display->display_options['fields']['title']['id'] = 'title';$handler->display->display_options['fields']['title']['table'] = 'commerce_product';$handler->display->display_options['fields']['title']['field'] = 'title';$handler->display->display_options['fields']['title']['relationship'] = 'commerce_product_product_id';$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;$handler->display->display_options['fields']['title']['alter']['external'] = 0;$handler->display->display_options['fields']['title']['alter']['replace_spaces'] = 0;$handler->display->display_options['fields']['title']['alter']['trim_whitespace'] = 0;$handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 1;$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 1;$handler->display->display_options['fields']['title']['alter']['more_link'] = 0;$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;$handler->display->display_options['fields']['title']['alter']['trim'] = 0;$handler->display->display_options['fields']['title']['alter']['html'] = 0;$handler->display->display_options['fields']['title']['element_label_colon'] = 1;$handler->display->display_options['fields']['title']['element_default_classes'] = 1;$handler->display->display_options['fields']['title']['hide_empty'] = 0;$handler->display->display_options['fields']['title']['empty_zero'] = 0;$handler->display->display_options['fields']['title']['hide_alter_empty'] = 1;$handler->display->display_options['fields']['title']['link_to_product'] = 0;/* Contextual filter: Commerce Order: Uid */$handler->display->display_options['arguments']['uid']['id'] = 'uid';$handler->display->display_options['arguments']['uid']['table'] = 'commerce_order';$handler->display->display_options['arguments']['uid']['field'] = 'uid';$handler->display->display_options['arguments']['uid']['default_action'] = 'default';$handler->display->display_options['arguments']['uid']['default_argument_type'] = 'current_user';$handler->display->display_options['arguments']['uid']['default_argument_skip_url'] = 0;$handler->display->display_options['arguments']['uid']['summary']['number_of_records'] = '0';$handler->display->display_options['arguments']['uid']['summary']['format'] = 'default_summary';$handler->display->display_options['arguments']['uid']['summary_options']['items_per_page'] = '25';$handler->display->display_options['arguments']['uid']['break_phrase'] = 0;$handler->display->display_options['arguments']['uid']['not'] = 0;/* 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',);/* Display: Block */$handler = $view->new_display('block', 'Block', 'block'); - Josh Miller on August 10, 2012 Log in or register to post a comment.
Comments
Or you could import this view and it will work (though I think it will show items that are in a shopping cart as well)...
$view = new view;
$view->name = 'recent_purchased_products';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'commerce_order';
$view->human_name = 'Recent purchased products';
$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'] = 'Recent purchased products';
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '5';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Relationship: Commerce Order: Referenced line item */
$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'] = 1;
/* Relationship: Commerce Line item: Referenced product */
$handler->display->display_options['relationships']['commerce_product_product_id']['id'] = 'commerce_product_product_id';
$handler->display->display_options['relationships']['commerce_product_product_id']['table'] = 'field_data_commerce_product';
$handler->display->display_options['relationships']['commerce_product_product_id']['field'] = 'commerce_product_product_id';
$handler->display->display_options['relationships']['commerce_product_product_id']['relationship'] = 'commerce_line_items_line_item_id';
$handler->display->display_options['relationships']['commerce_product_product_id']['required'] = 0;
/* Field: Commerce Product: SKU */
$handler->display->display_options['fields']['sku']['id'] = 'sku';
$handler->display->display_options['fields']['sku']['table'] = 'commerce_product';
$handler->display->display_options['fields']['sku']['field'] = 'sku';
$handler->display->display_options['fields']['sku']['relationship'] = 'commerce_product_product_id';
$handler->display->display_options['fields']['sku']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['sku']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['sku']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['sku']['alter']['external'] = 0;
$handler->display->display_options['fields']['sku']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['sku']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['sku']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['sku']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['sku']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['sku']['alter']['more_link'] = 0;
$handler->display->display_options['fields']['sku']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['sku']['alter']['trim'] = 0;
$handler->display->display_options['fields']['sku']['alter']['html'] = 0;
$handler->display->display_options['fields']['sku']['element_label_colon'] = 1;
$handler->display->display_options['fields']['sku']['element_default_classes'] = 1;
$handler->display->display_options['fields']['sku']['hide_empty'] = 0;
$handler->display->display_options['fields']['sku']['empty_zero'] = 0;
$handler->display->display_options['fields']['sku']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['sku']['link_to_product'] = 0;
/* Field: Commerce Product: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'commerce_product';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['relationship'] = 'commerce_product_product_id';
$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['title']['alter']['external'] = 0;
$handler->display->display_options['fields']['title']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['title']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['title']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['title']['alter']['more_link'] = 0;
$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
$handler->display->display_options['fields']['title']['alter']['html'] = 0;
$handler->display->display_options['fields']['title']['element_label_colon'] = 1;
$handler->display->display_options['fields']['title']['element_default_classes'] = 1;
$handler->display->display_options['fields']['title']['hide_empty'] = 0;
$handler->display->display_options['fields']['title']['empty_zero'] = 0;
$handler->display->display_options['fields']['title']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['title']['link_to_product'] = 0;
/* Contextual filter: Commerce Order: Uid */
$handler->display->display_options['arguments']['uid']['id'] = 'uid';
$handler->display->display_options['arguments']['uid']['table'] = 'commerce_order';
$handler->display->display_options['arguments']['uid']['field'] = 'uid';
$handler->display->display_options['arguments']['uid']['default_action'] = 'default';
$handler->display->display_options['arguments']['uid']['default_argument_type'] = 'current_user';
$handler->display->display_options['arguments']['uid']['default_argument_skip_url'] = 0;
$handler->display->display_options['arguments']['uid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['uid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['uid']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['uid']['break_phrase'] = 0;
$handler->display->display_options['arguments']['uid']['not'] = 0;
/* 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',
);
/* Display: Block */
$handler = $view->new_display('block', 'Block', 'block');