diff --git a/.changeset/cart-warnings-feedback.md b/.changeset/cart-warnings-feedback.md new file mode 100644 index 0000000000..3e9f90054d --- /dev/null +++ b/.changeset/cart-warnings-feedback.md @@ -0,0 +1,6 @@ +--- +'@shopify/cli-hydrogen': patch +'skeleton': patch +--- + +Add cart warnings component to display feedback to users when there are issues with their cart. Includes new `InlineFeedback` component and a `CartWarnings` component for collecting and displaying cart errors and warnings in an accessible way. diff --git a/e2e/specs/smoke/cart.spec.ts b/e2e/specs/smoke/cart.spec.ts index 467c2e0d50..3760b7a323 100644 --- a/e2e/specs/smoke/cart.spec.ts +++ b/e2e/specs/smoke/cart.spec.ts @@ -1,4 +1,4 @@ -import {setTestStore, test, expect} from '../../fixtures'; +import {setTestStore, test, expect, Page} from '../../fixtures'; setTestStore('mockShop'); diff --git a/templates/skeleton/app/components/CartLineItem.tsx b/templates/skeleton/app/components/CartLineItem.tsx index fb2a8ecf7b..1b8aaf9abb 100644 --- a/templates/skeleton/app/components/CartLineItem.tsx +++ b/templates/skeleton/app/components/CartLineItem.tsx @@ -2,13 +2,10 @@ import type {CartLineUpdateInput} from '@shopify/hydrogen/storefront-api-types'; import type {CartLayout, LineItemChildrenMap} from '~/components/CartMain'; import {CartForm, Image, type OptimisticCartLine} from '@shopify/hydrogen'; import {useVariantUrl} from '~/lib/variants'; -import {Link} from 'react-router'; +import {href, Link, useFetcher, type FetcherWithComponents} from 'react-router'; import {ProductPrice} from './ProductPrice'; import {useAside} from './Aside'; -import type { - CartApiQueryFragment, - CartLineFragment, -} from 'storefrontapi.generated'; +import type {CartApiQueryFragment} from 'storefrontapi.generated'; export type CartLine = OptimisticCartLine; @@ -98,13 +95,13 @@ export function CartLineItem({ */ function CartLineQuantity({line}: {line: CartLine}) { if (!line || typeof line?.quantity === 'undefined') return null; + const {id: lineId, quantity, isOptimistic} = line; const prevQuantity = Number(Math.max(0, quantity - 1).toFixed(0)); const nextQuantity = Number((quantity + 1).toFixed(0)); - return (
- Quantity: {quantity}    + Quantity: