- Posts: 15
- Thank you received: 1
Restricted price will not update when customer login at checkout
9 years 1 month ago #275591
by hugoaf
-- 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.
-- 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.
9 years 1 month ago - 9 years 1 month ago #275614
by nicolas
Replied by nicolas on topic Restricted price will not update when customer login at checkout
Hi,
Edit the file administrator/components/com_hikashop/helpers/checkout/login.php and in there, replace the two occurrences of the code:
by:
and that should help. Please let us know how that goes so that we can add that patch for the next release.
Edit the file administrator/components/com_hikashop/helpers/checkout/login.php and in there, replace the two occurrences of the code:
Code:
if($cartClass->sessionToUser($cart->cart_id, $old_session, $user_id))
$checkoutHelper->getCart(true);
Code:
if($cartClass->sessionToUser($cart->cart_id, $old_session, $user_id)) {
$cartClass->get('reset_cache');
$checkoutHelper->getCart(true);
}
Last edit: 9 years 1 month ago by Jerome. Reason: code clean
Please Log in or Create an account to join the conversation.
9 years 1 month ago #275655
by hugoaf
Replied by hugoaf on topic Restricted price will not update when customer login at checkout
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)
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.
9 years 1 month ago #275656
by Jerome
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.
Replied by Jerome on topic Restricted price will not update when customer login at checkout
Hello,
You replaced the two occurrences of the code in the file ?
Regards,
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.
9 years 1 month ago #275710
by hugoaf
Replied by hugoaf on topic Restricted price will not update when customer login at checkout
Yes Jerome, I did exactly what Nicholas asked.
Please Log in or Create an account to join the conversation.
9 years 1 month ago #275773
by Jerome
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.
Replied by Jerome on topic Restricted price will not update when customer login at checkout
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
By
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,
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
Code:
if(!empty(self::$cache['get'][$cart_id]->user_id) && !empty($user_id))
Code:
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))
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.
9 years 1 month ago #275787
by hugoaf
Replied by hugoaf on topic Restricted price will not update when customer login at checkout
Please Log in or Create an account to join the conversation.
9 years 1 month ago #275793
by hugoaf
Replied by hugoaf on topic Restricted price will not update when customer login at checkout
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.
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.
9 years 1 month ago #275804
by Jerome
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.
Replied by Jerome on topic Restricted price will not update when customer login at checkout
Hello,
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,
Yes, I duplicated the issue.Okay, I finally got it !
It was a side effect of the HikaShop user plugin which perform the cart migration during the login action.
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.318 seconds