Skip to content

Commit 40aeb75

Browse files
set default lineItem fulfillmentMode to NONE (#1248)
* set default lineItem fulfillmentMode to NONE * fix react hooks error
1 parent 28ec121 commit 40aeb75

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

.changeset/chatty-carpets-watch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@godaddy/react": patch
3+
---
4+
5+
Set default storefront lineItem fulfillmentMode to NONE when adding to cart

packages/react/src/components/storefront/hooks/use-add-to-cart.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export function useAddToCart(options?: UseAddToCartOptions) {
6363
skuId: input.skuId,
6464
name: input.name,
6565
quantity: input.quantity,
66-
fulfillmentMode: 'SHIP',
66+
fulfillmentMode: 'NONE',
6767
status: 'DRAFT',
6868
details: {
6969
productAssetUrl: input.productAssetUrl || undefined,

packages/react/src/components/storefront/product-grid.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,17 @@ export function ProductGrid({
135135
enabled: !!storeId && !!clientId,
136136
});
137137

138+
const pageInfo = data?.skuGroups?.pageInfo;
139+
140+
useEffect(() => {
141+
if (pageInfo?.endCursor && pageInfo?.hasNextPage) {
142+
setPageCursors(prev => {
143+
if (prev[currentPageIndex + 1]) return prev;
144+
return [...prev, pageInfo.endCursor];
145+
});
146+
}
147+
}, [pageInfo?.endCursor, pageInfo?.hasNextPage, currentPageIndex]);
148+
138149
if (isLoading || !data) {
139150
return <ProductGridSkeleton count={enablePagination ? perPage : 6} />;
140151
}
@@ -149,20 +160,10 @@ export function ProductGrid({
149160
}
150161

151162
const skuGroups = data?.skuGroups?.edges;
152-
const pageInfo = data?.skuGroups?.pageInfo;
153163
const totalCount = data?.skuGroups?.totalCount || 0;
154164
const totalPages = Math.ceil(totalCount / perPage);
155165
const currentPage = currentPageIndex + 1;
156166

157-
useEffect(() => {
158-
if (pageInfo?.endCursor && pageInfo?.hasNextPage) {
159-
setPageCursors(prev => {
160-
if (prev[currentPageIndex + 1]) return prev;
161-
return [...prev, pageInfo.endCursor];
162-
});
163-
}
164-
}, [pageInfo?.endCursor, pageInfo?.hasNextPage, currentPageIndex]);
165-
166167
const handlePageChange = (page: number) => {
167168
setCurrentPageIndex(page - 1);
168169
window.scrollTo({ top: 0, behavior: 'smooth' });

0 commit comments

Comments
 (0)