开发者

Magento and Wordpress not sharing session data (like number of items in cart)

开发者 https://www.devze.com 2023-01-17 19:03 出处:网络
Using the code below in the index.php file of a WP template: require_once \'/Users/xxx/Documents/Projects/honora/trunk/app/Mage.php\';

Using the code below in the index.php file of a WP template:

require_once '/Users/xxx/Documents/Projects/honora/trunk/app/Mage.php';
umask(0);
Mage::app('default');
Mage::getSingleton('core/session', array('name' => 'frontend'));
Mage::log(Mage::helper('checkout/cart')->getCart()->getItemsCount());

should in theory give me the number of items in my cart in a Wordpress blog in the Mage log. After adding an item to my cart in one version of Magento I have, the log of when I arrive at my blog shows that I correctly have 1 item. However, in a completely different version of Magento, this isn't th开发者_JAVA技巧e case, and instead logs 0.

Now I know that this is a pretty vague question, but can anyone throw out some possible solutions or ways to check into what's going on? I don't believe it's necessarily an issue with WP, instead believing it's something that's happening between Mage::app() and the call to the session model.

Any help would be appreciated.


May want to try this in your Wordpress, instead of the code you posted. Working fine for me in 1.4.x

http://wordpress.org/extend/plugins/mage-enabler/


I realise this is an old question, but our new Wordgento plugin should help people solve this issue in future.

0

精彩评论

暂无评论...
验证码 换一张
取 消