GuestShippingInformationManagement.php 1.6 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 GuestShippingInformationManagement implements \Magento\Checkout\Api\GuestShippingInformationManagementInterface
  8. {
  9. /**
  10. * @var \Magento\Quote\Model\QuoteIdMaskFactory
  11. */
  12. protected $quoteIdMaskFactory;
  13. /**
  14. * @var \Magento\Checkout\Api\ShippingInformationManagementInterface
  15. */
  16. protected $shippingInformationManagement;
  17. /**
  18. * @param \Magento\Quote\Model\QuoteIdMaskFactory $quoteIdMaskFactory
  19. * @param \Magento\Checkout\Api\ShippingInformationManagementInterface $shippingInformationManagement
  20. * @codeCoverageIgnore
  21. */
  22. public function __construct(
  23. \Magento\Quote\Model\QuoteIdMaskFactory $quoteIdMaskFactory,
  24. \Magento\Checkout\Api\ShippingInformationManagementInterface $shippingInformationManagement
  25. ) {
  26. $this->quoteIdMaskFactory = $quoteIdMaskFactory;
  27. $this->shippingInformationManagement = $shippingInformationManagement;
  28. }
  29. /**
  30. * {@inheritDoc}
  31. */
  32. public function saveAddressInformation(
  33. $cartId,
  34. \Magento\Checkout\Api\Data\ShippingInformationInterface $addressInformation
  35. ) {
  36. /** @var $quoteIdMask \Magento\Quote\Model\QuoteIdMask */
  37. $quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id');
  38. return $this->shippingInformationManagement->saveAddressInformation(
  39. $quoteIdMask->getQuoteId(),
  40. $addressInformation
  41. );
  42. }
  43. }