12
12
$ addressCollection = $ block ->getData ('customerAddressCollection ' );
13
13
14
14
$ addressArray = [];
15
- if ($ block ->getCustomerId ()) :
15
+ if ($ block ->getCustomerId ()):
16
16
$ addressArray = $ addressCollection ->setCustomerFilter ([$ block ->getCustomerId ()])->toArray ();
17
17
endif ;
18
18
@@ -22,9 +22,15 @@ endif;
22
22
$ customerAddressFormatter = $ block ->getData ('customerAddressFormatter ' );
23
23
24
24
/**
25
- * @var \Magento\Sales\Block\Adminhtml\Order\Create\ Billing\Address|\Magento\Sales\Block\Adminhtml\Order\Create\Shipping\Address $block
25
+ * @var \Magento\Sales\ViewModel\Customer\Address\ Billing\AddressDataProvider $billingAddressDataProvider
26
26
*/
27
- if ($ block ->getIsShipping ()) :
27
+ $ billingAddressDataProvider = $ block ->getData ('billingAddressDataProvider ' );
28
+
29
+ /**
30
+ * @var \Magento\Sales\Block\Adminhtml\Order\Create\Billing\Address|
31
+ * \Magento\Sales\Block\Adminhtml\Order\Create\Shipping\Address $block
32
+ */
33
+ if ($ block ->getIsShipping ()):
28
34
$ _fieldsContainerId = 'order-shipping_address_fields ' ;
29
35
$ _addressChoiceContainerId = 'order-shipping_address_choice ' ;
30
36
?>
@@ -35,7 +41,7 @@ if ($block->getIsShipping()) :
35
41
});
36
42
</script>
37
43
<?php
38
- else :
44
+ else :
39
45
$ _fieldsContainerId = 'order-billing_address_fields ' ;
40
46
$ _addressChoiceContainerId = 'order-billing_address_choice ' ;
41
47
?>
@@ -52,29 +58,37 @@ endif; ?>
52
58
<span><?= $ block ->escapeHtml ($ block ->getHeaderText ()) ?> </span>
53
59
</legend><br>
54
60
55
- <fieldset id="<?= $ block ->escapeHtmlAttr ($ _addressChoiceContainerId ) ?> " class="admin__fieldset order-choose-address">
56
- <?php if ($ block ->getIsShipping ()) : ?>
61
+ <fieldset id="<?= $ block ->escapeHtmlAttr ($ _addressChoiceContainerId ) ?> "
62
+ class="admin__fieldset order-choose-address">
63
+ <?php if ($ block ->getIsShipping ()): ?>
57
64
<div class="admin__field admin__field-option admin__field-shipping-same-as-billing">
58
65
<input type="checkbox" id="order-shipping_same_as_billing" name="shipping_same_as_billing"
59
66
onclick="order.setShippingAsBilling(this.checked)" class="admin__control-checkbox"
60
- <?php if ($ block ->getIsAsBilling ()) : ?> checked<?php endif ; ?> />
67
+ <?php if ($ block ->getIsAsBilling ()): ?> checked<?php endif ; ?> />
61
68
<label for="order-shipping_same_as_billing" class="admin__field-label">
62
69
<?= $ block ->escapeHtml (__ ('Same As Billing Address ' )) ?>
63
70
</label>
64
71
</div>
65
72
<?php endif ; ?>
66
73
<div class="admin__field admin__field-select-from-existing-address">
67
- <label class="admin__field-label"><?= $ block ->escapeHtml (__ ('Select from existing customer addresses: ' )) ?> </label>
74
+ <label class="admin__field-label">
75
+ <?= $ block ->escapeHtml (__ ('Select from existing customer addresses: ' )) ?>
76
+ </label>
68
77
<?php $ _id = $ block ->getForm ()->getHtmlIdPrefix () . 'customer_address_id ' ?>
69
78
<div class="admin__field-control">
70
79
<select id="<?= $ block ->escapeHtmlAttr ($ _id ) ?> "
71
80
name="<?= /* @noEscape */ $ block ->getForm ()->getHtmlNamePrefix () ?> [customer_address_id]"
72
- onchange="order.selectAddress(this, '<?= $ block ->escapeHtmlAttr ($ block ->escapeJs ($ _fieldsContainerId )) ?> ')"
81
+ onchange="order.selectAddress(
82
+ this,
83
+ '<?= $ block ->escapeHtmlAttr ($ block ->escapeJs ($ _fieldsContainerId )) ?> ')"
73
84
class="admin__control-select">
74
85
<option value=""><?= $ block ->escapeHtml (__ ('Add New Address ' )) ?> </option>
75
- <?php foreach ($ addressArray as $ addressId => $ address ) : ?>
86
+ <?php foreach ($ addressArray as $ addressId => $ address ): ?>
76
87
<option
77
- value="<?= $ block ->escapeHtmlAttr ($ addressId ) ?> "<?php if ($ addressId == $ block ->getAddressId ()) : ?> selected="selected"<?php endif ; ?> >
88
+ value="<?= $ block ->escapeHtmlAttr ($ addressId ) ?> "
89
+ <?php if ($ addressId == $ block ->getAddressId ()): ?>
90
+ selected="selected"
91
+ <?php endif ; ?> >
78
92
<?= $ block ->escapeHtml ($ customerAddressFormatter ->getAddressAsString ($ address )) ?>
79
93
</option>
80
94
<?php endforeach ; ?>
@@ -87,9 +101,16 @@ endif; ?>
87
101
<?= $ block ->getForm ()->toHtml () ?>
88
102
89
103
<div class="admin__field admin__field-option order-save-in-address-book">
90
- <input name="<?= /* @noEscape */ $ block ->getForm ()->getHtmlNamePrefix () ?> [save_in_address_book]" type="checkbox" id="<?= /* @noEscape */ $ block ->getForm ()->getHtmlIdPrefix () ?> save_in_address_book" value="1"<?php if (!$ block ->getDontSaveInAddressBook ()) : ?> checked="checked"<?php endif ; ?> class="admin__control-checkbox"/>
104
+ <input name="<?= /* @noEscape */ $ block ->getForm ()->getHtmlNamePrefix () ?> [save_in_address_book]"
105
+ type="checkbox" id="<?= /* @noEscape */ $ block ->getForm ()->getHtmlIdPrefix () ?> save_in_address_book"
106
+ value="1"
107
+ <?php if ($ billingAddressDataProvider && $ billingAddressDataProvider ->getSaveInAddressBook () ||
108
+ $ block ->getIsShipping () && !$ block ->getDontSaveInAddressBook () && !$ block ->getAddressId ()): ?>
109
+ checked="checked"
110
+ <?php endif ; ?>
111
+ class="admin__control-checkbox"/>
91
112
<label for="<?= /* @noEscape */ $ block ->getForm ()->getHtmlIdPrefix () ?> save_in_address_book"
92
- class="admin__field-label"><?= $ block ->escapeHtml (__ ('Save in address book ' )) ?> </label>
113
+ class="admin__field-label"><?= $ block ->escapeHtml (__ ('Add to address book ' )) ?> </label>
93
114
</div>
94
115
</div>
95
116
<?php $ hideElement = 'address- ' . ($ block ->getIsShipping () ? 'shipping ' : 'billing ' ) . '-overlay ' ; ?>
@@ -101,7 +122,7 @@ endif; ?>
101
122
require(["Magento_Sales/order/create/form"], function(){
102
123
order.bindAddressFields('<?= $ block ->escapeJs ($ _fieldsContainerId ) ?> ');
103
124
order.bindAddressFields('<?= $ block ->escapeJs ($ _addressChoiceContainerId ) ?> ');
104
- <?php if ($ block ->getIsShipping () && $ block ->getIsAsBilling ()) : ?>
125
+ <?php if ($ block ->getIsShipping () && $ block ->getIsAsBilling ()): ?>
105
126
order.disableShippingAddress(true);
106
127
<?php endif ; ?>
107
128
});
0 commit comments