CartManagementInterface.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Quote\Api;
  7. use Magento\Quote\Api\Data\PaymentInterface;
  8. /**
  9. * Interface CartManagementInterface
  10. * @api
  11. * @since 100.0.2
  12. */
  13. interface CartManagementInterface
  14. {
  15. /**
  16. * Checkout types: Checkout as Guest
  17. */
  18. const METHOD_GUEST = 'guest';
  19. /**
  20. * Creates an empty cart and quote for a guest.
  21. *
  22. * @return int Cart ID.
  23. * @throws \Magento\Framework\Exception\CouldNotSaveException The empty cart and quote could not be created.
  24. */
  25. public function createEmptyCart();
  26. /**
  27. * Creates an empty cart and quote for a specified customer if customer does not have a cart yet.
  28. *
  29. * @param int $customerId The customer ID.
  30. * @return int new cart ID if customer did not have a cart or ID of the existing cart otherwise.
  31. * @throws \Magento\Framework\Exception\CouldNotSaveException The empty cart and quote could not be created.
  32. */
  33. public function createEmptyCartForCustomer($customerId);
  34. /**
  35. * Returns information for the cart for a specified customer.
  36. *
  37. * @param int $customerId The customer ID.
  38. * @return \Magento\Quote\Api\Data\CartInterface Cart object.
  39. * @throws \Magento\Framework\Exception\NoSuchEntityException The specified customer does not exist.
  40. */
  41. public function getCartForCustomer($customerId);
  42. /**
  43. * Assigns a specified customer to a specified shopping cart.
  44. *
  45. * @param int $cartId The cart ID.
  46. * @param int $customerId The customer ID.
  47. * @param int $storeId
  48. * @return boolean
  49. */
  50. public function assignCustomer($cartId, $customerId, $storeId);
  51. /**
  52. * Places an order for a specified cart.
  53. *
  54. * @param int $cartId The cart ID.
  55. * @param PaymentInterface|null $paymentMethod
  56. * @throws \Magento\Framework\Exception\CouldNotSaveException
  57. * @return int Order ID.
  58. */
  59. public function placeOrder($cartId, PaymentInterface $paymentMethod = null);
  60. }