Actually, order id is available in order confirmation page… But it is in the url of the page.
What you can do :
Add a Form in the order confirmation page, add a hidden input to this form and with vanilla js or jquery get the url parameter from the order confirmation url, it’s a parameter written like this : orderId
Here’s a function to get parameters in a url :
// look for URL params
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = window.location.search.substring(1),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
}
}
};
You just need to write a script that passes the orderId in this function to get a variable with your orderId inside. Then you can use it wherever you need.
Hope this helps