Prevent new address from pre-populating Last Name

  • Posts: 48
  • Thank you received: 1
9 years 9 months ago #189084

-- HikaShop version -- : 2.3.5
-- Joomla version -- : 2.5.28
-- PHP version -- : 5.4.37

This is actually more of an issue with JFusion/Joomla than Hikashop, but I need to figure out a way to fix it in Hikashop.

We're running an environment where most users were populated by JFusion from a phpBB install. That's changing, but for now, we have a ton of users with only their Username available in the DB. Joomla sticks that in the name field when the user sync is done.

The problem is that when they go to create a new address, Hikashop fills that into the last_name field automatically, so I'm getting users missing that and getting <First Name> <UserID> in their address.

Two ways I could fix it, but I'm not sure how.

One, don't auto-populate anything. This would work, I don't mind forcing my users to fill out their names again.
Two, detect if a first name is present in the address form view, and only fill in the last name if first name is already present. I'd prefer this method, but I can't figure out how to go about it.

Any easy way to accomplish either of these?

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
9 years 9 months ago #189098

Hi,

Edit the file components/com_hikashop/views/address/view.html.php
and look for the code:

$userCMS = JFactory::getUser();
			if(!$userCMS->guest) {
				$name = $userCMS->get('name');
				$pos = strpos($name, ' ');
				if($pos !== false) {
					$address->address_firstname = substr($name, 0, $pos);
					$name = substr($name, $pos + 1);
				}
				$address->address_lastname = $name;
			}
in both the functions show and form in that file.

If you don't want the last name to be prefilled, just change the line:
$address->address_lastname = $name;
to:
$address->address_lastname = '';

It's basically the same change for the firstname if you also don't want to prefill it.

The following user(s) said Thank You: Llarian

Please Log in or Create an account to join the conversation.

  • Posts: 48
  • Thank you received: 1
9 years 9 months ago #189171

Perfect, that did it.

Thanks!

Please Log in or Create an account to join the conversation.

Time to create page: 0.086 seconds
Powered by Kunena Forum