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 1212 <arguments >
1313 <argument name =" customerAddressFormatter" xsi : type =" object" >Magento\Sales\ViewModel\Customer\AddressFormatter</argument >
1414 <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 >
1516 </arguments >
1617 </block >
1718 </referenceContainer >
Original file line number Diff line number Diff line change @@ -24,6 +24,11 @@ endif;
2424 */
2525$ customerAddressFormatter = $ block ->getData ('customerAddressFormatter ' );
2626
27+ /**
28+ * @var \Magento\Sales\ViewModel\Customer\Address\Billing\Address $billingAddress
29+ */
30+ $ billingAddress = $ block ->getData ('customerBillingAddress ' );
31+
2732/**
2833 * @var \Magento\Sales\Block\Adminhtml\Order\Create\Billing\Address|
2934 * \Magento\Sales\Block\Adminhtml\Order\Create\Shipping\Address $block
@@ -114,7 +119,9 @@ endif; ?>
114119 type="checkbox"
115120 id="<?= $ block ->escapeHtmlAttr ($ block ->getForm ()->getHtmlIdPrefix ()) ?> save_in_address_book"
116121 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 ()): ?>
118125 checked="checked"
119126 <?php endif ; ?>
120127 class="admin__control-checkbox"/>
You can’t perform that action at this time.
0 commit comments