Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

231
Views
Get shipping address on checkout_onepage_controller_success_action in Magento 2

I want to fetch all shipping details on the checkout_onepage_controller_success_action event.

I am using the following code:

$event = $observer->getEvent();
$orderIds = $event->getOrderIds();
$order_id = $orderIds[0];
$shipping = $order_id->getShippingAddress()->getData();
$shippingMethod = $order_id->getShippingMethod();

And I'm getting the error:

Error: Call to a member function getShippingAddress() on string.

According to me the way of passing $order_id on getShippingAddress() is wrong. Can someone brief me on the same? I want to fetch complete data across order id.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

This code within your observer class should work:

protected $orderFactory;

public function __construct(
    \Magento\Sales\Model\OrderFactory $orderFactory
) {
    $this->orderFactory = $orderFactory;
}

public function execute(\Magento\Framework\Event\Observer $observer)
{
    $orderId = $observer->getEvent()->getOrderIds()[0];
    $order = $this->orderFactory->create()->load($orderId);
    $shippingInformation = $order->getShippingAddress();
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!