From b7a98fbaa9bd2c8d9fafbe3090bc2c0a8a09dde5 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 16 Dec 2022 15:39:02 +0700 Subject: no message --- src/pages/shop/product/[slug].js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/pages/shop/product') diff --git a/src/pages/shop/product/[slug].js b/src/pages/shop/product/[slug].js index de52eb72..2b54a1e0 100644 --- a/src/pages/shop/product/[slug].js +++ b/src/pages/shop/product/[slug].js @@ -83,10 +83,18 @@ export default function ProductDetail({ product }) { } let addItemToCart = () => { + if (product.variant_total > 1 && !selectedVariant) { + toast.error('Pilih varian terlebih dahulu untuk menambahkan ke keranjang', { duration: 2000 }); + return false; + } + if (quantity > 0) { toast.success('Berhasil menambahkan ke keranjang', { duration: 1500 }); createOrUpdateItemCart(activeVariant.id, parseInt(quantity)); + } else { + toast.error('Jumlah barang yang ditambahkan minimal 1 pcs', { duration: 2000 }); } + return true; } @@ -101,7 +109,7 @@ export default function ProductDetail({ product }) {

{product.name}{activeVariant.attributes ? ' - ' + activeVariant.attributes : ''}

- {product.variant_total > 1 && !selectedVariant ? ( + {product.variant_total > 1 && !selectedVariant && product.lowest_price.price > 0 ? (

Harga mulai dari:

) : ''} @@ -145,7 +153,7 @@ export default function ProductDetail({ product }) { -- cgit v1.2.3