News:

Support the VirtueMart project and become a member

Main Menu

Cart module clear after deconnexion

Started by berges, November 26, 2021, 14:22:36 PM

Previous topic - Next topic

GJC Web Design

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
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

berges

hello
yes in virtuemart.cfg i didn't have CartsDontSave entry
can i add it directly ?

Studio 42

Tryy in Joomla config to change session method :  PHP <> database

Jumbo!

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.

berges

i test without user logged cart is "saved" in session ... incredible problem
=> @jumbo! thanks i can send you on mp ?

pinochico

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...
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

berges

as i says, #__virtuemart_carts is empty

pinochico

Quoteas i says, #__virtuemart_carts is empty

Yes? where? :)
Im old man and don't see as before :)
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

berges

sorry i din't explain so much => i checked cart bd table is empty

Jumbo!

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.

Jumbo!

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. :)

berges


pinochico

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?
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products