Skip to content

Commit 4203618

Browse files
Merge remote-tracking branch 'remotes/github/MAGETWO-36337' into EPAM-PR-55
2 parents d0288a7 + f11cc70 commit 4203618

File tree

3 files changed

+86
-2
lines changed

3 files changed

+86
-2
lines changed

app/code/Magento/Sales/Block/Adminhtml/Order/Create/Shipping/Address.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Sales\Block\Adminhtml\Order\Create\Shipping;
79

810
/**
@@ -81,6 +83,15 @@ public function getIsAsBilling()
8183
*/
8284
public function getDontSaveInAddressBook()
8385
{
86+
$shippingIsTheSameAsBilling = $this->getIsAsBilling() && $this->getIsShipping();
87+
$params = $this->getRequest()->getParams();
88+
if ($shippingIsTheSameAsBilling && $params) {
89+
$save = $params['order']['billing_address']['save_in_address_book'] ?? false;
90+
return !$save;
91+
}
92+
if ($shippingIsTheSameAsBilling) {
93+
return !$shippingIsTheSameAsBilling;
94+
}
8495
return $this->getIsAsBilling();
8596
}
8697

@@ -121,6 +132,7 @@ public function getAddress()
121132

122133
/**
123134
* Return is address disabled flag
135+
*
124136
* Return true is the quote is virtual
125137
*
126138
* @return bool
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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="AdminSaveInAddressBookCheckboxStateTest">
12+
<annotations>
13+
<title value="The state of 'Save in address book' check-box inside 'Shipping Address' section on 'create Order' Admin page"/>
14+
<description value="The state of 'Save in address book' check-box inside 'Shipping Address' section on 'create Order' Admin page"/>
15+
<features value="Sales"/>
16+
<severity value="MAJOR"/>
17+
<testCaseId value="MAGETWO-36337"/>
18+
<useCaseId value="MAGETWO-99320"/>
19+
<group value="sales"/>
20+
</annotations>
21+
<before>
22+
<!-- Create customer, category, product and log in -->
23+
<comment userInput="Create customer, category, product and log in" stepKey="createTestData"/>
24+
<createData entity="Simple_US_CA_Customer" stepKey="createCustomer"/>
25+
<createData entity="ApiCategory" stepKey="createCategory"/>
26+
<createData entity="ApiSimpleProduct" stepKey="createSimpleProduct">
27+
<requiredEntity createDataKey="createCategory"/>
28+
</createData>
29+
<actionGroup ref="LoginActionGroup" stepKey="login"/>
30+
</before>
31+
<after>
32+
<!-- Delete created data and log out -->
33+
<comment userInput="Delete created data and log out" stepKey="deleteDataAndLogOut"/>
34+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
35+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
36+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
37+
<actionGroup ref="logout" stepKey="logOut"/>
38+
</after>
39+
<!-- Create new order and choose an existing customer -->
40+
<comment userInput="Create new order and choose an existing customer" stepKey="createOrderAndAddCustomer"/>
41+
<actionGroup ref="navigateToNewOrderPageExistingCustomer" stepKey="navigateToNewOrderPage">
42+
<argument name="customer" value="$$createCustomer$$"/>
43+
</actionGroup>
44+
<!-- Add simple product to order -->
45+
<comment userInput="Add simple product to order" stepKey="addSimpleProdToOrder"/>
46+
<actionGroup ref="addSimpleProductToOrder" stepKey="addSimpleProductToOrder">
47+
<argument name="product" value="$$createSimpleProduct$$"/>
48+
</actionGroup>
49+
<!-- Just in case uncheck and check 'Same as Billing Address checkbox' -->
50+
<comment userInput="Just in case uncheck and check 'Same as Billing Address checkbox'" stepKey="uncheckAndCheckAgain"/>
51+
<uncheckOption selector="{{AdminOrderFormShippingAddressSection.SameAsBilling}}" stepKey="unCheckSameAsShippingAddressCheckbox"/>
52+
<waitForPageLoad stepKey="waitPageToLoad1"/>
53+
<checkOption selector="{{AdminOrderFormShippingAddressSection.SameAsBilling}}" stepKey="checkSameAsShippingAddressCheckbox"/>
54+
<waitForPageLoad stepKey="waitPageToLoad2"/>
55+
<!-- Check 'Save in address book' checkbox in 'Billing Address' section -->
56+
<comment userInput="Check 'Save in address book' checkbox in Billing Address section" stepKey="checkSaveInAddressBookCheckbox"/>
57+
<checkOption selector="{{AdminOrderFormBillingAddressSection.SaveAddress}}" stepKey="checkSaveBillingAddressCheckbox"/>
58+
<!-- See if 'Save in Address Book' checkbox is selected in 'Shipping Address' section -->
59+
<comment userInput="'Save in Address Book' checkbox is checked in 'Shipping Address' section" stepKey="checkIfCheckboxIsChecked"/>
60+
<seeCheckboxIsChecked selector="{{AdminOrderFormShippingAddressSection.SaveAddress}}" stepKey="seeCheckBoxIsSelected"/>
61+
<!-- Uncheck 'Save in Address Book' checkbox in 'Billing Address' section -->
62+
<comment userInput="Uncheck 'Save in Address Book' checkbox in 'Billing Address' section" stepKey="uncheckCheckboxInBillingAddressSection"/>
63+
<uncheckOption selector="{{AdminOrderFormBillingAddressSection.SaveAddress}}" stepKey="uncheckSaveBillingAddressCheckbox"/>
64+
<!-- See if 'Save in Address Book' checkbox is deselected in 'Shipping Address' section -->
65+
<comment userInput="See if 'Save in Address Book' checkbox is unchecked in 'Shipping Address' section" stepKey="seeIfCheckboxIsUnchecked"/>
66+
<dontSeeCheckboxIsChecked selector="{{AdminOrderFormShippingAddressSection.SaveAddress}}" stepKey="seeCheckBoxIsUnchecked"/>
67+
</test>
68+
</tests>

app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ define([
263263
data = data.toObject();
264264

265265
if (type === 'billing' && this.shippingAsBilling) {
266-
this.syncAddressField(this.shippingAddressContainer, field.name, field.value);
266+
this.syncAddressField(this.shippingAddressContainer, field.name, field);
267267
resetShipping = true;
268268
}
269269

@@ -316,7 +316,11 @@ define([
316316

317317
$(container).select('[name="' + syncName + '"]').each(function (element) {
318318
if (~['input', 'textarea', 'select'].indexOf(element.tagName.toLowerCase())) {
319-
element.value = fieldValue;
319+
if (element.type === "checkbox") {
320+
element.checked = fieldValue.checked;
321+
} else {
322+
element.value = fieldValue.value;
323+
}
320324
}
321325
});
322326
},

0 commit comments

Comments
 (0)