v1.2.5: How to fix Fatal error when viewing order on M2.2.x?

Created by Jane D, Modified on Thu, 18 Feb, 2021 at 11:27 AM by Jane D

QUESTION:


I upgraded the module to v1.2.5 for my site Magento 2.2.10, when I clicked "view" order, I got error as below:


Fatal error: Uncaught TypeError: Argument 1 passed to Magento\Sales\Model\Order\Invoice::setExtensionAttributes() must implement interface Magento\Sales\Api\Data\InvoiceExtensionInterface, instance of Magento\Sales\Api\Data\OrderExtension given, called in /var/xxxx/xxxx/xxxxx/app/code/Bss/CheckoutCustomField/Model/Observer/Sales/CustomFieldHelper.php on line 94 and defined in /var/xxxxx/xxxxx/xxxx/vendor/magento/module-sales/Model/Order/Invoice.php:1620 Stack trace: #0 /var/xxxx/xxxx/xxxx/app/code/Bss/CheckoutCustomField/Model/Observer/Sales/CustomFieldHelper.php(94): Magento\Sales\Model\Order\Invoice->setExtensionAttributes(Object(Magento\Sales\Api\Data\OrderExtension)) #1 /varxxxx/xxxx/xxxx/app/code/Bss/CheckoutCustomField/Model/Observer/Sales/InvoiceLoadAfter.php(61): Bss\CheckoutCustomField\Model\Observer\Sales\CustomFieldHelper->executeSetExtensionAttributes(Object(Magento\Sales\Model\Order\Interceptor), Object(Magento\Sales\Mod in /var/www/xxxxxx/xxxxxx/xxxxxx/vendor/magento/module-sales/Model/Order/Invoice.php on line 1620


Please tell me how to fix it?


ANSWER:


This error only appears on M2.2.x, to fix this error, please edit file app/code/Bss/CheckoutCustomField/Model/Observer/Sales/CustomFieldHelper.php as below: 



Or download the attached file below and overwrite the current file on your site.


If you have any other question or concern, please feel free to contact us. We'd be happy to support!

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article