Discussions

How to access [commerce-order:uid] or [commerce-order:owner] using php code?

Hi short time reader. first time poster :)
I don´t know if this is the place to ask, but here goes anyway.

Im using rules. and the problem is, that I need the user account of an order ( [commerce-order:uid] ), normally I could put that into the "Data selector" but this time where I need it the data selector will only accept date variables. ok so I´m writing some extra php code. But how do I call [commerce-order:uid] in php code. Or what is the equivalent php code to the token?
is it possible?
if it is, is there a place to look it up?

In advance thank you for your time :)

Posted: Dec 6, 2011

Comments

dasmoermel on December 10, 2011

Hi!

I'm not sure, but I think you can use the tokens in PHP-Code.
All availabe variables are shown below the editorfield in Rules "own PHP code".

kind regards, Marc

bolind on December 20, 2011

Hi kind marc, thank you for the reply :)

The problem here is that neither [commerce-order:uid] or [commerce-order:owner] are available variables in this situation.
im tying to get at them from SCHEDULED EVALUATION DATE in rules. But this box only deals with time. sadly i would really like to know the owner and then add some time dependant on the owner.

If i use $user_id = $GLOBALS['user']->uid; i end up in a situation where the admin role might be used and not the order owner :|

So im wondering if it is possible to get at them another way?
From looking at the api* it does not mention anything about an owner. so im wondering how drupalcommerce keeps track? :´|

maybe im just looking at this wrong.

-----
api* http://api.drupalcommerce.org/api/Drupal%20Commerce/constants/DC