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