Helllo, I’m trying to code a return form for returning products but I can’t find out how to check if an order really exists, by getting the information from the number itself: URL: Returns and Refunds – InteriorGlows looks like this
And I got this code:
document.addEventListener('DOMContentLoaded', function() {
// Get the "Check Order" button
const checkOrderBtn = document.getElementById('checkOrderBtn');
// Add event listener for the button
checkOrderBtn.addEventListener('click', function() {
// Get the form elements
const nameField = document.getElementById('ContactForm-name');
const emailField = document.getElementById('ContactForm-email');
const orderNumberField = document.getElementById('ContactForm-order-number');
const returnTypeField = document.getElementById('ContactForm-return-type');
// Check if all required fields are filled
if (!nameField.value || !emailField.value || !orderNumberField.value || !returnTypeField.value) {
alert("Please fill in all required fields.");
return;
}
// If all fields are filled, proceed with order check
var orderNumber = orderNumberField.value;
var orderExists = checkIfOrderExists(orderNumber);
if (orderExists) {
alert("Order found!");
} else {
alert("Order not found.");
}
});
// Simulated function to check if the order exists
function checkIfOrderExists(orderNumber) {
// How can I check if order really exists and get the information from it
}
});
But I do not know how to get the order information (if it exist) from the variable orderNumber. Can anyone please help me get it
