Skip to content

Commit 0cb2ac8

Browse files
committed
Merge remote-tracking branch 'origin/MC-36884' into 2.4-develop-pr41
2 parents 5977749 + 12bc082 commit 0cb2ac8

File tree

2 files changed

+70
-1
lines changed

2 files changed

+70
-1
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="CheckoutDifferentDefaultCountryPerStoreTest">
12+
<annotations>
13+
<features value="One Page Checkout"/>
14+
<stories value="Checkout via the Storefront"/>
15+
<title value="Checkout different default country per store"/>
16+
<description value="Checkout display default country per store view"/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="MC-37707"/>
19+
<useCaseId value="MC-36884"/>
20+
<group value="checkout"/>
21+
</annotations>
22+
<before>
23+
<!-- Create simple product -->
24+
<createData entity="SimpleProduct2" stepKey="createProduct"/>
25+
<!-- Create store view -->
26+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginToAdminArea"/>
27+
<actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createStoreView">
28+
<argument name="customStore" value="customStore"/>
29+
</actionGroup>
30+
<!-- Set Germany as default country for created store view -->
31+
<magentoCLI command="config:set --scope=stores --scope-code={{customStore.code}} general/country/default {{DE_Address_Berlin_Not_Default_Address.country_id}}" stepKey="changeDefaultCountry"/>
32+
</before>
33+
<after>
34+
<!--Delete product and store view-->
35+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
36+
<actionGroup ref="AdminDeleteStoreViewActionGroup" stepKey="deleteStoreView">
37+
<argument name="customStore" value="customStore"/>
38+
</actionGroup>
39+
</after>
40+
<!-- Open product and add product to cart-->
41+
<actionGroup ref="OpenStoreFrontProductPageActionGroup" stepKey="openProductPage">
42+
<argument name="productUrlKey" value="$$createProduct.custom_attributes[url_key]$$"/>
43+
</actionGroup>
44+
<actionGroup ref="StorefrontAddProductToCartActionGroup" stepKey="addProductToCart">
45+
<argument name="product" value="$$createProduct$$"/>
46+
<argument name="productCount" value="1"/>
47+
</actionGroup>
48+
<!-- Go to cart -->
49+
<actionGroup ref="StorefrontOpenCartFromMinicartActionGroup" stepKey="openCart"/>
50+
<!-- Switch store view -->
51+
<actionGroup ref="StorefrontSwitchStoreViewActionGroup" stepKey="switchStoreViewActionGroup">
52+
<argument name="storeView" value="customStore"/>
53+
</actionGroup>
54+
<!-- Go to checkout page -->
55+
<actionGroup ref="OpenStoreFrontCheckoutShippingPageActionGroup" stepKey="openCheckoutShippingPage"/>
56+
<!-- Grab country code from checkout page and assert value with default country for created store view -->
57+
<grabValueFrom selector="{{CheckoutShippingSection.country}}" stepKey="grabCountry"/>
58+
<assertEquals stepKey="assertCountryValue">
59+
<actualResult type="const">$grabCountry</actualResult>
60+
<expectedResult type="string">{{DE_Address_Berlin_Not_Default_Address.country_id}}</expectedResult>
61+
</assertEquals>
62+
</test>
63+
</tests>

app/code/Magento/Checkout/view/frontend/web/js/view/cart/shipping-estimation.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,13 @@ define(
7979

8080
if (!quote.isVirtual()) {
8181
checkoutProvider.on('shippingAddress', function (shippingAddressData) {
82-
checkoutData.setShippingAddressFromData(shippingAddressData);
82+
//jscs:disable requireCamelCaseOrUpperCaseIdentifiers
83+
if (quote.shippingAddress().countryId !== shippingAddressData.country_id ||
84+
(shippingAddressData.postcode || shippingAddressData.region_id)
85+
) {
86+
checkoutData.setShippingAddressFromData(shippingAddressData);
87+
}
88+
//jscs:enable requireCamelCaseOrUpperCaseIdentifiers
8389
});
8490
} else {
8591
checkoutProvider.on('shippingAddress', function (shippingAddressData) {

0 commit comments

Comments
 (0)