Discussions

Custom Rules Action (completing order) and Order ID

Hello all,

I have created a custom rules action via module. My only problem is making the Order ID available.

My function prototype is as follows:
function create_this_node($node, $context = array())

If I print_r($context), I can see the Order ID in a few places. The only problem is, all the data is protected so I cannot directly access it.

e.g. [id:protected] => 52

I have tried adding conditions to my rules via the GUI but still unable to access the order id.

So what do I need to do in order to get access to the Order ID?

Cheers,
Amarjit

Posted: Jan 6, 2012

Comments

Amarjit on March 19, 2012

Nevermind!

I have figured it out. I was trying to access the 'wrapper' directly; as in trying to extract the protected properties from an object.

I used the function value() to get access to the data, see below.

<?php
  $order
= $context->variables['commerce_order'];
 
$order_wrapper = entity_metadata_wrapper('commerce_order', $order); 
 
drupal_set_message('<pre>'. print_r($order_wrapper->value(), TRUE) .'</pre>');
?>