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