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