vfremaux / moodle-local_shop

core plugin for a moodle integrated shop system. this is the community version
4 stars 3 forks source link

custom fullname function #6

Open danmarsden opened 6 years ago

danmarsden commented 6 years ago

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.

vfremaux commented 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.

danmarsden commented 6 years ago

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!)