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. .

  • in which step.after order place or before order – Amit Bera Jun 9 '15 at 8:21
  • After order place – hari haran Jun 9 '15 at 8:21
  • on checkout success page or else? – Amit Bera Jun 9 '15 at 8:22
  • Beside checkout page – hari haran Jun 9 '15 at 8:22
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;
                }

             }
         }
  • 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 Jun 9 '15 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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