GuestTotalsInformationManagement.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Checkout\Model;
  7. class GuestTotalsInformationManagement implements \Magento\Checkout\Api\GuestTotalsInformationManagementInterface
  8. {
  9. /**
  10. * @var \Magento\Quote\Model\QuoteIdMaskFactory
  11. */
  12. protected $quoteIdMaskFactory;
  13. /**
  14. * @var \Magento\Checkout\Api\TotalsInformationManagementInterface
  15. */
  16. protected $totalsInformationManagement;
  17. /**
  18. * @param \Magento\Quote\Model\QuoteIdMaskFactory $quoteIdMaskFactory
  19. * @param \Magento\Checkout\Api\TotalsInformationManagementInterface $totalsInformationManagement
  20. * @codeCoverageIgnore
  21. */
  22. public function __construct(
  23. \Magento\Quote\Model\QuoteIdMaskFactory $quoteIdMaskFactory,
  24. \Magento\Checkout\Api\TotalsInformationManagementInterface $totalsInformationManagement
  25. ) {
  26. $this->quoteIdMaskFactory = $quoteIdMaskFactory;
  27. $this->totalsInformationManagement = $totalsInformationManagement;
  28. }
  29. /**
  30. * {@inheritDoc}
  31. */
  32. public function calculate(
  33. $cartId,
  34. \Magento\Checkout\Api\Data\TotalsInformationInterface $addressInformation
  35. ) {
  36. /** @var $quoteIdMask \Magento\Quote\Model\QuoteIdMask */
  37. $quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id');
  38. return $this->totalsInformationManagement->calculate(
  39. $quoteIdMask->getQuoteId(),
  40. $addressInformation
  41. );
  42. }
  43. }