Hi, I’m trying to run few events.js functions, for example when a user updates his cart, or a new order is being placed.
I’ve tried to run the example code from the Velo API, but the function just won’t run (I’m on a published site).
I’ve tried to log the events to the monitor console, or add it a logs database, but nothing happens.
Here is a code that I’ve tried, as I understand this sould run when a user creates new cart or updates one (this is literally copy from the API).
import wixEcomBackend from ‘wix-ecom-backend’ ;
import wixStoresBackend from ‘wix-stores-backend’ ;
import wixStores from ‘wix-stores’ ;
import wixData from ‘wix-data’ ;
export function wixEcom_onCartUpdated ( event ) {
const cartSubtotal = event.entity.subtotal.amount ;
const cartId = event.entity._id ;
const eventId = event.metadata.id ;
wixData . insert ( ‘logs’ , event )
console . log ( ‘Cart updated’ , event );
}
// Place this code in the events.js file
// of your site’s Backend section.
// Add the file if it doesn’t exist.
export function wixEcom_onCartCreated ( event ) {
const cartSubtotal = event.entity.subtotal.amount ;
const cartId = event.entity._id ;
const eventId = event.metadata.id ;
wixData . insert ( ‘logs’ , event )
console . log ( ‘Cart created’ , event )
}
Can someone help me understand why functions doesn’t run?