fix: Track order completion BEFORE clearing checkout
The checkout was being cleared before tracking, causing getTotal() to return 0. Fixed by reordering operations: 1. Track order completion (while checkout data exists) 2. Then clear the checkout Added console log to verify total is captured correctly.
This commit is contained in:
@@ -307,12 +307,10 @@ export default function CheckoutPage() {
|
||||
setOrderNumber(result.order.number);
|
||||
setOrderComplete(true);
|
||||
|
||||
// Clear the checkout/cart from the store
|
||||
clearCheckout();
|
||||
|
||||
// Track order completion
|
||||
// Track order completion BEFORE clearing checkout
|
||||
const lines = getLines();
|
||||
const total = getTotal();
|
||||
console.log("[Checkout] Order total before tracking:", total, "RSD");
|
||||
trackOrderCompleted({
|
||||
order_id: checkout.id,
|
||||
order_number: result.order.number,
|
||||
@@ -323,6 +321,9 @@ export default function CheckoutPage() {
|
||||
customer_email: shippingAddress.email,
|
||||
});
|
||||
|
||||
// Clear the checkout/cart from the store
|
||||
clearCheckout();
|
||||
|
||||
// Identify the user
|
||||
identifyUser({
|
||||
profileId: shippingAddress.email,
|
||||
|
||||
Reference in New Issue
Block a user