0

I need to get

  • Address Line 1
  • Address Line 2
  • Each Product Order Quantity
  • MRP(Manufacturer's Suggested Retail Price)

code inside

vendor/magento/module-checkout/view/frontend/templates/success.phtml

<?php
$lid = $this->getOrderId();
echo  "Order ID:".$lid."<br/>";

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objectManager->create('Magento\Sales\Model\Order')->load($lid);


$totall = $order->getGrandTotal();
echo "Order Total:".$totall."<br/>";

$shippingAddress = $order->getShippingAddress();

echo "Telephone No:".$shippingAddress->getTelephone()."<br/>"; 

echo "postcode".$shippingAddress->getPostcode()."<br/>"; 

echo "city".$shippingAddress->getCity()."<br/>"; 

$items = $order->getAllItems();


foreach($items as $i):
   $_productsku = 
$objectManager->create('Magento\Catalog\Model\Product')->load($i->getProductId())->getSku();
   $_productquantity = 
$objectManager->create('Magento\Catalog\Model\Product')->load($i->getProductId())->getQtyOrdered();
   $_productprice = 
$objectManager->create('Magento\Catalog\Model\Product')->load($i->getProductId())->getPrice();

echo "product sku:".$_productsku."<br/>";
echo "product quantity:".$_productname."<br/>";
echo "product Rate:".$_productprice."<br/>";
endforeach;
?>
  • Specify the problem which you face using above code. – Dinesh Yadav Nov 11 '17 at 7:00
  • no problems no errors. need to know, how can i get MRP, address1, address2, product order quantity for display purpose – Tamil Selvan Nov 11 '17 at 7:45
0

In your code in for each loop you are calling product obj for get qty order , it is not need just call from I object

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.