How can I get the current user who purchased a product from the onOrderComplete event?
Since this is happening from the onOrderComplete event, the easiest way to get the currently logged in user is with UserSessionService::getUser():



$user = craft()-&gt;userSession-&gt;getUser();


Alternatively, if you want to go through the actual Commerce_OrderModel that was passed as a parameter on the event, you can do this:

$user = $event-&gt;params['order']-&gt;getCustomer()-&gt;getUser();


Either way, it’s a good idea to verify that $user gets set to something, just in case:

if ($user) {
    // ...
}