![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-bundle/Model/Sales/Order/Plugin/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Bundle\Model\Sales\Order\Plugin; /** * Plugin to calculate bundle item qty available for cancel */ class Item { /** * Retrieve item qty available for cancel * * @param \Magento\Sales\Model\Order\Item $subject * @param float|integer $result * @return float|integer */ public function afterGetQtyToCancel(\Magento\Sales\Model\Order\Item $subject, $result) { if ($subject->getProductType() === \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE || $subject->getParentItem() && $subject->getParentItem()->getProductType() === \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE ) { $qtyToCancel = $this->getQtyToCancelBundle($subject); return max($qtyToCancel, 0); } return $result; } /** * Retrieve item qty available for ship * * @param \Magento\Sales\Model\Order\Item $subject * @param float|integer $result * @return bool */ public function afterIsProcessingAvailable(\Magento\Sales\Model\Order\Item $subject, $result) { if ($subject->getProductType() === \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE || $subject->getParentItem() && $subject->getParentItem()->getProductType() === \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE ) { return $subject->getSimpleQtyToShip() > $subject->getQtyToCancel(); } return $result; } /** * Retrieve Bundle child item qty available for cancel * getQtyToShip() always returns 0 for BundleItems that ship together * * @param \Magento\Sales\Model\Order\Item $item * @return float|integer */ private function getQtyToCancelBundle($item) { if ($item->isDummy(true)) { return min($item->getQtyToInvoice(), $item->getSimpleQtyToShip()); } return min($item->getQtyToInvoice(), $item->getQtyToShip()); } }