Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
MykolaMalovanets committed Aug 11, 2023
2 parents b926e96 + 46427d9 commit 543fc84
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
13 changes: 11 additions & 2 deletions Model/Quote/GetQuote.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Bold\Checkout\Api\Quote\GetQuoteInterface;
use Bold\Checkout\Model\Http\Client\Request\Validator\ShopIdValidator;
use Bold\Checkout\Model\Quote\Result\Builder;
use Magento\Checkout\Model\Cart;
use Magento\Framework\Exception\LocalizedException;
use Magento\Quote\Api\CartRepositoryInterface;

Expand All @@ -30,19 +31,27 @@ class GetQuote implements GetQuoteInterface
*/
private $quoteResultBuilder;

/**
* @var Cart
*/
private $cart;

/**
* @param CartRepositoryInterface $cartRepository
* @param ShopIdValidator $shopIdValidator
* @param Builder $quoteResultBuilder
* @param Cart $cart used for the backward compatibility with earlier versions of Magento.
*/
public function __construct(
CartRepositoryInterface $cartRepository,
ShopIdValidator $shopIdValidator,
Builder $quoteResultBuilder
Builder $quoteResultBuilder,
Cart $cart
) {
$this->cartRepository = $cartRepository;
$this->shopIdValidator = $shopIdValidator;
$this->quoteResultBuilder = $quoteResultBuilder;
$this->cart = $cart;
}

/**
Expand All @@ -58,7 +67,7 @@ public function getQuote(
} catch (LocalizedException $e) {
return $this->quoteResultBuilder->createErrorResult($e->getMessage());
}

$this->cart->setQuote($quote);
return $this->quoteResultBuilder->createSuccessResult($quote);
}
}
12 changes: 11 additions & 1 deletion Model/Quote/SetQuoteShippingMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Bold\Checkout\Model\Quote\Result\Builder;
use Magento\Checkout\Api\Data\ShippingInformationInterfaceFactory;
use Magento\Checkout\Api\ShippingInformationManagementInterface;
use Magento\Checkout\Model\Cart;
use Magento\Framework\Exception\LocalizedException;
use Magento\Quote\Api\CartRepositoryInterface;

Expand Down Expand Up @@ -53,28 +54,36 @@ class SetQuoteShippingMethod implements SetQuoteShippingMethodInterface
*/
private $config;

/**
* @var Cart
*/
private $cart;

/**
* @param ShippingInformationManagementInterface $shippingInformationManagement
* @param ShippingInformationInterfaceFactory $shippingInformationFactory
* @param CartRepositoryInterface $cartRepository
* @param ShopIdValidator $shopIdValidator
* @param Builder $quoteResultBuilder
* @param ConfigInterface $config
* @param Cart $cart used for the backward compatibility with earlier versions of Magento.
*/
public function __construct(
ShippingInformationManagementInterface $shippingInformationManagement,
ShippingInformationInterfaceFactory $shippingInformationFactory,
CartRepositoryInterface $cartRepository,
ShopIdValidator $shopIdValidator,
Builder $quoteResultBuilder,
ConfigInterface $config
ConfigInterface $config,
Cart $cart
) {
$this->shippingInformationManagement = $shippingInformationManagement;
$this->shippingInformationFactory = $shippingInformationFactory;
$this->cartRepository = $cartRepository;
$this->quoteResultBuilder = $quoteResultBuilder;
$this->shopIdValidator = $shopIdValidator;
$this->config = $config;
$this->cart = $cart;
}

/**
Expand All @@ -95,6 +104,7 @@ public function setShippingMethod(
if ($this->config->isCheckoutTypeSelfHosted((int)$quote->getStore()->getWebsiteId())) {
$this->quoteResultBuilder->createSuccessResult($quote);
}
$this->cart->setQuote($quote);
$shippingInformation = $this->shippingInformationFactory->create()
->setShippingAddress($quote->getShippingAddress())
->setBillingAddress($quote->getBillingAddress())
Expand Down

0 comments on commit 543fc84

Please sign in to comment.