@@ -60,18 +60,15 @@ define([
60
60
template : 'Magento_Checkout/shipping' ,
61
61
shippingFormTemplate : 'Magento_Checkout/shipping-address/form' ,
62
62
shippingMethodListTemplate : 'Magento_Checkout/shipping-address/shipping-method-list' ,
63
- shippingMethodItemTemplate : 'Magento_Checkout/shipping-address/shipping-method-item' ,
64
- saveInAddressBook : 1 ,
65
- links : {
66
- saveInAddressBook : '${ $.provider }:shippingAddress.save_in_address_book'
67
- }
63
+ shippingMethodItemTemplate : 'Magento_Checkout/shipping-address/shipping-method-item'
68
64
} ,
69
65
visible : ko . observable ( ! quote . isVirtual ( ) ) ,
70
66
errorValidationMessage : ko . observable ( false ) ,
71
67
isCustomerLoggedIn : customer . isLoggedIn ,
72
68
isFormPopUpVisible : formPopUpState . isVisible ,
73
69
isFormInline : addressList ( ) . length === 0 ,
74
70
isNewAddressAdded : ko . observable ( false ) ,
71
+ saveInAddressBook : 1 ,
75
72
quoteIsVirtual : quote . isVirtual ( ) ,
76
73
77
74
/**
@@ -117,7 +114,7 @@ define([
117
114
if ( shippingAddressData ) {
118
115
checkoutProvider . set (
119
116
'shippingAddress' ,
120
- $ . extend ( { } , checkoutProvider . get ( 'shippingAddress' ) , shippingAddressData )
117
+ $ . extend ( true , { } , checkoutProvider . get ( 'shippingAddress' ) , shippingAddressData )
121
118
) ;
122
119
}
123
120
checkoutProvider . on ( 'shippingAddress' , function ( shippingAddrsData ) {
@@ -129,14 +126,6 @@ define([
129
126
return this ;
130
127
} ,
131
128
132
- /** @inheritdoc */
133
- initObservable : function ( ) {
134
- this . _super ( )
135
- . observe ( 'saveInAddressBook' ) ;
136
-
137
- return this ;
138
- } ,
139
-
140
129
/**
141
130
* Load data from server for shipping step
142
131
*/
@@ -165,6 +154,8 @@ define([
165
154
166
155
/** @inheritdoc */
167
156
click : function ( ) {
157
+ // Revert address.
158
+ checkoutData . setShippingAddressFromData ( self . tempData ) ;
168
159
this . closeModal ( ) ;
169
160
}
170
161
}
@@ -174,6 +165,12 @@ define([
174
165
this . popUpForm . options . closed = function ( ) {
175
166
self . isFormPopUpVisible ( false ) ;
176
167
} ;
168
+
169
+ /** @inheritdoc */
170
+ this . popUpForm . options . opened = function ( ) {
171
+ // Store temporary address for revert action in case when user click cancel action
172
+ self . temporaryAddress = $ . extend ( true , { } , checkoutData . getShippingAddressFromData ( ) ) ;
173
+ } ;
177
174
popUp = modal ( this . popUpForm . options , $ ( this . popUpForm . element ) ) ;
178
175
}
179
176
@@ -200,7 +197,7 @@ define([
200
197
if ( ! this . source . get ( 'params.invalid' ) ) {
201
198
addressData = this . source . get ( 'shippingAddress' ) ;
202
199
// if user clicked the checkbox, its value is true or false. Need to convert.
203
- addressData [ 'save_in_address_book' ] = this . saveInAddressBook ( ) ? 1 : 0 ;
200
+ addressData [ 'save_in_address_book' ] = this . saveInAddressBook ? 1 : 0 ;
204
201
205
202
// New address must be selected as a shipping address
206
203
newShippingAddress = createShippingAddress ( addressData ) ;
0 commit comments