Dynamic Page Via Database Search

Hi, I have created a dynamic ‘my order’ page that displays a customer’s order once they type in a valid ‘order number’. The problem I have is that it finds 0 results in my database with a valid order number, however when testing in preview mode it works just fine.
I have already changed my database from private to readable. I’m not sure what’s up and I’m out of options. Thanks.

The page: https:www.autopc.co.uk/my-order

The code:
export function inputOrderNo_change(event) {
//Important
wixData.query(“OrderDetails”)
.eq(“title”, $w(“#inputOrderNo”).value)
.find()
.then( (results) => {

	let orders = results; 
	if(orders.length > 0){ 
		let order = orders.items[0]; 
    	console.log(order["title"]); 

//Non important (this is just the HTML that I’m changing
$w(“#text1”).html = “<p style="text-align:center">Dear " + order[“name”] +”
Auto PC has chosen the computer below to best meet all your needs.

<p style="text-align:center">Order Number: “+ order[“title”] +”

“;
$w(”#text2").html = “


Your PC: “+ order[“pcLink”] + “

At only £”+ order[“pcPrice”] + " + " + order[“pcShip”]+” shipping

”;
$w(“#text3”).html = “<p style="text-align:center">
Thank you very much for using our service.

<p style="text-align:center">Please fill in a short (3-min) feedback survey to make Auto PC the best it can be.

<p style="text-align:center">Feedback survey: 123contactform.com/form-2980129/Feedback-Form

”;
$w(“#text4”).html = “


Tips: “+ order[“tip”] +”


-”+ order[“server”] +“

”;
$w(“#line1”).expand();
$w(“#text1”).expand();
$w(“#text2”).expand();
$w(“#text3”).expand();
$w(“#text4”).expand();
} else {
//Important
console.log(“No results”);
$w(“#line1”).expand();
$w(“#text1”).html = “<p style="text-align:center">Please enter a valid Order Number

”;
$w(“#text1”).expand();
}
} )
.catch( (err) => {
console.log(err);
} );
}

Have you synced the sandbox database to your live website, that would explain why it works in preview but not live.

1 Like

Thank you so much, that was exactly it.