Why am I receiving: The current user does not have permissions to find on the Stores/Orders collection? If they made it, it must be usable, right? I also tried moving it to the backend, but I’m clueless as to retrieving the correct order number from the thank you page or anywhere else. I can’t go with the last order number created, because of the possibility of multiple orders around the same time frame. Does anyone have any suggestions?
$w.onReady(async function () {
$w(‘#thankYouPage1’).getOrder()
.then( (order) => {
email = order.shippingInfo.shipmentDetails.email;
firstName = order.shippingInfo.shipmentDetails.firstName;
lastName = order.shippingInfo.shipmentDetails.lastName;
company = order.shippingInfo.shipmentDetails.company;
paidOrderId = order.number;
purchaseDt = order._updatedDate;
orderNumber = order.number;
let OrderIDItems = [], OrderIDItem = {}, lineItem = {};
let lineItems = order.lineItems;
for (var i = 0; i < lineItems.length; i++) {
lineItem = lineItems[i];
OrderIDItem = {
email: email,
...};
OrderIDItems.push(OrderIDItem);
}
let options = {"suppressAuth": true};
wixData.bulkInsert("paidLineItems", OrderIDItems, options)
.then((bulkResults) => {
console.log(bulkResults);
})
.catch((error) => {
console.log(error);
});
})
await getSeqNbrs();
await writeLineItems();
});