Skip to content

Commit

Permalink
#518 Put all variable assignments in the same places
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Glushko committed Feb 17, 2018
1 parent 68694a8 commit 131fc1c
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,22 @@ public function execute(OrderInterface $order): ShippingAlgorithmResultInterface

/** @var OrderItemInterface|OrderItem $orderItem */
foreach ($order->getItems() as $orderItem) {
$itemSku = $orderItem->getSku();
$qtyToDeliver = $orderItem->getQtyOrdered();

if ($orderItem->isDeleted() || $orderItem->getParentItemId() || $this->isZero($qtyToDeliver)) {
continue;
}

$itemSku = $orderItem->getSku();
foreach ($sources as $source) {
$sourceItem = $this->getStockItemBySku($source->getSourceCode(), $itemSku);
$sourceItemQty = $sourceItem->getQuantity();
$qtyToDeduct = min($sourceItemQty, $qtyToDeliver);

if ($this->isZero($sourceItemQty)) {
continue;
}

$qtyToDeduct = min($sourceItemQty, $qtyToDeliver);

$sourceSelections[] = $this->sourceSelectionFactory->create([
'sourceCode' => $sourceItem->getSourceCode(),
'sourceItemSelections' => $this->sourceItemSelectionFactory->create([
Expand Down

0 comments on commit 131fc1c

Please sign in to comment.