diff --git a/.changeset/chatty-carpets-watch.md b/.changeset/chatty-carpets-watch.md new file mode 100644 index 00000000..3a5af578 --- /dev/null +++ b/.changeset/chatty-carpets-watch.md @@ -0,0 +1,5 @@ +--- +"@godaddy/react": patch +--- + +Set default storefront lineItem fulfillmentMode to NONE when adding to cart diff --git a/packages/react/src/components/storefront/hooks/use-add-to-cart.ts b/packages/react/src/components/storefront/hooks/use-add-to-cart.ts index 07a4a9f4..43cd8b8d 100644 --- a/packages/react/src/components/storefront/hooks/use-add-to-cart.ts +++ b/packages/react/src/components/storefront/hooks/use-add-to-cart.ts @@ -63,7 +63,7 @@ export function useAddToCart(options?: UseAddToCartOptions) { skuId: input.skuId, name: input.name, quantity: input.quantity, - fulfillmentMode: 'SHIP', + fulfillmentMode: 'NONE', status: 'DRAFT', details: { productAssetUrl: input.productAssetUrl || undefined, diff --git a/packages/react/src/components/storefront/product-grid.tsx b/packages/react/src/components/storefront/product-grid.tsx index 0f17d234..d1a1c652 100644 --- a/packages/react/src/components/storefront/product-grid.tsx +++ b/packages/react/src/components/storefront/product-grid.tsx @@ -135,6 +135,17 @@ export function ProductGrid({ enabled: !!storeId && !!clientId, }); + const pageInfo = data?.skuGroups?.pageInfo; + + useEffect(() => { + if (pageInfo?.endCursor && pageInfo?.hasNextPage) { + setPageCursors(prev => { + if (prev[currentPageIndex + 1]) return prev; + return [...prev, pageInfo.endCursor]; + }); + } + }, [pageInfo?.endCursor, pageInfo?.hasNextPage, currentPageIndex]); + if (isLoading || !data) { return ; } @@ -149,20 +160,10 @@ export function ProductGrid({ } const skuGroups = data?.skuGroups?.edges; - const pageInfo = data?.skuGroups?.pageInfo; const totalCount = data?.skuGroups?.totalCount || 0; const totalPages = Math.ceil(totalCount / perPage); const currentPage = currentPageIndex + 1; - useEffect(() => { - if (pageInfo?.endCursor && pageInfo?.hasNextPage) { - setPageCursors(prev => { - if (prev[currentPageIndex + 1]) return prev; - return [...prev, pageInfo.endCursor]; - }); - } - }, [pageInfo?.endCursor, pageInfo?.hasNextPage, currentPageIndex]); - const handlePageChange = (page: number) => { setCurrentPageIndex(page - 1); window.scrollTo({ top: 0, behavior: 'smooth' });