Question:
why am I not seeing any fired events.js wix_ecom events?
Product:
Velo
What are you trying to achieve:
Hi,
unfortunately i’ve tried EVERYTHING in this thread and failed.
im simply trying to get a single console.log to see if i can trigger a backend event.
my main goal is to add an order to “orders” collection (i’ve created it manually with extra columns i need) when the order is paid.
but im so much behind it.
I can’t see any backend event logs.
I cant open properties panel on “events.js”
im using new eCom api.
im frustrated of all the trials to solve it.
please assist.
What have you already tried:
Additional information:
here is the current Code:
export function wixEcom_onCheckoutCompleted(event) {
const checkoutSubtotal = event.entity.subtotal.amount;
const checkoutId = event.entity._id;
const checkoutComplete = event.entity.completed;
const eventId = event.metadata.id;
console.log('Checkout completed', event)
}
export function wixEcom_onOrderUpdated(event) {
const orderId = event.data.order._id;
const orderTotalPrice = event.data.order.priceSummary.totalPrice.amount;
const eventId = event.metadata.id;
console.log('Order updated', event)
}
export function wixEcom_onCheckoutCreated(event) {
console.log('Checkout created', event)
const checkoutSubtotal = event.entity.subtotal.amount;
const checkoutId = event.entity._id;
const eventId = event.metadata.id;
}
export function wixEcom_onOrderCreated(event) {
console.log("wixEcom_onOrderCreated")
const eventId = event.metadata.id
const entityId = event.entity._id;
}
export async function wixEcom_onOrderPaymentStatusUpdated(event) {
console.log("event", JSON.stringify(event));
const order = event.data.order;
const orderId = order._id;
const email = order.buyerInfo.email;
const selectedTemplatesUrls = [];
order.lineItems.forEach(item => {
selectedTemplatesUrls.push({
id: item._id,
url: item.image
})
});
const phone = order.buyerInfo.phone;
console.log("orderId", orderId)
console.log("email", email)
console.log("selectedTemplatesUrls": )
selectedTemplatesUrls.forEach(item => {
console.log(JSON.stringify(item))
});
console.log('Order payment status updated', event)
try {
// Use a unique identifier for your order records, separate from Wix's _id
let existingOrder = await wixData.query("orders").eq("orderId", orderId).find();
if (existingOrder.totalCount === 0) {
const newOrder = {
email,
phone,
selectedTemplatesUrls
};
const createdOrder = await wixData.insert("orders", newOrder);
console.log('Order inserted in database:', createdOrder);
} else {
console.log('Order already exists in database');
}
} catch (error) {
console.error('Error updating order in database:', error);
}
}
truly desperate here… please assist.