File tree Expand file tree Collapse file tree 3 files changed +63
-1
lines changed
ViewModel/Customer/Address/Billing
templates/order/create/form Expand file tree Collapse file tree 3 files changed +63
-1
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+ declare (strict_types=1 );
7
+
8
+ namespace Magento \Sales \ViewModel \Customer \Address \Billing ;
9
+
10
+ use Magento \Framework \View \Element \Block \ArgumentInterface ;
11
+ use Magento \Sales \Model \AdminOrder \Create ;
12
+ use Magento \Quote \Model \Quote \Address as QuoteAddress ;
13
+
14
+ /**
15
+ * Customer address formatter
16
+ */
17
+ class Address implements ArgumentInterface
18
+ {
19
+ /**
20
+ * @var Create
21
+ */
22
+ protected $ orderCreate ;
23
+
24
+ /**
25
+ * Customer billing address
26
+ *
27
+ * @param Create $orderCreate
28
+ */
29
+ public function __construct (
30
+ Create $ orderCreate
31
+ ) {
32
+ $ this ->orderCreate = $ orderCreate ;
33
+ }
34
+
35
+ /**
36
+ * Return billing address object
37
+ *
38
+ * @return QuoteAddress
39
+ */
40
+ public function getAddress (): QuoteAddress
41
+ {
42
+ return $ this ->orderCreate ->getBillingAddress ();
43
+ }
44
+
45
+ /**
46
+ * Get save billing address in the address book
47
+ *
48
+ * @return int
49
+ */
50
+ public function getSaveInAddressBook (): int
51
+ {
52
+ return (int )$ this ->getAddress ()->getSaveInAddressBook ();
53
+ }
54
+ }
Original file line number Diff line number Diff line change 12
12
<arguments >
13
13
<argument name =" customerAddressFormatter" xsi : type =" object" >Magento\Sales\ViewModel\Customer\AddressFormatter</argument >
14
14
<argument name =" customerAddressCollection" xsi : type =" object" >Magento\Customer\Model\ResourceModel\Address\Collection</argument >
15
+ <argument name =" customerBillingAddress" xsi : type =" object" >Magento\Sales\ViewModel\Customer\Address\Billing\Address</argument >
15
16
</arguments >
16
17
</block >
17
18
</referenceContainer >
Original file line number Diff line number Diff line change @@ -24,6 +24,11 @@ endif;
24
24
*/
25
25
$ customerAddressFormatter = $ block ->getData ('customerAddressFormatter ' );
26
26
27
+ /**
28
+ * @var \Magento\Sales\ViewModel\Customer\Address\Billing\Address $billingAddress
29
+ */
30
+ $ billingAddress = $ block ->getData ('customerBillingAddress ' );
31
+
27
32
/**
28
33
* @var \Magento\Sales\Block\Adminhtml\Order\Create\Billing\Address|
29
34
* \Magento\Sales\Block\Adminhtml\Order\Create\Shipping\Address $block
@@ -114,7 +119,9 @@ endif; ?>
114
119
type="checkbox"
115
120
id="<?= $ block ->escapeHtmlAttr ($ block ->getForm ()->getHtmlIdPrefix ()) ?> save_in_address_book"
116
121
value="1"
117
- <?php if (!$ block ->getDontSaveInAddressBook () && !$ block ->getAddressId ()): ?>
122
+ <?php if ($ billingAddress && $ billingAddress ->getSaveInAddressBook ()): ?>
123
+ checked="checked"
124
+ <?php elseif ($ block ->getIsShipping () && !$ block ->getDontSaveInAddressBook () && !$ block ->getAddressId ()): ?>
118
125
checked="checked"
119
126
<?php endif ; ?>
120
127
class="admin__control-checkbox"/>
You can’t perform that action at this time.
0 commit comments