diff --git a/vendor/magento/module-async-order/etc/di.xml b/vendor/magento/module-async-order/etc/di.xml
index 89db4f49c0b..74f14273411 100644
--- a/vendor/magento/module-async-order/etc/di.xml
+++ b/vendor/magento/module-async-order/etc/di.xml
@@ -86,16 +86,6 @@
-
-
- Magento\AsyncOrder\Model\CartRepository
-
-
-
-
- Magento\AsyncOrder\Model\CartRepository
-
-
asyncCustomerPaymentInformationManagement
diff --git a/vendor/magento/module-checkout-staging/Plugin/GuestPaymentInformationManagementPlugin.php b/vendor/magento/module-checkout-staging/Plugin/GuestPaymentInformationManagementPlugin.php
index 10925ea9ade..97c7c5bc775 100644
--- a/vendor/magento/module-checkout-staging/Plugin/GuestPaymentInformationManagementPlugin.php
+++ b/vendor/magento/module-checkout-staging/Plugin/GuestPaymentInformationManagementPlugin.php
@@ -8,11 +8,8 @@ namespace Magento\CheckoutStaging\Plugin;
use Magento\Checkout\Api\GuestPaymentInformationManagementInterface;
use Magento\Framework\Exception\LocalizedException;
-use Magento\Quote\Api\CartRepositoryInterface;
use Magento\Quote\Api\Data\AddressInterface;
use Magento\Quote\Api\Data\PaymentInterface;
-use Magento\Quote\Model\QuoteIdMaskFactory;
-use Magento\Quote\Model\Quote;
use Magento\Staging\Model\VersionManager;
/**
@@ -25,28 +22,14 @@ class GuestPaymentInformationManagementPlugin
*/
private $versionManager;
- /**
- * @var QuoteIdMaskFactory
- */
- private $quoteIdMaskFactory;
-
- /**
- * @var CartRepositoryInterface
- */
- private $cartRepository;
-
/**
* GuestPaymentInformationManagement constructor
*
* @param VersionManager $versionManager
- * @param QuoteIdMaskFactory $quoteIdMaskFactory
- * @param CartRepositoryInterface $cartRepository
*/
- public function __construct(VersionManager $versionManager, QuoteIdMaskFactory $quoteIdMaskFactory, CartRepositoryInterface $cartRepository)
+ public function __construct(VersionManager $versionManager)
{
$this->versionManager = $versionManager;
- $this->quoteIdMaskFactory = $quoteIdMaskFactory;
- $this->cartRepository = $cartRepository;
}
/**
@@ -67,66 +50,9 @@ class GuestPaymentInformationManagementPlugin
$email,
PaymentInterface $paymentMethod,
AddressInterface $billingAddress = null
- ) {
+ ): void {
if ($this->versionManager->isPreviewVersion()) {
throw new LocalizedException(__("The order can't be submitted in preview mode."));
}
-
- $quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'masked_id');
- /** @var Quote $quote */
- $quote = $this->cartRepository->getActive($quoteIdMask->getQuoteId());
- $shippingAddress = $quote->getShippingAddress();
-
- if (!empty($billingAddress)) {
- $sameAsBillingFlag = $this->checkIfShippingAddressMatchesWithBillingAddress($quote, $billingAddress);
- } else {
- $sameAsBillingFlag = 0;
- }
-
- if ($sameAsBillingFlag) {
- $shippingAddress->setSameAsBilling(1);
- }
- }
-
- /**
- * Returns true if shipping address is same as billing address
- *
- * @param Quote $quote
- * @param AddressInterface $billingAddress
- * @return bool
- */
- private function checkIfShippingAddressMatchesWithBillingAddress(Quote $quote, AddressInterface $billingAddress): bool
- {
- $quoteShippingAddressData = $quote->getShippingAddress()->getData();
- $billingData = $this->convertAddressValueToFlatArray($billingAddress->getData());
- $billingKeys = array_flip(array_keys($billingData));
- $shippingData = array_intersect_key($quoteShippingAddressData, $billingKeys);
- $removeKeys = ['region_code', 'save_in_address_book'];
- $billingData = array_diff_key($billingData, array_flip($removeKeys));
- $difference = array_diff($billingData,$shippingData);
- return empty($difference);
- }
-
- /**
- * Convert $address value to flat array
- *
- * @param array $address
- * @return array
- */
- private function convertAddressValueToFlatArray(array $address): array
- {
- array_walk(
- $address,
- function (&$value) {
- if (is_array($value) && isset($value['value'])) {
- if (!is_array($value['value'])) {
- $value = (string)$value['value'];
- } elseif (isset($value['value'][0]['file'])) {
- $value = $value['value'][0]['file'];
- }
- }
- }
- );
- return $address;
}
}
diff --git a/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php b/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php
index 077039dcdd6..ac22735de37 100644
--- a/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php
+++ b/vendor/magento/module-checkout-staging/Plugin/PaymentInformationManagementPlugin.php
@@ -7,12 +7,9 @@
namespace Magento\CheckoutStaging\Plugin;
use Magento\Checkout\Api\PaymentInformationManagementInterface;
-use Magento\Customer\Api\AddressRepositoryInterface;
use Magento\Framework\Exception\LocalizedException;
-use Magento\Quote\Api\CartRepositoryInterface;
use Magento\Quote\Api\Data\AddressInterface;
use Magento\Quote\Api\Data\PaymentInterface;
-use Magento\Quote\Model\Quote;
use Magento\Staging\Model\VersionManager;
/**
@@ -25,29 +22,14 @@ class PaymentInformationManagementPlugin
*/
private $versionManager;
- /**
- * @var CartRepositoryInterface
- */
- private $quoteRepository;
-
- /**
- * @var AddressRepositoryInterface
- */
- private $addressRepository;
-
/**
* PaymentInformationManagement constructor
*
* @param VersionManager $versionManager
- * @param CartRepositoryInterface $quoteRepository
- * @param AddressRepositoryInterface $addressRepository
*/
- public function __construct(VersionManager $versionManager, CartRepositoryInterface $quoteRepository,
- AddressRepositoryInterface $addressRepository)
+ public function __construct(VersionManager $versionManager)
{
$this->versionManager = $versionManager;
- $this->quoteRepository = $quoteRepository;
- $this->addressRepository = $addressRepository;
}
/**
@@ -66,125 +48,9 @@ class PaymentInformationManagementPlugin
$cartId,
PaymentInterface $paymentMethod,
AddressInterface $billingAddress = null
- ) {
+ ): void {
if ($this->versionManager->isPreviewVersion()) {
throw new LocalizedException(__("The order can't be submitted in preview mode."));
}
-
- /** @var Quote $quote */
- $quote = $this->quoteRepository->getActive($cartId);
- $shippingAddress = $quote->getShippingAddress();
-
- $quoteSameAsBilling = (int) $shippingAddress->getSameAsBilling();
- $customer = $quote->getCustomer();
- $customerId = $customer->getId();
- $hasDefaultBilling = $customer->getDefaultBilling();
- $hasDefaultShipping = $customer->getDefaultShipping();
-
- if ($quoteSameAsBilling === 1) {
- $sameAsBillingFlag = 1;
- } elseif (!empty($shippingAddress) && !empty($billingAddress)) {
- $sameAsBillingFlag = $quote->getCustomerId() &&
- $this->checkIfShippingNullOrNotSameAsBillingAddress($shippingAddress, $billingAddress);
- } else {
- $sameAsBillingFlag = 0;
- }
-
- if ($sameAsBillingFlag) {
- $shippingAddress->setSameAsBilling(1);
- if ($customerId && !$hasDefaultBilling && !$hasDefaultShipping) {
- $this->processCustomerShippingAddress($quote);
- }
- }
- }
-
- /**
- * Returns true if shipping address is same as billing or it is undefined
- *
- * @param AddressInterface $shippingAddress
- * @param AddressInterface $billingAddress
- * @return bool
- */
- private function checkIfShippingNullOrNotSameAsBillingAddress(AddressInterface $shippingAddress, AddressInterface $billingAddress): bool
- {
- if($shippingAddress->getCustomerAddressId() !== null &&
- $billingAddress->getCustomerAddressId() !== null) {
- $sameAsBillingFlag = ((int)$shippingAddress->getCustomerAddressId() === (int)$billingAddress->getCustomerAddressId());
- } else {
- $quoteShippingAddressData = $shippingAddress->getData();
- $billingAddressData = $billingAddress->getData();
- if (!empty($quoteShippingAddressData) && !empty($billingAddressData)) {
- $billingData = $this->convertAddressValueToFlatArray($billingAddressData);
- $billingKeys = array_flip(array_keys($billingData));
- $shippingData = array_intersect_key($quoteShippingAddressData, $billingKeys);
- $removeKeys = ['region_code', 'save_in_address_book'];
- $billingData = array_diff_key($billingData, array_flip($removeKeys));
- $difference = array_diff($billingData, $shippingData);
- $sameAsBillingFlag = empty($difference);
- } else {
- $sameAsBillingFlag = false;
- }
- }
-
- return $sameAsBillingFlag;
- }
-
- /**
- * Convert $address value to flat array
- *
- * @param array $address
- * @return array
- */
- private function convertAddressValueToFlatArray(array $address): array
- {
- array_walk(
- $address,
- function (&$value) {
- if (is_array($value) && isset($value['value'])) {
- if (!is_array($value['value'])) {
- $value = (string)$value['value'];
- } elseif (isset($value['value'][0]['file'])) {
- $value = $value['value'][0]['file'];
- }
- }
- }
- );
- return $address;
- }
-
- /**
- * Process customer shipping address
- *
- * @param Quote $quote
- * @return void
- * @throws LocalizedException
- */
- private function processCustomerShippingAddress(Quote $quote): void
- {
- $shippingAddress = $quote->getShippingAddress();
- $billingAddress = $quote->getBillingAddress();
-
- $customer = $quote->getCustomer();
- $hasDefaultBilling = $customer->getDefaultBilling();
- $hasDefaultShipping = $customer->getDefaultShipping();
-
- if ($shippingAddress->getQuoteId()) {
- $shippingAddressData = $shippingAddress->exportCustomerAddress();
- }
- if (isset($shippingAddressData)) {
- if (!$hasDefaultShipping) {
- //Make provided address as default shipping address
- $shippingAddressData->setIsDefaultShipping(true);
- if (!$hasDefaultBilling && !$billingAddress->getSaveInAddressBook()) {
- $shippingAddressData->setIsDefaultBilling(true);
- }
- }
- //save here new customer address
- $shippingAddressData->setCustomerId($quote->getCustomerId());
- $this->addressRepository->save($shippingAddressData);
- $quote->addCustomerAddress($shippingAddressData);
- $shippingAddress->setCustomerAddressData($shippingAddressData);
- $shippingAddress->setCustomerAddressId($shippingAddressData->getId());
- }
}
}