In ubercart how to get uid and order_id after the user is created and associated to order
I have seen similar questions such as drupal :: order complete hook and upgrade user permission/roles which would work for me except that my order never reaches completed, only payment_received. At this time the uid is 0. It still doesn't work if I add a conditional action under "Customer completes开发者_Go百科 checkout" to mark the status as complete as the uid is still 0.
So my question is, how can I get the uid and the order object after the user has successfully completed checkout and been created?
When Ubercart creates the user it also logs them in so you would just have to do this to get the uid:
global $user;
$uid = $user->uid;
It would probably be best served in hook_order() as mentioned in the similar question you linked to.
UPDATE
If there's no uid
associated with the order you should be able to something like this:
function MYMODULE_order($op, &$order, $arg2) {
if ($op == 'update' && $arg2 == 'payment_received') {
if ($order->uid) {
$uid = $order->uid;
}
else {
global $user;
$uid = $user->uid;
}
}
}
精彩评论