2

In Magento Checkout page i want to get the Cart Details Like

Product name, Price, Quantity, product Image.

Using Session . . I dont know how to get the session Details.. Kindly Help Me out here. .

4
  • in which step.after order place or before order
    – Amit Bera
    Commented Jun 9, 2015 at 8:21
  • After order place
    – hari haran
    Commented Jun 9, 2015 at 8:21
  • on checkout success page or else?
    – Amit Bera
    Commented Jun 9, 2015 at 8:22
  • Beside checkout page
    – hari haran
    Commented Jun 9, 2015 at 8:22

1 Answer 1

2

You can get your order from checkout session .Then using order id you can get orders item details by load of sales models.

 $session=Mage::getSingleton('checkout/type_onepage')->getCheckout();
$session->getLastSuccessQuoteId();
$orderId= $session->getLastOrderId();
// If checkout onepage singleton not work then use checkout session
if(is_null($orderId)){
$orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
}

        if ($orderId) {
            $order = Mage::getModel('sales/order')->load($orderId);
            if ($order->getId()) {
                 $items =$order->getAllVisibleItems();

                foreach ($items as $item)
                {
                    $item->getName(); // product name 
                    $item->getPrice();
                    $item->getSku();    
                    $item->getProductId();
                    $item->getQtyOrdered(); 
                    // load product model for gettting images
                    $product=Mage::getModel('catalog/product')->load($item->getProductId());
                    if($product->getId()):
                    echo $product->getSmallImageUrl();
                    endif;
                }

             }
         }
1
  • but if we apply this code only one product will appering in display. . if we add another one product in cart , the product price only updated in grand total not the name, quantity etc. . what to do??
    – hari haran
    Commented Jun 9, 2015 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.