it4mage / CashOnDelivery

Cash on delivery module for Magento 2
25 stars 19 forks source link

Fix error on reorder functionality #1

Closed renatocason closed 6 years ago

renatocason commented 6 years ago

When using the reorder functionality from the customer account section, the getAllBaseTotalAmounts function on Magento\Quote\Model\Quote\Address\Total returns null, causing the following error if the initial order had Cash on Delivery selected as payment method.

Fatal error: Uncaught TypeError: Argument 1 passed to MSP\CashOnDelivery\Model\Cashondelivery::getBaseAmount() must be of the type array, null given, called in vendor/msp/cashondelivery/Model/Total/Quote/Cashondelivery.php on line 66

The proposed solution calls the getBaseAmount only if the result of that function is not null, if so it assumes the total is 0.