File tree 4 files changed +24
-56
lines changed
apple-pay-integration/src
checkout-buttons/strategies/apple-pay
customer/strategies/apple-pay
4 files changed +24
-56
lines changed Original file line number Diff line number Diff line change @@ -267,27 +267,19 @@ export default class ApplePayButtonStrategy implements CheckoutButtonStrategy {
267
267
]
268
268
: [ ] ;
269
269
270
- unselectedOptions
271
- ?. filter ( ( option ) => option . isRecommended )
272
- ?. forEach ( ( option ) =>
273
- shippingOptions . push ( {
274
- label : option . description ,
275
- amount : `${ option . cost . toFixed ( decimalPlaces ) } ` ,
276
- detail : option . additionalDescription ,
277
- identifier : option . id ,
278
- } ) ,
279
- ) ;
280
-
281
- unselectedOptions
282
- ?. filter ( ( option ) => ! option . isRecommended )
283
- ?. forEach ( ( option ) =>
270
+ if ( unselectedOptions ) {
271
+ [
272
+ ...unselectedOptions . filter ( ( option ) => option . isRecommended ) ,
273
+ ...unselectedOptions . filter ( ( option ) => ! option . isRecommended ) ,
274
+ ] . forEach ( ( option ) =>
284
275
shippingOptions . push ( {
285
276
label : option . description ,
286
277
amount : `${ option . cost . toFixed ( decimalPlaces ) } ` ,
287
278
detail : option . additionalDescription ,
288
279
identifier : option . id ,
289
280
} ) ,
290
281
) ;
282
+ }
291
283
292
284
if ( ! isShippingOptions ( availableOptions ) ) {
293
285
throw new Error ( 'Shipping options not available.' ) ;
Original file line number Diff line number Diff line change @@ -297,27 +297,19 @@ export default class ApplePayCustomerStrategy implements CustomerStrategy {
297
297
]
298
298
: [ ] ;
299
299
300
- unselectedOptions
301
- ?. filter ( ( option ) => option . isRecommended )
302
- ?. forEach ( ( option ) =>
303
- shippingOptions . push ( {
304
- label : option . description ,
305
- amount : `${ option . cost . toFixed ( decimalPlaces ) } ` ,
306
- detail : option . additionalDescription ,
307
- identifier : option . id ,
308
- } ) ,
309
- ) ;
310
-
311
- unselectedOptions
312
- ?. filter ( ( option ) => ! option . isRecommended )
313
- ?. forEach ( ( option ) =>
300
+ if ( unselectedOptions ) {
301
+ [
302
+ ...unselectedOptions . filter ( ( option ) => option . isRecommended ) ,
303
+ ...unselectedOptions . filter ( ( option ) => ! option . isRecommended ) ,
304
+ ] . forEach ( ( option ) =>
314
305
shippingOptions . push ( {
315
306
label : option . description ,
316
307
amount : `${ option . cost . toFixed ( decimalPlaces ) } ` ,
317
308
detail : option . additionalDescription ,
318
309
identifier : option . id ,
319
310
} ) ,
320
311
) ;
312
+ }
321
313
322
314
if ( ! isShippingOptions ( availableOptions ) ) {
323
315
throw new Error ( 'Shipping options not available.' ) ;
Original file line number Diff line number Diff line change @@ -282,27 +282,19 @@ export default class ApplePayButtonStrategy implements CheckoutButtonStrategy {
282
282
]
283
283
: [ ] ;
284
284
285
- unselectedOptions
286
- ?. filter ( ( option ) => option . isRecommended )
287
- ?. forEach ( ( option ) =>
288
- shippingOptions . push ( {
289
- label : option . description ,
290
- amount : `${ option . cost . toFixed ( decimalPlaces ) } ` ,
291
- detail : option . additionalDescription ,
292
- identifier : option . id ,
293
- } ) ,
294
- ) ;
295
-
296
- unselectedOptions
297
- ?. filter ( ( option ) => ! option . isRecommended )
298
- ?. forEach ( ( option ) =>
285
+ if ( unselectedOptions ) {
286
+ [
287
+ ...unselectedOptions . filter ( ( option ) => option . isRecommended ) ,
288
+ ...unselectedOptions . filter ( ( option ) => ! option . isRecommended ) ,
289
+ ] . forEach ( ( option ) =>
299
290
shippingOptions . push ( {
300
291
label : option . description ,
301
292
amount : `${ option . cost . toFixed ( decimalPlaces ) } ` ,
302
293
detail : option . additionalDescription ,
303
294
identifier : option . id ,
304
295
} ) ,
305
296
) ;
297
+ }
306
298
307
299
if ( ! isShippingOptions ( availableOptions ) ) {
308
300
throw new Error ( 'Shipping options not available.' ) ;
Original file line number Diff line number Diff line change @@ -323,27 +323,19 @@ export default class ApplePayCustomerStrategy implements CustomerStrategy {
323
323
]
324
324
: [ ] ;
325
325
326
- unselectedOptions
327
- ?. filter ( ( option ) => option . isRecommended )
328
- ?. forEach ( ( option ) =>
329
- shippingOptions . push ( {
330
- label : option . description ,
331
- amount : `${ option . cost . toFixed ( decimalPlaces ) } ` ,
332
- detail : option . additionalDescription ,
333
- identifier : option . id ,
334
- } ) ,
335
- ) ;
336
-
337
- unselectedOptions
338
- ?. filter ( ( option ) => ! option . isRecommended )
339
- ?. forEach ( ( option ) =>
326
+ if ( unselectedOptions ) {
327
+ [
328
+ ...unselectedOptions . filter ( ( option ) => option . isRecommended ) ,
329
+ ...unselectedOptions . filter ( ( option ) => ! option . isRecommended ) ,
330
+ ] . forEach ( ( option ) =>
340
331
shippingOptions . push ( {
341
332
label : option . description ,
342
333
amount : `${ option . cost . toFixed ( decimalPlaces ) } ` ,
343
334
detail : option . additionalDescription ,
344
335
identifier : option . id ,
345
336
} ) ,
346
337
) ;
338
+ }
347
339
348
340
if ( ! isShippingOptions ( availableOptions ) ) {
349
341
throw new Error ( 'Shipping options not available.' ) ;
You can’t perform that action at this time.
0 commit comments