I have coded some back end modules and functions that perform repetitive tasks and also query the tables thatI have created. When they are called in the preview mode , they work fine. But, do not get work in the release candidate.
I am trying to get the line items of an order as currently the feature is not available in Wix. Also trying to query and insert for points function that i need for my site.
Here is code inProductDetails.jsw
export function IsDonateNeedItem(sku){
if (sku.startsWith("DN")){return true;}
else {return false;}
}
const TableAuthOptions = {"suppressAuth": true};
export async function GetProductOwner (ProductID,sku){
// SEARCHES IN ALL CATEGORY TABLES FOR THE OWNER
//Pass sku = null if not available. If available uses it to search product owner.
//check sku if empty use quert products to get SKU
let SKU = "";
console.log ("sku passed " + sku);
if (sku === null || sku === "" || sku === " "){
const SKUResult = await wixData.query("Products",TableAuthOptions)
.eq("_id",ProductID)
.find()
console.log("SKU search count "+ SKUResult.totalCount)
if (SKUResult.totalCount > 0){
SKU = SKUResult.items[0].SKU;
}
console.log("SKU " + SKU);
} else {
SKU = sku;
}
//Get Table from SKU
const DBTable = await TableCategoryMapping(SKU);
console.log("Owner search by table functon : Query table: " + DBTable + " Product : " + ProductID );
return wixData.query(DBTable,TableAuthOptions)
//.include("product")
.eq("product", ProductID)
.find()
.then( (Result) => {
console.log("GetProductOwner functon : " + DBTable + " Query complete item count " + Result.totalCount);
if (Result.totalCount > 0) { return Result.items[0].member;}
else {
return null;
}
})
}
Here is the code from points.jsw
export function GetProductPoints(sku){
//SKU <HR/SW/DO/BY/SL/DN>-<point to deduct format nn>-<Table with the Product ex BO for books table>
let point = sku.substr(3,2);
let pointNumber = Number(point.valueOf());
return pointNumber;
}
export function GetDonatePoints(sku){
let point = sku.substr(3,2);
let pointNumber = Number(point.valueOf())
return pointNumber;
}
Here is the call from Cart page
let DonateNeedItemFlag = await IsDonateNeedItem(sku);
//If SKU is not for Donate and NEED item deduct points
if (DonateNeedItemFlag){
let ProductOwner = await GetProductOwner(SelectedProduct.productId,sku);
console.log(" in cart page Product Owner " + ProductOwner);
if (ProductOwner === MemberID){
console.log("Owner is name are buyer. No points earned");
}
else {
let DonatePoint = 0;
DonatePoint = await GetDonatePoints(sku);
console.log("Earned point "+ EarnedPoints.toString())
console.log("Donate point " + DonatePoint.toString() + "str " + sku.substr(3,2))
EarnedPoints = EarnedPoints + DonatePoint;
console.log("Earned point " + EarnedPoints.toString())
}
} else {
console.log("Cart point "+ CartPoints.toString())
let ProductPoints = await GetProductPoints(sku);
console.log("Product point " + ProductPoints.toString())
CartPoints = CartPoints + ProductPoints.valueOf();
console.log("Cart point " + CartPoints.toString())
}
I can see the corresponding console log entries of cart page in preview mode , but can’t see them in the release candidate.
Screenshot of the release candidate
Screenshot of the preview mode
Web module permissions for all functions and all files are set to “Anyone” can call the function
The table permissions are also same Anyone can read.
Please help fix this