summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/cart/components/Cart.jsx8
-rw-r--r--src/lib/checkout/components/Checkout.jsx4
-rw-r--r--src/lib/product/components/Product/ProductDesktop.jsx6
3 files changed, 13 insertions, 5 deletions
diff --git a/src/lib/cart/components/Cart.jsx b/src/lib/cart/components/Cart.jsx
index 907d1267..8c4e7d42 100644
--- a/src/lib/cart/components/Cart.jsx
+++ b/src/lib/cart/components/Cart.jsx
@@ -17,6 +17,7 @@ import DesktopView from '@/core/components/views/DesktopView'
import ProductCard from '@/lib/product/components/ProductCard'
import productSearchApi from '@/lib/product/api/productSearchApi'
import whatsappUrl from '@/core/utils/whatsappUrl'
+import { gtagBeginCheckout } from '@/core/utils/googleTag'
const Cart = () => {
const router = useRouter()
@@ -134,6 +135,11 @@ const Cart = () => {
toast.success('Berhasil menghapus barang dari keranjang')
}
+ const handleCheckout = () => {
+ gtagBeginCheckout(products)
+ router.push('/shop/checkout')
+ }
+
return (
<>
<BottomPopup
@@ -465,7 +471,7 @@ const Cart = () => {
type='button'
className='btn-solid-red flex-1'
disabled={selectedProduct().length == 0}
- onClick={() => router.push('/shop/checkout')}
+ onClick={handleCheckout}
>
Checkout
</button>
diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx
index 525a641b..07d9acb6 100644
--- a/src/lib/checkout/components/Checkout.jsx
+++ b/src/lib/checkout/components/Checkout.jsx
@@ -22,8 +22,8 @@ import DesktopView from '@/core/components/views/DesktopView'
import ExpedisiList from '../api/ExpedisiList'
import whatsappUrl from '@/core/utils/whatsappUrl'
import { createSlug } from '@/core/utils/slug'
-import { Button, Modal } from 'flowbite-react'
import BottomPopup from '@/core/components/elements/Popup/BottomPopup'
+import { gtagPurchase } from '@/core/utils/googleTag'
const SELF_PICKUP_ID = 32
@@ -233,6 +233,8 @@ const Checkout = () => {
return
}
+ gtagPurchase(products, biayaKirim, isCheckouted.name)
+
const midtrans = async () => {
for (const product of products) deleteItemCart({ productId: product.id })
const payment = await axios.post(
diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx
index 4a584761..6a87d022 100644
--- a/src/lib/product/components/Product/ProductDesktop.jsx
+++ b/src/lib/product/components/Product/ProductDesktop.jsx
@@ -65,10 +65,10 @@ const ProductDesktop = ({ product, wishlist, toggleWishlist }) => {
setAddCartAlert(true)
}
- const handleBuy = (variantId) => {
- const quantity = variantQuantityRefs.current[variantId].value
+ const handleBuy = (variant) => {
+ const quantity = variantQuantityRefs.current[variant.id].value
if (!validQuantity(quantity)) return
- router.push(`/shop/checkout?productId=${variantId}&quantity=${quantity}`)
+ router.push(`/shop/checkout?productId=${variant.id}&quantity=${quantity}`)
}
const variantSectionRef = useRef(null)