Skip to content

Commit 54fac76

Browse files
committed
MAGETWO-36337: Not user-friendly behaviour of "Save in address book" check-box inside "Shipping Address" section on "create Order" Admin page
1 parent ae611f6 commit 54fac76

File tree

2 files changed

+16
-2
lines changed
  • app/code/Magento/Sales

2 files changed

+16
-2
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ public function getIsAsBilling()
8181
*/
8282
public function getDontSaveInAddressBook()
8383
{
84+
$shippingIsTheSameAsBilling = $this->getIsAsBilling() && $this->getIsShipping();
85+
$params = $this->getRequest()->getParams();
86+
if ($shippingIsTheSameAsBilling && $params) {
87+
$save = $params['order']['billing_address']['save_in_address_book'] ?? false;
88+
return !$save;
89+
}
90+
if ($shippingIsTheSameAsBilling) {
91+
return !($this->getIsAsBilling() && $this->getIsShipping());
92+
}
8493
return $this->getIsAsBilling();
8594
}
8695

@@ -121,6 +130,7 @@ public function getAddress()
121130

122131
/**
123132
* Return is address disabled flag
133+
*
124134
* Return true is the quote is virtual
125135
*
126136
* @return bool

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
@@ -259,7 +259,7 @@ define([
259259
data = data.toObject();
260260

261261
if (type === 'billing' && this.shippingAsBilling) {
262-
this.syncAddressField(this.shippingAddressContainer, field.name, field.value);
262+
this.syncAddressField(this.shippingAddressContainer, field.name, field);
263263
resetShipping = true;
264264
}
265265

@@ -308,7 +308,11 @@ define([
308308

309309
$(container).select('[name="' + syncName + '"]').each(function (element) {
310310
if (~['input', 'textarea', 'select'].indexOf(element.tagName.toLowerCase())) {
311-
element.value = fieldValue;
311+
if (element.type === "checkbox") {
312+
element.checked = fieldValue.checked;
313+
} else {
314+
element.value = fieldValue.value;
315+
}
312316
}
313317
});
314318
},

0 commit comments

Comments
 (0)