28 private $totalsFactory;
35 private $quoteRepository;
40 private $dataObjectHelper;
45 private $itemConverter;
66 Api\
Data\TotalsInterfaceFactory $totalsFactory,
73 $this->totalsFactory = $totalsFactory;
78 $this->itemConverter = $converter;
92 $addressTotalsData =
$quote->getBillingAddress()->getData();
93 $addressTotals =
$quote->getBillingAddress()->getTotals();
95 $addressTotalsData =
$quote->getShippingAddress()->getData();
96 $addressTotals =
$quote->getShippingAddress()->getTotals();
101 $quoteTotals = $this->totalsFactory->create();
102 $this->dataObjectHelper->populateWithArray(
105 \
Magento\Quote\Api\Data\TotalsInterface::class
111 $calculatedTotals = $this->totalsConverter->process($addressTotals);
112 $quoteTotals->setTotalSegments($calculatedTotals);
114 $amount = $quoteTotals->getGrandTotal() - $quoteTotals->getTaxAmount();
116 $quoteTotals->setCouponCode($this->couponService->get(
$cartId));
117 $quoteTotals->setGrandTotal(
$amount);
118 $quoteTotals->setItems(
$items);
119 $quoteTotals->setItemsQty(
$quote->getItemsQty());
120 $quoteTotals->setBaseCurrencyCode(
$quote->getBaseCurrencyCode());
121 $quoteTotals->setQuoteCurrencyCode(
$quote->getQuoteCurrencyCode());
const EXTENSION_ATTRIBUTES_KEY
__construct(Api\Data\TotalsInterfaceFactory $totalsFactory, CartRepositoryInterface $quoteRepository, DataObjectHelper $dataObjectHelper, CouponManagementInterface $couponService, TotalsConverter $totalsConverter, ItemConverter $converter)