I am trying to update the order status after the shipping address was changed manually from the adminpanel (when the order is already created).

This is my di.xml content:

<type name="Magento\Sales\Model\Order\AddressRepository">
    <plugin name="custom_order_status" type="Vendor\Module\Plugin\OrderAddressAfterSave" sortOrder="1" disabled="false" />

and the OrderAddressAfterSave content:

    use Magento\Sales\Api\Data\OrderAddressInterface;

    class OrderAddressAfterSave
        public function afterSave(OrderAddressInterface $subject, $result)
            return $result;


If the order status is shipping_error and someone updates the shipping address from adminpanel, I would like to update the order status from shipping_error to processing.

Currently I am running into this error:

Fatal error: Uncaught TypeError: Argument 1 passed to Vendor\Module\Plugin\OrderAddressAfterSave::afterSave() must implement interface Magento\Sales\Api\Data\OrderAddressInterface, instance of Magento\Sales\Model\Order\AddressRepository\Interceptor given, called in path/to/vendor/magento/framework/Interception/Interceptor.php on line 146 and defined in path/to/app/code/Vendor/Module/Plugin/OrderAddressAfterSave.php:8 Stack trace: #0 path/to/vendor/magento/framework/Interception/Interceptor.php(146): Vendor\Module\Plugin\OrderAddressAfterSave->afterSave(Object(Magento\Sales\Model\Order\AddressRepository\Interceptor), Object(Magento\Sales\Model\Order\Address), Object(Magento\Sales\Model\Order\Address)) #1 path/to/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Sales\Model\Order\AddressRepository\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Sales\Model\Ord in /path/to/app/code/Vendor/Module/Plugin/OrderAddressAfterSave.php on line 8

Any idea why? and what would be the best approach to fix this ? Thank you


Was getting that error because of the type name was incorrect. Instead of: Magento\Sales\Model\Order\AddressRepository I need to change into the Magento\Sales\Api\Data\OrderAddressInterface.

| improve this answer | |

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.