Question

I'm building a commerce site using Drupal Commerce. I've got it going very smoothly now but I've hit a dead end when I'm trying to create a module for handling shipping information and sending it to the shipping company for label printing.

The problem is, that I have created a new tab in an Order page,

admin/commerce/orders/order_id/printlabel

and I can access this page via a tab when I edit an order.

Now, I have no idea how I can pull the order_id number in the module. I have tried almost everything, entity_view, entity_metadata_wrapper, commerce_order.module API, but I have no idea how I can access the id and that is the key. When I get the ID, I can get the shipping information linked to it and I can send this data to the shipping company and save it.I also looked into the ways Commerce does things like combine Payment with Views but it seemed a bit too complicated for me to try so, I'm asking here. I can't get any answers on Drupal's own support forums.

Was it helpful?

Solution

Hope i got your question right.You created a custom menu admin/commerce/orders/*/printlabel where * is the order id of a particular order. You need the order id.

The simplest solution to it is getting it through the arguments or arg(). This is a function that drupal provides to get data from the arguments. For eg

if your url is www.xyz.com/admin/commerce/orders/0001/printlabel & you need order id i.e 0001 you can get it using arg(3).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top