diff --git a/vendor/magento/module-async-order/Plugin/Api/VerifyIsGuestCheckoutEnabledBeforeSavePaymentInformationAndPlaceOrder.php b/vendor/magento/module-async-order/Plugin/Api/VerifyIsGuestCheckoutEnabledBeforeSavePaymentInformationAndPlaceOrder.php new file mode 100644 index 00000000000..3c7c1b0a9db --- /dev/null +++ b/vendor/magento/module-async-order/Plugin/Api/VerifyIsGuestCheckoutEnabledBeforeSavePaymentInformationAndPlaceOrder.php @@ -0,0 +1,76 @@ +checkoutHelper = $checkoutHelper; + $this->quoteIdMaskFactory = $quoteIdMaskFactory; + $this->cartRepository = $cartRepository; + } + + /** + * Checks whether guest checkout is enabled before placing order + * + * @param AsyncPaymentInformationGuestPublisherInterface $subject + * @param string $cartId + * @param string $email + * @param PaymentInterface $paymentMethod + * @param AddressInterface|null $billingAddress + * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function beforeSavePaymentInformationAndPlaceOrder( + AsyncPaymentInformationGuestPublisherInterface $subject, + $cartId, + $email, + PaymentInterface $paymentMethod, + AddressInterface $billingAddress = null + ): void { + /** @var $quoteIdMask QuoteIdMask */ + $quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id'); + $quote = $this->cartRepository->get($quoteIdMask->getQuoteId()); + if (!$this->checkoutHelper->isAllowedGuestCheckout($quote)) { + throw new CouldNotSaveException(__('Sorry, guest checkout is not available.')); + } + } +} diff --git a/vendor/magento/module-async-order/etc/webapi_rest/di.xml b/vendor/magento/module-async-order/etc/webapi_rest/di.xml new file mode 100644 index 00000000000..5847e4ec0da --- /dev/null +++ b/vendor/magento/module-async-order/etc/webapi_rest/di.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/vendor/magento/module-async-order/etc/webapi_soap/di.xml b/vendor/magento/module-async-order/etc/webapi_soap/di.xml new file mode 100644 index 00000000000..5847e4ec0da --- /dev/null +++ b/vendor/magento/module-async-order/etc/webapi_soap/di.xml @@ -0,0 +1,12 @@ + + + + + + +