Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5320 Fixed shipping estimates calculation #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions src/Model/Resolver/EstimateShippingCosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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;
}

Expand All @@ -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'])
Expand All @@ -155,3 +152,4 @@ public function resolve(
}, $shippingMethods);
}
}