I am getting this error while online refunding credit memo using a script.

"Unable to create credit memo for order" error appear, this is due to this https://github.com/pepe1518/magento2/blob/89adbabc2a295c9b6f88768d541fd2858f59aae5/vendor/magento/module-sales/Model/Order.php#L603

I want to know in which conditions, this error come ?

  • any thoughts on this ?
    – devhs
    Commented Jun 10, 2021 at 4:40
  • 1
    Maybe just put breakpoint in canCreditmemo function, and check, where exactly it returns false? There are like 5 ifs to check. So You have like 5 or 6 possibilities.. Check Order status. Is it mached to any requirement in one of if? What about TotalPaid and Refunded? If You can use xdebug, just check manually all ifs and compare to current state of order. YOu can also check MagentoDev for Credit Memo docs.magento.com/user-guide/v2.3/sales/credit-memo-create.html Commented Jun 10, 2021 at 9:39
  • Thanks for the suggestion, appreciate it
    – devhs
    Commented Jun 10, 2021 at 10:25
  • any thoughts on this ?
    – devhs
    Commented Jun 11, 2021 at 4:58
  • 1
    Hey, there is no possibility that anyone here will know know that... There are like 6 condition. Issue may come from every single one. It depends on order and order current configuration / status. Without more information about order and possible shop configuration, noone will answer You... Commented Jun 11, 2021 at 6:35

2 Answers 2


You need to debug code step by step, add logs in your main logic after line by line. Check from where the logic fails. This error is caused when there is no item passed to refund array (ordered item id) should be passed in order to process refund.


See this for how flag ForcedCanCreditmemo property was set. Note that this property is just for current instance not a field in database, also cannot be saved.


It seem like Creditmemo for free transactions is not possible.

But if you might want to customize it, add this flag on observer event sales_order_load_after

if($order->getPayment()->getMethodInstance()->getCode() === 'free') {

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.