Skip to content

Commit 5be9b84

Browse files
author
Viktor Kopin
committed
MC-38113: Same shipping address is repeating multiple times in storefront checkout when Reordered
1 parent 6cd10d7 commit 5be9b84

File tree

6 files changed

+107
-1
lines changed

6 files changed

+107
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/>
2828
<click selector="{{CheckoutShippingSection.firstShippingMethod}}" stepKey="selectFirstShippingMethod"/>
2929
<waitForElement selector="{{CheckoutShippingSection.next}}" time="30" stepKey="waitForNextButton"/>
30+
<waitForLoadingMaskToDisappear stepKey="waitForShippingLoadingMask"/>
3031
<click selector="{{CheckoutShippingSection.next}}" stepKey="clickNext"/>
3132
<waitForElement selector="{{CheckoutPaymentSection.paymentSectionTitle}}" time="30" stepKey="waitForPaymentSectionLoaded"/>
3233
<seeInCurrentUrl url="{{CheckoutPage.url}}/#payment" stepKey="assertCheckoutPaymentUrl"/>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AssertCustomerHasNoOtherAddressesActionGroup">
11+
<annotations>
12+
<description>Verifies customer no additional address in address book</description>
13+
</annotations>
14+
<amOnPage url="customer/address/" stepKey="goToAddressPage"/>
15+
<waitForText userInput="You have no other address entries in your address book." selector=".block-addresses-list" stepKey="assertOtherAddresses"/>
16+
</actionGroup>
17+
</actionGroups>

app/code/Magento/Sales/Model/AdminOrder/Create.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,9 @@ public function initFromOrder(\Magento\Sales\Model\Order $order)
550550

551551
$quote = $this->getQuote();
552552
if (!$quote->isVirtual() && $this->getShippingAddress()->getSameAsBilling()) {
553+
$quote->getBillingAddress()->setCustomerAddressId(
554+
$quote->getShippingAddress()->getCustomerAddressId()
555+
);
553556
$this->setShippingAsBilling(1);
554557
}
555558

@@ -2120,6 +2123,9 @@ private function isAddressesAreEqual(Order $order)
21202123
$billingData['address_type'],
21212124
$billingData['entity_id']
21222125
);
2126+
if (isset($shippingData['customer_address_id']) && !isset($billingData['customer_address_id'])) {
2127+
unset($shippingData['customer_address_id']);
2128+
}
21232129

21242130
return $shippingData == $billingData;
21252131
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AdminReorderActionGroup">
11+
<annotations>
12+
<description>Reorder existing order. Requires admin order page to be opened.</description>
13+
</annotations>
14+
15+
<click selector="{{AdminOrderDetailsMainActionsSection.reorder}}" stepKey="clickReorder"/>
16+
<waitForPageLoad stepKey="waitPageLoad"/>
17+
18+
<click selector="{{AdminOrderFormActionSection.SubmitOrder}}" stepKey="clickSubmit"/>
19+
<waitForPageLoad stepKey="waitOrderCreated"/>
20+
<waitForText selector="{{AdminMessagesSection.success}}" userInput="You created the order." stepKey="seeOrderCreatedMessage"/>
21+
</actionGroup>
22+
</actionGroups>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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="AdminReorderAddressNotSavedInAddressBookTest">
11+
<annotations>
12+
<title value="Same shipping address is repeating multiple times in storefront checkout when Reordered"/>
13+
<stories value="MC-38113: Same shipping address is repeating multiple times in storefront checkout when Reordered"/>
14+
<description value="Same shipping address is repeating multiple times in storefront checkout when Reordered"/>
15+
<features value="Sales"/>
16+
<testCaseId value="MC-38113"/>
17+
<severity value="MAJOR"/>
18+
<group value="Sales"/>
19+
</annotations>
20+
<before>
21+
<createData entity="ApiCategory" stepKey="Category"/>
22+
<createData entity="ApiSimpleProduct" stepKey="Product">
23+
<requiredEntity createDataKey="Category"/>
24+
</createData>
25+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
26+
<actionGroup ref="StorefrontOpenCustomerAccountCreatePageActionGroup" stepKey="openCreateAccountPage"/>
27+
<actionGroup ref="StorefrontFillCustomerAccountCreationFormActionGroup" stepKey="fillCreateAccountForm">
28+
<argument name="customer" value="CustomerEntityOne"/>
29+
</actionGroup>
30+
<actionGroup ref="StorefrontClickCreateAnAccountCustomerAccountCreationFormActionGroup" stepKey="submitCreateAccountForm"/>
31+
</before>
32+
<after>
33+
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="customerLogout"/>
34+
<actionGroup ref="DeleteCustomerFromAdminActionGroup" stepKey="deleteCustomer"/>
35+
<actionGroup ref="AdminLogoutActionGroup" stepKey="adminLogout"/>
36+
<deleteData createDataKey="Product" stepKey="deleteProduct"/>
37+
<deleteData createDataKey="Category" stepKey="deleteCategory"/>
38+
</after>
39+
40+
<!-- Create order for registered customer -->
41+
<actionGroup ref="AddSimpleProductToCartActionGroup" stepKey="addSimpleProductToOrder">
42+
<argument name="product" value="$Product$"/>
43+
</actionGroup>
44+
<actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="openCheckoutPage"/>
45+
<actionGroup ref="LoggedInUserCheckoutFillingShippingSectionActionGroup" stepKey="fillAddressForm"/>
46+
<actionGroup ref="ClickPlaceOrderActionGroup" stepKey="clickPlaceOrder"/>
47+
<grabTextFrom selector="{{CheckoutSuccessMainSection.orderNumber22}}" stepKey="grabOrderNumber"/>
48+
49+
<!-- Reorder created order -->
50+
<actionGroup ref="OpenOrderByIdActionGroup" stepKey="openOrderById">
51+
<argument name="orderId" value="$grabOrderNumber"/>
52+
</actionGroup>
53+
<actionGroup ref="AdminReorderActionGroup" stepKey="reorder"/>
54+
55+
<!-- Assert no additional addresses saved -->
56+
<actionGroup ref="AssertCustomerHasNoOtherAddressesActionGroup" stepKey="assertAddresses"/>
57+
</test>
58+
</tests>

app/code/Magento/Sales/view/adminhtml/templates/order/create/form/address.phtml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ endif; ?>
114114
type="checkbox"
115115
id="<?= $block->escapeHtmlAttr($block->getForm()->getHtmlIdPrefix()) ?>save_in_address_book"
116116
value="1"
117-
<?php if (!$block->getDontSaveInAddressBook()): ?> checked="checked"<?php endif; ?>
117+
<?php if (!$block->getDontSaveInAddressBook() && !$block->getAddressId()): ?>
118+
checked="checked"
119+
<?php endif; ?>
118120
class="admin__control-checkbox"/>
119121
<label for="<?= $block->escapeHtmlAttr($block->getForm()->getHtmlIdPrefix()) ?>save_in_address_book"
120122
class="admin__field-label"><?= $block->escapeHtml(__('Save in address book')) ?></label>

0 commit comments

Comments
 (0)