Magento Expert Forum - Improve your Magento experience

Results 1 to 6 of 6

get cart item details in external php file

  1. #1
    New member
    Join Date
    Oct 2015
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy get cart item details in external php file


  2. #2
    Administrator david's Avatar
    Join Date
    Nov 2012
    Posts
    261
    Thanks
    22
    Thanked 42 Times in 34 Posts

    Default

    After include the core lib, you can use this code


    Code:
    $cart = Mage::getModel('checkout/cart')->getQuote();
    foreach ($cart->getAllItems() as $item) {
        $productName = $item->getProduct()->getName();
        $productPrice = $item->getProduct()->getPrice();
    }
    But it will need you call on browser where session key is available for this cart

  3. #3
    New member
    Join Date
    Oct 2015
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    But it will need you call on browser where session key is available for this cart
    I did not get this line. I am running my site in locally in xampp, I have tried the above code but nothing is displayed on the page. How can I get the session key and how I can I use that.

  4. #4
    Administrator david's Avatar
    Join Date
    Nov 2012
    Posts
    261
    Thanks
    22
    Thanked 42 Times in 34 Posts

    Default

    My code not include the display. You can try this

    Code:
    $cart = Mage::getModel('checkout/cart')->getQuote();
    foreach ($cart->getAllItems() as $item) {
        $productName = $item->getProduct()->getName();
        $productPrice = $item->getProduct()->getPrice();
        echo $productName . " | " . $productPrice;
    }

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •