Skip to content

Commit 711b09c

Browse files
authored
Merge pull request #6141 from magento-tsg-csl3/2.4-develop-pr40
[TSG-CSL3] For 2.4 (pr40)
2 parents 6783060 + b320212 commit 711b09c

File tree

12 files changed

+177
-33
lines changed

12 files changed

+177
-33
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,11 @@ public function saveAddressInformation(
209209
if (!$quote->getIsVirtual()
210210
&& !$shippingAddress->getShippingRateByCode($shippingAddress->getShippingMethod())
211211
) {
212-
throw new NoSuchEntityException(
212+
$errorMessage = $methodCode ?
213213
__('Carrier with such method not found: %1, %2', $carrierCode, $methodCode)
214+
: __('The shipping method is missing. Select the shipping method and try again.');
215+
throw new NoSuchEntityException(
216+
$errorMessage
214217
);
215218
}
216219

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@
8181
<data key="label">All Allowed Countries</data>
8282
<data key="value">0</data>
8383
</entity>
84+
<entity name="EnableFlatRateShowMethodNoApplicableConfigData">
85+
<data key="path">carriers/flatrate/showmethod</data>
86+
<data key="scope">carriers</data>
87+
<data key="scope_id">1</data>
88+
<data key="label">Show Method if Not Applicable</data>
89+
<data key="value">1</data>
90+
</entity>
8491
<entity name="DisableFlatRateConfigData">
8592
<data key="path">carriers/flatrate/active</data>
8693
<data key="scope">carriers</data>

app/code/Magento/Checkout/Test/Mftf/Section/CheckoutShippingMethodsSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@
2020
<element name="shippingMethodLoader" type="button" selector="//div[contains(@class, 'checkout-shipping-method')]/following-sibling::div[contains(@class, 'loading-mask')]"/>
2121
<element name="freeShippingShippingMethod" type="input" selector="#s_method_freeshipping_freeshipping" timeout="30"/>
2222
<element name="noQuotesMsg" type="text" selector="#checkout-step-shipping_method div"/>
23+
<element name="price" type="text" selector="//*[@id='checkout-shipping-method-load']//td[@class='col col-price']"/>
2324
</section>
2425
</sections>
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="StorefrontCheckoutForShowShippingMethodNoApplicableTest">
12+
<annotations>
13+
<stories value="Checkout for not applicable shipping method"/>
14+
<title value="Storefront checkout for not applicable shipping method test"/>
15+
<description value="Checkout flow if shipping rates are not applicable"/>
16+
<severity value="AVERAGE"/>
17+
<testCaseId value="MC-37420"/>
18+
<group value="checkout"/>
19+
</annotations>
20+
<before>
21+
<!-- Create simple product -->
22+
<createData entity="SimpleProduct2" stepKey="createProduct"/>
23+
<!-- Enable flat rate shipping to specific country - Afghanistan -->
24+
<magentoCLI command="config:set {{EnableFlatRateConfigData.path}} {{EnableFlatRateConfigData.value}}" stepKey="enableFlatRate"/>
25+
<magentoCLI command="config:set {{EnableFlatRateToSpecificCountriesConfigData.path}} {{EnableFlatRateToSpecificCountriesConfigData.value}}" stepKey="allowFlatRateSpecificCountries"/>
26+
<magentoCLI command="config:set {{EnableFlatRateToAfghanistanConfigData.path}} {{EnableFlatRateToAfghanistanConfigData.value}}" stepKey="enableFlatRateToAfghanistan"/>
27+
<!-- Enable Show Method if Not Applicable-->
28+
<magentoCLI command="config:set {{EnableFlatRateShowMethodNoApplicableConfigData.path}} {{EnableFlatRateShowMethodNoApplicableConfigData.value}}" stepKey="enableShowMethodNoApplicable"/>
29+
<!-- Create Customer with filled Shipping & Billing Address -->
30+
<createData entity="CustomerEntityOne" stepKey="createCustomer"/>
31+
</before>
32+
<after>
33+
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="logoutFromStorefront"/>
34+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
35+
<magentoCLI command="config:set {{EnableFlatRateToAllAllowedCountriesConfigData.path}} {{EnableFlatRateToAllAllowedCountriesConfigData.value}}" stepKey="allowFlatRateToAllCountries"/>
36+
<magentoCLI command="config:set {{EnableFlatRateShowMethodNoApplicableConfigData.path}} 0" stepKey="disableShowMethodNoApplicable"/>
37+
<!-- Delete product -->
38+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
39+
</after>
40+
<!-- Login with created Customer -->
41+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginAsCustomer">
42+
<argument name="Customer" value="$$createCustomer$$"/>
43+
</actionGroup>
44+
<!-- Add product to cart -->
45+
<actionGroup ref="OpenStoreFrontProductPageActionGroup" stepKey="openProductPage">
46+
<argument name="productUrlKey" value="$$createProduct.custom_attributes[url_key]$$"/>
47+
</actionGroup>
48+
<actionGroup ref="StorefrontAddProductToCartActionGroup" stepKey="addProductToCart">
49+
<argument name="product" value="$$createProduct$$"/>
50+
<argument name="productCount" value="1"/>
51+
</actionGroup>
52+
<!-- Go to checkout page -->
53+
<actionGroup ref="OpenStoreFrontCheckoutShippingPageActionGroup" stepKey="openCheckoutShippingPage"/>
54+
<!-- Assert shipping price for US > California -->
55+
<dontSeeElement selector="{{CheckoutShippingMethodsSection.price}}" stepKey="dontSeePrice"/>
56+
<!-- Assert Next button is available -->
57+
<seeElement selector="{{CheckoutShippingMethodsSection.next}}" stepKey="seeNextButton"/>
58+
<click selector="{{CheckoutShippingMethodsSection.next}}" stepKey="clickNextButton"/>
59+
<!-- Assert order cannot be placed and error message will shown. -->
60+
<waitForPageLoad stepKey="waitForError"/>
61+
<see stepKey="seeShippingMethodError" userInput="The shipping method is missing. Select the shipping method and try again."/>
62+
</test>
63+
</tests>

app/code/Magento/Checkout/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,4 @@ Payment,Payment
185185
"Close","Close"
186186
"Show Cross-sell Items in the Shopping Cart","Show Cross-sell Items in the Shopping Cart"
187187
"You added %1 to your <a href=""%2"">shopping cart</a>.","You added %1 to your <a href=""%2"">shopping cart</a>."
188+
"The shipping method is missing. Select the shipping method and try again.","The shipping method is missing. Select the shipping method and try again."

app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,12 @@ define([
299299
this.source.set('params.invalid', false);
300300
this.triggerShippingDataValidateEvent();
301301

302+
if (!quote.shippingMethod()['method_code']) {
303+
this.errorValidationMessage(
304+
$t('The shipping method is missing. Select the shipping method and try again.')
305+
);
306+
}
307+
302308
if (emailValidationResult &&
303309
this.source.get('params.invalid') ||
304310
!quote.shippingMethod()['method_code'] ||

app/code/Magento/Checkout/view/frontend/web/template/shipping-address/shipping-method-item.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
attr="'aria-labelledby': 'label_method_' + method.method_code + '_' + method.carrier_code + ' ' + 'label_carrier_' + method.method_code + '_' + method.carrier_code,
1616
'checked': element.rates().length == 1 || element.isSelected" />
1717
</td>
18+
<!-- ko ifnot: (method.error_message) -->
1819
<td class="col col-price">
1920
<each args="element.getRegion('price')" render="" />
2021
</td>
22+
<!-- /ko -->
2123
<td class="col col-method"
2224
attr="'id': 'label_method_' + method.method_code + '_' + method.carrier_code"
2325
text="method.method_title" />

dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/configurable_products.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
$product = $objectManager->create(Product::class);
4545
$productId = array_shift($productIds);
4646
$product->setTypeId(Type::TYPE_SIMPLE)
47-
->setId($productId)
4847
->setAttributeSetId($attributeSetId)
4948
->setWebsiteIds([1])
5049
->setName('Configurable Option' . $option->getLabel())
@@ -84,7 +83,6 @@
8483
$product->setExtensionAttributes($extensionConfigurableAttributes);
8584

8685
$product->setTypeId(Configurable::TYPE_CODE)
87-
->setId(1)
8886
->setAttributeSetId($attributeSetId)
8987
->setWebsiteIds([1])
9088
->setName('Configurable Product')
@@ -110,7 +108,6 @@
110108
$product = $objectManager->create(Product::class);
111109
$productId = array_shift($productIds);
112110
$product->setTypeId(Type::TYPE_SIMPLE)
113-
->setId($productId)
114111
->setAttributeSetId($attributeSetId)
115112
->setWebsiteIds([1])
116113
->setName('Configurable Option' . $option->getLabel())
@@ -155,7 +152,6 @@
155152
$product->setExtensionAttributes($extensionConfigurableAttributes);
156153

157154
$product->setTypeId(Configurable::TYPE_CODE)
158-
->setId(11)
159155
->setAttributeSetId($attributeSetId)
160156
->setWebsiteIds([1])
161157
->setName('Configurable Product 12345')

dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/quote_with_configurable_product_last_variation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
$quote = $objectManager->create(\Magento\Quote\Model\Quote::class);
1515
/** @var ProductRepositoryInterface $productRepository */
1616
$productRepository = $objectManager->create(ProductRepositoryInterface::class);
17-
$product = $productRepository->getById(10);
17+
$product = $productRepository->get('simple_10');
1818
$product->setStockData(['use_config_manage_stock' => 1, 'qty' => 1, 'is_qty_decimal' => 0, 'is_in_stock' => 1]);
1919
$productRepository->save($product);
2020

21-
$product = $productRepository->getById(20);
21+
$product = $productRepository->get('simple_20');
2222
$product->setStockData(['use_config_manage_stock' => 1, 'qty' => 0, 'is_qty_decimal' => 0, 'is_in_stock' => 0]);
2323
$productRepository->save($product);
2424

dev/tests/integration/testsuite/Magento/Multishipping/Fixtures/quote_with_configurable_product.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
$objectManager = Bootstrap::getObjectManager();
2525
/** @var ProductRepositoryInterface $productRepository */
2626
$productRepository = $objectManager->create(ProductRepositoryInterface::class);
27-
$product = $productRepository->getById(10);
27+
$product = $productRepository->get('simple_10');
2828
$product->setStockData(['use_config_manage_stock' => 1, 'qty' => 4, 'is_qty_decimal' => 0, 'is_in_stock' => 1]);
2929
$productRepository->save($product);
3030

0 commit comments

Comments
 (0)