Donāt have a picture of it since there is no error. The backend just doesnāt fire. It was previously. I tried looking at the console but nothing there too.
ok, if you put console.log() inside the export function can you see it in the browser? if not try to export again the function, maybe you changed the id name of the element.
This is what I have now and I still donāt see the log in the console. The function in events.js is not firing.
This is also on a unpaid wix site for testing purposes. Does that make a difference? I hope so not.
import wixData from 'wix-data';
import wixStores from 'wix-stores';
import wixStoresBackend from 'wix-stores-backend';
export function wixStores_onCartCreated(event) {
let total = event.totals.total;
console.log("cart event fired");
}
FYI you do not need to import the Wix Stores API on the events.js file. It will work without it.
Also, if you are using the onCartCreated function note that it will not fire when a user adds an item to the cart from the quick view window like below
Hello, Iām stuck on the same issue. The adding to the cart is being done using the full page instead of the quickAdd window. But still, the event is not being fired. here is the code for events.js file:
I want to make an api call after the purchase is completed, for testing purposes first, I tried to simply log the event and add it to backendLog collection as well
because some other posts suggested to do so to see if its even firing. Its not.
Anything Iām missing here ?
import { fetch } from "wix-fetch";
import wixData from 'wix-data';
// import wixStores from 'wix-stores';
import wixStores from 'wix-stores-backend';
export function wixStores_onCartCreated(event) {
let total = event.totals.total;
console.log("cart event fired");
wixData.insert('backendLog', {'title': total});
}
import wixData from 'wix-data';
import wixStores from 'wix-stores-backend';
export function wixStores_onNewOrder(event) {
let newOrderId = event.orderId;
wixData.insert('Logs', {'orders': newOrderId})
}
orders is a reference field in Logs collection, so it shows me the the order from Stores/Orders collection.
import wixData from 'wix-data';
import wixStores from 'wix-stores-backend';
export function wixStores_onCartCreated(event) {
let total = event.totals.total;
wixData.insert('Logs', {'title': total})
}
export function wixStores_onNewOrder(event) {
let newOrderId = event.orderId;
wixData.insert('Logs', {'orders': newOrderId})
}
I have exactly the same problem. My wixStores_onNewOrder() is not fired. What do you mean with ātry to export again the event from the property panelā? This is my 1st day with wix and somehow I am lost.
Itās not accessible - I am in āCode Filesā | āBackendā | āevents.jsā.
When I click in āPage Codeā and there for example on āmasterPage.jsā, yes, then itās enabled.
OK guys, I could solve it. This was my 1st day with WIX. The site is not using wix Store - so of course, no event could be fired. May be this comment helps somebody else.
I have been suffering and pulling my hairs with this not firing backend events issues since yesterday.
In my case, It was neither āeventS.jsā nor āimport wixStores from āwix-stores-backendāā
It was āTEST SITEā!
You should āPublishā first to make backend event handlers in āevents.jsā
Then, all changes in event handlers code will be reflected in āTest Siteā as well.
To reproduce:
0. Install wix blog
Publish your site using āPublish Buttonā site comment out any event handler in āevents.jsā like
// events.js
// export function wixBlog_onPostCreated(event) {
// console.log('new blog posted!',event)
// }
Use āCreate Test Siteā to make test site with the event handler uncommented
//events.js
export function wixBlog_onPostCreated(event) {
console.log('new blog posted!',event)
}
Open Developer Tools> Site Events>
Try add a blog post. You will see nothing in Site Events log. onPostCreated handler was not triggered.
Now, āPublishā site. And add a blog post. You will see a log in Site Events. onPostCreated handler triggered!
Now change code in events.js
//events.js
export function wixBlog_onPostCreated(event) {
console.log('new blog posted in Test Site',event)
}
Check Event log. You will see a log ānew blog posted in Test Siteā now triggered with new code.
I think events.js handlers are registered only when they are published. Once registered in backend, triggered with new code in events.js
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.
I was having the same issue then i realised i need to have the logs open in another tab whilst i test things on the live site in a seperate tab. Sometimes I just need to publish and refresh the live site if the logs are not showing. hope it helps