Is it possible to get the basket table with Product name, quantity and price to show on the Order success page?
Also to show the shipping and billing address underneath this.
Please Advise.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityIs it possible to get the basket table with Product name, quantity and price to show on the Order success page?
Also to show the shipping and billing address underneath this.
Please Advise.
Yes, you can get the order by using the order increment id (which is already on success page) on the success page. And after that you can get the order items from order. After that get the product from order item.
Use following code
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$incrId = 100005363;
$collection = $objectManager->create('Magento\Sales\Model\Order');
$order = $collection->loadByIncrementId($incrId);
$orderItems = $order->getAllItems();
foreach($orderItems as $item)
{
$product = $item->getProduct();
}
Get shiiping and billing address
$billingAddress = $order->getBillingAddress();
$shippingAddress = $order->getShippingAddress();
Yes, It is possible to show recent order data on order success page. As you already have recent order increment Id.
protected $orderFactory;
public function __construct(
\Magento\Sales\Api\Data\OrderInterfaceFactory $orderFactory,
......
) {
$this->orderFactory = $orderFactory;
}
Load order object by increment id:
/** @var \Magento\Sales\Api\Data\OrderInterface $order **/
$order = $this->orderFactory->create()->loadByIncrementId('00001952-42');
$orderItems = $order->getAllItems();
foreach($orderItems as $item) {
$product = $item->getProduct()
}
Template to ovveride in your theme vendor/magento/module-checkout/view/frontend/templates/success.phtml