Subversion Repositories SmartDukaan

Rev

Rev 10838 | Rev 11063 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 10838 Rev 10953
Line 209... Line 209...
209
    document.getElementById(Id).className += ' selected';
209
    document.getElementById(Id).className += ' selected';
210
    document.getElementById(Id).children[0].innerHTML = '-';
210
    document.getElementById(Id).children[0].innerHTML = '-';
211
    e.currentTarget.nextElementSibling.style.display = 'block';
211
    e.currentTarget.nextElementSibling.style.display = 'block';
212
    //document.getElementById(Id).style.display = 'block';
212
    //document.getElementById(Id).style.display = 'block';
213
    defaultPayment = e.currentTarget;
213
    defaultPayment = e.currentTarget;
-
 
214
    if(typeof _gaq != "undefined" && _gaq != null)  {
214
    ga('send', 'event', 'Payment Option', 'Payment option tab clicked',title);
215
      _gaq.push(['_trackEvent', 'Payment Option', 'Payment option tab clicked',title]);
-
 
216
    }
215
  }
217
  }
216
}
218
}
217
if(typeof bankInfo != 'undefined'){
219
if(typeof bankInfo != 'undefined'){
218
var defaultBank = bankInfo.Id;
220
var defaultBank = bankInfo.Id;
219
}
221
}
Line 226... Line 228...
226
  document.getElementById('pay-emi').value = payOption;
228
  document.getElementById('pay-emi').value = payOption;
227
  defaultBank = Id;
229
  defaultBank = Id;
228
  var id = e.currentTarget.id;
230
  var id = e.currentTarget.id;
229
  var a = document.getElementById(id);
231
  var a = document.getElementById(id);
230
  var bankName = a.options[a.selectedIndex].text;
232
  var bankName = a.options[a.selectedIndex].text;
-
 
233
  if(typeof _gaq != "undefined" && _gaq != null)  {
231
  ga('send', 'event', 'EMI', 'Bank Selection',bankName);
234
      _gaq.push(['_trackEvent', 'EMI', 'Bank Selection',bankName]);
-
 
235
    }
232
}
236
}
233
function changePay(e){
237
function changePay(e){
234
  debugger;
238
  debugger;
235
  var Id = e.currentTarget.id;
239
  var Id = e.currentTarget.id;
236
  var payOption = document.getElementById('pay-emi').value;
240
  var payOption = document.getElementById('pay-emi').value;
Line 238... Line 242...
238
  document.getElementById(Id).className += ' selected';
242
  document.getElementById(Id).className += ' selected';
239
  document.getElementById('pay-emi').value = Id;
243
  document.getElementById('pay-emi').value = Id;
240
  var bankName = e.currentTarget.getAttribute('data-bank');
244
  var bankName = e.currentTarget.getAttribute('data-bank');
241
  var tenure = e.currentTarget.getAttribute('data-tenure');
245
  var tenure = e.currentTarget.getAttribute('data-tenure');
242
  bankName = bankName+'-'+tenure;
246
  bankName = bankName+'-'+tenure;
-
 
247
  if(typeof _gaq != "undefined" && _gaq != null)  {
243
  ga('send', 'event', 'EMI', 'Plan Selection',bankName);
248
      _gaq.push(['_trackEvent', 'EMI', 'Plan Selection',bankName]);
-
 
249
    }
244
}
250
}
245
var netBanking;
251
var netBanking;
246
function changeNetBanking(e){
252
function changeNetBanking(e){
247
  debugger;
253
  debugger;
248
  var Id;
254
  var Id;
Line 259... Line 265...
259
  }
265
  }
260
  document.getElementById('pay-net').value = Id;
266
  document.getElementById('pay-net').value = Id;
261
  netBanking = Id;
267
  netBanking = Id;
262
  var title = e.currentTarget.getAttribute('data-parent');
268
  var title = e.currentTarget.getAttribute('data-parent');
263
  title = title+'-'+Id;
269
  title = title+'-'+Id;
-
 
270
  if(typeof _gaq != "undefined" && _gaq != null)  {
264
  ga('send', 'event', 'Payment Option', 'Payment option tab-payotion selected',title);
271
      _gaq.push(['_trackEvent', 'Payment Option', 'Payment option tab-payoption selected',title]);
-
 
272
    }
265
}
273
}
266
function changeCountry(e){
274
function changeCountry(e){
267
  debugger;
275
  debugger;
268
  var Id = e.currentTarget.id;
276
  var Id = e.currentTarget.id;
269
  if(Id == 'india'){
277
  if(Id == 'india'){
Line 292... Line 300...
292
  }
300
  }
293
  document.getElementById('pay-credit').value = Id;
301
  document.getElementById('pay-credit').value = Id;
294
  previousCard = Id;
302
  previousCard = Id;
295
  var title = e.currentTarget.getAttribute('data-parent');
303
  var title = e.currentTarget.getAttribute('data-parent');
296
  title = title+'-'+Id;
304
  title = title+'-'+Id;
-
 
305
  if(typeof _gaq != "undefined" && _gaq != null)  {
297
  ga('send', 'event', 'Payment Option', 'Payment option tab-payotion selected',title);
306
      _gaq.push(['_trackEvent', 'Payment Option', 'Payment option tab-payoption selected',title]);
-
 
307
    }
298
}
308
}
299
var previousDebit;
309
var previousDebit;
300
function selectDebitCard(e){
310
function selectDebitCard(e){
301
  debugger;
311
  debugger;
302
  var Id = e.currentTarget.id;
312
  var Id = e.currentTarget.id;
Line 309... Line 319...
309
  }
319
  }
310
  document.getElementById('pay-debit').value = Id;
320
  document.getElementById('pay-debit').value = Id;
311
  previousDebit = Id;
321
  previousDebit = Id;
312
  var title = e.currentTarget.getAttribute('data-parent');
322
  var title = e.currentTarget.getAttribute('data-parent');
313
  title = title+'-'+Id;
323
  title = title+'-'+Id;
-
 
324
  if(typeof _gaq != "undefined" && _gaq != null)  {
314
  ga('send', 'event', 'Payment Option', 'Payment option tab-payoption selected',title);
325
      _gaq.push(['_trackEvent', 'Payment Option', 'Payment option tab-payoption selected',title]);
-
 
326
    }
315
}
327
}
316
var previousCC;
328
var previousCC;
317
function selectCashCard(e){
329
function selectCashCard(e){
318
  debugger;
330
  debugger;
319
  var Id = e.currentTarget.id;
331
  var Id = e.currentTarget.id;
Line 326... Line 338...
326
  }
338
  }
327
  document.getElementById('pay-cc').value = Id;
339
  document.getElementById('pay-cc').value = Id;
328
  previousCC = Id;
340
  previousCC = Id;
329
  var title = e.currentTarget.getAttribute('data-parent');
341
  var title = e.currentTarget.getAttribute('data-parent');
330
  title = title+'-'+Id;
342
  title = title+'-'+Id;
-
 
343
  if(typeof _gaq != "undefined" && _gaq != null)  {
331
  ga('send', 'event', 'Payment Option', 'Payment option tab-payoption selected',title);
344
      _gaq.push(['_trackEvent', 'Payment Option', 'Payment option tab-payoption selected',title]);
-
 
345
    }
332
}
346
}
333
// function changeCaptcha(){
347
// function changeCaptcha(){
334
//   var url = base_url+'checkout/changeCaptcha';
348
//   var url = base_url+'checkout/changeCaptcha';
335
//     microAjax(url, function (res) {
349
//     microAjax(url, function (res) {
336
//         debugger;
350
//         debugger;
Line 382... Line 396...
382
  for(i=0;i<currentStore.length;i++){
396
  for(i=0;i<currentStore.length;i++){
383
    storeAddress +='<div class="pickup-spot" id="'+currentStore[i].id+'" data-key="'+currentStore[i].hotspotId+'" onclick=selectStore(event)><div>'+currentStore[i].name+'</div><div>'+currentStore[i].line1+'</div><div>'+currentStore[i].line2+'</div><div>'+currentStore[i].city+'</div><div>'+currentStore[i].state+'</div><div>Pin: '+currentStore[i].pin+'</div><div>Phone: '+currentStore[i].phone+'</div></div>'; 
397
    storeAddress +='<div class="pickup-spot" id="'+currentStore[i].id+'" data-key="'+currentStore[i].hotspotId+'" onclick=selectStore(event)><div>'+currentStore[i].name+'</div><div>'+currentStore[i].line1+'</div><div>'+currentStore[i].line2+'</div><div>'+currentStore[i].city+'</div><div>'+currentStore[i].state+'</div><div>Pin: '+currentStore[i].pin+'</div><div>Phone: '+currentStore[i].phone+'</div></div>'; 
384
  }
398
  }
385
 document.getElementById('appendData').innerHTML = storeAddress;
399
 document.getElementById('appendData').innerHTML = storeAddress;
386
 prevZone = value;
400
 prevZone = value;
-
 
401
 if(typeof _gaq != "undefined" && _gaq != null)  {
387
 ga('send', 'event', 'InStore Pickup Region', 'Store Zone',value);
402
      _gaq.push(['_trackEvent', 'InStore Pickup Region', 'Store Zone',value]);
-
 
403
    }
388
 }
404
 }
389
}
405
}
390
var shopId;
406
var shopId;
391
var inStoreDelivery;
407
var inStoreDelivery;
392
function selectStore(e){
408
function selectStore(e){
Line 497... Line 513...
497
  });
513
  });
498
  }
514
  }
499
  if(type == 2){
515
  if(type == 2){
500
    if(pickupStore == true){
516
    if(pickupStore == true){
501
    if(inStoreDelivery == true){
517
    if(inStoreDelivery == true){
-
 
518
      if(typeof _gaq != "undefined" && _gaq != null)  {
502
      ga('send','event','Delivery Type','In-Store Pickup');
519
      _gaq.push(['_trackEvent', 'Delivery Type','In-Store Pickup']);
-
 
520
    }
503
    }else if(inStoreDelivery == false){
521
    }else if(inStoreDelivery == false){
504
      document.getElementById('error').style.display = "block";
522
      document.getElementById('error').style.display = "block";
505
      document.getElementById('error').innerHTML ="Please select a delivery store!" ;
523
      document.getElementById('error').innerHTML ="Please select a delivery store!" ;
506
      return false;
524
      return false;
507
    }
525
    }
508
  }else{
526
  }else{
-
 
527
      if(typeof _gaq != "undefined" && _gaq != null)  {
509
      ga('send','event','Delivery Type','Deliver to address');
528
      _gaq.push(['_trackEvent', 'Delivery Type','Deliver to address']);
-
 
529
    }
-
 
530
    }
-
 
531
    if(typeof _gaq != "undefined" && _gaq != null)  {
-
 
532
      _gaq.push(['_trackEvent', 'Order','Proceed To Pay']);
510
    }
533
    }
511
    ga('send','event','Order','Proceed To Pay');
-
 
512
    if(locationServiceable == false){
534
    if(locationServiceable == false){
513
      document.getElementById('error').style.display = "block";
535
      document.getElementById('error').style.display = "block";
514
      document.getElementById('error').innerHTML ='Location not serviceable. Please specify a different address';
536
      document.getElementById('error').innerHTML ='Location not serviceable. Please specify a different address';
515
      return false;
537
      return false;
516
    }
538
    }
517
    window.location.href = base_url+'payment';
539
    window.location.href = base_url+'payment';
518
  }
540
  }
519
}else{
541
}else{
520
  if(pickupStore == true){
542
  if(pickupStore == true){
521
    if(inStoreDelivery == true){
543
    if(inStoreDelivery == true){
-
 
544
      if(typeof _gaq != "undefined" && _gaq != null)  {
522
      ga('send','event','Delivery Type','In-Store Pickup');
545
      _gaq.push(['_trackEvent', 'Delivery Type','In-Store Pickup']);
-
 
546
    }
523
    }else if(inStoreDelivery == false){
547
    }else if(inStoreDelivery == false){
524
      document.getElementById('error').style.display = "block";
548
      document.getElementById('error').style.display = "block";
525
      document.getElementById('error').innerHTML ="Please select a delivery store!" ;
549
      document.getElementById('error').innerHTML ="Please select a delivery store!" ;
526
      return false;
550
      return false;
527
    }
551
    }
528
  }else{
552
  }else{
-
 
553
      if(typeof _gaq != "undefined" && _gaq != null)  {
529
      ga('send','event','Delivery Type','Deliver to address');
554
      _gaq.push(['_trackEvent', 'Delivery Type','Deliver to address']);
-
 
555
    }
-
 
556
    }
-
 
557
    if(typeof _gaq != "undefined" && _gaq != null)  {
-
 
558
      _gaq.push(['_trackEvent', 'Order','Proceed To Pay']);
530
    }
559
    }
531
    ga('send','event','Order','Proceed To Pay');
-
 
532
    if(locationServiceable == false){
560
    if(locationServiceable == false){
533
      document.getElementById('error').style.display = "block";
561
      document.getElementById('error').style.display = "block";
534
      document.getElementById('error').innerHTML ='Location not serviceable. Please specify a different address';
562
      document.getElementById('error').innerHTML ='Location not serviceable. Please specify a different address';
535
      return false;
563
      return false;
536
    }
564
    }
Line 545... Line 573...
545
      document.getElementById('error').style.display = "block";
573
      document.getElementById('error').style.display = "block";
546
          document.getElementById('error').innerHTML ='Please select payment method!';
574
          document.getElementById('error').innerHTML ='Please select payment method!';
547
          window.scrollTo(0,0); return false;
575
          window.scrollTo(0,0); return false;
548
    }
576
    }
549
    var paymentTitle = e.currentTarget.getAttribute('data-key');
577
    var paymentTitle = e.currentTarget.getAttribute('data-key');
-
 
578
    if(typeof _gaq != "undefined" && _gaq != null)  {
550
    ga('send', 'event', 'Payment Option', 'Form Submission',paymentTitle);
579
      _gaq.push(['_trackEvent', 'Payment Option', 'Form Submission',paymentTitle]);
-
 
580
    }
551
 
581
 
552
  }else if(Id == 'debitcard'){
582
  }else if(Id == 'debitcard'){
553
    if(previousDebit == undefined){
583
    if(previousDebit == undefined){
554
      document.getElementById('error').style.display = "block";
584
      document.getElementById('error').style.display = "block";
555
          document.getElementById('error').innerHTML ='Please select payment method!';
585
          document.getElementById('error').innerHTML ='Please select payment method!';
556
          window.scrollTo(0,0); return false;
586
          window.scrollTo(0,0); return false;
557
    }
587
    }
558
    var paymentTitle = e.currentTarget.getAttribute('data-key');
588
    var paymentTitle = e.currentTarget.getAttribute('data-key');
-
 
589
    if(typeof _gaq != "undefined" && _gaq != null)  {
559
    ga('send', 'event', 'Payment Option', 'Form Submission',paymentTitle);
590
      _gaq.push(['_trackEvent', 'Payment Option', 'Form Submission',paymentTitle]);
-
 
591
    }
560
  }else if(Id == 'netbanking'){
592
  }else if(Id == 'netbanking'){
561
    var payOption = document.getElementById('pay-net').value;
593
    var payOption = document.getElementById('pay-net').value;
562
    if(payOption == undefined || payOption ==""){
594
    if(payOption == undefined || payOption ==""){
563
      document.getElementById('error').style.display = "block";
595
      document.getElementById('error').style.display = "block";
564
          document.getElementById('error').innerHTML ='Please select payment method!';
596
          document.getElementById('error').innerHTML ='Please select payment method!';
565
          window.scrollTo(0,0); return false;
597
          window.scrollTo(0,0); return false;
566
    }
598
    }
567
    var paymentTitle = e.currentTarget.getAttribute('data-key');
599
    var paymentTitle = e.currentTarget.getAttribute('data-key');
-
 
600
    if(typeof _gaq != "undefined" && _gaq != null)  {
568
    ga('send', 'event', 'Payment Option', 'Form Submission',paymentTitle);
601
      _gaq.push(['_trackEvent', 'Payment Option', 'Form Submission',paymentTitle]);
-
 
602
    }
569
  }else if(Id == 'cashcards'){
603
  }else if(Id == 'cashcards'){
570
    if(previousCC == undefined){
604
    if(previousCC == undefined){
571
      document.getElementById('error').style.display = "block";
605
      document.getElementById('error').style.display = "block";
572
          document.getElementById('error').innerHTML ='Please select payment method!';
606
          document.getElementById('error').innerHTML ='Please select payment method!';
573
          window.scrollTo(0,0); return false;
607
          window.scrollTo(0,0); return false;
574
    }
608
    }
575
    var paymentTitle = e.currentTarget.getAttribute('data-key');
609
    var paymentTitle = e.currentTarget.getAttribute('data-key');
-
 
610
    if(typeof _gaq != "undefined" && _gaq != null)  {
576
    ga('send', 'event', 'Payment Option', 'Form Submission',paymentTitle);
611
      _gaq.push(['_trackEvent', 'Payment Option', 'Form Submission',paymentTitle]);
-
 
612
    }
577
  }else if(Id == 'emiform'){
613
  }else if(Id == 'emiform'){
578
    var payOption = document.getElementById('pay-emi').value;
614
    var payOption = document.getElementById('pay-emi').value;
579
    if(payOption == undefined || payOption ==""){
615
    if(payOption == undefined || payOption ==""){
580
      document.getElementById('error').style.display = "block";
616
      document.getElementById('error').style.display = "block";
581
          document.getElementById('error').innerHTML ='Please select payment method!';
617
          document.getElementById('error').innerHTML ='Please select payment method!';
582
          window.scrollTo(0,0); return false;
618
          window.scrollTo(0,0); return false;
583
    }
619
    }
584
    var paymentTitle = e.currentTarget.getAttribute('data-key');
620
    var paymentTitle = e.currentTarget.getAttribute('data-key');
-
 
621
    if(typeof _gaq != "undefined" && _gaq != null)  {
585
    ga('send', 'event', 'Payment Option', 'Form Submission',paymentTitle);
622
      _gaq.push(['_trackEvent', 'Payment Option', 'Form Submission',paymentTitle]);
-
 
623
    }
586
  }else if(Id == 'cod'){
624
  }else if(Id == 'cod'){
587
        if(document.getElementById('captcha_response_box').value == ''){
625
        if(document.getElementById('captcha_response_box').value == ''){
588
        // document.forms['recharge-confirm'].submit();
626
        // document.forms['recharge-confirm'].submit();
589
      // }else{
627
      // }else{
590
        var bRed = document.getElementById('captcha_response_box');
628
        var bRed = document.getElementById('captcha_response_box');
Line 597... Line 635...
597
          bRed.value = '';
635
          bRed.value = '';
598
        },3000);
636
        },3000);
599
        return false;
637
        return false;
600
      }
638
      }
601
    var paymentTitle = e.currentTarget.getAttribute('data-key');
639
    var paymentTitle = e.currentTarget.getAttribute('data-key');
-
 
640
    if(typeof _gaq != "undefined" && _gaq != null)  {
602
    ga('send', 'event', 'Payment Option', 'Form Submission',paymentTitle);
641
      _gaq.push(['_trackEvent', 'Payment Option', 'Form Submission',paymentTitle]);
-
 
642
    }
603
  }else if(Id == 'zod'){
643
  }else if(Id == 'zod'){
604
        if(document.getElementById('captcha_response_box').value == ''){
644
        if(document.getElementById('captcha_response_box').value == ''){
605
        // document.forms['recharge-confirm'].submit();
645
        // document.forms['recharge-confirm'].submit();
606
      // }else{
646
      // }else{
607
        var bRed = document.getElementById('captcha_response_box');
647
        var bRed = document.getElementById('captcha_response_box');
Line 614... Line 654...
614
          bRed.value = '';
654
          bRed.value = '';
615
        },3000);
655
        },3000);
616
        return false;
656
        return false;
617
      }
657
      }
618
    var paymentTitle = e.currentTarget.getAttribute('data-key');
658
    var paymentTitle = e.currentTarget.getAttribute('data-key');
-
 
659
    if(typeof _gaq != "undefined" && _gaq != null)  {
619
    ga('send', 'event', 'Payment Option', 'Form Submission',paymentTitle);
660
      _gaq.push(['_trackEvent', 'Payment Option', 'Form Submission',paymentTitle]);
-
 
661
    }
620
  }
662
  }
621
}
663
}
622
var url;
664
var url;
623
 url = document.URL;
665
 url = document.URL;
624
 if(url.indexOf('pay-success') != -1){
666
 if(url.indexOf('pay-success') != -1){
625
  if(orderConfirmation != undefined){
667
  if(orderConfirmation != undefined){
626
    debugger;
668
    debugger;
627
    ga('require', 'ecommerce', 'ecommerce.js');
-
 
628
    var orders = orderConfirmation['result']['orders'];
669
    var orders = orderConfirmation['result']['orders'];
629
    for(i=0;i<orders.length;i++){
670
    for(i=0;i<orders.length;i++){
630
      debugger
671
      debugger
631
      var amount = orders[i].totalAmount.replace(',','');
672
      var amount = orders[i].totalAmount.replace(',','');
632
      amount = parseFloat(amount).toFixed(2);
673
      amount = parseFloat(amount).toFixed(2);
633
      var orderId = orders[i].orderId;
674
      var orderId = orders[i].orderId;
634
      ga('ecommerce:addTransaction', {
675
      _gaq.push(['_addTrans',
635
        'id': orderId,                     // Transaction ID. Required.
676
          orderId,                     // Transaction ID. Required.
636
        'affiliation': 'shop2020',   // Affiliation or store name.
677
          'shop2020',   // Affiliation or store name.
637
        'revenue': amount,               // Grand Total.
678
          amount,               // Grand Total.
638
        'shipping': '0',                  // Shipping.
679
          '0',                  // Shipping.
639
        'tax': '0',                     // Tax.
680
          '0',                     // Tax.
640
        'city':"",
681
          "",
641
        'state':"",
682
          "",
642
        'country':"India"
683
          "India"
643
      });
684
      ]);
644
      ga('ecommerce:addItem', {
685
      _gaq.push(['_addItem',
645
        'id': orderId,                     // Transaction ID. Required.
686
          orderId,                     // Transaction ID. Required.
646
        'name': orders[i].itemName,    // Product name. Required.
687
          orders[i].itemName,    // Product name. Required.
647
        'sku': orders[i].itemName,                 // SKU/code.
688
          orders[i].itemName,                 // SKU/code.
648
        'category': 'Physical',         // Category or variation.
689
          'Physical',         // Category or variation.
649
        'price': amount,                 // Unit price.
690
          amount,                 // Unit price.
650
        'quantity': orders[i].quantity                   // Quantity.
691
          orders[i].quantity                   // Quantity.
651
      });
692
      ]);
652
    }
693
    }
653
    ga('ecommerce:send');
694
    _gaq.push(['_trackTrans']); //submits transaction to the Analytics servers
654
  }
695
  }
655
 }
696
 }