From 4925c1ff114f94a2ea2ce685af954bd6436316b9 Mon Sep 17 00:00:00 2001 From: Vladimir Bratukhin Date: Tue, 26 Jul 2022 11:10:47 +0200 Subject: [PATCH] Fix missing scope on isShippingCarrierAvailable The scope to isShippingCarrierAvailable is not applied from $request. This makes issues with shipping methods when quote is being created from backend via 3rd party modules. This applies storeId scope directly from $request->getStoreId() to make sure scope is not lost when quote is created by admin. --- app/code/Magento/Shipping/Model/Shipping.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Shipping/Model/Shipping.php b/app/code/Magento/Shipping/Model/Shipping.php index 57dc85a34d110..7e5a9574e8b92 100644 --- a/app/code/Magento/Shipping/Model/Shipping.php +++ b/app/code/Magento/Shipping/Model/Shipping.php @@ -273,7 +273,7 @@ public function collectRates(\Magento\Quote\Model\Quote\Address\RateRequest $req */ private function prepareCarrier(string $carrierCode, RateRequest $request): AbstractCarrier { - $carrier = $this->isShippingCarrierAvailable($carrierCode) + $carrier = $this->isShippingCarrierAvailable($carrierCode, $request->getStoreId()) ? $this->_carrierFactory->create($carrierCode, $request->getStoreId()) : null; if (!$carrier) { @@ -541,13 +541,15 @@ public function setCarrierAvailabilityConfigField($code = 'active') * Checks availability of carrier. * * @param string $carrierCode + * @param null|int $storeId * @return bool */ - private function isShippingCarrierAvailable(string $carrierCode): bool + private function isShippingCarrierAvailable(string $carrierCode, ?int $storeId = null): bool { return $this->_scopeConfig->isSetFlag( 'carriers/' . $carrierCode . '/' . $this->_availabilityConfigField, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $storeId ); } }