Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CartTotalManagement.php
Go to the documentation of this file.
1 <?php
7 
9 
14 {
19 
24 
29 
33  protected $dataProcessor;
34 
41  public function __construct(
46  ) {
47  $this->shippingMethodManagement = $shippingMethodManagement;
48  $this->paymentMethodManagement = $paymentMethodManagement;
49  $this->cartTotalsRepository = $cartTotalsRepository;
50  $this->dataProcessor = $dataProcessor;
51  }
52 
56  public function collectTotals(
57  $cartId,
58  \Magento\Quote\Api\Data\PaymentInterface $paymentMethod,
59  $shippingCarrierCode = null,
60  $shippingMethodCode = null,
61  \Magento\Quote\Api\Data\TotalsAdditionalDataInterface $additionalData = null
62  ) {
63  if ($shippingCarrierCode && $shippingMethodCode) {
64  $this->shippingMethodManagement->set($cartId, $shippingCarrierCode, $shippingMethodCode);
65  }
66  $this->paymentMethodManagement->set($cartId, $paymentMethod);
67  if ($additionalData !== null) {
68  $this->dataProcessor->process($additionalData, $cartId);
69  }
70  return $this->cartTotalsRepository->get($cartId);
71  }
72 }
collectTotals( $cartId, \Magento\Quote\Api\Data\PaymentInterface $paymentMethod, $shippingCarrierCode=null, $shippingMethodCode=null, \Magento\Quote\Api\Data\TotalsAdditionalDataInterface $additionalData=null)
$cartId
Definition: quote.php:22
__construct(\Magento\Quote\Api\ShippingMethodManagementInterface $shippingMethodManagement, \Magento\Quote\Api\PaymentMethodManagementInterface $paymentMethodManagement, \Magento\Quote\Api\CartTotalRepositoryInterface $cartTotalsRepository, \Magento\Quote\Model\Cart\TotalsAdditionalDataProcessor $dataProcessor)