0

Is there a way to do it from the tpl?

ie: page--admin--commerce--orders.tpl.php

I've tried this, but naturally, I get an undefined $order_id variable

if (commerce_order_load($order_id)) {
  echo $order->uid;
}
4

If you're looking for the order ID related to the current cart you can use commerce_cart_order_id():

$order = commerce_order_load(commerce_cart_order_id());

But you shouldn't use it directly in a template file. Use a preprocess hook instead, it's better all round.

| improve this answer | |
  • Thanks! How to know what preprocessors to use with drupal commerce? (api.drupalcommerce.org/api/Drupal%20Commerce/…)? – Rosamunda Dec 23 '14 at 19:25
  • I mean, in order to get to: moduleName_preprocess_hook what is the hook I'm after? Thanks again for your help! – Rosamunda Dec 23 '14 at 19:31
  • It would just be hook_preprocess_page(), you can check request_uri() against whatever URL (admin/commerce/orders maybe?) to check you're on the right page – Clive Dec 23 '14 at 19:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.