Skip to content

Commit 26bd53b

Browse files
committed
Merge branch 'MC-18281' of https://github.com/magento-mpi/magento2ce into pr_2019_07_24
2 parents 72f72dd + 586cea2 commit 26bd53b

File tree

7 files changed

+115
-3
lines changed

7 files changed

+115
-3
lines changed

app/code/Magento/Checkout/Model/DefaultConfigProvider.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,10 @@ public function getConfig()
343343
)
344344
)
345345
];
346+
$output['useQty'] = $this->scopeConfig->isSetFlag(
347+
'checkout/cart_link/use_qty',
348+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
349+
);
346350
$output['activeCarriers'] = $this->getActiveCarriers();
347351
$output['originCountryCode'] = $this->getOriginCountryCode();
348352
$output['paymentMethods'] = $this->getPaymentMethods();

app/code/Magento/Checkout/Test/Mftf/Data/ConfigData.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,16 @@
8888
<data key="label">No</data>
8989
<data key="value">0</data>
9090
</entity>
91+
92+
<!-- Checkout Config: Display Cart Summary -->
93+
<entity name="DisplayItemsQuantities">
94+
<data key="path">checkout/cart_link/use_qty</data>
95+
<data key="label">Display items quantities</data>
96+
<data key="value">1</data>
97+
</entity>
98+
<entity name="DisplayUniqueItems">
99+
<data key="path">checkout/cart_link/use_qty</data>
100+
<data key="label">Display number of items in cart</data>
101+
<data key="value">0</data>
102+
</entity>
91103
</entities>

app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddProductWithAllTypesOfCustomOptionToTheShoppingCartTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
<!-- Assert Product Count in Mini Cart -->
101101
<actionGroup ref="StorefrontAssertMiniCartItemCountActionGroup" stepKey="assertProductCountAndTextInMiniCart">
102102
<argument name="productCount" value="2"/>
103-
<argument name="productCountText" value="1 Item in Cart"/>
103+
<argument name="productCountText" value="2 Item in Cart"/>
104104
</actionGroup>
105105

106106
<!--Assert Product Items in Mini cart-->
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="StorefrontCartItemsCountDisplayItemsQuantities">
11+
<annotations>
12+
<stories value="Checkout order summary has wrong item count"/>
13+
<title value="Checkout order summary has wrong item count - display items quantities"/>
14+
<description value="Items count in shopping cart and on checkout page should be consistent with settings 'checkout/cart_link/use_qty'"/>
15+
<testCaseId value="MC-18281"/>
16+
<severity value="CRITICAL"/>
17+
<group value="checkout"/>
18+
</annotations>
19+
20+
<before>
21+
<!--Set Display Cart Summary to display items quantities-->
22+
<magentoCLI command="config:set {{DisplayItemsQuantities.path}} {{DisplayItemsQuantities.value}}" stepKey="setDisplayCartSummary"/>
23+
<!--Create simple product-->
24+
<createData entity="SimpleProduct2" stepKey="simpleProduct1"/>
25+
<!--Create simple product-->
26+
<createData entity="SimpleProduct2" stepKey="simpleProduct2"/>
27+
</before>
28+
<after>
29+
<deleteData createDataKey="simpleProduct1" stepKey="deleteProduct1"/>
30+
<deleteData createDataKey="simpleProduct2" stepKey="deleteProduct2"/>
31+
<magentoCLI command="config:set {{DisplayItemsQuantities.path}} {{DisplayItemsQuantities.value}}" stepKey="resetDisplayCartSummary"/>
32+
</after>
33+
34+
<!-- Add simpleProduct1 to cart -->
35+
<amOnPage url="{{StorefrontProductPage.url($$simpleProduct1.custom_attributes[url_key]$)}}" stepKey="amOnProduct1Page"/>
36+
<actionGroup ref="AddProductWithQtyToCartFromStorefrontProductPage" stepKey="addProduct1ToCart">
37+
<argument name="productName" value="$$simpleProduct1.name$$"/>
38+
<argument name="productQty" value="2"/>
39+
</actionGroup>
40+
<!-- Add simpleProduct2 to cart -->
41+
<amOnPage url="{{StorefrontProductPage.url($$simpleProduct2.custom_attributes[url_key]$)}}" stepKey="amOnProduct2Page"/>
42+
<actionGroup ref="AddProductWithQtyToCartFromStorefrontProductPage" stepKey="addProduct2ToCart">
43+
<argument name="productName" value="$$simpleProduct2.name$$"/>
44+
<argument name="productQty" value="1"/>
45+
</actionGroup>
46+
47+
<!-- Open Mini Cart -->
48+
<actionGroup ref="StorefrontOpenMiniCartActionGroup" stepKey="openMiniCart"/>
49+
50+
<!-- Assert Products Count in Mini Cart -->
51+
<actionGroup ref="StorefrontAssertMiniCartItemCountActionGroup" stepKey="assertProductCountAndTextInMiniCart">
52+
<argument name="productCount" value="3"/>
53+
<argument name="productCountText" value="3 Items in Cart"/>
54+
</actionGroup>
55+
<!-- Assert Products Count on checkout page -->
56+
<actionGroup ref="StorefrontCheckoutAndAssertOrderSummaryDisplayActionGroup" stepKey="assertProductCountOnCheckoutPage">
57+
<argument name="itemsText" value="3 Items in Cart"/>
58+
</actionGroup>
59+
</test>
60+
<test name="StorefrontCartItemsCountDisplayUniqueItems" extends="StorefrontCartItemsCountDisplayItemsQuantities">
61+
<annotations>
62+
<stories value="Checkout order summary has wrong item count"/>
63+
<title value="Checkout order summary has wrong item count - display unique items"/>
64+
<description value="Items count in shopping cart and on checkout page should be consistent with settings 'checkout/cart_link/use_qty'"/>
65+
<testCaseId value="MC-18281"/>
66+
<severity value="CRITICAL"/>
67+
<group value="checkout"/>
68+
</annotations>
69+
70+
<!-- Assert Products Count in Mini Cart -->
71+
<actionGroup ref="StorefrontAssertMiniCartItemCountActionGroup" stepKey="assertProductCountAndTextInMiniCart">
72+
<argument name="productCount" value="2"/>
73+
<argument name="productCountText" value="2 Items in Cart"/>
74+
</actionGroup>
75+
<!-- Assert Products Count on checkout page -->
76+
<actionGroup ref="StorefrontCheckoutAndAssertOrderSummaryDisplayActionGroup" stepKey="assertProductCountOnCheckoutPage">
77+
<argument name="itemsText" value="2 Items in Cart"/>
78+
</actionGroup>
79+
80+
<before>
81+
<!--Set Display Cart Summary to display items quantities-->
82+
<magentoCLI command="config:set {{DisplayUniqueItems.path}} {{DisplayUniqueItems.value}}" stepKey="setDisplayCartSummary"/>
83+
</before>
84+
</test>
85+
</tests>

app/code/Magento/Checkout/view/frontend/web/js/view/summary/cart-items.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ define([
1212
], function (ko, totals, Component, stepNavigator, quote) {
1313
'use strict';
1414

15+
var useQty = window.checkoutConfig.useQty;
16+
1517
return Component.extend({
1618
defaults: {
1719
template: 'Magento_Checkout/summary/cart-items'
@@ -44,6 +46,15 @@ define([
4446
return parseInt(totals.getItems()().length, 10);
4547
},
4648

49+
/**
50+
* Returns shopping cart items summary (includes config settings)
51+
*
52+
* @returns {Number}
53+
*/
54+
getCartSummaryItemsCount: function () {
55+
return useQty ? this.getItemsQty() : this.getCartLineItemsCount();
56+
},
57+
4758
/**
4859
* @inheritdoc
4960
*/

app/code/Magento/Checkout/view/frontend/web/template/minicart/content.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<div class="items-total">
3030
<span class="count" if="maxItemsToDisplay < getCartLineItemsCount()" text="maxItemsToDisplay"/>
3131
<translate args="'of'" if="maxItemsToDisplay < getCartLineItemsCount()"/>
32-
<span class="count" text="getCartLineItemsCount()"/>
32+
<span class="count" text="getCartParam('summary_count')"/>
3333
<!-- ko if: (getCartLineItemsCount() === 1) -->
3434
<span translate="'Item in Cart'"/>
3535
<!--/ko-->

app/code/Magento/Checkout/view/frontend/web/template/summary/cart-items.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<strong role="heading" aria-level="1">
1010
<translate args="maxCartItemsToDisplay" if="maxCartItemsToDisplay < getCartLineItemsCount()"/>
1111
<translate args="'of'" if="maxCartItemsToDisplay < getCartLineItemsCount()"/>
12-
<span data-bind="text: getCartLineItemsCount()"></span>
12+
<span data-bind="text: getCartSummaryItemsCount()"></span>
1313
<translate args="'Item in Cart'" if="getCartLineItemsCount() === 1"/>
1414
<translate args="'Items in Cart'" if="getCartLineItemsCount() > 1"/>
1515
</strong>

0 commit comments

Comments
 (0)