diff --git a/vendor/magento/module-inventory-in-store-pickup-frontend/Model/Ui/SelectedPickupLocationCodeProvider.php b/vendor/magento/module-inventory-in-store-pickup-frontend/Model/Ui/SelectedPickupLocationCodeProvider.php new file mode 100644 index 000000000000..bc1dfe499b76 --- /dev/null +++ b/vendor/magento/module-inventory-in-store-pickup-frontend/Model/Ui/SelectedPickupLocationCodeProvider.php @@ -0,0 +1,49 @@ +isInStorePickupDeliveryCart->execute($this->checkoutSession->getQuote())) { + $pickupLocationCode = $this->checkoutSession->getQuote() + ->getShippingAddress() + ?->getExtensionAttributes() + ?->getPickupLocationCode(); + + if ($pickupLocationCode) { + $config['selectedPickupLocationCode'] = $pickupLocationCode; + } + } + return $config; + } +} diff --git a/vendor/magento/module-inventory-in-store-pickup-frontend/etc/frontend/di.xml b/vendor/magento/module-inventory-in-store-pickup-frontend/etc/frontend/di.xml index 7d952d2555cd..2983e1e152bc 100644 --- a/vendor/magento/module-inventory-in-store-pickup-frontend/etc/frontend/di.xml +++ b/vendor/magento/module-inventory-in-store-pickup-frontend/etc/frontend/di.xml @@ -1,8 +1,8 @@ @@ -11,6 +11,7 @@ Magento\InventoryInStorePickupFrontend\Model\Ui\WebsiteCodeConfigProvider Magento\InventoryInStorePickupFrontend\Model\Ui\DelimiterConfigProvider + Magento\InventoryInStorePickupFrontend\Model\Ui\SelectedPickupLocationCodeProvider diff --git a/vendor/magento/module-inventory-in-store-pickup-frontend/view/frontend/web/js/view/store-pickup.js b/vendor/magento/module-inventory-in-store-pickup-frontend/view/frontend/web/js/view/store-pickup.js index 95f0f0a2ebc6..5cdbe4acce04 100644 --- a/vendor/magento/module-inventory-in-store-pickup-frontend/view/frontend/web/js/view/store-pickup.js +++ b/vendor/magento/module-inventory-in-store-pickup-frontend/view/frontend/web/js/view/store-pickup.js @@ -236,6 +236,11 @@ define([ selectedSourceCode = this.getPickupLocationCodeFromAddress(selectedPickupAddress); } + if (!selectedSourceCode) { + // Get the source code from the checkout config + selectedSourceCode = window.checkoutConfig.selectedPickupLocationCode; + } + if (selectedSourceCode) { pickupLocationsService .getLocation(selectedSourceCode) diff --git a/vendor/magento/module-inventory-in-store-pickup-quote/Plugin/Quote/ReplaceShippingAddressWithPickupLocationAddressOnAssignCustomer.php b/vendor/magento/module-inventory-in-store-pickup-quote/Plugin/Quote/ReplaceShippingAddressWithPickupLocationAddressOnAssignCustomer.php new file mode 100644 index 000000000000..97dc595d2153 --- /dev/null +++ b/vendor/magento/module-inventory-in-store-pickup-quote/Plugin/Quote/ReplaceShippingAddressWithPickupLocationAddressOnAssignCustomer.php @@ -0,0 +1,96 @@ +isInStorePickupDeliveryCart->execute($quote) + && $quote->getShippingAddress()?->getExtensionAttributes()?->getPickupLocationCode() + ) { + try { + $location = $this->getPickupLocation->execute( + (string) $quote->getShippingAddress()->getExtensionAttributes()->getPickupLocationCode(), + SalesChannelInterface::TYPE_WEBSITE, + $this->getWebsiteCodeByStoreId->execute((int)$quote->getStoreId()) + ); + } catch (NoSuchEntityException $e) { // phpcs:ignore Magento2.CodeAnalysis.EmptyBlock.DetectedCatch + // Pickup location is not found or is invalid for this store + } + if (isset($location)) { + $shippingAddress = $quote->getShippingAddress(); + if (!$this->isPickupLocationShippingAddress->execute($location, $shippingAddress)) { + $pickupLocationAddressData = $this->getShippingAddressData->execute() + + $this->extractPickupLocationShippingAddressData->execute($location); + + $this->dataObjectHelper->populateWithArray( + $shippingAddress, + $pickupLocationAddressData, + AddressInterface::class + ); + } + } + } + return [$customer, $billingAddress, $shippingAddress]; + } +} diff --git a/vendor/magento/module-inventory-in-store-pickup-quote/etc/di.xml b/vendor/magento/module-inventory-in-store-pickup-quote/etc/di.xml index a722010bb7e4..7677508c62e8 100644 --- a/vendor/magento/module-inventory-in-store-pickup-quote/etc/di.xml +++ b/vendor/magento/module-inventory-in-store-pickup-quote/etc/di.xml @@ -1,8 +1,8 @@ @@ -34,4 +34,7 @@ + + +