Thursday, October 7, 2010

Accessing magento Session variables.

Getting the Data From Magento

// Access Mage
include_once 'app/Mage.php';
umask(0);
Mage::app("default");
Mage::getSingleton("core/session", array("name" => "frontend"));


// Output Username or Guest
if(isset($_GET['mode']) && $_GET['mode'] == 'mage_welcome') {

if($session->isLoggedIn()){

$first_name .= $session->getCustomer()->getData('firstname').' ';
$last_name .= $session->getCustomer()->getData('lastname').'!';

$mage_welcome = '

Welcome, '.$first_name.' '.$last_name.'

Not you? Log Out

';

}

else {

$mage_welcome = '

Welcome!
Create an account
or log in

';

}

// Store in variable for later
echo $mage_welcome;
}

source: http://bretglassett.com/blog/pull-mageto-user-session-data-into-wordpress

No comments:

Post a Comment