Magento 2 get customer order details from order id


Magento 2 script to get the order details form the order id , how to get the order increment number ,


customer details from the order number , customer first name , last name, middle name , order state ,

order status , no of quantity purchased , coupon code  details



       $orderId = "1";

       $orderDetailsArray = $objectManager->create('Magento\Sales\Model\Order')->load($orderId);


      echo $orderDataArray->getData('entity_id'); // get order entity id





# get state of the order
echo $orderDataArray->getData('state');



# get status of the order
echo $orderDataArray->getData('status');



# get coupon_code of the order
echo $orderDataArray->getData('coupon_code');



# get shipping_description of the order
echo $orderDataArray->getData('shipping_description');



# check if  virtual product in the order
echo $orderDataArray->getData('is_virtual');




# get store_id of the orderecho
echo $orderDataArray->getData('store_id');



# get customer_id of the order
echo $orderDataArray->getData('customer_id');



# get base_discount_amount of the order
echo $orderDataArray->getData('base_discount_amount');



# get base_discount_canceled of the order
echo $orderDataArray->getData('base_discount_canceled');



# get base_discount_invoiced of the order
echo $orderDataArray->getData('base_discount_invoiced');



# get  base_discount_refunded of the order
echo $orderDataArray->getData('base_discount_refunded');




# get base_grand_total of the order
echo $orderDataArray->getData('base_grand_total');



# get base_shipping_amount of the order
echo $orderDataArray->getData('base_shipping_amount');



# get base_shipping_canceled of the order
echo $orderDataArray->getData('base_shipping_canceled');



# get base_shipping_invoiced of the order
echo $orderDataArray->getData('base_shipping_invoiced');



# get base_shipping_refunded of the order
echo $orderDataArray->getData('base_shipping_refunded');



# get discount_amount  of the order
echo $orderDataArray->getData('discount_amount');



# get grand_total of the order
echo $orderDataArray->getData('grand_total');



# get shipping_amount of the order
echo $orderDataArray->getData('shipping_amount');



# get total_qty_ordered of the order
echo $orderDataArray->getData('total_qty_ordered');



# get customer_email of the order
echo $orderDataArray->getData('customer_email');



# get customer_firstname of the order
echo $orderDataArray->getData('customer_firstname');



# get customer_lastname of the order
echo $orderDataArray->getData('customer_lastname');



# get created_at of the order
echo $orderDataArray->getData('created_at');



# get coupon_rule_name of the order
echo $orderDataArray->getData('coupon_rule_name');



# get total_item_count of the order
echo $orderDataArray->getData('total_item_count');

Comments