-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathorder-detail.js
69 lines (53 loc) · 1.85 KB
/
order-detail.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
var templates = {};
var order = null;
// ---------------------------------------------------------
// Security (well, not really security, but a helper to
// redirect the user if they're not logged in. Security
// is handled by the REST API.
// ---------------------------------------------------------
var redirectToLogin = function () {
var location_href = "index.html";
if (location.hash && location.hash.length > 0) {
location_href += "?hash=" + location.hash.substring(1);
}
location.href = location_href;
};
var theDocument = jQuery(document);
theDocument.ajaxSend(function (event, xhr) {
var cartId = getCookie('UltraCartShoppingCartID');
var merchantId = window.merchantId || getCookie('UltraCartMerchantID');
xhr.setRequestHeader("cache-control", "no-cache");
xhr.setRequestHeader("X-UC-Merchant-Id", merchantId);
xhr.setRequestHeader("X-UC-Shopping-Cart-Id", cartId);
});
theDocument.ajaxError(function (event, xhr) {
if (xhr.status === 401)
redirectToLogin();
});
jQuery.ajaxSetup({cache: false});
function initialize() {
// find the order id.
var params = uc.commonFunctions.parseHttpParameters();
if (params['orderid'] && params['orderid'].length) {
var orderId = params['orderid'][0];
loadOrder(orderId);
}
}
function loadOrder(orderId) {
//noinspection JSUnusedLocalSymbols
ultracart.myAccount.getOrder(orderId, {
success: function (order) {
var html = 'This order could not be found at this time.';
if (order) {
html = templates.order(order);
// console.log(html);
}
jQuery('#order').html(html);
}
});
}
jQuery(document).ready(function () {
enablePleaseWaitMessage();
templates.order = Handlebars.compile(jQuery('#order-template').html());
initialize();
});