[Skip to main content](#vessel-content)

#   Restricted price will not update when customer login at checkout

##

- **[hugoaf](/forum/user/22909-hugoaf "View hugoaf's Profile")**
- [![hugoaf's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/22909-hugoaf "View hugoaf's Profile") Topic Author
- [ Offline](/forum/user/22909-hugoaf)

Less More

- Posts: 15
- Thank you received: 1
-
-

9 years 3 months ago [\#275591](#275591) by [hugoaf](/forum/user/22909-hugoaf "View hugoaf's Profile")  *[Restricted price will not update when customer login at checkout](/forum/27-checkout/891450-restricted-price-will-not-update-when-customer-login-at-checkout#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.")* was created by *[hugoaf](/forum/user/22909-hugoaf "View hugoaf's Profile")*

-- 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](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5MTQ1MC1yZXN0cmljdGVkLXByaWNlLXdpbGwtbm90LXVwZGF0ZS13aGVuLWN1c3RvbWVyLWxvZ2luLWF0LWNoZWNrb3V0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14325
-
-

9 years 3 months ago -  9 years 3 months ago [\#275614](#275614) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Restricted price will not update when customer login at checkout](/forum/27-checkout/891450-restricted-price-will-not-update-when-customer-login-at-checkout#275614 "-- 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.")*

Hi,

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

if($cartClass-&gt;sessionToUser($cart-&gt;cart_id, $old_session, $user_id)) $checkoutHelper-&gt;getCart(true);

by: Code:

if($cartClass-&gt;sessionToUser($cart-&gt;cart_id, $old_session, $user_id)) { $cartClass-&gt;get('reset_cache'); $checkoutHelper-&gt;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: 9 years 3 months ago by [Jerome](/forum/user/80-jerome "View Jerome's Profile"). Reason: code clean

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5MTQ1MC1yZXN0cmljdGVkLXByaWNlLXdpbGwtbm90LXVwZGF0ZS13aGVuLWN1c3RvbWVyLWxvZ2luLWF0LWNoZWNrb3V0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[hugoaf](/forum/user/22909-hugoaf "View hugoaf's Profile")**
- [![hugoaf's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/22909-hugoaf "View hugoaf's Profile") Topic Author
- [ Offline](/forum/user/22909-hugoaf)

Less More

- Posts: 15
- Thank you received: 1
-
-

9 years 3 months ago [\#275655](#275655) by [hugoaf](/forum/user/22909-hugoaf "View hugoaf's Profile")  Replied by *[hugoaf](/forum/user/22909-hugoaf "View hugoaf's Profile")* on topic *[Restricted price will not update when customer login at checkout](/forum/27-checkout/891450-restricted-price-will-not-update-when-customer-login-at-checkout#275655 "-- 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.")*

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](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5MTQ1MC1yZXN0cmljdGVkLXByaWNlLXdpbGwtbm90LXVwZGF0ZS13aGVuLWN1c3RvbWVyLWxvZ2luLWF0LWNoZWNrb3V0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26402
- Thank you received: 4081
-
- [](http://obsi.dev)
-

9 years 3 months ago [\#275656](#275656) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Restricted price will not update when customer login at checkout](/forum/27-checkout/891450-restricted-price-will-not-update-when-customer-login-at-checkout#275656 "-- 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.")*

Hello,

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

Regards,

---

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

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5MTQ1MC1yZXN0cmljdGVkLXByaWNlLXdpbGwtbm90LXVwZGF0ZS13aGVuLWN1c3RvbWVyLWxvZ2luLWF0LWNoZWNrb3V0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[hugoaf](/forum/user/22909-hugoaf "View hugoaf's Profile")**
- [![hugoaf's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/22909-hugoaf "View hugoaf's Profile") Topic Author
- [ Offline](/forum/user/22909-hugoaf)

Less More

- Posts: 15
- Thank you received: 1
-
-

9 years 3 months ago [\#275710](#275710) by [hugoaf](/forum/user/22909-hugoaf "View hugoaf's Profile")  Replied by *[hugoaf](/forum/user/22909-hugoaf "View hugoaf's Profile")* on topic *[Restricted price will not update when customer login at checkout](/forum/27-checkout/891450-restricted-price-will-not-update-when-customer-login-at-checkout#275710 "-- 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.")*

Yes Jerome, I did exactly what Nicholas asked.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5MTQ1MC1yZXN0cmljdGVkLXByaWNlLXdpbGwtbm90LXVwZGF0ZS13aGVuLWN1c3RvbWVyLWxvZ2luLWF0LWNoZWNrb3V0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26402
- Thank you received: 4081
-
- [](http://obsi.dev)
-

9 years 3 months ago [\#275773](#275773) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Restricted price will not update when customer login at checkout](/forum/27-checkout/891450-restricted-price-will-not-update-when-customer-login-at-checkout#275773 "-- 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.")*

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 Code:

if(!empty(self::$cache['get'][$cart_id]-&gt;user_id) &amp;&amp; !empty($user_id))

By Code:

if(!empty($user_id) &amp;&amp; (int)self::$cache['get'][$cart_id]-&gt;user_id === (int)$user_id) return true; if(!empty(self::$cache['get'][$cart_id]-&gt;user_id) &amp;&amp; !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 &amp; HikaSerial developer / HikaShop core dev team.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5MTQ1MC1yZXN0cmljdGVkLXByaWNlLXdpbGwtbm90LXVwZGF0ZS13aGVuLWN1c3RvbWVyLWxvZ2luLWF0LWNoZWNrb3V0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[hugoaf](/forum/user/22909-hugoaf "View hugoaf's Profile")**
- [![hugoaf's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/22909-hugoaf "View hugoaf's Profile") Topic Author
- [ Offline](/forum/user/22909-hugoaf)

Less More

- Posts: 15
- Thank you received: 1
-
-

9 years 3 months ago [\#275787](#275787) by [hugoaf](/forum/user/22909-hugoaf "View hugoaf's Profile")  Replied by *[hugoaf](/forum/user/22909-hugoaf "View hugoaf's Profile")* on topic *[Restricted price will not update when customer login at checkout](/forum/27-checkout/891450-restricted-price-will-not-update-when-customer-login-at-checkout#275787 "-- 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.")*

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

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

&amp;&amp; !empty($user_id))

condition. You can see that in the attached image.
[ ![hs-cart.jpg](/forum/attachment/39662) ](/forum/attachment/39662 "hs-cart.jpg")

- [ ![hs-cart.jpg](/forum/attachment/39662) ](/forum/attachment/39662 "hs-cart.jpg") [ ](/forum/attachment/39662?download=1 "hs-cart.jpg")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5MTQ1MC1yZXN0cmljdGVkLXByaWNlLXdpbGwtbm90LXVwZGF0ZS13aGVuLWN1c3RvbWVyLWxvZ2luLWF0LWNoZWNrb3V0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[hugoaf](/forum/user/22909-hugoaf "View hugoaf's Profile")**
- [![hugoaf's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/22909-hugoaf "View hugoaf's Profile") Topic Author
- [ Offline](/forum/user/22909-hugoaf)

Less More

- Posts: 15
- Thank you received: 1
-
-

9 years 3 months ago [\#275793](#275793) by [hugoaf](/forum/user/22909-hugoaf "View hugoaf's Profile")  Replied by *[hugoaf](/forum/user/22909-hugoaf "View hugoaf's Profile")* on topic *[Restricted price will not update when customer login at checkout](/forum/27-checkout/891450-restricted-price-will-not-update-when-customer-login-at-checkout#275793 "-- 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.")*

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](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5MTQ1MC1yZXN0cmljdGVkLXByaWNlLXdpbGwtbm90LXVwZGF0ZS13aGVuLWN1c3RvbWVyLWxvZ2luLWF0LWNoZWNrb3V0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26402
- Thank you received: 4081
-
- [](http://obsi.dev)
-

9 years 3 months ago [\#275804](#275804) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Restricted price will not update when customer login at checkout](/forum/27-checkout/891450-restricted-price-will-not-update-when-customer-login-at-checkout#275804 "-- 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.")*

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 &amp; HikaSerial developer / HikaShop core dev team.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0Lzg5MTQ1MC1yZXN0cmljdGVkLXByaWNlLXdpbGwtbm90LXVwZGF0ZS13aGVuLWN1c3RvbWVyLWxvZ2luLWF0LWNoZWNrb3V0P3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.075 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
