File tree Expand file tree Collapse file tree 2 files changed +16
-8
lines changed
app/code/Magento/Checkout/view/frontend/web/js Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change 8
8
define ( [
9
9
'ko' ,
10
10
'underscore' ,
11
+ 'Magento_Checkout/js/checkout-data' ,
11
12
'domReady!'
12
- ] , function ( ko , _ ) {
13
+ ] , function ( ko , _ , checkoutData ) {
13
14
'use strict' ;
14
15
15
16
/**
@@ -148,6 +149,17 @@ define([
148
149
*/
149
150
isPersistent : function ( ) {
150
151
return ! ! Number ( quoteData [ 'is_persistent' ] ) ;
152
+ } ,
153
+
154
+ /**
155
+ * @return {String|null }
156
+ */
157
+ getSelectedMethod : function ( ) {
158
+ const selectedShippingMethod = checkoutData . getSelectedShippingRate ( ) ;
159
+ return selectedShippingMethod ? selectedShippingMethod :
160
+ this . shippingMethod ( ) ?
161
+ this . shippingMethod ( ) [ 'carrier_code' ] + '_' + quote . shippingMethod ( ) [ 'method_code' ] :
162
+ null ;
151
163
}
152
164
} ;
153
165
} ) ;
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ define([
73
73
isNewAddressAdded : ko . observable ( false ) ,
74
74
saveInAddressBook : 1 ,
75
75
quoteIsVirtual : quote . isVirtual ( ) ,
76
-
76
+ selectedShippingRate : null ,
77
77
/**
78
78
* @return {exports }
79
79
*/
@@ -113,7 +113,7 @@ define([
113
113
114
114
registry . async ( 'checkoutProvider' ) ( function ( checkoutProvider ) {
115
115
var shippingAddressData = checkoutData . getShippingAddressFromData ( ) ;
116
-
116
+ this . selectedShippingRate = checkoutData . getSelectedShippingRate ( ) ;
117
117
if ( shippingAddressData ) {
118
118
checkoutProvider . set (
119
119
'shippingAddress' ,
@@ -259,11 +259,7 @@ define([
259
259
rates : shippingService . getShippingRates ( ) ,
260
260
isLoading : shippingService . isLoading ,
261
261
isSelected : ko . computed ( function ( ) {
262
- const selectedShippingMethod = checkoutData . getSelectedShippingRate ( ) ;
263
- return selectedShippingMethod ? selectedShippingMethod :
264
- quote . shippingMethod ( ) ?
265
- quote . shippingMethod ( ) [ 'carrier_code' ] + '_' + quote . shippingMethod ( ) [ 'method_code' ] :
266
- null ;
262
+ return quote . getSelectedMethod ( ) ;
267
263
} ) ,
268
264
269
265
/**
You can’t perform that action at this time.
0 commit comments