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