Author Topic: Cart module clear after deconnexion  (Read 5969 times)

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 10882
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.8.8
Re: Cart module clear after deconnexion
« Reply #15 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
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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

  • Jr. Member
  • **
  • Posts: 85
Re: Cart module clear after deconnexion
« Reply #16 on: November 30, 2021, 22:14:00 PM »
hello
yes in virtuemart.cfg i didn't have CartsDontSave entry
can i add it directly ?

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4728
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Cart module clear after deconnexion
« Reply #17 on: December 01, 2021, 00:39:30 AM »
Tryy in Joomla config to change session method :  PHP <> database

Jumbo!

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 930
  • Full-stack Web Developer
    • www.virtueplanet.com
  • VirtueMart Version: Always the latest
Re: Cart module clear after deconnexion
« Reply #18 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.

berges

  • Jr. Member
  • **
  • Posts: 85
Re: Cart module clear after deconnexion
« Reply #19 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 ?

pinochico

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1707
    • MiniJoomla
  • Skype Name: support-easysoftware
  • VirtueMart Version: 3
Re: Cart module clear after deconnexion
« Reply #20 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...
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

  • Jr. Member
  • **
  • Posts: 85
Re: Cart module clear after deconnexion
« Reply #21 on: December 01, 2021, 11:32:39 AM »
as i says, #__virtuemart_carts is empty

pinochico

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1707
    • MiniJoomla
  • Skype Name: support-easysoftware
  • VirtueMart Version: 3
Re: Cart module clear after deconnexion
« Reply #22 on: December 01, 2021, 11:35:24 AM »
Quote
as 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

  • Jr. Member
  • **
  • Posts: 85
Re: Cart module clear after deconnexion
« Reply #23 on: December 01, 2021, 11:49:29 AM »
sorry i din't explain so much => i checked cart bd table is empty

Jumbo!

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 930
  • Full-stack Web Developer
    • www.virtueplanet.com
  • VirtueMart Version: Always the latest
Re: Cart module clear after deconnexion
« Reply #24 on: December 01, 2021, 13:00:52 PM »
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!

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 930
  • Full-stack Web Developer
    • www.virtueplanet.com
  • VirtueMart Version: Always the latest
Re: Cart module clear after deconnexion
« Reply #25 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:

Code: [Select]
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 -

Code: [Select]
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

  • Jr. Member
  • **
  • Posts: 85
Re: Cart module clear after deconnexion
« Reply #26 on: December 01, 2021, 21:29:08 PM »
Many thanks !!!! a million !

pinochico

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1707
    • MiniJoomla
  • Skype Name: support-easysoftware
  • VirtueMart Version: 3
Re: Cart module clear after deconnexion
« Reply #27 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?
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