From 6a3eeea3f93db5c1160f780936efc4e6d83d9550 Mon Sep 17 00:00:00 2001 From: Wisley Date: Wed, 20 Dec 2023 09:36:00 -0300 Subject: [PATCH] fix(getNewFreight): Correct error if new shipping is not found --- functions/lib/galaxpay/update-subscription.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/functions/lib/galaxpay/update-subscription.js b/functions/lib/galaxpay/update-subscription.js index 34c95de..01f1889 100644 --- a/functions/lib/galaxpay/update-subscription.js +++ b/functions/lib/galaxpay/update-subscription.js @@ -84,6 +84,8 @@ const getNewFreight = async (storeId, itemsOrder, to, subtotal, shippingLineOrig service: service || (sameApp.response?.shipping_services && sameApp.response?.shipping_services[0]) } } else { + if (!result[0]?.response?.shipping_services.length) return null + let minPrice = result[0]?.response?.shipping_services[0]?.shipping_line?.total_price const indexPosition = { app: 0, service: 0 } for (let i = 0; i < result.length; i++) {