Hi, is it possible to add to the Operations drop-down list in the megarows views of Orders, Products etc?

For instance, I've enabled Commerce Invoice Receipt module to my site. In the megarows view of Orders, provided by Commerce BackOffice Order, I'd like to add the word 'Print' to the Operations drop-down list, and link this new Print command to printing the invoice provided by Commerce Invoice.. (Well, any kind of printing would do for a start)

And/or, is it possible to add a Print button to the Quick Edit pane?

Thanks for your help.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jsacksick’s picture

Issue summary: View changes
Status: Active » Fixed

If you want to add "print" to the operations dropdown list then you have to make that link contextual and the url should be something like admin/commerce/orders/%commerce_order/print

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

ShaneOnABike’s picture

Status: Closed (fixed) » Active

Hrrm... are you sure that's all it takes? If you look at the code of Commerce Invoice Receipt you have

function commerce_invoice_receipt_menu() {
  $items = array();

  $items['admin/commerce/orders/%commerce_order/view/print'] = array(
    'title' => 'Print',
    'page callback' => 'commerce_invoice_receipt_view_print',
    'page arguments' => array(3),
    'access callback' => 'commerce_order_access',
    'access arguments' => array('view', 3),
    'type' => MENU_LOCAL_TASK,
    'weight' => 1,
    'parent' => 'admin/commerce/orders/%commerce_order',
    'file' => 'includes/commerce_invoice_receipt.admin.inc',
  );

Now according to you this should just be picked up but it isn't....

TrevorBradley’s picture

Version: 7.x-1.3 » 7.x-1.4

Was just looking into this myself, also with Commerce Invoice Receipt.

commerce_backoffice_handler_field_node_operations.inc makes use of menu_contextual_links, which only grabs menu items with a defined "context" of MENU_CONTEXT_INLINE. Theoretically this might make it a Commerce Invoice Receipt issue, but I tried hacking in MENU_CONTEXT_INLINE into the menu items there and it didn't seem to work (it actually broke the menu items for Invoice Print). menu_contextual_links also makes reference to finding only "the first layer of registered local tasks", so I fear there might be a bit of a double whammy here.

Now, menu_contextual_links has a drupal_alter call near the end,. I tried messing around with it to be able to add items to the list, but it seemed a very roundabout way of adding links.

This looks like a combo problem between Backoffice and Invoice Receipt: Backoffice stubbornly looks only for links that menu_contextual_links finds valid (without considering that other chlid links, including non MENU_CONTEXT_INLINE could be valid Backoffice links), while Commerce Invoice Receipt hasn't set up MENU_CONTEXT_INLINE links that Backoffice expects.

All this being said, I did manage to add "Print Invoice" to the pull down menu using my own module and hook_menu_alter:

function MYMODULE_menu_alter(&$items) {
  $items['admin/commerce/orders/%commerce_order/print'] = array(
    'title' => 'Print Invoice',
    'page callback' => 'commerce_invoice_receipt_view_print',
    'page arguments' => array(3),
    'access callback' => 'commerce_order_access',
    'access arguments' => array('view', 3),
    'type' => MENU_LOCAL_TASK,
    'weight' => 1,
    'parent' => 'admin/commerce/orders/%commerce_order',
    'file' => 'includes/commerce_invoice_receipt.admin.inc',
    'context' => MENU_CONTEXT_INLINE,
    'module' => 'commerce_invoice_receipt',
  );
}

Here, I've changed the path from admin/commerce/orders/%commerce_order/view/print down to admin/commerce/orders/%commerce_order/view/print, and changed the context to MENU_CONTEXT_INLINE. It does the trick well enough without hacking either module.

For some reason, simply changing the existing admin/commerce/orders/%commerce_order/view/print to the correct context both broke the menu, *and* didn't work in Backoffice. Not sure why. The URL being a second level deep isn't the issue. I changed the url to "aaa/print", and it also worked.

As a side note, I'm a bit baffled why commerce_backoffice_handler_field_node_operations.inc has the following code:

    // Remove the View link, that functionality opens in a megarow.
    array_shift($links);

Commenting it out adds a view link that works great from the orders page.

jsacksick’s picture

Title: Change Operations drop-down items » Allow the alteration of the order's dropdown links
Category: Support request » Feature request
Status: Active » Fixed
FileSize
1.72 KB

I committed some code that allows you to alter the order's operations links (See attached patch).

  • jsacksick committed 57056d9 on 7.x-1.x
    Issue #2110569: Allow the alteration of the order's operation links.
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.