diff --git a/.changeset/fix-missing-shipping-info-error.md b/.changeset/fix-missing-shipping-info-error.md new file mode 100644 index 00000000..be7d29b9 --- /dev/null +++ b/.changeset/fix-missing-shipping-info-error.md @@ -0,0 +1,5 @@ +--- +"@godaddy/react": patch +--- + +Return the missing shipping info error when checkout is blocked by absent shipping lines or fulfillment. diff --git a/packages/react/src/components/checkout/payment/utils/use-confirm-checkout.ts b/packages/react/src/components/checkout/payment/utils/use-confirm-checkout.ts index 33680d0c..0aac3cca 100644 --- a/packages/react/src/components/checkout/payment/utils/use-confirm-checkout.ts +++ b/packages/react/src/components/checkout/payment/utils/use-confirm-checkout.ts @@ -103,8 +103,8 @@ export function useConfirmCheckout() { isShipping && (!hasShippingLines || hasLineItemsMissingShippingFulfillment) ) { - setCheckoutErrors(['SHIPPING_METHOD_APPLICATION_FAILED']); - throw new Error('SHIPPING_METHOD_APPLICATION_FAILED'); + setCheckoutErrors(['MISSING_SHIPPING_INFO']); + throw new Error('MISSING_SHIPPING_INFO'); } const pickUpData = isPickup diff --git a/packages/react/src/components/checkout/shipping/shipping-method.tsx b/packages/react/src/components/checkout/shipping/shipping-method.tsx index cb4f712c..756bb04d 100644 --- a/packages/react/src/components/checkout/shipping/shipping-method.tsx +++ b/packages/react/src/components/checkout/shipping/shipping-method.tsx @@ -50,8 +50,7 @@ export function ShippingMethodForm() { const formatCurrency = useFormatCurrency(); const form = useFormContext(); const { t } = useGoDaddyContext(); - const { session, isConfirmingCheckout, setCheckoutErrors } = - useCheckoutContext(); + const { session, isConfirmingCheckout } = useCheckoutContext(); const updateTaxes = useUpdateTaxes(); const queryClient = useQueryClient(); const isPaymentDisabled = useIsPaymentDisabled(); @@ -205,14 +204,6 @@ export function ShippingMethodForm() { queryKey: ['draft-order', session.id], }); }, - onError: () => { - if (!isFulfillmentSync || !session?.id) return; - - setCheckoutErrors(['SHIPPING_METHOD_APPLICATION_FAILED']); - queryClient.invalidateQueries({ - queryKey: ['draft-order', session.id], - }); - }, }); } else if (session?.enableTaxCollection) { updateTaxes.mutate(undefined); @@ -239,7 +230,6 @@ export function ShippingMethodForm() { form, applyShippingMethod, updateTaxes.mutate, - setCheckoutErrors, session?.enableTaxCollection, queryClient, session?.id,