0

We are using Magento 2.2.8

When we refund back-ordered items, the order status is not set to complete even though all items have either been refunded or shipped. This happens only when the partial shipment and partial refund occur on the same SKU.

Steps:

  1. Create an order with multiple quantities (at least 2) of a single SKU.
  2. Ship out only some of the items leaving the rest to be refunded.
  3. Refund the remaining items so that all items on the order are either shipped or refunded.
  4. Observe order status

Result:

The Order status is set to "processing" as configured in Magento.

Expected Result:

I expected the order to have a status of "complete" since all items have either shipped or been refunded.

Two keys to this. One, that the refund occurs after a shipment and as the final action on the order. And two, that the partial shipment and refund occur on the same SKU. For example your customer ordered 20 XL Super Cool T-Shirts SKU: SC123-XL. Unfortunately you only have 15 of SC123-XL on hand so you ship the 15 you have. The customer later calls and asks the remaining 5 be refunded. When you issue the refund in Magento, the order will not complete. This is the issue we are having.

Thanks!

0

I have found a fix for this issue in the following commit https://github.com/magento/magento2/commit/54139e30a538312077526f44052abe85b3b17c49#diff-886404471665983d5e6c6cf05c4788d8

The solution is to either update to Magento 2.3.2 where this fix resides or you can create a plugin to address the problem.

The plugin

<?php

namespace Company\CreditmemoFix22x\Plugin;


class ItemPlugin {

    public function afterGetSimpleQtyToShip(\Magento\Sales\Model\Order\Item $subject, $result) {
        $qty = $subject->getQtyOrdered() - $subject->getQtyShipped() - $subject->getQtyRefunded() - $subject->getQtyCanceled();
        return max(round($qty, 8), 0);
    }
}

And here's the di.xml

<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
   <type name="Magento\Sales\Model\Order\Item">
       <plugin name="item_plugin" type="Company\CreditmemoFix22x\Plugin\ItemPlugin" sortOrder="100" />
   </type>
</config>

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.