< script >
if (window.location.href.indexOf('checkout/thankyou/') > 1) {
// Define these parameters
var APP_NAME = "Vitapharma";
var IOS_SCHEME = "be.vitapharma";
var ANDROID_SCHEME = "be.vitapharma.vitapharma://";
var shopId = {
{
shop.id
}
};
var orderId = {
{
order.information.id
}
}
var currency = {
{
order.information.currency
}
}
var price_incl = {
{
order.information.price_incl
}
}
var http = new XMLHttpRequest();
var url = "https://app1.jmango360.com/mobileweb/seoshop/shop/" + shopId + "/orders/" + orderId;
http.open("GET", url, true);
http.setRequestHeader("Content-Type", "application/json");
http.onreadystatechange = function() { //Call a function when the state changes.
if (http.readyState == 4 && http.status == 200) {
var result = JSON.parse(http.responseText);
if (result.success) {
if (getMobileOperatingSystem() == "iOS") {
window.location = IOS_SCHEME +
"://view?transasction_id=" + orderId + "¤cy=" + currency + "&price_incl=" + price_incl;
} else if (getMobileOperatingSystem() == "Android") {
if (confirm("Would you like to return " + APP_NAME + " app?") == true) {
window.location.href = ANDROID_SCHEME +
"://?transasction_id=" + orderId + "¤cy=" + currency + "&price_incl=" + price_incl;
}
}
}
}
}
http.send();
}
/**
* Determine the mobile operating system.
* This function returns one of 'iOS', 'Android', 'Windows Phone', or 'unknown'.
*
* @returns {String}
*/
function getMobileOperatingSystem() {
var userAgent = navigator.userAgent || navigator.vendor || window.opera;
// Windows Phone must come first because its UA also contains "Android"
if (/windows phone/i.test(userAgent)) {
return "Windows Phone";
}
if (/android/i.test(userAgent)) {
return "Android";
}
// iOS detection from: http://stackoverflow.com/a/9039885/177710
if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
return "iOS";
}
return "unknown";
} <
/script>