Hi,
I’m trying to capture the event that fires every time a new order is entered to my store.
-
I read all the relevant article in the forum
-
I’ve added an events.js file under site structure\backend
-
I add the following code as shown by one of Wix’ employees
let newOrderId = event.orderId;
let NewOrder = wixData.get(‘Orders’, newOrderId);
-
I added console.log every where to see if the event was capture
Nothing happens, it looks like the events.js file is not called or captures the event.
Please advice
Ronen
Please post the editor URL of your site. Only authorized Wix personnel can get access to your site in the editor. Please include the name of the page involved.
Hi Yisrael,
Thanks for replying.
This is the link: https://editor.wix.com/html/editor/web/renderer/edit/841ca98f-898c-45f7-8330-6792f034658e?metaSiteId=b5fc84e8-7ba6-48e4-92cf-3cfc40896f7c&editorSessionId=33dcfd03-35bf-5ece-9f13-26be1b0a72b2
My purpose is to capture every new order in the store using events.js file that I added under the Backend partition under site structure and copy some of its fields to Order_Status Table.
And if I may another question. Is there a way to debug code under Backend?
Appreciate your help,
Thanks Ronen
@ronenin One thing I noticed in your code… the get() needs the “full path” for the data collection. You should use:
let NewOrder = wixData.get('Stores/Orders', newOrderId);
See the article Corvid: Testing and Debugging Your Code for information on how to debug your code (including backend). You can also use the browser’s Javascript debugging console to view console.log() messages.
@yisrael-wix I read the article Corvid: Testing and Debugging Your Code many times. on’t forget that the on new order event can not be tested in preview mode since we need the payment simulation in order to perform a new order and the article does not specify how to debug a js file under backend
Thanks
Ronen
@ronenin Well, the “real” way to properly debug backend is by using the Site Monitoring feature. I didn’t mention this earlier since it is a bit involved, but it is simply awesome .