| Line 1... |
Line 1... |
| 1 |
window.onload=function(){
|
1 |
window.onload=function(){
|
| 2 |
var pheight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
|
2 |
var pheight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
|
| 3 |
if(document.getElementsByClassName('cart-cont')[0] != undefined){
|
3 |
if(document.getElementsByClassName('cart-cont')[0] != undefined){
|
| 4 |
|
4 |
|
| 5 |
document.getElementsByClassName('cart-cont')[0].style.minHeight = pheight - 235 +'px';
|
5 |
document.getElementsByClassName('cart-cont')[0].style.minHeight = pheight - 235 +'px';
|
| 6 |
}
|
6 |
}
|
| 7 |
};
|
7 |
};
|
| 8 |
|
8 |
|
| 9 |
function clearmsg() {
|
9 |
function clearmsg() {
|
| 10 |
if (document.getElementById("coupon-msg").style.display == "block") {
|
10 |
if (document.getElementById("coupon-msg").style.display == "block") {
|
| 11 |
document.getElementById("coupon-msg").style.display = "none";
|
11 |
document.getElementById("coupon-msg").style.display = "none";
|
| 12 |
}
|
12 |
}
|
| 13 |
}
|
13 |
}
|
| 14 |
|
14 |
|
| 15 |
function applycoupon() {
|
15 |
function applycoupon() {
|
| 16 |
var coupon = document.getElementById("couponcode").value;
|
16 |
var coupon = document.getElementById("couponcode").value;
|
| 17 |
if (coupon.length <= 0) {
|
17 |
if (coupon.length <= 0) {
|
| 18 |
if (document.getElementById("error").style.display == "block") {
|
18 |
if (document.getElementById("error").style.display == "block") {
|
| 19 |
document.getElementById("error").style.display = "none";
|
19 |
document.getElementById("error").style.display = "none";
|
| 20 |
}
|
20 |
}
|
| 21 |
var bRed = document.getElementById("couponcode");
|
21 |
var bRed = document.getElementById("couponcode");
|
| 22 |
bRed.style.border = "red solid 1px";
|
22 |
bRed.style.border = "red solid 1px";
|
| 23 |
bRed.style.color = "red";
|
23 |
bRed.style.color = "red";
|
| 24 |
bRed.value = "Please enter the coupon code!";
|
24 |
bRed.value = "Please enter the coupon code!";
|
| 25 |
setTimeout(function() {
|
25 |
setTimeout(function() {
|
| 26 |
bRed.style.border = "";
|
26 |
bRed.style.border = "";
|
| 27 |
bRed.style.color = "";
|
27 |
bRed.style.color = "";
|
| 28 |
bRed.value = "";
|
28 |
bRed.value = "";
|
| 29 |
}, 3000);
|
29 |
}, 3000);
|
| 30 |
return false;
|
30 |
return false;
|
| 31 |
} else {
|
31 |
} else {
|
| 32 |
if (document.getElementById("error").style.display == "block") {
|
32 |
if (document.getElementById("error").style.display == "block") {
|
| 33 |
document.getElementById("error").style.display = "none";
|
33 |
document.getElementById("error").style.display = "none";
|
| 34 |
}
|
34 |
}
|
| 35 |
var url = base_url + "cart/coupon/" + coupon;
|
35 |
var url = base_url + "cart/coupon/" + coupon;
|
| 36 |
microAjax(url, function(res) {
|
36 |
microAjax(url, function(res) {
|
| 37 |
var data = JSON.parse(res);
|
37 |
var data = JSON.parse(res);
|
| 38 |
var message = data.message;
|
38 |
var message = data.message;
|
| 39 |
document.getElementById("addCoupon").style.display = "block";
|
39 |
document.getElementById("addCoupon").style.display = "block";
|
| 40 |
document.getElementById("coupon-msg").style.display = "block";
|
40 |
document.getElementById("coupon-msg").style.display = "block";
|
| 41 |
if (message.length > 0) {
|
41 |
if (message.length > 0) {
|
| 42 |
document.getElementById("coupon-msg").innerHTML = message;
|
42 |
document.getElementById("coupon-msg").innerHTML = message;
|
| 43 |
}
|
43 |
}
|
| 44 |
//if (data.discountedPrice != undefined && parseInt(data.discountedPrice) >= 0) {
|
44 |
//if (data.discountedPrice != undefined && parseInt(data.discountedPrice) >= 0) {
|
| 45 |
if (data.couponCode != undefined && data.couponCode.length > 0) {
|
45 |
if (data.couponCode != undefined && data.couponCode.length > 0) {
|
| 46 |
var dealtextdivs = document.getElementsByClassName('dealdiv');
|
46 |
var dealtextdivs = document.getElementsByClassName('dealdiv');
|
| 47 |
for(var i in dealtextdivs){
|
47 |
for(var i in dealtextdivs){
|
| 48 |
if(dealtextdivs[i].innerHTML===undefined)continue;
|
48 |
if(dealtextdivs[i].innerHTML===undefined)continue;
|
| 49 |
var item_id = dealtextdivs[i].getAttribute('id');
|
49 |
var item_id = dealtextdivs[i].getAttribute('id');
|
| 50 |
dealtextdivs[i].innerHTML = data.dealTextArray[item_id];
|
50 |
dealtextdivs[i].innerHTML = data.dealTextArray[item_id];
|
| 51 |
if(data.dealTextArray[item_id]==''){
|
51 |
if(data.dealTextArray[item_id]==''){
|
| 52 |
dealtextdivs[i].style.display='none';
|
52 |
dealtextdivs[i].style.display='none';
|
| 53 |
}
|
53 |
}
|
| 54 |
}
|
54 |
}
|
| 55 |
//document.getElementById("addCoupon").style.display = "none";
|
55 |
//document.getElementById("addCoupon").style.display = "none";
|
| 56 |
document.getElementById("removeCoupon").style.display = "block";
|
56 |
document.getElementById("removeCoupon").style.display = "block";
|
| 57 |
if (data.couponCode.length > 0) {
|
57 |
if (data.couponCode.length > 0) {
|
| 58 |
document.getElementById("removeCoupon").innerHTML = "Remove Coupon: " + data.couponCode;
|
58 |
document.getElementById("removeCoupon").innerHTML = "Remove Coupon: " + data.couponCode;
|
| 59 |
if ( typeof _gaq != "undefined" && _gaq != null) {
|
59 |
if ( typeof _gaq != "undefined" && _gaq != null) {
|
| 60 |
_gaq.push(["_trackEvent", "COUPON", "Coupon Applied", data.couponCode, itemString]);
|
60 |
_gaq.push(["_trackEvent", "COUPON", "Coupon Applied", data.couponCode]);
|
| 61 |
}
|
61 |
}
|
| 62 |
}else{
|
62 |
}else{
|
| 63 |
document.getElementById("removeCoupon").innerHTML = "Remove Coupon";
|
63 |
document.getElementById("removeCoupon").innerHTML = "Remove Coupon";
|
| 64 |
}
|
64 |
}
|
| 65 |
document.getElementById("discount").style.display = "block";
|
65 |
document.getElementById("discount").style.display = "block";
|
| 66 |
var discount = parseInt(data.totalPrice) - parseInt(data.discountedPrice);
|
66 |
var discount = parseInt(data.totalPrice) - parseInt(data.discountedPrice);
|
| 67 |
document.getElementById("discountAmt").innerHTML = discount;
|
67 |
document.getElementById("discountAmt").innerHTML = discount;
|
| 68 |
document.getElementById("discountPrice").style.display = "block";
|
68 |
document.getElementById("discountPrice").style.display = "block";
|
| 69 |
document.getElementById("discountedPrice").innerHTML = parseInt(document.getElementById("total").innerHTML) - discount;
|
69 |
document.getElementById("discountedPrice").innerHTML = parseInt(document.getElementById("total").innerHTML) - discount;
|
| 70 |
} else {
|
70 |
} else {
|
| 71 |
document.getElementById("discount").style.display = "none";
|
71 |
document.getElementById("discount").style.display = "none";
|
| 72 |
document.getElementById("discountPrice").style.display = "none";
|
72 |
document.getElementById("discountPrice").style.display = "none";
|
| 73 |
}
|
73 |
}
|
| 74 |
});
|
74 |
});
|
| 75 |
}
|
75 |
}
|
| 76 |
}
|
76 |
}
|
| 77 |
|
77 |
|
| 78 |
function clearcoupon(code) {
|
78 |
function clearcoupon(code) {
|
| 79 |
var url = base_url + "cart/couponClear/" + code;
|
79 |
var url = base_url + "cart/couponClear/" + code;
|
| 80 |
microAjax(url, function(res) {
|
80 |
microAjax(url, function(res) {
|
| 81 |
if ( typeof _gaq != "undefined" && _gaq != null) {
|
81 |
if ( typeof _gaq != "undefined" && _gaq != null) {
|
| 82 |
_gaq.push(["_trackEvent", "COUPON", "Coupon Removed", code]);
|
82 |
_gaq.push(["_trackEvent", "COUPON", "Coupon Removed", document.getElementById("couponcode").value]);
|
| 83 |
}
|
83 |
}
|
| 84 |
var data = JSON.parse(res);
|
84 |
var data = JSON.parse(res);
|
| 85 |
var message = data.message;
|
85 |
var message = data.message;
|
| 86 |
var total = data.totalPrice;
|
86 |
var total = data.totalPrice;
|
| 87 |
document.getElementById("addCoupon").style.display = "block";
|
87 |
document.getElementById("addCoupon").style.display = "block";
|
| 88 |
document.getElementById("removeCoupon").style.display = "none";
|
88 |
document.getElementById("removeCoupon").style.display = "none";
|
| 89 |
document.getElementById("discount").style.display = "none";
|
89 |
document.getElementById("discount").style.display = "none";
|
| 90 |
document.getElementById("discountPrice").style.display = "none";
|
90 |
document.getElementById("discountPrice").style.display = "none";
|
| 91 |
document.getElementById("coupon-msg").style.display = "none";
|
91 |
document.getElementById("coupon-msg").style.display = "none";
|
| 92 |
document.getElementById("couponcode").value = "";
|
92 |
document.getElementById("couponcode").value = "";
|
| 93 |
var finalinsurance = 0;
|
93 |
var finalinsurance = 0;
|
| 94 |
if (insuredItems.length > 0) {
|
94 |
if (insuredItems.length > 0) {
|
| 95 |
for ( j = 0; j < insuredItems.length; j++) {
|
95 |
for ( j = 0; j < insuredItems.length; j++) {
|
| 96 |
var insurance = insuredItems[j] + "theft";
|
96 |
var insurance = insuredItems[j] + "theft";
|
| 97 |
var cost = document.getElementById(insurance).innerHTML;
|
97 |
var cost = document.getElementById(insurance).innerHTML;
|
| 98 |
finalinsurance = finalinsurance + parseInt(cost);
|
98 |
finalinsurance = finalinsurance + parseInt(cost);
|
| 99 |
}
|
99 |
}
|
| 100 |
}
|
100 |
}
|
| 101 |
if (parseInt(finalinsurance) > 0) {
|
101 |
if (parseInt(finalinsurance) > 0) {
|
| 102 |
total = parseInt(total) + parseInt(finalinsurance);
|
102 |
total = parseInt(total) + parseInt(finalinsurance);
|
| 103 |
document.getElementById("total").innerHTML = total;
|
103 |
document.getElementById("total").innerHTML = total;
|
| 104 |
}
|
104 |
}
|
| 105 |
});
|
105 |
});
|
| 106 |
}
|
106 |
}
|
| 107 |
|
107 |
|
| 108 |
function updateQty(e) {
|
108 |
function updateQty(e) {
|
| 109 |
var oldValue = e.currentTarget.getAttribute("data-value");
|
109 |
var oldValue = e.currentTarget.getAttribute("data-value");
|
| 110 |
var newvalue = e.currentTarget.value;
|
110 |
var newvalue = e.currentTarget.value;
|
| 111 |
if (parseInt(newvalue) != parseInt(oldValue)) {
|
111 |
if (parseInt(newvalue) != parseInt(oldValue)) {
|
| 112 |
var url = base_url + "cart/update/" + e.currentTarget.id + "/" + newvalue;
|
112 |
var url = base_url + "cart/update/" + e.currentTarget.id + "/" + newvalue;
|
| 113 |
window.location.href = url;
|
113 |
window.location.href = url;
|
| 114 |
}
|
114 |
}
|
| 115 |
}
|
115 |
}
|
| 116 |
|
116 |
|
| 117 |
function removeItem(itemId) {
|
117 |
function removeItem(itemId) {
|
| 118 |
var url = base_url + "cart/delete/" + itemId;
|
118 |
var url = base_url + "cart/delete/" + itemId;
|
| 119 |
window.location.href = url;
|
119 |
window.location.href = url;
|
| 120 |
}
|
120 |
}
|
| 121 |
|
121 |
|
| 122 |
var insuredItems = new Array();
|
122 |
var insuredItems = new Array();
|
| 123 |
function teftinsure(e) {
|
123 |
function teftinsure(e) {
|
| 124 |
var key = e.currentTarget.getAttribute("data-key");
|
124 |
var key = e.currentTarget.getAttribute("data-key");
|
| 125 |
if (key == "ins") {
|
125 |
if (key == "ins") {
|
| 126 |
if (document.getElementById("error").style.display == "block") {
|
126 |
if (document.getElementById("error").style.display == "block") {
|
| 127 |
document.getElementById("error").style.display = "none";
|
127 |
document.getElementById("error").style.display = "none";
|
| 128 |
}
|
128 |
}
|
| 129 |
var id = e.currentTarget.id;
|
129 |
var id = e.currentTarget.id;
|
| 130 |
var insure = document.getElementById(id).checked;
|
130 |
var insure = document.getElementById(id).checked;
|
| 131 |
var itemId = e.currentTarget.getAttribute("data-value");
|
131 |
var itemId = e.currentTarget.getAttribute("data-value");
|
| 132 |
var tnc = itemId + "tnc";
|
132 |
var tnc = itemId + "tnc";
|
| 133 |
var tc = itemId + "tc";
|
133 |
var tc = itemId + "tc";
|
| 134 |
tncChkd = document.getElementById(tnc).checked;
|
134 |
tncChkd = document.getElementById(tnc).checked;
|
| 135 |
var theft = itemId + "theft";
|
135 |
var theft = itemId + "theft";
|
| 136 |
var theft = document.getElementById(theft).innerHTML;
|
136 |
var theft = document.getElementById(theft).innerHTML;
|
| 137 |
theft = parseInt(theft);
|
137 |
theft = parseInt(theft);
|
| 138 |
var total = document.getElementById("total").innerHTML;
|
138 |
var total = document.getElementById("total").innerHTML;
|
| 139 |
total = parseInt(total);
|
139 |
total = parseInt(total);
|
| 140 |
if (insure == true) {
|
140 |
if (insure == true) {
|
| 141 |
insuredItems.push(itemId);
|
141 |
insuredItems.push(itemId);
|
| 142 |
if ( typeof _gaq != "undefined" && _gaq != null) {
|
142 |
if ( typeof _gaq != "undefined" && _gaq != null) {
|
| 143 |
_gaq.push(["_trackEvent", "insurance", "Want Insurance", itemId]);
|
143 |
_gaq.push(["_trackEvent", "insurance", "Want Insurance", itemId]);
|
| 144 |
}
|
144 |
}
|
| 145 |
if (document.getElementById("discountPrice").style.display == "block") {
|
145 |
if (document.getElementById("discountPrice").style.display == "block") {
|
| 146 |
var discountPrice = document.getElementById("discountedPrice").innerHTML;
|
146 |
var discountPrice = document.getElementById("discountedPrice").innerHTML;
|
| 147 |
discountPrice = parseInt(discountPrice);
|
147 |
discountPrice = parseInt(discountPrice);
|
| 148 |
document.getElementById("discountedPrice").innerHTML = discountPrice + theft;
|
148 |
document.getElementById("discountedPrice").innerHTML = discountPrice + theft;
|
| 149 |
} else {
|
149 |
} else {
|
| 150 |
document.getElementById("total").innerHTML = total + theft;
|
150 |
document.getElementById("total").innerHTML = total + theft;
|
| 151 |
}
|
151 |
}
|
| 152 |
}
|
152 |
}
|
| 153 |
if (insure == false) {
|
153 |
if (insure == false) {
|
| 154 |
if (document.getElementById("error").style.display == "block") {
|
154 |
if (document.getElementById("error").style.display == "block") {
|
| 155 |
document.getElementById("error").style.display = "none";
|
155 |
document.getElementById("error").style.display = "none";
|
| 156 |
}
|
156 |
}
|
| 157 |
if (document.getElementById(tc).style.display == "block") {
|
157 |
if (document.getElementById(tc).style.display == "block") {
|
| 158 |
document.getElementById(tc).style.display = "none";
|
158 |
document.getElementById(tc).style.display = "none";
|
| 159 |
}
|
159 |
}
|
| 160 |
var ind = insuredItems.indexOf(itemId);
|
160 |
var ind = insuredItems.indexOf(itemId);
|
| 161 |
insuredItems.splice(ind, 1);
|
161 |
insuredItems.splice(ind, 1);
|
| 162 |
if (document.getElementById("discountPrice").style.display == "block") {
|
162 |
if (document.getElementById("discountPrice").style.display == "block") {
|
| 163 |
var discountPrice = document.getElementById("discountedPrice").innerHTML;
|
163 |
var discountPrice = document.getElementById("discountedPrice").innerHTML;
|
| 164 |
discountPrice = parseInt(discountPrice);
|
164 |
discountPrice = parseInt(discountPrice);
|
| 165 |
document.getElementById("discountedPrice").innerHTML = discountPrice - theft;
|
165 |
document.getElementById("discountedPrice").innerHTML = discountPrice - theft;
|
| 166 |
} else {
|
166 |
} else {
|
| 167 |
document.getElementById("total").innerHTML = total - theft;
|
167 |
document.getElementById("total").innerHTML = total - theft;
|
| 168 |
}
|
168 |
}
|
| 169 |
}
|
169 |
}
|
| 170 |
}
|
170 |
}
|
| 171 |
if (key == "tnc") {
|
171 |
if (key == "tnc") {
|
| 172 |
if (document.getElementById("error").style.display == "block") {
|
172 |
if (document.getElementById("error").style.display == "block") {
|
| 173 |
document.getElementById("error").style.display = "none";
|
173 |
document.getElementById("error").style.display = "none";
|
| 174 |
}
|
174 |
}
|
| 175 |
var id = e.currentTarget.id;
|
175 |
var id = e.currentTarget.id;
|
| 176 |
var tncChkd = document.getElementById(id).checked;
|
176 |
var tncChkd = document.getElementById(id).checked;
|
| 177 |
var itemId = e.currentTarget.getAttribute("data-value");
|
177 |
var itemId = e.currentTarget.getAttribute("data-value");
|
| 178 |
var insurance = itemId + "insurance";
|
178 |
var insurance = itemId + "insurance";
|
| 179 |
var tc = itemId + "tc";
|
179 |
var tc = itemId + "tc";
|
| 180 |
var insure = document.getElementById(insurance).checked;
|
180 |
var insure = document.getElementById(insurance).checked;
|
| 181 |
}
|
181 |
}
|
| 182 |
if (insure == true && tncChkd == false) {
|
182 |
if (insure == true && tncChkd == false) {
|
| 183 |
if (document.getElementById("error").style.display == "block") {
|
183 |
if (document.getElementById("error").style.display == "block") {
|
| 184 |
document.getElementById("error").style.display = "none";
|
184 |
document.getElementById("error").style.display = "none";
|
| 185 |
}
|
185 |
}
|
| 186 |
if (document.getElementById(tc).style.display == "block") {
|
186 |
if (document.getElementById(tc).style.display == "block") {
|
| 187 |
var url = base_url + "cart/insure/" + itemId + "/" + tncChkd + "/1";
|
187 |
var url = base_url + "cart/insure/" + itemId + "/" + tncChkd + "/1";
|
| 188 |
microAjax(url, function(res) {
|
188 |
microAjax(url, function(res) {
|
| 189 |
var data = JSON.parse(res);
|
189 |
var data = JSON.parse(res);
|
| 190 |
data = data.status;
|
190 |
data = data.status;
|
| 191 |
if (data == true) {
|
191 |
if (data == true) {
|
| 192 |
}
|
192 |
}
|
| 193 |
if (data == false) {
|
193 |
if (data == false) {
|
| 194 |
alert(data);
|
194 |
alert(data);
|
| 195 |
}
|
195 |
}
|
| 196 |
});
|
196 |
});
|
| 197 |
} else {
|
197 |
} else {
|
| 198 |
document.getElementById(tc).style.display = "block";
|
198 |
document.getElementById(tc).style.display = "block";
|
| 199 |
}
|
199 |
}
|
| 200 |
} else {
|
200 |
} else {
|
| 201 |
if (insure == true && tncChkd == true) {
|
201 |
if (insure == true && tncChkd == true) {
|
| 202 |
if ( typeof _gaq != "undefined" && _gaq != null) {
|
202 |
if ( typeof _gaq != "undefined" && _gaq != null) {
|
| 203 |
_gaq.push(["_trackEvent", "Insurance", "Agreed to Terms", itemId]);
|
203 |
_gaq.push(["_trackEvent", "Insurance", "Agreed to Terms", itemId]);
|
| 204 |
}
|
204 |
}
|
| 205 |
var url = base_url + "cart/insure/" + itemId + "/" + insure + "/1";
|
205 |
var url = base_url + "cart/insure/" + itemId + "/" + insure + "/1";
|
| 206 |
microAjax(url, function(res) {
|
206 |
microAjax(url, function(res) {
|
| 207 |
var data = JSON.parse(res);
|
207 |
var data = JSON.parse(res);
|
| 208 |
data = data.status;
|
208 |
data = data.status;
|
| 209 |
if (data == true) {
|
209 |
if (data == true) {
|
| 210 |
}
|
210 |
}
|
| 211 |
if (data == false) {
|
211 |
if (data == false) {
|
| 212 |
alert(data);
|
212 |
alert(data);
|
| 213 |
}
|
213 |
}
|
| 214 |
});
|
214 |
});
|
| 215 |
} else {
|
215 |
} else {
|
| 216 |
if (insure == false && tncChkd == true) {
|
216 |
if (insure == false && tncChkd == true) {
|
| 217 |
var url = base_url + "cart/insure/" + itemId + "/" + insure + "/1";
|
217 |
var url = base_url + "cart/insure/" + itemId + "/" + insure + "/1";
|
| 218 |
microAjax(url, function(res) {
|
218 |
microAjax(url, function(res) {
|
| 219 |
var data = JSON.parse(res);
|
219 |
var data = JSON.parse(res);
|
| 220 |
data = data.status;
|
220 |
data = data.status;
|
| 221 |
if (data == true) {
|
221 |
if (data == true) {
|
| 222 |
document.getElementById(tnc).checked = false;
|
222 |
document.getElementById(tnc).checked = false;
|
| 223 |
document.getElementById(tc).style.display = "none";
|
223 |
document.getElementById(tc).style.display = "none";
|
| 224 |
}
|
224 |
}
|
| 225 |
if (data == false) {
|
225 |
if (data == false) {
|
| 226 |
alert(data);
|
226 |
alert(data);
|
| 227 |
}
|
227 |
}
|
| 228 |
});
|
228 |
});
|
| 229 |
} else {
|
229 |
} else {
|
| 230 |
if (insure == false && tncChkd == true) {
|
230 |
if (insure == false && tncChkd == true) {
|
| 231 |
var url = base_url + "cart/insure/" + itemId + "/" + insure + "/1";
|
231 |
var url = base_url + "cart/insure/" + itemId + "/" + insure + "/1";
|
| 232 |
microAjax(url, function(res) {
|
232 |
microAjax(url, function(res) {
|
| 233 |
var data = JSON.parse(res);
|
233 |
var data = JSON.parse(res);
|
| 234 |
data = data.status;
|
234 |
data = data.status;
|
| 235 |
if (data == true) {
|
235 |
if (data == true) {
|
| 236 |
document.getElementById(tnc).checked = false;
|
236 |
document.getElementById(tnc).checked = false;
|
| 237 |
document.getElementById(tc).style.display = "none";
|
237 |
document.getElementById(tc).style.display = "none";
|
| 238 |
}
|
238 |
}
|
| 239 |
if (data == false) {
|
239 |
if (data == false) {
|
| 240 |
alert(data);
|
240 |
alert(data);
|
| 241 |
}
|
241 |
}
|
| 242 |
});
|
242 |
});
|
| 243 |
}
|
243 |
}
|
| 244 |
}
|
244 |
}
|
| 245 |
}
|
245 |
}
|
| 246 |
}
|
246 |
}
|
| 247 |
}
|
247 |
}
|
| 248 |
|
248 |
|
| 249 |
function dataprotection(e) {
|
249 |
function dataprotection(e) {
|
| 250 |
var id = e.currentTarget.id;
|
250 |
var id = e.currentTarget.id;
|
| 251 |
var protection = document.getElementById(id).checked;
|
251 |
var protection = document.getElementById(id).checked;
|
| 252 |
var itemId = e.currentTarget.getAttribute("data-value");
|
252 |
var itemId = e.currentTarget.getAttribute("data-value");
|
| 253 |
var url = base_url + "cart/insure/" + itemId + "/" + protection + "/2";
|
253 |
var url = base_url + "cart/insure/" + itemId + "/" + protection + "/2";
|
| 254 |
microAjax(url, function(res) {
|
254 |
microAjax(url, function(res) {
|
| 255 |
var data = JSON.parse(res);
|
255 |
var data = JSON.parse(res);
|
| 256 |
data = data.status;
|
256 |
data = data.status;
|
| 257 |
if (data == true) {
|
257 |
if (data == true) {
|
| 258 |
}
|
258 |
}
|
| 259 |
if (data == false) {
|
259 |
if (data == false) {
|
| 260 |
}
|
260 |
}
|
| 261 |
});
|
261 |
});
|
| 262 |
}
|
262 |
}
|
| 263 |
|
263 |
|
| 264 |
function checkout() {
|
264 |
function checkout() {
|
| 265 |
var chx = document.getElementsByClassName("checkbox");
|
265 |
var chx = document.getElementsByClassName("checkbox");
|
| 266 |
for (var i = 0; i < chx.length; i++) {
|
266 |
for (var i = 0; i < chx.length; i++) {
|
| 267 |
if (chx[i].type == "checkbox" && chx[i].checked) {
|
267 |
if (chx[i].type == "checkbox" && chx[i].checked) {
|
| 268 |
var id = chx[i].getAttribute("data-value");
|
268 |
var id = chx[i].getAttribute("data-value");
|
| 269 |
var tnc = id + "tnc";
|
269 |
var tnc = id + "tnc";
|
| 270 |
if (document.getElementById(tnc).checked == false) {
|
270 |
if (document.getElementById(tnc).checked == false) {
|
| 271 |
if ( typeof _gaq != "undefined" && _gaq != null) {
|
271 |
if ( typeof _gaq != "undefined" && _gaq != null) {
|
| 272 |
_gaq.push(["_trackEvent", "Insurance", "Alert for tnc"]);
|
272 |
_gaq.push(["_trackEvent", "Insurance", "Alert for tnc"]);
|
| 273 |
}
|
273 |
}
|
| 274 |
document.getElementById("error").style.display = "block";
|
274 |
document.getElementById("error").style.display = "block";
|
| 275 |
document.getElementById("error").innerHTML = "Please agree to the terms and conditions to get insurance";
|
275 |
document.getElementById("error").innerHTML = "Please agree to the terms and conditions to get insurance";
|
| 276 |
window.scrollTo(0, 0);
|
276 |
window.scrollTo(0, 0);
|
| 277 |
return false;
|
277 |
return false;
|
| 278 |
break;
|
278 |
break;
|
| 279 |
}
|
279 |
}
|
| 280 |
}
|
280 |
}
|
| 281 |
}
|
281 |
}
|
| 282 |
if (locationServicable == false) {
|
282 |
if (locationServicable == false) {
|
| 283 |
var pincode = document.getElementById("pincode").value;
|
283 |
var pincode = document.getElementById("pincode").value;
|
| 284 |
if ( typeof _gaq != "undefined" && _gaq != null) {
|
284 |
if ( typeof _gaq != "undefined" && _gaq != null) {
|
| 285 |
_gaq.push(["_trackEvent", "Cart", "Location not serviceable", pincode]);
|
285 |
_gaq.push(["_trackEvent", "Cart", "Location not serviceable", pincode]);
|
| 286 |
}
|
286 |
}
|
| 287 |
document.getElementById("error").style.display = "block";
|
287 |
document.getElementById("error").style.display = "block";
|
| 288 |
if (itemsNotServicable == items.length) {
|
288 |
if (itemsNotServicable == items.length) {
|
| 289 |
document.getElementById("error").innerHTML = "Location not serviceable. Please try a different pincode";
|
289 |
document.getElementById("error").innerHTML = "Location not serviceable. Please try a different pincode";
|
| 290 |
} else {
|
290 |
} else {
|
| 291 |
if (itemsNotServicable != items.length) {
|
291 |
if (itemsNotServicable != items.length) {
|
| 292 |
document.getElementById("error").innerHTML = "Location not serviceable for one of the products. Please try a different pincode or try removing the product";
|
292 |
document.getElementById("error").innerHTML = "Location not serviceable for one of the products. Please try a different pincode or try removing the product";
|
| 293 |
}
|
293 |
}
|
| 294 |
}
|
294 |
}
|
| 295 |
window.scrollTo(0, 0);
|
295 |
window.scrollTo(0, 0);
|
| 296 |
return false;
|
296 |
return false;
|
| 297 |
}
|
297 |
}
|
| 298 |
if ((notServiceableLocation != undefined) && (notServiceableLocation != 0)) {
|
298 |
if ((notServiceableLocation != undefined) && (notServiceableLocation != 0)) {
|
| 299 |
var pincode = document.getElementById("pincode").value;
|
299 |
var pincode = document.getElementById("pincode").value;
|
| 300 |
if ( typeof _gaq != "undefined" && _gaq != null) {
|
300 |
if ( typeof _gaq != "undefined" && _gaq != null) {
|
| 301 |
_gaq.push(["_trackEvent", "Cart", "Location not serviceable", pincode]);
|
301 |
_gaq.push(["_trackEvent", "Cart", "Location not serviceable", pincode]);
|
| 302 |
}
|
302 |
}
|
| 303 |
document.getElementById("error").style.display = "block";
|
303 |
document.getElementById("error").style.display = "block";
|
| 304 |
if (notServiceableLocation == items.length) {
|
304 |
if (notServiceableLocation == items.length) {
|
| 305 |
document.getElementById("error").innerHTML = "Location not serviceable. Please try a different pincode";
|
305 |
document.getElementById("error").innerHTML = "Location not serviceable. Please try a different pincode";
|
| 306 |
} else {
|
306 |
} else {
|
| 307 |
if (notServiceableLocation != items.length) {
|
307 |
if (notServiceableLocation != items.length) {
|
| 308 |
document.getElementById("error").innerHTML = "Location not serviceable for one of the products. Please try a different pincode or try removing the product";
|
308 |
document.getElementById("error").innerHTML = "Location not serviceable for one of the products. Please try a different pincode or try removing the product";
|
| 309 |
}
|
309 |
}
|
| 310 |
}
|
310 |
}
|
| 311 |
window.scrollTo(0, 0);
|
311 |
window.scrollTo(0, 0);
|
| 312 |
return false;
|
312 |
return false;
|
| 313 |
}
|
313 |
}
|
| 314 |
window.location.href = base_url + "shipping";
|
314 |
window.location.href = base_url + "shipping";
|
| 315 |
}
|
315 |
}
|
| 316 |
|
316 |
|
| 317 |
var j = 0;
|
317 |
var j = 0;
|
| 318 |
var locationServicable;
|
318 |
var locationServicable;
|
| 319 |
var itemsNotServicable = 0;
|
319 |
var itemsNotServicable = 0;
|
| 320 |
function checkShipping() {
|
320 |
function checkShipping() {
|
| 321 |
if (j != 0) {
|
321 |
if (j != 0) {
|
| 322 |
j = 0;
|
322 |
j = 0;
|
| 323 |
}
|
323 |
}
|
| 324 |
if (itemsNotServicable != 0) {
|
324 |
if (itemsNotServicable != 0) {
|
| 325 |
itemsNotServicable = 0;
|
325 |
itemsNotServicable = 0;
|
| 326 |
}
|
326 |
}
|
| 327 |
var pincode = document.getElementById("pincode").value;
|
327 |
var pincode = document.getElementById("pincode").value;
|
| 328 |
pincode = pincode.trim();
|
328 |
pincode = pincode.trim();
|
| 329 |
if (/^\d+$/.test(pincode) && pincode.length == 6) {
|
329 |
if (/^\d+$/.test(pincode) && pincode.length == 6) {
|
| 330 |
if (document.getElementById("error")) {
|
330 |
if (document.getElementById("error")) {
|
| 331 |
document.getElementById("error").style.display = "none";
|
331 |
document.getElementById("error").style.display = "none";
|
| 332 |
}
|
332 |
}
|
| 333 |
for ( i = 0; i < items.length; i++) {
|
333 |
for ( i = 0; i < items.length; i++) {
|
| 334 |
itemId = items[i].id;
|
334 |
itemId = items[i].id;
|
| 335 |
var url = base_url + "productinfo/getDeliveryDetails/" + itemId + "/" + pincode;
|
335 |
var url = base_url + "productinfo/getDeliveryDetails/" + itemId + "/" + pincode;
|
| 336 |
j = i;
|
336 |
j = i;
|
| 337 |
microAjax(url, function(res) {
|
337 |
microAjax(url, function(res) {
|
| 338 |
if (res != "") {
|
338 |
if (res != "") {
|
| 339 |
data = JSON.parse(res);
|
339 |
data = JSON.parse(res);
|
| 340 |
days = data.business_days;
|
340 |
days = data.business_days;
|
| 341 |
if (days >= 0) {
|
341 |
if (days >= 0) {
|
| 342 |
locationServicable = true;
|
342 |
locationServicable = true;
|
| 343 |
var service = items[j].id + "service";
|
343 |
var service = items[j].id + "service";
|
| 344 |
document.getElementById(service).style.display = "none";
|
344 |
document.getElementById(service).style.display = "none";
|
| 345 |
var delivery = items[j].id + "delivery";
|
345 |
var delivery = items[j].id + "delivery";
|
| 346 |
if (document.getElementById(delivery)) {
|
346 |
if (document.getElementById(delivery)) {
|
| 347 |
document.getElementById(delivery).style.display = "block";
|
347 |
document.getElementById(delivery).style.display = "block";
|
| 348 |
var del = items[j].id + "del";
|
348 |
var del = items[j].id + "del";
|
| 349 |
document.getElementById(del).innerHTML = data.delivery_estimate;
|
349 |
document.getElementById(del).innerHTML = data.delivery_estimate;
|
| 350 |
}
|
350 |
}
|
| 351 |
if (data.is_cod_available_for_location == true) {
|
351 |
if (data.is_cod_available_for_location == true) {
|
| 352 |
var cod = items[j].id + "cod";
|
352 |
var cod = items[j].id + "cod";
|
| 353 |
if (document.getElementById(cod).style.display == "none") {
|
353 |
if (document.getElementById(cod).style.display == "none") {
|
| 354 |
document.getElementById(cod).style.display = "block";
|
354 |
document.getElementById(cod).style.display = "block";
|
| 355 |
}
|
355 |
}
|
| 356 |
}
|
356 |
}
|
| 357 |
if (data.on_time_guarantee == true) {
|
357 |
if (data.on_time_guarantee == true) {
|
| 358 |
var otg = items[j].id + "otg";
|
358 |
var otg = items[j].id + "otg";
|
| 359 |
if (document.getElementById(otg).style.display == "none") {
|
359 |
if (document.getElementById(otg).style.display == "none") {
|
| 360 |
document.getElementById(otg).style.display = "block";
|
360 |
document.getElementById(otg).style.display = "block";
|
| 361 |
}
|
361 |
}
|
| 362 |
}
|
362 |
}
|
| 363 |
} else {
|
363 |
} else {
|
| 364 |
var del = items[j].id + "delivery";
|
364 |
var del = items[j].id + "delivery";
|
| 365 |
document.getElementById(del).style.display = "none";
|
365 |
document.getElementById(del).style.display = "none";
|
| 366 |
var cod = items[j].id + "cod";
|
366 |
var cod = items[j].id + "cod";
|
| 367 |
document.getElementById(cod).style.display = "none";
|
367 |
document.getElementById(cod).style.display = "none";
|
| 368 |
var otg = items[j].id + "otg";
|
368 |
var otg = items[j].id + "otg";
|
| 369 |
document.getElementById(otg).style.display = "none";
|
369 |
document.getElementById(otg).style.display = "none";
|
| 370 |
var service = items[j].id + "service";
|
370 |
var service = items[j].id + "service";
|
| 371 |
document.getElementById(service).style.display = "block";
|
371 |
document.getElementById(service).style.display = "block";
|
| 372 |
document.getElementById(service).innerHTML = "Location is not serviceable";
|
372 |
document.getElementById(service).innerHTML = "Location is not serviceable";
|
| 373 |
locationServicable = false;
|
373 |
locationServicable = false;
|
| 374 |
itemsNotServicable++;
|
374 |
itemsNotServicable++;
|
| 375 |
}
|
375 |
}
|
| 376 |
j--;
|
376 |
j--;
|
| 377 |
}
|
377 |
}
|
| 378 |
});
|
378 |
});
|
| 379 |
}
|
379 |
}
|
| 380 |
} else {
|
380 |
} else {
|
| 381 |
document.getElementById("error").style.display = "block";
|
381 |
document.getElementById("error").style.display = "block";
|
| 382 |
document.getElementById("error").innerHTML = "Invalid pincode!";
|
382 |
document.getElementById("error").innerHTML = "Invalid pincode!";
|
| 383 |
}
|
383 |
}
|
| 384 |
}
|
384 |
}
|
| 385 |
|
385 |
|
| 386 |
function shomoreredirect() {
|
386 |
function shomoreredirect() {
|
| 387 |
window.location.href = base_url;
|
387 |
window.location.href = base_url;
|
| 388 |
}
|
388 |
}
|