-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from markfischmann/fix/remove-double-quantity-…
…refund-on-shipped-orders Remove plugin that will prevent double quantity refund
- Loading branch information
Showing
5 changed files
with
159 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/Plugin/Preference/SalesInventory/ProcessReturnQtyOnCreditMemoPlugin.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
declare(strict_types=1); | ||
namespace Ampersand\DisableStockReservation\Plugin\Preference\SalesInventory; | ||
|
||
use Magento\Sales\Api\Data\CreditmemoInterface; | ||
use Magento\Sales\Api\Data\OrderInterface; | ||
use Magento\SalesInventory\Model\Order\ReturnProcessor; | ||
use Magento\InventorySales\Model\GetBackorder; | ||
use Magento\InventorySales\Plugin\SalesInventory\ProcessReturnQtyOnCreditMemoPlugin as CorePlugin; | ||
|
||
class ProcessReturnQtyOnCreditMemoPlugin extends CorePlugin | ||
{ | ||
/** | ||
* Conditionally disable process_return_product_qty_on_credit_memo plugin | ||
* | ||
* It does additional stock replenishment on creditmemo in 2.4.5 and above, we have already covered that case | ||
* | ||
* @see \Ampersand\DisableStockReservation\Observer\RestoreSourceItemQuantityOnRefundObserver | ||
* @link https://github.com/magento/inventory/pull/2896 | ||
* | ||
* @param ReturnProcessor $subject | ||
* @param callable $proceed | ||
* @param CreditmemoInterface $creditmemo | ||
* @param OrderInterface $order | ||
* @param array $returnToStockItems | ||
* @param bool $isAutoReturn | ||
* @return void | ||
*/ | ||
public function aroundExecute( | ||
ReturnProcessor $subject, | ||
callable $proceed, | ||
CreditmemoInterface $creditmemo, | ||
OrderInterface $order, | ||
array $returnToStockItems = [], | ||
bool $isAutoReturn = false | ||
): void { | ||
// GetBackOrder class only available in 2.4.5 and higher, we need to disable this plugin on those versions | ||
if (\class_exists(GetBackorder::class)) { | ||
return; | ||
} | ||
parent::aroundExecute($subject, $proceed, $creditmemo, $order, $returnToStockItems, $isAutoReturn); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters