diff --git a/src/components/ProductPreview/AddToCart.js b/src/components/ProductPreview/AddToCart.js index e85e8323..358c7cfb 100644 --- a/src/components/ProductPreview/AddToCart.js +++ b/src/components/ProductPreview/AddToCart.js @@ -100,13 +100,21 @@ export default class AddToCart extends Component { render() { const { variants } = this.props; - const id = this.props.productId.substring(58, 64) + const id = this.props.productId.substring(58, 64); + const hasVariants = variants.length > 1; + + /* + * For products without variants, we disable the whole Add to Cart button + * and change the text. This flag prevents us from duplicating the logic in + * multiple places. + */ + const isOutOfStock = !hasVariants && !variants[0].availableForSale; return ( {({ addVariantToCart }) => (
- {variants.length > 1 && ( + {hasVariants && ( <> Choose a size: {variants.map(variant => ( - ))} @@ -128,7 +136,7 @@ export default class AddToCart extends Component { Quantity: )} - {variants.length <= 1 && ( + {!hasVariants && ( Quantity: )} - + )}
diff --git a/src/components/Store/ProductListings.js b/src/components/Store/ProductListings.js index 82f2b3b5..da7006b5 100644 --- a/src/components/Store/ProductListings.js +++ b/src/components/Store/ProductListings.js @@ -30,6 +30,7 @@ export default () => ( shopifyId title price + availableForSale } images { id