@@ -264,16 +264,6 @@ export async function checkIfShipmentRequired(
264264 return lineItems . length > 0
265265}
266266
267- export function prepareShipments ( shipments ?: Shipment [ ] ) {
268- return ( shipments || [ ] ) . map ( ( a ) => {
269- return {
270- shipmentId : a . id ,
271- shippingMethodId : a . shipping_method ?. id ,
272- shippingMethodName : a . shipping_method ?. name ,
273- }
274- } )
275- }
276-
277267function isPaymentRequired ( order : Order ) {
278268 return ! ( order . total_amount_with_taxes_float === 0 )
279269}
@@ -392,13 +382,26 @@ export function calculateSelectedShipments(
392382 }
393383 : shipment
394384 } )
385+ const hasShippingMethod = hasShippingMethodSet ( shipmentsSelected )
386+ return { shipments : shipmentsSelected , ...hasShippingMethod }
387+ }
388+
389+ export function prepareShipments ( shipments ?: Shipment [ ] ) {
390+ return ( shipments || [ ] ) . map ( ( a ) => {
391+ return {
392+ shipmentId : a . id ,
393+ shippingMethodId : a . shipping_method ?. id ,
394+ shippingMethodName : a . shipping_method ?. name ,
395+ }
396+ } )
397+ }
395398
396- const shippingMethods = shipmentsSelected ?. map (
399+ export function hasShippingMethodSet ( shipments : ShipmentSelected [ ] ) {
400+ const shippingMethods = shipments ?. map (
397401 ( a : ShipmentSelected ) => a . shippingMethodId
398402 )
399403 const hasShippingMethod = Boolean (
400404 shippingMethods ?. length && ! shippingMethods ?. includes ( undefined )
401405 )
402-
403- return { shipments : shipmentsSelected , hasShippingMethod }
406+ return { hasShippingMethod }
404407}
0 commit comments