Restricted price will not update when customer login at checkout

  • Posts: 15
  • Thank you received: 1
  • Hikashop Business
7 years 3 months ago #275591

-- HikaShop version -- : 3.3.1
-- Joomla version -- : 3.7.4
-- PHP version -- : 7.0.12

Steps to reproduce:

Back-end:
1. Create a product with general price
2. Add a restricted to user-group (discount) price

Front-end:
1. Add product to cart (the price shown here is the general price, as user does not log in yet)
2. Go to cart (still the price shown is general)
3. Log in in cart with an account with discount user-group privileges. Here, the expectation is that the price of products in cart be updated according to the user privileges, but is not happening, the user needs to remove the product or change quantity to force price update.

How can I have the cart prices to update automatically according to the just loged in user group.

Thanks.

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
7 years 3 months ago #275614

Hi,

Edit the file administrator/components/com_hikashop/helpers/checkout/login.php and in there, replace the two occurrences of the code:

			if($cartClass->sessionToUser($cart->cart_id, $old_session, $user_id))
				$checkoutHelper->getCart(true);
by:
			if($cartClass->sessionToUser($cart->cart_id, $old_session, $user_id)) {
				$cartClass->get('reset_cache');
				$checkoutHelper->getCart(true);
			}
and that should help. Please let us know how that goes so that we can add that patch for the next release.

Last edit: 7 years 3 months ago by Jerome. Reason: code clean

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

  • Posts: 15
  • Thank you received: 1
  • Hikashop Business
7 years 3 months ago #275655

Unfortunately the patch didn't work for me.

Still not seeing an ajax call for cart or price update. (currently there are 4 ajax calls, 1: submitblock, 2: showblock address, 3: showblock payment, 4: showblock status)

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
7 years 3 months ago #275656

Hello,

You replaced the two occurrences of the code in the file ?

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 15
  • Thank you received: 1
  • Hikashop Business
7 years 3 months ago #275710

Yes Jerome, I did exactly what Nicholas asked.

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
7 years 3 months ago #275773

Hello,

Okay, I finally got it !
It was a side effect of the HikaShop user plugin which perform the cart migration during the login action.
In the HikaShop cart class (administrator/components/com_hikashop/classes/cart.php) you need to replace the line

		if(!empty(self::$cache['get'][$cart_id]->user_id) && !empty($user_id))
By
		if(!empty($user_id) && (int)self::$cache['get'][$cart_id]->user_id === (int)$user_id)
			return true;
		if(!empty(self::$cache['get'][$cart_id]->user_id) && !empty($user_id))
So the call to "sessionToUser" will return a "true" if the cart is already assigned to the logged user.
Otherwise the function return a "false" and the cache is not cleared.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 15
  • Thank you received: 1
  • Hikashop Business
7 years 3 months ago #275787

Yep, that did the trick Jerome, it's working now, thanks.

Just a quick note, my original code does not have the

&& !empty($user_id))
condition. You can see that in the attached image.

Attachments:

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

  • Posts: 15
  • Thank you received: 1
  • Hikashop Business
7 years 3 months ago #275793

Jerome and Nicolas, this is embarrassing to me, I have to declare that I made some wrong tests.

I have two instances of my online store for testing, the one that have this issue was running an outdated version of hikashop (3.0.1). And the issue is actually solved with your code changes.

Nevertheless, I have repeated the tests, without any patch, in the website instance running the latest hikashop 3.1.1 and I was unable to replicate the issue. Maybe I have some others different configurations, I guess.

I really don't know if you replicated the issue some how, or if the patch will have a benefit for others cases, but if not, I am really sorry, If I made you waste your time.

Best regards.

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
7 years 3 months ago #275804

Hello,

Okay, I finally got it !
It was a side effect of the HikaShop user plugin which perform the cart migration during the login action.

Yes, I duplicated the issue.
Afterwards, they are plenty possibilities to avoid that issue just with a different checkout workflow ; I had to use a very specific configuration to be sure to generate that issue.
So, the patch is not useless.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

Time to create page: 0.082 seconds
Powered by Kunena Forum