Show placeholder img if product doesnt have one

This commit is contained in:
Karol Manijak 2024-09-18 10:00:40 +08:00
parent 008beb3243
commit d648e223ca
1 changed files with 4 additions and 3 deletions

View File

@ -43,10 +43,11 @@ const ProductButton: React.FC< {
} }
const showPlaceholder = ! product; const showPlaceholder = ! product;
const imgSrc = showPlaceholder const showPlacholderImg = showPlaceholder || ! product?.images?.[ 0 ]?.src;
const imgSrc = showPlacholderImg
? `${ WC_BLOCKS_IMAGE_URL }/blocks/product-collection/placeholder.svg` ? `${ WC_BLOCKS_IMAGE_URL }/blocks/product-collection/placeholder.svg`
: product?.images?.[ 0 ]?.src; : product.images[ 0 ].src;
const imgAlt = showPlaceholder ? '' : product?.name; const imgAlt = showPlacholderImg ? '' : product?.name;
return ( return (
<Button <Button