How do I create a link to a view in Commerce Order listing? I want to create a link on an order dropdown menu in commerce order that is attached to a view.  So for example, when you are looking at the list of orders, there is a drop down menu which has Quick Edit, Payment, Delete, etc.  I want to another element to this drop down menu which points to a view that I have created.

I have successfully added a link this dropdown menu using the following code, but it links to a form.     

$items['admin/commerce/orders/%commerce_order/cancel'] = array(
    'title' =&gt; 'Cancel',
    'page callback' =&gt; 'bh_order_handling_ui_order_cancel_form_wrapper',
    'page arguments' =&gt; array(3),
    'access callback' =&gt; 'bh_order_handling_ui_cancel_access',
    'access arguments' =&gt; array(3),
    'type' =&gt; MENU_LOCAL_TASK,
    'weight' =&gt; 30,
    'context' =&gt; MENU_CONTEXT_INLINE,
);


What I want to do is link to a view that I have created at the path admin/commerce/orders/%/takehomeitems.

I have tried the following, using suggestions from http://zufelt.ca/blog/embedding-view-menu-hook-drupal

$items['admin/commerce/orders/%/takehomeitems'] = array(
        'title' =&gt; 'Take Home Items',
        'page callback' =&gt; 'views_embed_view',
        'page arguments' =&gt; array('bh_view_customer_donation_line_item','default',3),
        'access callback' =&gt; 'bh_donate_takehomeorder_access',
        'access arguments' =&gt; array(3),
        'type' =&gt; MENU_LOCAL_TASK,
        'weight' =&gt; 10,
        'context' =&gt; MENU_CONTEXT_INLINE,
        'file path' =&gt; drupal_get_path('module', 'views'),
        'file' =&gt; 'views.module',
);
I needed to call views_embed_view in my own page callback because I needed to pass the commerce order id for my contextual filter.  Here is what I did:

I first defined the menu item.  Note that the path has %commerce_order instead of just %. This is needed to access the order object which has the id. 

When creating the view, I put in in a separate path, not the path I used for the $items.  When I tried to use the same path, it didn't work.  I think it is because the $items path is needed to create the listing in the dropdown menu.

I defined the path of my view as something that was not admin/commerce/orders/%commerce_order/takehomeitems
It is important that your view have a contextual filter which takes the order id. My path was /admin/hubadmin/takehomeitems/%

See the bottom of my posted answer for the exported view example.

Then in hook_menu, i defined the following:

 $items['admin/commerce/orders/%commerce_order/takehomeitems'] = array(
   'title' =&gt; 'Take Home Items',
   'page callback' =&gt; '_bh_donate_takehome_lineitems',
   'page arguments' =&gt; array(3),
   'access callback' =&gt; 'bh_donate_takehomeorder_access',
   'access arguments' =&gt; array(3),
   'type' =&gt; MENU_LOCAL_TASK,
   'weight' =&gt; 10,
   'context' =&gt; MENU_CONTEXT_INLINE,
 );


I then defined the page callback which calls views_embed_view and by passing in the %commerce_order, I am able to get the order id

function _bh_donate_takehome_lineitems($order) {
  return views_embed_view('YOURVIEWNAME', 'YOURDISPLAYID', $order-&gt;order_id);
} //DISPLAYID is usually default. To find this out, choose to export your view and look at $handler = $view-&gt;new_display('default', 'Master', 'default'); The last parameter is the display id.


This creates a item in the dropdown menu of the order which links to a view. The breadcrumb path points to the order.

Here is my exported view that worked for an example. 

$view = new view();
    $view-&gt;name = 'bh_view_customer_donation_line_item';
    $view-&gt;description = '';
    $view-&gt;tag = 'default';
    $view-&gt;base_table = 'commerce_order';
    $view-&gt;human_name = 'BH View: Customer Take Home Line Items';
    $view-&gt;core = 7;
    $view-&gt;api_version = '3.0';
    $view-&gt;disabled = FALSE; /* Edit this to true to make a default view disabled initially */

    /* Display: Master */
    $handler = $view-&gt;new_display('default', 'Master', 'default');
    $handler-&gt;display-&gt;display_options['title'] = 'Customer Take Home Line Items';
    $handler-&gt;display-&gt;display_options['use_more_always'] = FALSE;
    $handler-&gt;display-&gt;display_options['access']['type'] = 'none';
    $handler-&gt;display-&gt;display_options['cache']['type'] = 'none';
    $handler-&gt;display-&gt;display_options['query']['type'] = 'views_query';
    $handler-&gt;display-&gt;display_options['exposed_form']['type'] = 'basic';
    $handler-&gt;display-&gt;display_options['pager']['type'] = 'full';
    $handler-&gt;display-&gt;display_options['pager']['options']['items_per_page'] = '10';
    $handler-&gt;display-&gt;display_options['style_plugin'] = 'table';
    $handler-&gt;display-&gt;display_options['style_options']['columns'] = array(
        'vendor_user_reference' =&gt; 'vendor_user_reference',
        'commerce_product' =&gt; 'commerce_product',
        'quantity' =&gt; 'quantity',
        'commerce_unit_price' =&gt; 'commerce_unit_price',
        'commerce_total' =&gt; 'commerce_total',
    );
    $handler-&gt;display-&gt;display_options['style_options']['default'] = '-1';
    $handler-&gt;display-&gt;display_options['style_options']['info'] = array(
        'vendor_user_reference' =&gt; array(
            'sortable' =&gt; 0,
            'default_sort_order' =&gt; 'asc',
            'align' =&gt; '',
            'separator' =&gt; '',
            'empty_column' =&gt; 0,
        ),
        'commerce_product' =&gt; array(
            'sortable' =&gt; 0,
            'default_sort_order' =&gt; 'asc',
            'align' =&gt; '',
            'separator' =&gt; '',
            'empty_column' =&gt; 0,
        ),
        'quantity' =&gt; array(
            'sortable' =&gt; 0,
            'default_sort_order' =&gt; 'asc',
            'align' =&gt; '',
            'separator' =&gt; '',
            'empty_column' =&gt; 0,
        ),
        'commerce_unit_price' =&gt; array(
            'sortable' =&gt; 0,
            'default_sort_order' =&gt; 'asc',
            'align' =&gt; '',
            'separator' =&gt; '',
            'empty_column' =&gt; 0,
        ),
        'commerce_total' =&gt; array(
            'sortable' =&gt; 0,
            'default_sort_order' =&gt; 'asc',
            'align' =&gt; '',
            'separator' =&gt; '',
            'empty_column' =&gt; 0,
        ),
    );
    $handler-&gt;display-&gt;display_options['style_options']['empty_table'] = TRUE;
    /* Relationship: Commerce Order: Referenced line items */
    $handler-&gt;display-&gt;display_options['relationships']['commerce_line_items_line_item_id']['id'] = 'commerce_line_items_line_item_id';
    $handler-&gt;display-&gt;display_options['relationships']['commerce_line_items_line_item_id']['table'] = 'field_data_commerce_line_items';
    $handler-&gt;display-&gt;display_options['relationships']['commerce_line_items_line_item_id']['field'] = 'commerce_line_items_line_item_id';
    /* Relationship: Commerce Line item: Referenced products */
    $handler-&gt;display-&gt;display_options['relationships']['commerce_product_product_id']['id'] = 'commerce_product_product_id';
    $handler-&gt;display-&gt;display_options['relationships']['commerce_product_product_id']['table'] = 'field_data_commerce_product';
    $handler-&gt;display-&gt;display_options['relationships']['commerce_product_product_id']['field'] = 'commerce_product_product_id';
    $handler-&gt;display-&gt;display_options['relationships']['commerce_product_product_id']['relationship'] = 'commerce_line_items_line_item_id';
    /* Field: Commerce Product: Vendor User Reference */
    $handler-&gt;display-&gt;display_options['fields']['vendor_user_reference']['id'] = 'vendor_user_reference';
    $handler-&gt;display-&gt;display_options['fields']['vendor_user_reference']['table'] = 'field_data_vendor_user_reference';
    $handler-&gt;display-&gt;display_options['fields']['vendor_user_reference']['field'] = 'vendor_user_reference';
    $handler-&gt;display-&gt;display_options['fields']['vendor_user_reference']['relationship'] = 'commerce_product_product_id';
    $handler-&gt;display-&gt;display_options['fields']['vendor_user_reference']['label'] = 'Vendor ';
    $handler-&gt;display-&gt;display_options['fields']['vendor_user_reference']['element_type'] = '0';
    $handler-&gt;display-&gt;display_options['fields']['vendor_user_reference']['element_label_colon'] = FALSE;
    $handler-&gt;display-&gt;display_options['fields']['vendor_user_reference']['element_wrapper_type'] = '0';
    $handler-&gt;display-&gt;display_options['fields']['vendor_user_reference']['element_default_classes'] = FALSE;
    $handler-&gt;display-&gt;display_options['fields']['vendor_user_reference']['field_api_classes'] = TRUE;
    /* Field: Commerce Line item: Product */
    $handler-&gt;display-&gt;display_options['fields']['commerce_product']['id'] = 'commerce_product';
    $handler-&gt;display-&gt;display_options['fields']['commerce_product']['table'] = 'field_data_commerce_product';
    $handler-&gt;display-&gt;display_options['fields']['commerce_product']['field'] = 'commerce_product';
    $handler-&gt;display-&gt;display_options['fields']['commerce_product']['relationship'] = 'commerce_line_items_line_item_id';
    $handler-&gt;display-&gt;display_options['fields']['commerce_product']['element_type'] = '0';
    $handler-&gt;display-&gt;display_options['fields']['commerce_product']['element_label_colon'] = FALSE;
    $handler-&gt;display-&gt;display_options['fields']['commerce_product']['element_wrapper_type'] = '0';
    $handler-&gt;display-&gt;display_options['fields']['commerce_product']['element_default_classes'] = FALSE;
    $handler-&gt;display-&gt;display_options['fields']['commerce_product']['type'] = 'commerce_product_reference_sku_link';
    $handler-&gt;display-&gt;display_options['fields']['commerce_product']['settings'] = array(
        'show_quantity' =&gt; 0,
        'default_quantity' =&gt; '1',
        'combine' =&gt; 1,
        'show_single_product_attributes' =&gt; 0,
        'line_item_type' =&gt; 'product',
    );
    $handler-&gt;display-&gt;display_options['fields']['commerce_product']['field_api_classes'] = TRUE;
    /* Field: Commerce Line Item: Quantity */
    $handler-&gt;display-&gt;display_options['fields']['quantity']['id'] = 'quantity';
    $handler-&gt;display-&gt;display_options['fields']['quantity']['table'] = 'commerce_line_item';
    $handler-&gt;display-&gt;display_options['fields']['quantity']['field'] = 'quantity';
    $handler-&gt;display-&gt;display_options['fields']['quantity']['relationship'] = 'commerce_line_items_line_item_id';
    /* Field: Commerce Line item: Unit price */
    $handler-&gt;display-&gt;display_options['fields']['commerce_unit_price']['id'] = 'commerce_unit_price';
    $handler-&gt;display-&gt;display_options['fields']['commerce_unit_price']['table'] = 'field_data_commerce_unit_price';
    $handler-&gt;display-&gt;display_options['fields']['commerce_unit_price']['field'] = 'commerce_unit_price';
    $handler-&gt;display-&gt;display_options['fields']['commerce_unit_price']['relationship'] = 'commerce_line_items_line_item_id';
    $handler-&gt;display-&gt;display_options['fields']['commerce_unit_price']['element_type'] = '0';
    $handler-&gt;display-&gt;display_options['fields']['commerce_unit_price']['element_label_colon'] = FALSE;
    $handler-&gt;display-&gt;display_options['fields']['commerce_unit_price']['element_wrapper_type'] = '0';
    $handler-&gt;display-&gt;display_options['fields']['commerce_unit_price']['element_default_classes'] = FALSE;
    $handler-&gt;display-&gt;display_options['fields']['commerce_unit_price']['click_sort_column'] = 'amount';
    $handler-&gt;display-&gt;display_options['fields']['commerce_unit_price']['settings'] = array(
        'calculation' =&gt; FALSE,
    );
    $handler-&gt;display-&gt;display_options['fields']['commerce_unit_price']['field_api_classes'] = TRUE;
    /* Field: Commerce Line item: Total */
    $handler-&gt;display-&gt;display_options['fields']['commerce_total']['id'] = 'commerce_total';
    $handler-&gt;display-&gt;display_options['fields']['commerce_total']['table'] = 'field_data_commerce_total';
    $handler-&gt;display-&gt;display_options['fields']['commerce_total']['field'] = 'commerce_total';
    $handler-&gt;display-&gt;display_options['fields']['commerce_total']['relationship'] = 'commerce_line_items_line_item_id';
    $handler-&gt;display-&gt;display_options['fields']['commerce_total']['element_type'] = '0';
    $handler-&gt;display-&gt;display_options['fields']['commerce_total']['element_wrapper_type'] = '0';
    $handler-&gt;display-&gt;display_options['fields']['commerce_total']['element_default_classes'] = FALSE;
    $handler-&gt;display-&gt;display_options['fields']['commerce_total']['click_sort_column'] = 'amount';
    $handler-&gt;display-&gt;display_options['fields']['commerce_total']['settings'] = array(
        'calculation' =&gt; FALSE,
    );
    $handler-&gt;display-&gt;display_options['fields']['commerce_total']['field_api_classes'] = TRUE;
    /* Contextual filter: Commerce Line Item: Order ID */
    $handler-&gt;display-&gt;display_options['arguments']['order_id']['id'] = 'order_id';
    $handler-&gt;display-&gt;display_options['arguments']['order_id']['table'] = 'commerce_line_item';
    $handler-&gt;display-&gt;display_options['arguments']['order_id']['field'] = 'order_id';
    $handler-&gt;display-&gt;display_options['arguments']['order_id']['relationship'] = 'commerce_line_items_line_item_id';
    $handler-&gt;display-&gt;display_options['arguments']['order_id']['default_action'] = 'empty';
    $handler-&gt;display-&gt;display_options['arguments']['order_id']['title_enable'] = TRUE;
    $handler-&gt;display-&gt;display_options['arguments']['order_id']['title'] = 'Order %1';
    $handler-&gt;display-&gt;display_options['arguments']['order_id']['default_argument_type'] = 'fixed';
    $handler-&gt;display-&gt;display_options['arguments']['order_id']['summary']['number_of_records'] = '0';
    $handler-&gt;display-&gt;display_options['arguments']['order_id']['summary']['format'] = 'default_summary';
    $handler-&gt;display-&gt;display_options['arguments']['order_id']['summary_options']['items_per_page'] = '25';
    /* Filter criterion: Commerce Product: Vendor User Reference (vendor_user_reference) */
    $handler-&gt;display-&gt;display_options['filters']['vendor_user_reference_uid']['id'] = 'vendor_user_reference_uid';
    $handler-&gt;display-&gt;display_options['filters']['vendor_user_reference_uid']['table'] = 'field_data_vendor_user_reference';
    $handler-&gt;display-&gt;display_options['filters']['vendor_user_reference_uid']['field'] = 'vendor_user_reference_uid';
    $handler-&gt;display-&gt;display_options['filters']['vendor_user_reference_uid']['relationship'] = 'commerce_product_product_id';
    $handler-&gt;display-&gt;display_options['filters']['vendor_user_reference_uid']['operator'] = 'not empty';
    /* Filter criterion: Commerce Line Item: Type */
    $handler-&gt;display-&gt;display_options['filters']['type']['id'] = 'type';
    $handler-&gt;display-&gt;display_options['filters']['type']['table'] = 'commerce_line_item';
    $handler-&gt;display-&gt;display_options['filters']['type']['field'] = 'type';
    $handler-&gt;display-&gt;display_options['filters']['type']['relationship'] = 'commerce_line_items_line_item_id';
    $handler-&gt;display-&gt;display_options['filters']['type']['value'] = array(
        'product' =&gt; 'product',
    );

    /* Display: Page */
    $handler = $view-&gt;new_display('page', 'Page', 'page');
    $handler-&gt;display-&gt;display_options['path'] = 'admin/hubadmin/takehome-items/%';