GuestCartTotalManagement.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Quote\Model\GuestCart;
  7. use Magento\Quote\Model\QuoteIdMaskFactory;
  8. use Magento\Quote\Api\GuestCartTotalManagementInterface;
  9. /**
  10. * @inheritDoc
  11. */
  12. class GuestCartTotalManagement implements GuestCartTotalManagementInterface
  13. {
  14. /**
  15. * @var \Magento\Quote\Api\CartTotalManagementInterface
  16. */
  17. protected $cartTotalManagement;
  18. /**
  19. * @var QuoteIdMaskFactory
  20. */
  21. protected $quoteIdMaskFactory;
  22. /**
  23. * @param \Magento\Quote\Api\CartTotalManagementInterface $cartTotalManagement
  24. * @param QuoteIdMaskFactory $quoteIdMaskFactory
  25. */
  26. public function __construct(
  27. \Magento\Quote\Api\CartTotalManagementInterface $cartTotalManagement,
  28. QuoteIdMaskFactory $quoteIdMaskFactory
  29. ) {
  30. $this->cartTotalManagement = $cartTotalManagement;
  31. $this->quoteIdMaskFactory = $quoteIdMaskFactory;
  32. }
  33. /**
  34. * {@inheritDoc}
  35. */
  36. public function collectTotals(
  37. $cartId,
  38. \Magento\Quote\Api\Data\PaymentInterface $paymentMethod,
  39. $shippingCarrierCode = null,
  40. $shippingMethodCode = null,
  41. \Magento\Quote\Api\Data\TotalsAdditionalDataInterface $additionalData = null
  42. ) {
  43. $quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id');
  44. return $this->cartTotalManagement->collectTotals(
  45. $quoteIdMask->getQuoteId(),
  46. $paymentMethod,
  47. $shippingCarrierCode,
  48. $shippingMethodCode,
  49. $additionalData
  50. );
  51. }
  52. }