WordPress.org

Ready to get started?Download WordPress

Forums

Mage Enabler
[resolved] Mage Enabler customer session data not showing in wp (7 posts)

  1. patnz
    Member
    Posted 3 years ago #

    Hey, I'm trying to get mage-enabler to share topLinks with my wp cms. Im getting some session data showing up no problems, but the cart items data and login/out link data (isLoggedIn) are not coming through.

    Here's my code:

    `
    <?php
    //called at the top of header.php before any output
    Mage::getSingleton('core/session', array('name' => 'frontend'));
    $session = Mage::getSingleton("customer/session");
    $magento_block = Mage::getSingleton('core/layout');
    ?>
    `

    <?php magelinks($session,$magento_block); ?>

    `
    <?php
    function magelinks($session,$magento_block){

    if(class_exists('Mage')){

    # Initiate Blocks
    $linksBlock = $magento_block->createBlock("page/template_links");

    $checkoutLinksBlock = $magento_block->createBlock("checkout/links");
    $checkoutLinksBlock->setParentBlock($linksBlock);

    # Add Links
    $linksBlock->addLink($linksBlock->__('My Account'), 'store/customer/account', $linksBlock->__('My Account'), true, array(), 10, 'class="first"');
    $checkoutLinksBlock->addCartLink();
    $checkoutLinksBlock->addCheckoutLink();

    if ($session->isLoggedIn()) {
    $linksBlock->addLink($linksBlock->__('Log Out'), 'store/customer/account/logout', $linksBlock->__('Log Out'), true, array(), 100, 'class="last"');
    } else {
    $linksBlock->addLink($linksBlock->__('Log In'), 'store/customer/account/login', $linksBlock->__('Log In'), true, array(), 100, 'class="last"');
    }

    echo $magento_message.''.$linksBlock->renderView().'';
    }
    }?>
    `

  2. Richard Feraro
    Member
    Plugin Author

    Posted 3 years ago #

    Add the code below right after $session = Mage::getSingleton("customer/session");

    $session->login('<customer-email>','<customer-password>');

  3. patnz
    Member
    Posted 3 years ago #

    Hey Thanks Richard,

    I gave that a go but it gives a fatal error:
    Fatal error: Uncaught exception 'Mage_Core_Exception' with message 'Invalid login or password.' in myfile.php...

    Should I be replacing those <customer-email>','<customer-password> values with something.

    Thanks again.

  4. Richard Feraro
    Member
    Plugin Author

    Posted 3 years ago #

    Of course yes :) Use an active Magento customer credentials.
    If the username/email and password is wrong, a fatal error will occur with invalid login message.

  5. davepyro
    Member
    Posted 3 years ago #

    Hi,
    so how do you set it to pull in the username and password from the magento site?

  6. microkid
    Member
    Posted 2 years ago #

    If Magento is not running in your root / directory, make sure the session cookie is available in the directory where WordPress is running. Go to System > Configuration > Web > Session Cookie Management. You probably want to set the cookie path to /

  7. kevinfilteau
    Member
    Posted 2 years ago #

    I'm stuck with the same problem here. Can't get any session info. Using Magento 1.4.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic