Skip to content

Commit

Permalink
Remove unused freeBoxes logic
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaScorpion committed Oct 17, 2023
1 parent ee6d7a5 commit 0c4bb32
Showing 1 changed file with 0 additions and 40 deletions.
40 changes: 0 additions & 40 deletions Model/Carrier/Parcelpro.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ public function collectRates(RateRequest $request)
$object = $objectManager->create('\Magento\Sales\Model\AdminOrder\Create');
$total = $object->getQuote()->getSubtotal();
$grandTotal = $object->getQuote()->getGrandTotal();

$freeBoxes = $this->getFreeBoxesCount($request);
} else {
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$total = $objectManager->create('\Magento\Checkout\Model\Session')
Expand Down Expand Up @@ -216,42 +214,4 @@ public function collectRates(RateRequest $request)
}
return $result;
}

/**
* @param RateRequest $request
* @return int
*/
private function getFreeBoxesCount(RateRequest $request)
{
$freeBoxes = 0;
if ($request->getAllItems()) {
foreach ($request->getAllItems() as $item) {
if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
continue;
}

if ($item->getHasChildren() && $item->isShipSeparately()) {
$freeBoxes += $this->getFreeBoxesCountFromChildren($item);
} elseif ($item->getFreeShipping()) {
$freeBoxes += $item->getQty();
}
}
}
return $freeBoxes;
}

/**
* @param mixed $item
* @return mixed
*/
private function getFreeBoxesCountFromChildren($item)
{
$freeBoxes = 0;
foreach ($item->getChildren() as $child) {
if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
$freeBoxes += $item->getQty() * $child->getQty();
}
}
return $freeBoxes;
}
}

0 comments on commit 0c4bb32

Please sign in to comment.