From bdc57648f55d960a4d9a4f0ddc9fb5be3167eed8 Mon Sep 17 00:00:00 2001 From: Denis Protassoff Date: Mon, 28 Nov 2022 16:25:35 +0300 Subject: [PATCH] 5320 Fixed shipping estimates calculation --- src/Model/Resolver/EstimateShippingCosts.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Model/Resolver/EstimateShippingCosts.php b/src/Model/Resolver/EstimateShippingCosts.php index 9c4ce37..d6f16ca 100644 --- a/src/Model/Resolver/EstimateShippingCosts.php +++ b/src/Model/Resolver/EstimateShippingCosts.php @@ -14,17 +14,14 @@ namespace ScandiPWA\QuoteGraphQl\Model\Resolver; -use Magento\Customer\Api\Data\AddressInterfaceFactory; use Magento\Framework\GraphQl\Config\Element\Field; use Magento\Framework\GraphQl\Query\Resolver\ContextInterface; use Magento\Framework\GraphQl\Query\Resolver\Value; use Magento\Framework\GraphQl\Query\ResolverInterface; use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; -use Magento\Quote\Api\Data\EstimateAddressInterface; use Magento\Quote\Api\Data\EstimateAddressInterfaceFactory; use Magento\Quote\Api\Data\ShippingMethodInterface; use Magento\Quote\Model\QuoteIdMaskFactory; -use Magento\Quote\Model\QuoteIdMask; use Magento\Quote\Model\QuoteRepository; use Magento\Quote\Model\ShippingMethodManagement; use Magento\Quote\Model\Webapi\ParamOverriderCartId; @@ -51,17 +48,17 @@ class EstimateShippingCosts implements ResolverInterface { protected $overriderCartId; /** - * @var AddressInterfaceFactory + * @var EstimateAddressInterfaceFactory */ protected $addressInterfaceFactory; - /** - * @var StoreManagerInterface + /** + * @var StoreManagerInterface */ protected $storeManager; - /** - * @var QuoteRepository + /** + * @var QuoteRepository */ protected $quoteRepository; @@ -101,8 +98,9 @@ public function __construct( private function updateStoreId($cartId) { $quote = $this->quoteRepository->getActive($cartId); + // Though it should return int it actually returns string $storeId = $this->storeManager->getStore()->getId(); - if ($storeId === $quote->getStoreId()) { + if ($storeId == $quote->getStoreId()) { return; } @@ -128,7 +126,6 @@ public function resolve( array $value = null, array $args = null ) { - /** @var EstimateAddressInterface $address */ $shippingAddressObject = $this->addressInterfaceFactory->create([ 'data' => $args['address'] ]); $cartId = isset($args['guestCartId']) @@ -155,3 +152,4 @@ public function resolve( }, $shippingMethods); } } +