Skip to content

Commit 27b3d48

Browse files
authored
Merge pull request #3308 from magento-borg/BugFixPR
[2.3.0-regression] Bug Fixes
2 parents 8f5c010 + 0f9108d commit 27b3d48

File tree

6 files changed

+210
-3
lines changed

6 files changed

+210
-3
lines changed

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
use Magento\Framework\App\ObjectManager;
2020

2121
/**
22+
* Class ShippingInformationManagement
23+
*
24+
* @package Magento\Checkout\Model
2225
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2326
*/
2427
class ShippingInformationManagement implements \Magento\Checkout\Api\ShippingInformationManagementInterface
@@ -99,8 +102,8 @@ class ShippingInformationManagement implements \Magento\Checkout\Api\ShippingInf
99102
* @param \Magento\Customer\Api\AddressRepositoryInterface $addressRepository
100103
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
101104
* @param \Magento\Quote\Model\Quote\TotalsCollector $totalsCollector
102-
* @param CartExtensionFactory|null $cartExtensionFactory,
103-
* @param ShippingAssignmentFactory|null $shippingAssignmentFactory,
105+
* @param CartExtensionFactory|null $cartExtensionFactory
106+
* @param ShippingAssignmentFactory|null $shippingAssignmentFactory
104107
* @param ShippingFactory|null $shippingFactory
105108
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
106109
*/
@@ -136,7 +139,14 @@ public function __construct(
136139
}
137140

138141
/**
139-
* {@inheritDoc}
142+
* Save address information.
143+
*
144+
* @param int $cartId
145+
* @param \Magento\Checkout\Api\Data\ShippingInformationInterface $addressInformation
146+
* @return \Magento\Checkout\Api\Data\PaymentDetailsInterface
147+
* @throws InputException
148+
* @throws NoSuchEntityException
149+
* @throws StateException
140150
*/
141151
public function saveAddressInformation(
142152
$cartId,
@@ -151,6 +161,10 @@ public function saveAddressInformation(
151161
$address->setCustomerAddressId(null);
152162
}
153163

164+
if ($billingAddress && !$billingAddress->getCustomerAddressId()) {
165+
$billingAddress->setCustomerAddressId(null);
166+
}
167+
154168
if (!$address->getCountryId()) {
155169
throw new StateException(__('The shipping address is missing. Set the address and try again.'));
156170
}
@@ -208,6 +222,8 @@ protected function validateQuote(\Magento\Quote\Model\Quote $quote)
208222
}
209223

210224
/**
225+
* Prepare shipping assignment.
226+
*
211227
* @param CartInterface $quote
212228
* @param AddressInterface $address
213229
* @param string $method

app/code/Magento/Checkout/Test/Mftf/ActionGroup/CheckoutActionGroup.xml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,51 @@
3838
<seeInCurrentUrl url="{{CheckoutPage.url}}/#payment" stepKey="assertCheckoutPaymentUrl"/>
3939
</actionGroup>
4040

41+
<!-- Guest checkout filling shipping section without region -->
42+
<actionGroup name="GuestCheckoutFillingShippingSectionWithoutRegionActionGroup">
43+
<arguments>
44+
<argument name="customerVar"/>
45+
<argument name="customerAddressVar"/>
46+
</arguments>
47+
<fillField selector="{{CheckoutShippingSection.email}}" userInput="{{customerVar.email}}" stepKey="enterEmail"/>
48+
<fillField selector="{{CheckoutShippingSection.firstName}}" userInput="{{customerVar.firstname}}" stepKey="enterFirstName"/>
49+
<fillField selector="{{CheckoutShippingSection.lastName}}" userInput="{{customerVar.lastname}}" stepKey="enterLastName"/>
50+
<fillField selector="{{CheckoutShippingSection.street}}" userInput="{{customerAddressVar.street[0]}}" stepKey="enterStreet"/>
51+
<fillField selector="{{CheckoutShippingSection.city}}" userInput="{{customerAddressVar.city}}" stepKey="enterCity"/>
52+
<fillField selector="{{CheckoutShippingSection.postcode}}" userInput="{{customerAddressVar.postcode}}" stepKey="enterPostcode"/>
53+
<selectOption selector="{{CheckoutShippingSection.country}}" userInput="{{customerAddressVar.country_id}}" stepKey="enterCountry"/>
54+
<fillField selector="{{CheckoutShippingSection.telephone}}" userInput="{{customerAddressVar.telephone}}" stepKey="enterTelephone"/>
55+
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/>
56+
<click selector="{{CheckoutShippingSection.firstShippingMethod}}" stepKey="selectFirstShippingMethod"/>
57+
<waitForElement selector="{{CheckoutShippingSection.next}}" time="30" stepKey="waitForNextButton"/>
58+
<click selector="{{CheckoutShippingSection.next}}" stepKey="clickNext"/>
59+
<waitForElement selector="{{CheckoutPaymentSection.paymentSectionTitle}}" time="30" stepKey="waitForPaymentSectionLoaded"/>
60+
<seeInCurrentUrl url="{{CheckoutPage.url}}/#payment" stepKey="assertCheckoutPaymentUrl"/>
61+
</actionGroup>
62+
63+
<!-- Guest checkout filling shipping section with unavailable payments-->
64+
<actionGroup name="GuestCheckoutFillingShippingSectionUnavailablePaymentActionGroup">
65+
<arguments>
66+
<argument name="customerVar"/>
67+
<argument name="customerAddressVar"/>
68+
</arguments>
69+
<fillField selector="{{CheckoutShippingSection.email}}" userInput="{{customerVar.email}}" stepKey="enterEmail"/>
70+
<fillField selector="{{CheckoutShippingSection.firstName}}" userInput="{{customerVar.firstname}}" stepKey="enterFirstName"/>
71+
<fillField selector="{{CheckoutShippingSection.lastName}}" userInput="{{customerVar.lastname}}" stepKey="enterLastName"/>
72+
<fillField selector="{{CheckoutShippingSection.street}}" userInput="{{customerAddressVar.street[0]}}" stepKey="enterStreet"/>
73+
<fillField selector="{{CheckoutShippingSection.city}}" userInput="{{customerAddressVar.city}}" stepKey="enterCity"/>
74+
<selectOption selector="{{CheckoutShippingSection.region}}" userInput="{{customerAddressVar.state}}" stepKey="selectRegion"/>
75+
<fillField selector="{{CheckoutShippingSection.postcode}}" userInput="{{customerAddressVar.postcode}}" stepKey="enterPostcode"/>
76+
<fillField selector="{{CheckoutShippingSection.telephone}}" userInput="{{customerAddressVar.telephone}}" stepKey="enterTelephone"/>
77+
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/>
78+
<click selector="{{CheckoutShippingSection.firstShippingMethod}}" stepKey="selectFirstShippingMethod"/>
79+
<waitForElement selector="{{CheckoutShippingSection.next}}" time="30" stepKey="waitForNextButton"/>
80+
<click selector="{{CheckoutShippingSection.next}}" stepKey="clickNext"/>
81+
<seeInCurrentUrl url="{{CheckoutPage.url}}/#payment" stepKey="assertCheckoutPaymentUrl"/>
82+
<waitForElementVisible selector="{{CheckoutPaymentSection.noQuotes}}" stepKey="waitMessage"/>
83+
<see userInput="No Payment method available." stepKey="checkMessage"/>
84+
</actionGroup>
85+
4186
<!-- Logged in user checkout filling shipping section -->
4287
<actionGroup name="LoggedInUserCheckoutFillingShippingSectionActionGroup">
4388
<arguments>
@@ -59,6 +104,28 @@
59104
<seeInCurrentUrl url="{{CheckoutPage.url}}/#payment" stepKey="assertCheckoutPaymentUrl"/>
60105
</actionGroup>
61106

107+
<!-- Logged in user checkout filling shipping section -->
108+
<actionGroup name="LoggedInUserCheckoutAddNewShippingSectionWithoutRegionActionGroup">
109+
<arguments>
110+
<argument name="customerVar"/>
111+
<argument name="customerAddressVar"/>
112+
</arguments>
113+
<fillField selector="{{CheckoutShippingSection.firstName}}" userInput="{{customerVar.firstname}}" stepKey="enterFirstName"/>
114+
<fillField selector="{{CheckoutShippingSection.lastName}}" userInput="{{customerVar.lastname}}" stepKey="enterLastName"/>
115+
<fillField selector="{{CheckoutShippingSection.street}}" userInput="{{customerAddressVar.street[0]}}" stepKey="enterStreet"/>
116+
<fillField selector="{{CheckoutShippingSection.city}}" userInput="{{customerAddressVar.city}}" stepKey="enterCity"/>
117+
<fillField selector="{{CheckoutShippingSection.postcode}}" userInput="{{customerAddressVar.postcode}}" stepKey="enterPostcode"/>
118+
<selectOption selector="{{CheckoutShippingSection.country}}" userInput="{{customerAddressVar.country_id}}" stepKey="enterCountry"/>
119+
<fillField selector="{{CheckoutShippingSection.telephone}}" userInput="{{customerAddressVar.telephone}}" stepKey="enterTelephone"/>
120+
<click selector="{{CheckoutShippingSection.saveAddress}}" stepKey="clickSaveAddress"/>
121+
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/>
122+
<click selector="{{CheckoutShippingSection.firstShippingMethod}}" stepKey="selectFirstShippingMethod"/>
123+
<waitForElement selector="{{CheckoutShippingSection.next}}" time="30" stepKey="waitForNextButton"/>
124+
<click selector="{{CheckoutShippingSection.next}}" stepKey="clickNext"/>
125+
<waitForElement selector="{{CheckoutPaymentSection.paymentSectionTitle}}" time="30" stepKey="waitForPaymentSectionLoaded"/>
126+
<seeInCurrentUrl url="{{CheckoutPage.url}}/#payment" stepKey="assertCheckoutPaymentUrl"/>
127+
</actionGroup>
128+
62129
<!-- Check product in checkout cart items -->
63130
<actionGroup name="CheckProductInCheckoutCartItemsActionGroup">
64131
<arguments>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,6 @@
5050
<element name="shippingAndBillingAddressSame" type="input" selector="#billing-address-same-as-shipping-braintree_cc_vault"/>
5151
<element name="addressAction" type="button" selector="//span[text()='{{action}}']" parameterized="true"/>
5252
<element name="addressBook" type="button" selector="//a[text()='Address Book']"/>
53+
<element name="noQuotes" type="text" selector=".no-quotes-block"/>
5354
</section>
5455
</sections>

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

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,4 +193,69 @@
193193
<waitForPageLoad stepKey="waitForOrderSuccessPage2"/>
194194
<see stepKey="seeSuccessMessage2" selector="{{CheckoutSuccessMainSection.success}}" userInput="Your order number is:" />
195195
</test>
196+
<test name="StorefrontCustomerCheckoutTestWithRestrictedCountriesForPayment">
197+
<annotations>
198+
<features value="Checkout"/>
199+
<stories value="Checkout flow if payment solutions are not available"/>
200+
<title value="Checkout via Customer Checkout with restricted countries for payment"/>
201+
<description value="Should be able to place an order as a Customer with restricted countries for payment."/>
202+
<severity value="MAJOR"/>
203+
<testCaseId value="MAGETWO-42653"/>
204+
<group value="checkout"/>
205+
</annotations>
206+
<before>
207+
<createData entity="_defaultCategory" stepKey="createCategory"/>
208+
<createData entity="ApiSimpleProduct" stepKey="createProduct">
209+
<requiredEntity createDataKey="createCategory"/>
210+
</createData>
211+
<magentoCLI stepKey="allowSpecificValue" command="config:set payment/checkmo/allowspecific 1" />
212+
<magentoCLI stepKey="specificCountryValue" command="config:set payment/checkmo/specificcountry GB" />
213+
<createData entity="Simple_US_Customer" stepKey="simpleuscustomer"/>
214+
</before>
215+
<after>
216+
<amOnPage url="{{AdminLogoutPage.url}}" stepKey="amOnLogoutPage"/>
217+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
218+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
219+
<magentoCLI stepKey="allowSpecificValue" command="config:set payment/checkmo/allowspecific 0" />
220+
<magentoCLI stepKey="specificCountryValue" command="config:set payment/checkmo/specificcountry ''" />
221+
</after>
222+
<!-- Login as Customer -->
223+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="customerLogin">
224+
<argument name="Customer" value="$$simpleuscustomer$$" />
225+
</actionGroup>
226+
227+
<!-- Add product to cart -->
228+
<amOnPage url="{{StorefrontCategoryPage.url($$createCategory.name$$)}}" stepKey="onCategoryPage"/>
229+
<waitForPageLoad stepKey="waitForPageLoad1"/>
230+
<moveMouseOver selector="{{StorefrontCategoryMainSection.ProductItemInfo}}" stepKey="hoverProduct"/>
231+
<click selector="{{StorefrontCategoryMainSection.AddToCartBtn}}" stepKey="addToCart"/>
232+
<waitForElementVisible selector="{{StorefrontCategoryMainSection.SuccessMsg}}" time="30" stepKey="waitForProductAdded"/>
233+
<see selector="{{StorefrontCategoryMainSection.SuccessMsg}}" userInput="You added $$createProduct.name$$ to your shopping cart." stepKey="seeAddedToCartMessage"/>
234+
<see selector="{{StorefrontMinicartSection.quantity}}" userInput="1" stepKey="seeCartQuantity"/>
235+
236+
<!-- Go to checkout page -->
237+
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="customerGoToCheckoutFromMinicart" />
238+
239+
<!-- Select address -->
240+
<click stepKey="selectAddress" selector="{{CheckoutShippingMethodsSection.firstShippingMethod}}"/>
241+
<waitForElement stepKey="waitNextButton" selector="{{CheckoutShippingMethodsSection.next}}" time="30"/>
242+
<click stepKey="clickNextButton" selector="{{CheckoutShippingMethodsSection.next}}" />
243+
<waitForPageLoad stepKey="waitBillingForm"/>
244+
<seeInCurrentUrl url="{{CheckoutPage.url}}/#payment" stepKey="assertCheckoutPaymentUrl"/>
245+
<waitForElementVisible selector="{{CheckoutPaymentSection.noQuotes}}" stepKey="waitMessage"/>
246+
<see userInput="No Payment method available." stepKey="checkMessage"/>
247+
248+
<!-- Fill UK Address and verify that payment available and checkout successful -->
249+
<click selector="{{CheckoutHeaderSection.shippingMethodStep}}" stepKey="goToShipping" />
250+
<click selector="{{CheckoutShippingSection.newAddressButton}}" stepKey="fillNewAddress" />
251+
<actionGroup ref="LoggedInUserCheckoutAddNewShippingSectionWithoutRegionActionGroup" stepKey="customerCheckoutFillingShippingSectionUK">
252+
<argument name="customerVar" value="CustomerEntityOne" />
253+
<argument name="customerAddressVar" value="UK_Not_Default_Address" />
254+
</actionGroup>
255+
<actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="customerSelectCheckMoneyOrderPayment" />
256+
<actionGroup ref="CheckoutPlaceOrderActionGroup" stepKey="customerPlaceorder">
257+
<argument name="orderNumberMessage" value="CONST.successCheckoutOrderNumberMessage" />
258+
<argument name="emailYouMessage" value="CONST.successCheckoutEmailYouMessage" />
259+
</actionGroup>
260+
</test>
196261
</tests>

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

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,61 @@
6868
<see selector="{{AdminOrderDetailsInformationSection.shippingAddress}}" userInput="{{CustomerAddressSimple.street[0]}}" stepKey="seeAdminOrderShippingAddress"/>
6969
<see selector="{{AdminOrderDetailsInformationSection.itemsOrdered}}" userInput="$$createProduct.name$$" stepKey="seeAdminOrderProduct"/>
7070
</test>
71+
<test name="StorefrontGuestCheckoutTestWithRestrictedCountriesForPayment">
72+
<annotations>
73+
<features value="Checkout"/>
74+
<stories value="Checkout flow if payment solutions are not available"/>
75+
<title value="Checkout via Guest Checkout with restricted countries for payment"/>
76+
<description value="Should be able to place an order as a Guest with restricted countries for payment."/>
77+
<severity value="CRITICAL"/>
78+
<testCaseId value="MAGETWO-42653"/>
79+
<group value="checkout"/>
80+
</annotations>
81+
<before>
82+
<createData entity="_defaultCategory" stepKey="createCategory"/>
83+
<createData entity="ApiSimpleProduct" stepKey="createProduct">
84+
<requiredEntity createDataKey="createCategory"/>
85+
</createData>
86+
<magentoCLI stepKey="allowSpecificValue" command="config:set payment/checkmo/allowspecific 1" />
87+
<magentoCLI stepKey="specificCountryValue" command="config:set payment/checkmo/specificcountry GB" />
88+
89+
</before>
90+
<after>
91+
<amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/>
92+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
93+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
94+
<magentoCLI stepKey="allowSpecificValue" command="config:set payment/checkmo/allowspecific 0" />
95+
<magentoCLI stepKey="specificCountryValue" command="config:set payment/checkmo/specificcountry ''" />
96+
</after>
97+
98+
<!-- Add product to cart -->
99+
<amOnPage url="{{StorefrontCategoryPage.url($$createCategory.name$$)}}" stepKey="onCategoryPage"/>
100+
<waitForPageLoad stepKey="waitForPageLoad1"/>
101+
<moveMouseOver selector="{{StorefrontCategoryMainSection.ProductItemInfo}}" stepKey="hoverProduct"/>
102+
<click selector="{{StorefrontCategoryMainSection.AddToCartBtn}}" stepKey="addToCart"/>
103+
<waitForElementVisible selector="{{StorefrontCategoryMainSection.SuccessMsg}}" time="30" stepKey="waitForProductAdded"/>
104+
<see selector="{{StorefrontCategoryMainSection.SuccessMsg}}" userInput="You added $$createProduct.name$$ to your shopping cart." stepKey="seeAddedToCartMessage"/>
105+
<see selector="{{StorefrontMinicartSection.quantity}}" userInput="1" stepKey="seeCartQuantity"/>
106+
107+
<!-- Go to checkout page -->
108+
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="guestGoToCheckoutFromMinicart" />
109+
110+
<!-- Fill US Address and verify that no payment available -->
111+
<actionGroup ref="GuestCheckoutFillingShippingSectionUnavailablePaymentActionGroup" stepKey="guestCheckoutFillingShippingSection">
112+
<argument name="customerVar" value="CustomerEntityOne" />
113+
<argument name="customerAddressVar" value="CustomerAddressSimple" />
114+
</actionGroup>
115+
116+
<!-- Fill UK Address and verify that payment available and checkout successful -->
117+
<click selector="{{CheckoutHeaderSection.shippingMethodStep}}" stepKey="goToShipping" />
118+
<actionGroup ref="GuestCheckoutFillingShippingSectionWithoutRegionActionGroup" stepKey="guestCheckoutFillingShippingSectionUK">
119+
<argument name="customerVar" value="CustomerEntityOne" />
120+
<argument name="customerAddressVar" value="UK_Not_Default_Address" />
121+
</actionGroup>
122+
<actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="guestSelectCheckMoneyOrderPayment" />
123+
<actionGroup ref="CheckoutPlaceOrderActionGroup" stepKey="guestPlaceorder">
124+
<argument name="orderNumberMessage" value="CONST.successGuestCheckoutOrderNumberMessage" />
125+
<argument name="emailYouMessage" value="CONST.successCheckoutEmailYouMessage" />
126+
</actionGroup>
127+
</test>
71128
</tests>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ define([
247247
*/
248248
setShippingInformation: function () {
249249
if (this.validateShippingInformation()) {
250+
quote.billingAddress(null);
250251
checkoutDataResolver.resolveBillingAddress();
251252
setShippingInformationAction().done(
252253
function () {

0 commit comments

Comments
 (0)