From c8cb137354ec569b4a13e180bc9cac2cab90c470 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Sat, 6 Apr 2024 12:31:45 +0700 Subject: add voucher minus --- src/lib/checkout/components/Checkout.jsx | 38 +++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 13 deletions(-) (limited to 'src/lib/checkout/components/Checkout.jsx') diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 52edbd05..7a456d70 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -111,6 +111,7 @@ const Checkout = () => { const [checkoutValidation, setCheckoutValidation] = useState(false); const [loadingVoucher, setLoadingVoucher] = useState(true); const [loadingRajaOngkir, setLoadingRajaOngkir] = useState(false); + const [grandTotal, setGrandTotal] = useState(0); const expedisiValidation = useRef(null); @@ -295,6 +296,14 @@ const Checkout = () => { const [isLoading, setIsLoading] = useState(false); + useEffect(() => { + const GT = + cartCheckout?.grandTotal + + Math.round(parseInt(biayaKirim * 1.1) / 1000) * 1000; + const finalGT = GT < 0 ? 0 : GT; + setGrandTotal(finalGT); + }, [biayaKirim, cartCheckout?.grandTotal, activeVoucher]); + const checkout = async () => { const file = poFile.current.files[0]; if (typeof file !== 'undefined' && file.size > 5000000) { @@ -352,11 +361,20 @@ const Checkout = () => { const midtrans = async () => { for (const product of products) deleteItemCart({ productId: product.id }); - const payment = await axios.post( - `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/midtrans-payment?transactionId=${isCheckouted.id}` - ); - setIsLoading(false); - window.location.href = payment.data.redirectUrl; + if (grandTotal > 0) { + const payment = await axios.post( + `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/midtrans-payment?transactionId=${isCheckouted.id}` + ); + setIsLoading(false); + window.location.href = payment.data.redirectUrl; + } else { + window.location.href = `${ + process.env.NEXT_PUBLIC_SELF_HOST + }/shop/checkout/success?order_id=${isCheckouted.name.replace( + /\//g, + '-' + )}`; + } }; gtag('event', 'conversion', { @@ -913,10 +931,7 @@ const Checkout = () => {
Grand Total
- {currencyFormat( - cartCheckout?.grandTotal + - Math.round(parseInt(biayaKirim * 1.1) / 1000) * 1000 - )} + {currencyFormat(grandTotal)}
)} @@ -1208,10 +1223,7 @@ const Checkout = () => {
Grand Total
- {currencyFormat( - cartCheckout?.grandTotal + - Math.round(parseInt(biayaKirim * 1.1) / 1000) * 1000 - )} + {currencyFormat(grandTotal)}
)} -- cgit v1.2.3 From 1bb3f91f27db4db6a16a1ed3fe59016268ba3d44 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Wed, 8 May 2024 13:23:10 +0700 Subject: change wa number --- src/lib/checkout/components/Checkout.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib/checkout/components/Checkout.jsx') diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 7a456d70..0090acee 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -1454,7 +1454,7 @@ const SectionExpedisi = ({ dengan menghubungi admin melalui{' '} tautan ini -- cgit v1.2.3 From da80b7e00e2ee6aaa3a81902cd51ff556d4d7ef0 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Wed, 5 Jun 2024 15:01:12 +0700 Subject: fixing shipping address and invoice address --- src/lib/checkout/components/Checkout.jsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/lib/checkout/components/Checkout.jsx') diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 0090acee..5ca3611f 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -333,8 +333,10 @@ const Checkout = () => { quantity: product.quantity, })); let data = { - partner_shipping_id: auth.partnerId, - partner_invoice_id: auth.partnerId, + // partner_shipping_id: auth.partnerId, + // partner_invoice_id: auth.partnerId, + partner_shipping_id: selectedAddress?.shipping?.id || auth.partnerId, + partner_invoice_id: selectedAddress?.invoicing?.id || auth.partnerId, user_id: auth.id, order_line: JSON.stringify(productOrder), delivery_amount: biayaKirim, -- cgit v1.2.3 From b992edcc7f1b7395dea0c8562ddf272df9fc6b7f Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Sat, 29 Jun 2024 10:08:16 +0700 Subject: add parameter flag flash sale --- src/lib/checkout/components/Checkout.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/lib/checkout/components/Checkout.jsx') diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 5ca3611f..df1768fb 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -112,6 +112,7 @@ const Checkout = () => { const [loadingVoucher, setLoadingVoucher] = useState(true); const [loadingRajaOngkir, setLoadingRajaOngkir] = useState(false); const [grandTotal, setGrandTotal] = useState(0); + const [hasFlashSale, setHasFlashSale] = useState(false); const expedisiValidation = useRef(null); @@ -224,6 +225,7 @@ const Checkout = () => { setProducts(cartCheckout?.products); setCheckWeight(cartCheckout?.hasProductWithoutWeight); setTotalWeight(cartCheckout?.totalWeight.g); + setHasFlashSale(cartCheckout?.products[0]?.hasFlashsale ? cartCheckout.products[0].hasFlashsale : false); }, [cartCheckout]); useEffect(() => { @@ -343,6 +345,7 @@ const Checkout = () => { carrier_id: selectedCarrierId, estimated_arrival_days: splitDuration(etd), delivery_service_type: selectedExpedisiService, + flash_sale : !hasFlashSale, // dibuat negasi untuk ngetest kebalikan nilai false voucher: activeVoucher, type: 'sale_order', }; @@ -358,7 +361,7 @@ const Checkout = () => { toast.error('Gagal melakukan transaksi, terjadi kesalahan internal'); return; } - + console.log("isCheckouted",isCheckouted) gtagPurchase(products, biayaKirim, isCheckouted.name); const midtrans = async () => { -- cgit v1.2.3 From 703136862dc3d41d0a276c17fa7f4ecebd471527 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 1 Jul 2024 09:07:59 +0700 Subject: add flash sales to sales order --- src/lib/checkout/components/Checkout.jsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/lib/checkout/components/Checkout.jsx') diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index df1768fb..4aafdece 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -227,6 +227,7 @@ const Checkout = () => { setTotalWeight(cartCheckout?.totalWeight.g); setHasFlashSale(cartCheckout?.products[0]?.hasFlashsale ? cartCheckout.products[0].hasFlashsale : false); }, [cartCheckout]); + useEffect(() => { setCheckoutValidation(false); @@ -345,7 +346,7 @@ const Checkout = () => { carrier_id: selectedCarrierId, estimated_arrival_days: splitDuration(etd), delivery_service_type: selectedExpedisiService, - flash_sale : !hasFlashSale, // dibuat negasi untuk ngetest kebalikan nilai false + flash_sale : hasFlashSale, // dibuat negasi untuk ngetest kebalikan nilai false voucher: activeVoucher, type: 'sale_order', }; @@ -361,7 +362,7 @@ const Checkout = () => { toast.error('Gagal melakukan transaksi, terjadi kesalahan internal'); return; } - console.log("isCheckouted",isCheckouted) + gtagPurchase(products, biayaKirim, isCheckouted.name); const midtrans = async () => { -- cgit v1.2.3