To the Wix code team:
Hooks seems not to be working for the Stores/Orders collection. It works on custom made collections. We need it to work with Stores/Orders Collection to make an integration with another system.
I setup a afterInsert hook in the Stores/Orders Collection but when a make a product order the hook code is not being called.
To make sure the hook is working a created a new collection called “backEndLog” and placed the following code in the afterInsert Hook code and made a purchase of a product item:
From data.js:
import wixData from 'wix-data';
export function Stores$Orders_afterInsert(item, context) {
//TODO: write your code here...
//Add your code for this event here:
let toInsert = {
"title": "Mr.",
"first_name": "John",
"last_name": "Doe"
};
// register some data into the backEndLog Collection
wixData.insert("backEndLog", toInsert)
.then( (results) => {
let item2 = results; //see item below
} )
.catch( (err) => {
let errorMsg = err;
} );
}
Result: backEndLog Collection have no new registered row data
Can you help ?
Regards Joni