VirtueMart Forum

VirtueMart 2 + 3 + 4 => Frontend Modules => Topic started by: berges on November 26, 2021, 14:22:36 PM

Title: Cart module clear after deconnexion
Post by: berges on November 26, 2021, 14:22:36 PM
Hello
i have a problem with cart module
https://www.loom.com/share/1f7d49fe2e8e4527bddf03bba39212b3
user add some product
user deonnect
user reconnect cart is empty ...
i try to disable all plugins nothing more
i try to change template no more ...
VirtueMart 3.8.8 10472
any idea ?
Title: Re: Cart module clear after deconnexion
Post by: Jumbo! on November 26, 2021, 16:08:23 PM
That looks like JavaScript issue. Post the site link so we can review it.
Title: Re: Cart module clear after deconnexion
Post by: berges on November 26, 2021, 17:44:34 PM
thanks for helping you can see here
https://www.maisondelapresse-rabastens.fr/catalogue
Title: Re: Cart module clear after deconnexion
Post by: Jumbo! on November 27, 2021, 07:33:26 AM
Quote from: berges on November 26, 2021, 17:44:34 PM
thanks for helping you can see here
https://www.maisondelapresse-rabastens.fr/catalogue

No, there is no JS error on your site.

I tried to test by log-in into your site, but I could not create an account as new user registration is presently disabled on your site.
Title: Re: Cart module clear after deconnexion
Post by: berges on November 27, 2021, 08:06:56 AM
here you can test
i create an acconut for you
virtuetest
virtuetest
thanks
Title: Re: Cart module clear after deconnexion
Post by: pinochico on November 27, 2021, 15:45:11 PM
is problem with cache

Don't use cache for e-commerce website
Title: Re: Cart module clear after deconnexion
Post by: berges on November 27, 2021, 20:41:08 PM
i didn't use any cache (no joomla cache, no gzip, no jch) where did you see it ? maybe a cache on hoster ?
Title: Re: Cart module clear after deconnexion
Post by: Jörgen on November 27, 2021, 21:48:43 PM
Have You disabled the Joomla cache plugin ?
Check for cache from host.
Jörgen
Title: Re: Cart module clear after deconnexion
Post by: pinochico on November 28, 2021, 22:50:27 PM
If you disable Joomla cache, then VM still use cache - then we use plugin OPC stop browser cache
Title: Re: Cart module clear after deconnexion
Post by: GJC Web Design on November 29, 2021, 11:55:08 AM
The VM cache does not affect the cart/checkout .. only views like category
Title: Re: Cart module clear after deconnexion
Post by: berges on November 30, 2021, 14:25:25 PM
some other idea ?
Title: Re: Cart module clear after deconnexion
Post by: pinochico on November 30, 2021, 20:39:03 PM
Ok, I see video.

So If I understand right - the normal (standard) is
- login
- add something to cart
- logout
- login
- see the same before logout in the cart

That is standard what we want from e-commerce solution, isn't it? :)

But your shop is not function as standard == cart is empty after second login.

I don't know exactly right, but I think in new version VM (from version then cart remember products after logout/login) the info about cart is saved in DB (not in session).
You have to check if really saved in DB and exist BD table - first option

So if is right what wrote Jumbo:
QuoteI tried to test by log-in into your site, but I could not create an account as new user registration is presently disabled on your site.

then logic you don't have DB table for saving cart to user == then you can't load full cart with all product's after logout.

I think - logic will be enable registration on site, that do you mean?
Title: Re: Cart module clear after deconnexion
Post by: berges on November 30, 2021, 21:01:01 PM
sorry i am not agree, if you have a account try any e commerce
1 login
2 add product in cart
3 log out
4 login
=> last cart is loaded, old version of virtuemart works like this, in my cas nothing was write in bd table ...
Title: Re: Cart module clear after deconnexion
Post by: pinochico on November 30, 2021, 21:34:25 PM
I'm sorry, I don't think you understand my English and I don't understand yours :)
Title: Re: Cart module clear after deconnexion
Post by: berges on November 30, 2021, 21:36:50 PM
lol, y try to fhight with beguinner level
but in fact on old vrtuemart that work you can create a cart as a logged user, deconnect it, relogging and your cart is here not empty ... nothing was save in bd table .. i try to find any option in configuration but nothing ...
Title: Re: Cart module clear after deconnexion
Post by: GJC Web Design on November 30, 2021, 21:58:20 PM
In the cart helper  components\com_virtuemart\helpers\cart.php

public function storeCart($cartDataToStore = false)

there is

      //quorvia dont store non completed carts for logged in users
      $Cartsdontsave = VmConfig::get('CartsDontSave', 0 );
      if ($Cartsdontsave){
            return;
      }

      //quorvia dont store non completed cart data for shoppergroup
      $CartsdontsaveShopperGroup = VmConfig::get('CartsDontSaveByshoppergroup', 0 );
      if ($CartsdontsaveShopperGroup > 0 ){
         if(!empty($this->user->shopper_groups) AND in_array($CartsdontsaveShopperGroup, $this->user->shopper_groups)) {
            return;
         }
      }

hard to believe but check you have no entries for these 2 parameters in the VM config
if no entries then these default to false and the cart should be saved IF the user is logged in

administrator\components\com_virtuemart\virtuemart.cfg
Title: Re: Cart module clear after deconnexion
Post by: berges on November 30, 2021, 22:14:00 PM
hello
yes in virtuemart.cfg i didn't have CartsDontSave entry
can i add it directly ?
Title: Re: Cart module clear after deconnexion
Post by: Studio 42 on December 01, 2021, 00:39:30 AM
Tryy in Joomla config to change session method :  PHP <> database
Title: Re: Cart module clear after deconnexion
Post by: Jumbo! on December 01, 2021, 07:55:47 AM
It is not a cache or session-related issue. For the logged-in users, VirtueMart is not saving the cart session to the #__virtuemart_carts table due to some unknown reason. Everything else seems to be working fine.

You need to investigate the storeCart function in - components/com_virtuemart/helpers/cart.php to know the actual reason. If you want, you can PM me the FTP Access and Joomla Super Admin Access credentials of your site so that I can investigate the issue.
Title: Re: Cart module clear after deconnexion
Post by: berges on December 01, 2021, 08:56:12 AM
i test without user logged cart is "saved" in session ... incredible problem
=> @jumbo! thanks i can send you on mp ?
Title: Re: Cart module clear after deconnexion
Post by: pinochico on December 01, 2021, 11:10:47 AM
Quote
Jumbo! wrote:
VirtueMart is not saving the cart session to the #__virtuemart_carts table due to some unknown reason.

is the same info from me (maybe wrong translate but the some idea) :)

Quote
Rudolf wrote:

I don't know exactly right, but I think in new version VM (from version then cart remember products after logout/login) the info about cart is saved in DB (not in session).
You have to check if really saved in DB and exist DB table - first option


go on...
Title: Re: Cart module clear after deconnexion
Post by: berges on December 01, 2021, 11:32:39 AM
as i says, #__virtuemart_carts is empty
Title: Re: Cart module clear after deconnexion
Post by: pinochico on December 01, 2021, 11:35:24 AM
Quoteas i says, #__virtuemart_carts is empty

Yes? where? :)
Im old man and don't see as before :)
Title: Re: Cart module clear after deconnexion
Post by: berges on December 01, 2021, 11:49:29 AM
sorry i din't explain so much => i checked cart bd table is empty
Title: Re: Cart module clear after deconnexion
Post by: Jumbo! on December 01, 2021, 13:00:52 PM
Quote from: berges on December 01, 2021, 08:56:12 AM
i test without user logged cart is "saved" in session ... incredible problem
=> @jumbo! thanks i can send you on mp ?

Yes, you can send PM to me now.
Title: Re: Cart module clear after deconnexion
Post by: Jumbo! on December 01, 2021, 20:55:14 PM
I have fixed the issue. The site is working fine now.

It is a minor bug. The saved cart does not get loaded after log-in in the existing system if the user does not make changes to the cart session before that. For example, if the user first adds a product to the cart and then log-in to the site, it loads the saved cart. But if the user log-in to the site immediately after visiting the site, it will not load the saved cart. I could also reproduce this issue on my local development site.

I made the following change to fix it.

In file - components/com_virtuemart/helpers/cart.php

Original codes between lines 222 to 225:

if(empty(JFactory::getUser()->guest) and !empty($sessionCart->_guest)){
self::$_cart->loadCart(self::$_cart);
self::$_cart->_guest = 0;
}


$sessionCart->_guest property does not exist until some changes are made to the cart session. So I replaced the above code with the following -

if (!property_exists(self::$_cart, '_guest')) {
self::$_cart->_guest = true;
}

if (empty(JFactory::getUser()->guest) and !empty(self::$_cart->_guest)) {
self::$_cart->loadCart(self::$_cart);
self::$_cart->_guest = false;
}


That's it. :)
Title: Re: Cart module clear after deconnexion
Post by: berges on December 01, 2021, 21:29:08 PM
Many thanks !!!! a million !
Title: Re: Cart module clear after deconnexion
Post by: pinochico on December 02, 2021, 02:46:25 AM
Quote
Jumbo says:
I have fixed the issue.

So, it's VM bug from DEV team and will be fixed in next version by added this fix in core?