Using Shopify information on a Thank You page
<script type="text/javascript">
const orderQueryUrl = "https://live-api.checkoutchamp.com/providersApi/V1/ClubMembership/OrderQueryByOrderId";
// Set ccClientOrderQueryIterations numeric value type variable with number of order query iteraton needed to fetch required order details, currently set to 5
const ccClientOrderQueryIterations = 5;
var ccClientOrderCheckInterval, ccClientOrderQueryCallCount = 1;
// function to set order data details, function accepts an object type parameter containing order details
function ccSetOrderDetails(orderData) {
try {
if (orderData) {
//orderData.emailAddress
//orderData.phoneNumber
//orderData.orderId
//orderData.vendorOrderId (shopify order ID)
//orderData.clientCustomerId (shopify customer ID)
}
} catch(err) {err;}
}
async function ccClientOrderQuery(payload, orderData) {
try {
if (payload && orderData) {
if (ccClientOrderQueryCallCount > ccClientOrderQueryIterations) {
ccSetOrderDetails(orderData);
return;
}
ccClientOrderQueryCallCount++;
const data = await httpMethod(orderQueryUrl, payload);
if (data && data.result === "SUCCESS" && data.message && data.message.vendorOrderId) {
ccSetOrderDetails(data.message);
return;
}
setTimeout(function() { ccClientOrderQuery(payload, orderData); }, 3000);
}
} catch (err) {
setTimeout(function() { ccClientOrderQuery(payload, orderData); }, 3000);
}
}
function ccClientInitializeOrderSearchInterval() {
if (window.location.path !== "blank") {
ccClientOrderCheckInterval = setInterval( function() {
try {
const orderDataString = sessionStorage.getItem("orderData");
const orderData = (orderDataString && JSON.parse(orderDataString)) || {};
if (httpMethod && orderData.orderId) {
clearInterval(ccClientOrderCheckInterval);
const payload = JSON.stringify({ "orderId": orderData.orderId, "finalizeTransaction": 1 });
ccClientOrderQuery(payload, orderData);
}
} catch (err) {err;}
}, 3000);
}
}
ccClientInitializeOrderSearchInterval();
</script>Last updated