If you already have orders created in the background (based on customer preferences like date, time, or type of experience), you can send the customer directly into the checkout widget with that predefined order.
This way, the customer skips the product selection step and lands directly on the checkout page.
How to Implement
The code below is a sample snippet. To make it functional on your website, you will need to adjust it to your own specifications (for example, replacing the temporary order ID with a real one).
📒 NOTE
This version is written to work in a jsfiddle test example. It includes extra lines for testing purposes and comments that explain how each part of the code works. In production, remove the testing lines and uncomment the line that reads from the actual page URL.
function openOrderFromURL() {
// For production use, this line must be uncommented.
// const urlParams = new URLSearchParams(window.location.search);
// For production use, these four lines need to be deleted.
// It is just code used to help with testing on jsfiddle.
// At this link, you can create an order and obtain an temporaryOrderID -> https://jsfiddle.net/SebastianV/b356mkz1/
const temporaryOrderID = "FILL IN ORDER_ID"
const temporaryPage = "checkout"
const temporaryURL = new URL(`https://example.com/page?orderID=${temporaryOrderID}&page=${temporaryPage}`)
const urlParams = new URLSearchParams(temporaryURL.search)
const orderID = urlParams.get('orderID');
// Currently only the 'checkout' value can be used to redirect the customer.
const page = urlParams.get('page') ?? 'checkout';
return {orderID, page};
}
window.addEventListener('load', function() {
const { orderID, page } = openOrderFromURL();
if (orderID) {
if (typeof window.Ventrata === 'function') {
// This Ventrata function accepts all attributes you can pass into the data-config.
// For example, to open an order, you need to provide the orderID and specify the page where you want to send the user.
// If your data indicates that the order requires a questions, cross-sell or checkout,
// you can direct the user to that specific page using the page parameter.
// However, if you only need to send them directly to fill in contact details, set "page": "checkout".
// More options are available in the documentation.
window.Ventrata({"orderID": orderID, "page": page});
} else {
console.error('Ventrata checkout did not load.');
}
}
});
Checkout Flow with a Predefined Order
Your system creates an order in the background. You generate a link that includes the orderID
and desired page
, for example:
https://example.com/page?orderID=c6efd05f-11aa-41cc-9758-4aa0f3549439&page=checkout
When the customer visits the link, the script above detects the orderID
and page
. The widget opens directly on that page with the predefined order.