Skip to content

Commit

Permalink
Merge NordicWebTeam/release-1.0.3
Browse files Browse the repository at this point in the history
Release 1.0.3
  • Loading branch information
martinSternelius authored Dec 15, 2021
2 parents 4793c76 + 2eb01ef commit 2ac2f46
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions Model/Checkout/ApiBuilder/OrderLine/Collector/ItemsCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,20 @@ public function collect(CreatePaymentSession $paymentSession, $subject)
{
if ($subject instanceof Quote) {
$quote = $subject;
$orderAmount = 0;
foreach ($this->generateItems($quote->getAllItems()) as $item) {
$orderAmount += $item['unitprice'];
$paymentSession->addCartItem($item);
}
$paymentSession->addAmount($orderAmount);
$paymentSession->addAmount(
$this->toApiFloat(
$quote->getBaseGrandTotal() - $quote->getShippingAddress()->getBaseShippingInclTax()
)
);
}

if ($subject instanceof \Magento\Payment\Gateway\Data\OrderAdapterInterface) {
$orderAmount = 0;
foreach ($this->generateItems($subject->getItems()) as $item) {
$orderAmount += $item['unitprice'];
$orderAmount += $item['unitprice'] * $item['quantity'];
$paymentSession->addCartItem($item);
}
$paymentSession->setAmount($orderAmount);
Expand Down Expand Up @@ -119,7 +121,7 @@ private function shouldSkip($parentItem, $item)
}

/**
* @param $item
* @param \Magento\Quote\Model\Quote\Item $item
*
* @return array
*/
Expand All @@ -131,10 +133,9 @@ private function processItem($item)
'name' => $item->getName(),
'quantity' => ceil($this->getItemQty($item)),
'quantityunit' => 'pc',
'unitprice' => $this->toApiFloat($item->getBaseRowTotalInclTax() - $item->getBaseDiscountAmount())
?: $this->toApiFloat($item->getBaseRowTotalInclTax()),
'unitprice' => $this->toApiFloat($item->getBasePrice()),
'taxrate' => $this->toApiFloat($item->getTaxPercent()),
'discount' => $this->toApiFloat($item->getBaseDiscountAmount())
'discount' => $this->toApiFloat($item->getDiscountPercent())
];
}

Expand Down

0 comments on commit 2ac2f46

Please sign in to comment.