summaryrefslogtreecommitdiff
path: root/src/pages/shop/product
diff options
context:
space:
mode:
authorRafi Zadanly <rafizadanly@gmail.com>2022-12-16 15:39:02 +0700
committerRafi Zadanly <rafizadanly@gmail.com>2022-12-16 15:39:02 +0700
commitb7a98fbaa9bd2c8d9fafbe3090bc2c0a8a09dde5 (patch)
tree03b3553f3613fc739b8696191a0ef84e70f3dcf2 /src/pages/shop/product
parentf45dee703450c42521884f8e0da8ae49f652b8c6 (diff)
no message
Diffstat (limited to 'src/pages/shop/product')
-rw-r--r--src/pages/shop/product/[slug].js12
1 files changed, 10 insertions, 2 deletions
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 }) {
</Link>
<h1 className="h2 mt-2 mb-3">{product.name}{activeVariant.attributes ? ' - ' + activeVariant.attributes : ''}</h1>
- {product.variant_total > 1 && !selectedVariant ? (
+ {product.variant_total > 1 && !selectedVariant && product.lowest_price.price > 0 ? (
<p className="text-caption-2 text-gray-800 mb-1">Harga mulai dari:</p>
) : ''}
@@ -145,7 +153,7 @@ export default function ProductDetail({ product }) {
<button
className="btn-yellow w-full"
onClick={addItemToCart}
- disabled={(product.lowest_price.price == 0 ? true : false) || (product.variant_total > 1 && !selectedVariant)}
+ disabled={(product.lowest_price.price == 0 ? true : false)}
>
+ Keranjang
</button>