Show placeholder img if product doesnt have one
This commit is contained in:
parent
008beb3243
commit
d648e223ca
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue