Skip to content

Commit 3944abc

Browse files
committed
Merge branch 'ACP2E-172' of https://github.com/magento-l3/magento2ce into PR-2021-20-08
2 parents 63c5e9e + f59324e commit 3944abc

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

app/code/Magento/QuoteGraphQl/Model/Cart/GetCartForUser.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function execute(string $cartHash, ?int $customerId, int $storeId): Quote
9696
throw new GraphQlNoSuchEntityException(__('The cart isn\'t active.'));
9797
}
9898

99-
$this->updateCartCurrency($cart, $storeId);
99+
$cart = $this->updateCartCurrency($cart, $storeId);
100100

101101
$cartCustomerId = (int)$cart->getCustomerId();
102102

@@ -151,10 +151,11 @@ public function getCartForCheckout(string $cartHash, ?int $customerId, int $stor
151151
*
152152
* @param Quote $cart
153153
* @param int $storeId
154+
* @return Quote
154155
* @throws GraphQlInputException
155156
* @throws NoSuchEntityException
156157
*/
157-
private function updateCartCurrency(Quote $cart, int $storeId)
158+
private function updateCartCurrency(Quote $cart, int $storeId): Quote
158159
{
159160
$cartStore = $this->storeRepository->getById($cart->getStoreId());
160161
$currentCartCurrencyCode = $cartStore->getCurrentCurrency()->getCode();
@@ -171,8 +172,11 @@ private function updateCartCurrency(Quote $cart, int $storeId)
171172
} elseif ($cart->getQuoteCurrencyCode() !== $currentCartCurrencyCode) {
172173
$cart->setQuoteCurrencyCode($cartStore->getCurrentCurrency());
173174
} else {
174-
return;
175+
return $cart;
175176
}
176177
$this->cartRepository->save($cart);
178+
$cart = $this->cartRepository->get($cart->getId());
179+
180+
return $cart;
177181
}
178182
}

dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/AddConfigurableProductToCartTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,29 @@ public function testAddConfigurableProductWithImageToCartParentImage(): void
570570
self::assertEquals($sku, $variant['sku']);
571571
}
572572

573+
/**
574+
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
575+
* @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
576+
* @magentoApiDataFixture Magento/Store/_files/second_store.php
577+
*/
578+
public function testAddMoreProductsFromAnotherStore()
579+
{
580+
$parentSku = 'configurable';
581+
$sku = 'simple_20';
582+
$quantity = 400; // the number should be greater than the available qty / 3
583+
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_order_1');
584+
$query = $this->getQuery($maskedQuoteId, $parentSku, $sku, $quantity);
585+
586+
$headerMap = ['Store' => 'default'];
587+
$this->graphQlMutation($query, [], '', $headerMap);
588+
$headerMap = ['Store' => 'fixture_second_store'];
589+
$response = $this->graphQlMutation($query, [], '', $headerMap);
590+
self::assertEquals($maskedQuoteId, $response['addConfigurableProductsToCart']['cart']['id']);
591+
$cartItem = current($response['addConfigurableProductsToCart']['cart']['items']);
592+
self::assertEquals($parentSku, $cartItem['product']['sku']);
593+
self::assertEquals($quantity * 2, $cartItem['quantity']);
594+
}
595+
573596
/**
574597
* @param string $maskedQuoteId
575598
* @param string $parentSku
@@ -594,6 +617,7 @@ private function getQuery(string $maskedQuoteId, string $parentSku, string $sku,
594617
}
595618
) {
596619
cart {
620+
id
597621
items {
598622
id
599623
quantity

0 commit comments

Comments
 (0)