Open danmarsden opened 6 years ago
It is just because a customer registered in a Customer class is often NOT YET a moodle user. He will become a moodle user only if a purchase is concluded and the product handler do register the customer as moodle user effectively (It usually does, at least to enrol the customer in a customer support course).
What we might do is to check if a customer has a moodle account, and revert to the standard fullname() function in this case.
cool - makes sense. I wpuld also be tempted to try and create a $user object with the firstname/lastname from your new non-moodle user customer and pass it to fullname() so that the lang settings can still be used to display the name in the prefferred lang order. (not sure if a dummy object will work in fullname() though so it might not be possible!)
https://github.com/vfremaux/moodle-local_shop/blob/master/classes/Customer.class.php#L81
is there a reason you don't use the core fullname() function here? - some languages display them in a different order, some sites use other name fields etc.