2

I would like to ask if it is possible to assign another UID, different from that of the currently logged in user, to an order under checkout process (e.g. via rules)?

Any idea how to do that? Thanks.

2 Answers 2

0

If you'd like to change ownership during checkout, probably not, or not without reworking some core UC code; there are likely to be permission problems if you switch the user owner before order completion.

Changing the ownership of a UC order is a trivial change.

$order = uc_order_load($order_id);
$order->uid = 1234;
uc_order_save($order);

But, the core Ubercart rules integration do not support a rules action that changes order ownership. So in order to use rules you'd need to build a custom action there. Also, because aforementioned permission problems, you'd likely need to use an event that occurs when the purchasing user no longer needs to own the order.

In summary, the above code is somewhat of a starting point, but you're looking at tripping over UC's order ownership enforcement if you go down this route.

0

fwiw I do something similar with the Masquerade module. I made the masquerade block show up for employees and this enables them to switch to a customer account to place an order. It works beautifully!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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