Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#5 | commerce_backoffice_order-make-the-order-operations-links-alterable-2110569-5.patch | 1.72 KB | jsacksick |
Comments
Comment #1
jsacksick CreditAttribution: jsacksick commentedIf 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
Comment #3
ShaneOnABike CreditAttribution: ShaneOnABike commentedHrrm... are you sure that's all it takes? If you look at the code of Commerce Invoice Receipt you have
Now according to you this should just be picked up but it isn't....
Comment #4
TrevorBradley CreditAttribution: TrevorBradley commentedWas 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:
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:
Commenting it out adds a view link that works great from the orders page.
Comment #5
jsacksick CreditAttribution: jsacksick commentedI committed some code that allows you to alter the order's operations links (See attached patch).