Skip to content

Commit b91c499

Browse files
committed
Merge remote-tracking branch 'origin/MC-37884' into 2.4-develop-pr44
2 parents 8672f5c + bee2147 commit b91c499

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

app/code/Magento/QuoteGraphQl/Model/Resolver/CartPrices.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
4545

4646
/** @var Quote $quote */
4747
$quote = $value['model'];
48+
/**
49+
* To calculate a right discount value
50+
* before calculate totals
51+
* need to reset Cart Fixed Rules in the quote
52+
*/
53+
$quote->setCartFixedRules([]);
4854
$cartTotals = $this->totalsCollector->collectQuoteTotals($quote);
4955
$currency = $quote->getQuoteCurrencyCode();
5056

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/ApplyCouponsToCartTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ class ApplyCouponsToCartTest extends GraphQlAbstract
2121
*/
2222
private $getMaskedQuoteIdByReservedOrderId;
2323

24+
/**
25+
* @inheritdoc
26+
*/
2427
protected function setUp(): void
2528
{
2629
$objectManager = Bootstrap::getObjectManager();
@@ -36,12 +39,17 @@ protected function setUp(): void
3639
public function testApplyCouponsToCart()
3740
{
3841
$couponCode = '2?ds5!2d';
42+
$expectedGrandTotal = 15.00;
3943
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
4044
$query = $this->getQuery($maskedQuoteId, $couponCode);
4145
$response = $this->graphQlMutation($query);
4246

4347
self::assertArrayHasKey('applyCouponToCart', $response);
4448
self::assertEquals($couponCode, $response['applyCouponToCart']['cart']['applied_coupons'][0]['code']);
49+
self::assertEquals(
50+
$expectedGrandTotal,
51+
$response['applyCouponToCart']['cart']['prices']['grand_total']['value']
52+
);
4553
}
4654

4755
/**
@@ -146,6 +154,11 @@ private function getQuery(string $maskedQuoteId, string $couponCode): string
146154
applied_coupons {
147155
code
148156
}
157+
prices {
158+
grand_total {
159+
value
160+
}
161+
}
149162
}
150163
}
151164
}

0 commit comments

Comments
 (0)