Updated Joomla user e-mail address not updating Hikashop for checkout

  • Posts: 27
  • Thank you received: 0
  • Hikashop Essential
3 years 4 months ago #326009

-- HikaShop version -- : 4.4.0
-- Joomla version -- : 2.5.28
-- PHP version -- : 5.6.38

We're using Community Builder on our platform and Hikashop is not accessible unless a user is logged in to Joomla.

All Joomla users exist in Hikashop, while shipping and billing addresses need to be entered first time as an active customer in Hikashop. So far so good.

Recently I got order confirmations bouncing but didn't realize until today that the reason seems to be that:

  1. The user/customer has updated their Community Builder/Joomla e-mail address
  2. ...and the new e-mail address is actually transferred over to Hikashop
  3. ...but during checkout the old e-mail address stored in Hikashop is the one used to communicate with the customer

As I have believed the newest e-mail address is the one used in Hikashop, I have not implemented the Hikashop user control panel menu item, in order to allow customers to update their contact information. However, when testing the menu item it seems as if it is the Community Builder user panel that is pulled up, while for shipping/billing it is the Hikashop addresses, which means the old e-mail address seems to still be used in the order process.

How do I make sure Hikashop customer e-mail addresses always are pulled over to Hikashop when updated in Community Builder/Joomla, without having two or more e-mail addresses for the same customer in Hikashop?

If that is a technical challenge with what I have installed, what's the best way to show the e-mail address in the checkout process, allowing the customer to update it there instead?

Last edit: 3 years 4 months ago by Andor. Reason: Solved

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

  • Posts: 81379
  • Thank you received: 13037
  • MODERATOR
3 years 4 months ago #326015

Hi,

There was never a synchronization added to update the email address in HikaShop when the email is changed from the CB interface.
Try adding the code:

public function onAfterUserProfileSaved(&$user, $env) {
		if(empty($user->id) || empty($user->email))
			return;
		if(!defined('DS'))
			define('DS', DIRECTORY_SEPARATOR);
		if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php'))
			return true;
		$userClass = hikashop_get('class.user');
		$hikaUser = new stdClass();
		$hikaUser->user_email = $user->email;
		$hikaUser->user_cms_id = $user->id;
		$userClass->save($hikaUser, true);
	}
before the line:
public function onAfterStoreUser($user, $isnew, $success, $msg) {
in the file plugins/system/hikashopuser/hikashopuser.php
That should allow HikaShop to update the email address on his end when the email address is changed in CB.
Please let us know how that goes.

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

  • Posts: 27
  • Thank you received: 0
  • Hikashop Essential
3 years 4 months ago #326035

Thank you so much for your quick response - I will definitely test your suggestion.

Just a couple of questions for me to understand the current situation before testing:

  1. What HikaShop function adds a new e-mail address to HikaShop when an existing user changes his e-mail address in CB? HikaShop actually pulls in the new e-mail address but also keeps the old and using the old address in the order process.
  2. Adding the user control panel to the HikaShop menu gives the user the option to update their user details. However, the menu link brings up the Joomla/CB interface. If I change my e-mail address in that interface, would my HikaShop e-mail be updated without your suggested function?

Last edit: 3 years 4 months ago by Andor.

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

  • Posts: 81379
  • Thank you received: 13037
  • MODERATOR
3 years 4 months ago #326041

Hi,

1. I'm not sure what you mean here.
This new function updates the email address in HikaShop's user entry when it is updated in CB.

2. Normally, the link to the profile edition page from the user control panel of HikaShop is the Joomla profile edition page. And yes, if you change the email address in the Joomla profile edition page, it is updated in HikaShop as HikaShop implements the standard Joomla user triggers to pick up on such modifications.
However, if CB overrides that Joomla profile edition page with its own page, which doesn't trigger the standard Joomla triggers when a user information is modified, then the email address won't be updated in HikaShop. And in such case, I suppose this new function should fix that.
CB not triggering the standard Joomla user triggers when the user information is updated and not registering the Joomla user triggers so that it can update itself when the Joomla user information is changed from elsewhere has always been a problem.
We already have several patches in the code of HikaShop specific to CB (like for example during the user registration in HikaShop).
Ideally, extensions should only have have to update Joomla's user information and trigger the corresponding triggers so that other extensions could pick up on that by implementing the standard Joomla user triggers (like what HikaShop already does).
The way it's done in CB, any extension that has to touch the Joomla user information has to implement code specific to CB to keep the synchronization or that extension can't work properly with CB on the same website.

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

  • Posts: 27
  • Thank you received: 0
  • Hikashop Essential
3 years 4 months ago #326098

Thanks again for your quick response, which clarified how the Joomla profile triggers an update in HikaShop and that your patches already address CB and other modules.

My first question relates to the fact that already now - without implementing your new code/function - HikaShop adds a new user when CB users change their e-mail address. However, the code also keeps the old HikaShop user, while it probably would have been easier to just delete it, unless the e-mail address is the unique id.

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

  • Posts: 81379
  • Thank you received: 13037
  • MODERATOR
3 years 4 months ago #326103

Hi,

I suppose the issue is a timing and synchronization issue.
Without implementing the new code/function, HikaShop is not notified that the user changed his email address in CB.
However, CB does update the Joomla user entry.
Then, when the user arrives on a page of HikaShop, HikaShop doesn't see any entry corresponding to the email address of the current Joomla user and thus creates a new one.
With the new code/function, the user entry will be updated in HikaShop, so that new entry won't be created in HikaShop afterwards as HikaShop will already see the modified entry matching with the current Joomla user.

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

  • Posts: 27
  • Thank you received: 0
  • Hikashop Essential
3 years 4 months ago #326275

I just implemented and tested your new function and it works beautifully - thanks!

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

  • Posts: 81379
  • Thank you received: 13037
  • MODERATOR
3 years 4 months ago #326290

Hi,

Thank you for your feedback.
We'll add that change on our end for the next version of HikaShop so you won't have to redo it next time you update your HikaShop.

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

Time to create page: 0.070 seconds
Powered by Kunena Forum