Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Vendor name

 
Reply
   X-Cart forums > X-Cart 5 > General questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 10-03-2018, 03:46 AM
 
amarquis amarquis is offline
 

Advanced Member
  
Join Date: Apr 2018
Posts: 70
 

Default Vendor name

If a vendor removes all addresses from his address book, why does the following function return "Administrator" ??

PHP Code:
\XLite\Core\Auth::getInstance()->getProfile()->getName() 
__________________
5.3.5.8
Reply With Quote
  #2  
Old 11-29-2018, 04:23 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default Re: Vendor name

Hi @amarquis,

Sorry for the late answer and hope it is still relevant to you.

If you look at the implementation of the \XLite\Model\Profile::getName() method you will see its implementation as follows:

Code:
public function getName($useDefault = true) { $address = $this->getBillingAddress() ?: $this->getShippingAddress(); return $address && ($address->getFirstname() || $address->getLastname()) ? trim($address->getFirstname() . ' ' . $address->getLastname()) : ($useDefault ? $this->getDefaultName() : ''); } protected function getDefaultName() { return $this->isAdmin() ? static::t('na_admin') : static::t('na_customer'); }

In short words, X-Cart tries to pull either billing or shipping address, but if there are none and $useDefault is not passed or passed as true, it will either return 'Customer' or 'Admin' depending on the user type. If the $useDefault param is passed as 'false', it will return the empty string as you would expect.

So, you should just call it like this
PHP Code:
\XLite\Core\Auth::getInstance()->getProfile()->getName(false); 

Tony

Quote:
Originally Posted by amarquis
If a vendor removes all addresses from his address book, why does the following function return "Administrator" ??

PHP Code:
\XLite\Core\Auth::getInstance()->getProfile()->getName() 
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > General questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 07:03 AM.

   

 
X-Cart forums © 2001-2020