summaryrefslogtreecommitdiff
path: root/src/pages/shop/product
diff options
context:
space:
mode:
Diffstat (limited to 'src/pages/shop/product')
-rw-r--r--src/pages/shop/product/[slug].js8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/pages/shop/product/[slug].js b/src/pages/shop/product/[slug].js
index 5fce1c85..e44cfeca 100644
--- a/src/pages/shop/product/[slug].js
+++ b/src/pages/shop/product/[slug].js
@@ -9,6 +9,7 @@ import { LazyLoadImage } from "react-lazy-load-image-component";
import "react-lazy-load-image-component/src/effects/blur.css";
import ProductSlider from "../../../components/product/ProductSlider";
import Layout from "../../../components/Layout";
+import { addToCart } from "../../../helpers/cart";
export async function getServerSideProps( context ) {
const { slug } = context.query;
@@ -80,7 +81,10 @@ export default function ProductDetail({ product }) {
setQuantity("1");
}
- let addToCart = () => {
+ let addItemToCart = () => {
+ if (quantity > 0) {
+ addToCart(activeVariant.id, parseInt(quantity));
+ }
return true;
}
@@ -136,7 +140,7 @@ export default function ProductDetail({ product }) {
<div className="flex gap-x-2 mt-2">
<button className="btn-light w-full">+ Quotation</button>
- <button className="btn-yellow w-full" onClick={addToCart} disabled={(product.lowest_price.price == 0 ? true : false)}>+ Keranjang</button>
+ <button className="btn-yellow w-full" onClick={addItemToCart} disabled={(product.lowest_price.price == 0 ? true : false)}>+ Keranjang</button>
</div>
<div className="mt-10">