Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Api/Spc/Response/CartDetailsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public function getTotalShippingAmount();
*/
public function getTotalBaseAmount();

/**
* @return \Amazon\Pay\Api\Spc\Response\AmountInterface
*/
public function getTotalBaseInclTaxAmount();

/**
* @return \Amazon\Pay\Api\Spc\Response\AmountInterface
*/
Expand Down Expand Up @@ -107,6 +112,12 @@ public function setTotalShippingAmount(AmountInterface $amount);
*/
public function setTotalBaseAmount(AmountInterface $amount);

/**
* @param \Amazon\Pay\Api\Spc\Response\AmountInterface $amount
* @return $this
*/
public function setTotalBaseInclTaxAmount(AmountInterface $amount);

/**
* @param \Amazon\Pay\Api\Spc\Response\AmountInterface $amount
* @return $this
Expand Down
11 changes: 11 additions & 0 deletions Api/Spc/Response/LineItemInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public function getTotalListPrice();
*/
public function getDiscountedPrice();

/**
* @return \Amazon\Pay\Api\Spc\Response\AmountInterface
*/
public function getPriceInclTax();

/**
* @return \Amazon\Pay\Api\Spc\Response\PromoInterface[]
*/
Expand Down Expand Up @@ -90,6 +95,12 @@ public function setTotalListPrice(AmountInterface $listPrice);
*/
public function setDiscountedPrice(AmountInterface $discountedPrice);

/**
* @param \Amazon\Pay\Api\Spc\Response\AmountInterface $priceInclTax
* @return $this
*/
public function setPriceInclTax(AmountInterface $priceInclTax);

/**
* @param \Amazon\Pay\Api\Spc\Response\PromoInterface[] $appliedDiscounts
* @return $this
Expand Down
8 changes: 7 additions & 1 deletion Helper/Spc/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public function createResponse($quoteId, $checkoutSessionId = null)
$lineItemsResponse = $this->getLineItemsAndTotalBaseAmount($quote, $currencyCode);
$lineItems = $lineItemsResponse['line_items'];
$totalBaseAmount = $lineItemsResponse['total_base_amount'];
$totalBaseInclTaxAmount = $lineItemsResponse['total_base_incl_tax_amount'];
$lineItemsTotalDiscounts = $lineItemsResponse['total_discount_amount'];

// Get delivery options
Expand Down Expand Up @@ -211,6 +212,7 @@ public function createResponse($quoteId, $checkoutSessionId = null)
)
)
->setTotalBaseAmount($this->getAmountObject($totalBaseAmount, $currencyCode))
->setTotalBaseInclTaxAmount($this->getAmountObject($totalBaseInclTaxAmount, $currencyCode))
->setTotalTaxAmount($this->getAmountObject($quote->getShippingAddress()->getTaxAmount(), $currencyCode))
->setTotalChargeAmount($this->getAmountObject($quote->getGrandTotal(), $currencyCode))
->setTotalDiscountAmount($this->getAmountObject($totalDiscountAmount, $currencyCode))
Expand Down Expand Up @@ -254,6 +256,7 @@ protected function getLineItemsAndTotalBaseAmount($quote, $currencyCode)
{
$lineItems = [];
$totalBaseAmount = 0;
$totalBaseInclTaxAmount = 0;
$totalDiscountAmount = 0;

foreach ($quote->getAllVisibleItems() as $item) {
Expand Down Expand Up @@ -294,7 +297,7 @@ protected function getLineItemsAndTotalBaseAmount($quote, $currencyCode)

// Get item rule details
$rulesNameOrCode = [];

if ($quote->getAppliedRuleIds() && $item->getAppliedRuleIds()) {
$quoteRules = explode(',', $quote->getAppliedRuleIds());
$itemRules = explode(',', $item->getAppliedRuleIds());
Expand All @@ -321,6 +324,7 @@ protected function getLineItemsAndTotalBaseAmount($quote, $currencyCode)
}

$totalBaseAmount += $item->getRowTotal();
$totalBaseInclTaxAmount += $item->getPriceInclTax();
$discountedAmount = $item->getRowTotal() - $item->getDiscountAmount();
$totalDiscountAmount += $item->getDiscountAmount();

Expand All @@ -330,6 +334,7 @@ protected function getLineItemsAndTotalBaseAmount($quote, $currencyCode)
->setListPrice($this->getAmountObject($item->getRowTotal()/$item->getQty(), $currencyCode))
->setTotalListPrice($this->getAmountObject($item->getRowTotal(), $currencyCode))
->setDiscountedPrice($this->getAmountObject($discountedAmount, $currencyCode))
->setPriceInclTax($this->getAmountObject($item->getPriceInclTax(), $currencyCode))
->setAppliedDiscounts($rulesNameOrCode)
->setAdditionalAttributes($additionalAttributes)
->setStatus(
Expand All @@ -345,6 +350,7 @@ protected function getLineItemsAndTotalBaseAmount($quote, $currencyCode)
return [
'line_items' => $lineItems,
'total_base_amount' => $totalBaseAmount,
'total_base_incl_tax_amount' => $totalBaseInclTaxAmount,
'total_discount_amount' => $totalDiscountAmount
];
}
Expand Down
16 changes: 16 additions & 0 deletions Model/Spc/Response/CartDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ public function getTotalBaseAmount()
return $this->_getData('total_base_amount');
}

/**
* @inheritDoc
*/
public function getTotalBaseInclTaxAmount()
{
return $this->_getData('total_base_incl_tax_amount');
}

/**
* @inheritDoc
*/
Expand Down Expand Up @@ -160,6 +168,14 @@ public function setTotalBaseAmount(AmountInterface $amount)
return $this->setData('total_base_amount', $amount);
}

/**
* @inheritDoc
*/
public function setTotalBaseInclTaxAmount(AmountInterface $amount)
{
return $this->setData('total_base_incl_tax_amount', $amount);
}

/**
* @inheritDoc
*/
Expand Down
16 changes: 16 additions & 0 deletions Model/Spc/Response/LineItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ public function getDiscountedPrice()
return $this->_getData('discounted_price');
}

/**
* @inheritDoc
*/
public function getPriceInclTax()
{
return $this->_getData('price_incl_tax');
}

/**
* @inheritDoc
*/
Expand Down Expand Up @@ -138,6 +146,14 @@ public function setDiscountedPrice(AmountInterface $discountedPrice)
return $this->setData('discounted_price', $discountedPrice);
}

/**
* @inheritDoc
*/
public function setPriceInclTax(AmountInterface $priceInclTax)
{
return $this->setData('price_incl_tax', $priceInclTax);
}

/**
* @inheritDoc
*/
Expand Down