I am using Custom Shipping API where I am getting response from API. Here I want to save this response to my order and quote table, I used event checkout_onepage_controller_success_action Here's code of my event under etc/frontend

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
       <event name="checkout_onepage_controller_success_action">
        <observer name="bigpost_order_controller_success_action" instance="Some\Somename\Observer\Processorder" />

Here's I am using in doing in execute function under Observer/Processorder

          $order_ids = $observer->getEvent()->getOrderIds()[0];
           $order = $this->orderRepository->get($order_ids);           
           $order_id = $order->getIncrementId();   
$job = json_decode($resut, true); //response here 
  foreach ($job as $key => $consignment) {
      $condignment = $consignment['CarrierConsignmentNumber']; //got reponse 'BP459090'
      try {
        $orderDetailData = $condignment;
        $order_id->setData('carrier_consignment_number', $orderDetailData); //tried to set data
        print("succssfully done");

    } catch (\Exception $e) {
        print("error in this");

it's not saved my data in db under sale_order table or quote table. while I created column there.

Getting error here : Fatal error: Uncaught Error: Call to a member function setData() on string in

1 Answer 1


You are setting your data and also saving an order id which is a string instead of the order object.


$order_id->setData('carrier_consignment_number', $orderDetailData); //tried to set data


$order->setData('carrier_consignment_number', $orderDetailData); //tried to set data
  • Still have same error : Fatal error: Uncaught Error: Call to a member function setData() on string in Dec 6, 2019 at 5:39
  • Check what is the content of order_ids and also make sure an actual order has been returned by $this->orderRepository->get($order_ids); Dec 6, 2019 at 18:51
  • SetData always work with existing tables not with custom table for this we have to make a plugin or call model Dec 10, 2019 at 10:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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