Skip to content
This repository has been archived by the owner on Mar 29, 2022. It is now read-only.

Commit

Permalink
[feature] (PLENTY-88) NGW-IVsec: Only show discount position in baske…
Browse files Browse the repository at this point in the history
…t if it is set.
  • Loading branch information
Simon Gabriel committed Mar 12, 2019
1 parent 18f5a8a commit 5df403b
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions resources/lib/submitBasket.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,20 @@ function normalizeValue($value) {
$goodsAndShipmentNet += $shippingNet;

// Add discount position
$discountItem = new BasketItem();
$discountAmount = $basketData['couponDiscount'];
$discountNet = $basketAmountNet - $goodsAndShipmentNet;
$discountItem->setAmountGross(normalizeValue($discountAmount))
->setAmountNet(normalizeValue($discountNet))
->setQuantity(1)
->setAmountPerUnit(normalizeValue($discountAmount))
->setBasketItemReferenceId('discount')
->setTitle('Discount')
->setType('voucher');
if ($discountAmount !== 0) {
$discountItem = new BasketItem();
$discountNet = $basketAmountNet - $goodsAndShipmentNet;
$discountItem->setAmountGross(normalizeValue($discountAmount))
->setAmountNet(normalizeValue($discountNet))
->setQuantity(1)
->setAmountPerUnit(normalizeValue($discountAmount))
->setBasketItemReferenceId('discount')
->setTitle('Discount')
->setType('voucher');

$basket->addBasketItem($discountItem);
$basket->addBasketItem($discountItem);
}

$request = new BasketApiRequest();
$request->setAuthentication($authData['login'], $authData['password'], $authData['senderId']);
Expand Down

0 comments on commit 5df403b

Please sign in to comment.