Skip to content

Commit

Permalink
Fix cart item image error (vercel#600)
Browse files Browse the repository at this point in the history
  • Loading branch information
goncy authored Dec 9, 2021
1 parent 647b06c commit ea1bbcf
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions components/cart/CartItem/CartItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import cn from 'classnames'
import Image from 'next/image'
import Link from 'next/link'
import s from './CartItem.module.css'
import { Trash, Plus, Minus, Cross } from '@components/icons'
import { useUI } from '@components/ui/context'
import type { LineItem } from '@commerce/types/cart'
import usePrice from '@framework/product/use-price'
Expand All @@ -18,6 +17,8 @@ type ItemOption = {
valueId: number
}

const placeholderImg = '/product-img-placeholder.svg'

const CartItem = ({
item,
variant = 'default',
Expand Down Expand Up @@ -91,8 +92,8 @@ const CartItem = ({
className={s.productImage}
width={150}
height={150}
src={item.variant.image!.url}
alt={item.variant.image!.altText}
src={item.variant.image?.url || placeholderImg}
alt={item.variant.image?.altText || "Product Image"}
unoptimized
/>
</a>
Expand Down

0 comments on commit ea1bbcf

Please sign in to comment.