Hi All,
I am using Magento v1.9 and having problems with Customer logged in cart updates.
If the user is not logged in then my cart updates work fine. But as the user logs in the cart just fails.
I am throwing ajax calls to my custom PHP files within as below for example but not getting any session. Could anyone let me know why Magento is behaving in this way or that my code has some issues.
<?php require_once( '../app/Mage.php' ); umask(0); Mage::app('default'); // This has to run to authenticate customer and checkout session calls. Mage::getSingleton('core/session', array('name' => 'frontend')); // Get any customer model you desire. $oSession = Mage::getSingleton( 'customer/session' ); $oCustomer = $oSession->getCustomer(); $oCheckout = Mage::getSingleton( 'checkout/session' ); $oQuote = $oCheckout->getQuote(); foreach(Mage::getSingleton('checkout/session')->getQuote()->getItemsCollection() as $item){ echo $item->getId()."<br />"; } echo Mage::getSingleton('customer/session')->getCustomer()->getName(); //var_dump(Mage::getSingleton('customer/session')); //var_dump( Mage::getSingleton('core/session')->getData() ); // var_dump( $oSession ); //var_dump( $oQuote ); // var_dump( $oCheckout ); $oCart = $oQuote->getAllItems(); if( !empty( $oCart ) ) { foreach ( $oCart as $oItem ) { $sName = $oItem->getProduct()->getName(); $fPrice = $oItem->getProduct()->getPrice(); echo $sName ; echo $fPrice ; } } ?>
Thanks,
Amit
Also I am using Magento 1.9.1.0 to be more specific about the version.
Do you remember any changed you have done after which this functionality got stopped working?
No nothing changed, in-fact i just installed a fresh installation to check this on a vanilla instance but still the same thing.
Even right now i checked with the below code but still the same thing. Session is not returning even the simple customer logged in data.
Any settings missing from the admin or my WAMP installation?
<?php require_once( 'app/Mage.php' ); umask(0); Mage::app('default'); var_dump(Mage::getSingleton('customer/session')->getCustomer()->getEmail()); ?>