Subversion Repositories SmartDukaan

Rev

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

Rev 18702 Rev 18718
Line 539... Line 539...
539
    }
539
    }
540
        
540
        
541
});
541
});
542
 
542
 
543
$(document).on('submit', '#form2', function(e){
543
$(document).on('submit', '#form2', function(e){
-
 
544
	var address_id = $('p#confirmOrderText').attr('addressId');
544
    var payOption = $("input[type=submit][clicked=true]").data('name');
545
	var payOption = $("input[type=submit][clicked=true]").data('name');
-
 
546
	if(address_id!=''){
-
 
547
		if(payOption=='codoption'){
-
 
548
			handleConfirmOrder(payOption,address_id);
-
 
549
		}else if(payOption=='creditoption'){
-
 
550
			handleConfirmOrder(payOption,address_id);
-
 
551
		}
-
 
552
		return false;
-
 
553
	}else{
545
    var formData = {
554
		var formData = {
546
        'name'              : $('#name').val(),
555
		        'name'              : $('#name').val(),
547
        'line1'             : $('#line1').val(),
556
		        'line1'             : $('#line1').val(),
548
        'city'              : $('#city').val(),
557
		        'city'              : $('#city').val(),
549
        'phone'             : $('#phone').val(),
558
		        'phone'             : $('#phone').val(),
550
        'state'             : $('#state').val(),
559
		        'state'             : $('#state').val(),
551
        'pin'               : $('#pin').val()
560
		        'pin'               : $('#pin').val()
552
    };
561
		    };
-
 
562
		    
553
    $.ajax(
563
		    $.ajax(
554
    {
564
		    {
555
        method: "POST",
565
		        method: "POST",
556
        url:  apihost + "shippings/submitcheck",
566
		        url:  apihost + "shippings/submitcheck",
557
        data: formData,
567
		        data: formData,
558
    },'json')
568
		    },'json')
559
    .done(function(msg){ 
569
		    .done(function(msg){ 
560
        if(msg==''){    
570
		        if(msg==''){    
561
            window.location.replace(apihost + "shippings/index/"+msg);
571
		            window.location.replace(apihost + "shippings/index/"+msg);
562
        } else {
572
		        } else {
563
            if(payOption=='cod'){
573
		            if(payOption=='cod'){
564
                confirmCheckout(msg);
574
		                confirmCheckout(msg);
565
            } else if (payOption=='other_option'){
575
		            } else if (payOption=='other_option'){
566
                confirmPrepaid(msg);
576
		                confirmPrepaid(msg);
-
 
577
		            } else if(payOption=='codoption'){
-
 
578
		    			handleConfirmOrder(payOption,msg);
-
 
579
		    		} else if(payOption=='creditoption'){
-
 
580
		    			handleConfirmOrder(payOption,msg);
567
            }
581
		    		}
568
        }                           
582
		        }                           
569
    });
583
		    });
570
    return false;    
584
		    return false;
-
 
585
	}     
571
 
586
 
572
});
587
});
573
 
588
 
574
function confirmPrepaid(addressid){
589
function confirmPrepaid(addressid){
575
	if (typeof addressid=="undefined"){
590
	if (typeof addressid=="undefined"){
Line 633... Line 648...
633
        'type': 'hidden'
648
        'type': 'hidden'
634
    }));
649
    }));
635
    newForm.submit();
650
    newForm.submit();
636
}
651
}
637
 
652
 
638
function confirmCreditCheckout(){
653
function confirmCreditCheckout(addressid){
639
	if (typeof addressid=="undefined"){
654
	if (typeof addressid=="undefined"){
640
		addressid=$("input.css-checkbox:checked").val();
655
		addressid=$("input.css-checkbox:checked").val();
641
	}
656
	}
642
	if (addressid==undefined || typeof addressid=="undefined"){
657
	if (addressid==undefined || typeof addressid=="undefined"){
643
		$('#loadingModal').modal('hide');
658
		$('#loadingModal').modal('hide');
Line 669... Line 684...
669
        'type': 'hidden'
684
        'type': 'hidden'
670
    }));
685
    }));
671
    newForm.submit();
686
    newForm.submit();
672
}
687
}
673
 
688
 
-
 
689
function handleConfirmOrder(checkoutType, addressId){
-
 
690
	if (typeof addressId=="undefined"){
-
 
691
		addressId=$("input.css-checkbox:checked").val();
-
 
692
	}
-
 
693
	if (addressId==undefined || typeof addressId=="undefined"){
-
 
694
		$('#loadingModal').modal('hide');
-
 
695
		$('#message').empty();
-
 
696
        $('#message').append("Please select an address...");
-
 
697
        $('#message').removeClass('hidden');
-
 
698
        setTimeout(function() {
-
 
699
            $('#message').addClass('hidden');
-
 
700
        }, 2000);
-
 
701
        $('button.confirmcheckout').prop( "disabled", false );
-
 
702
        return;
-
 
703
	}
-
 
704
	$('button.confirmcredit').prop( "disabled", false );
-
 
705
	$('button.confirmcod').prop( "disabled", false );
-
 
706
	window.history.pushState('forward', null, './checkoutAlert');
-
 
707
	$('p#confirmOrderText').html("<span>To Place Order click on Order Now Button.<br> To Change Payment Option click Change Option Button. "
-
 
708
			+"</span><hr style='margin-top: 5px;margin-bottom: 5px;'>"
-
 
709
			+"<span>अभी खरीदने के लिए Order Now बटन पर क्लिक करें।<br>"
-
 
710
			+" भुगतान विकल्प बदलने के लिए Change Option बटन पर क्लिक करें। </span>");
-
 
711
	$('p#confirmOrderText').attr('addressId',addressId);
-
 
712
	$('p#confirmOrderText').attr('checkoutType',checkoutType);
-
 
713
	$('#myModal').modal('show');
-
 
714
	$('#loadingModal').modal('hide');
-
 
715
}
-
 
716
 
-
 
717
$(document).on('click','button#changeOption',function(){
-
 
718
	$('#myModal').modal('hide');
-
 
719
});
-
 
720
 
-
 
721
$(document).on('click','button#orderNow',function(){
-
 
722
	$('#myModal').modal('hide');
-
 
723
	$("#cartloader").removeClass('hidden');
-
 
724
	setTimeout(function () {history.back();}, 5000);
-
 
725
	var checkout_type = $('p#confirmOrderText').attr('checkoutType');
-
 
726
	if(checkout_type=='codoption'){
-
 
727
		var url = apihost + 'checkout/?user_id='+me+'&cod=1';
-
 
728
		var newForm = $('<form>', {
-
 
729
	        'action': url,
-
 
730
	        'method':'post'
-
 
731
	    }).append($('<input>', {
-
 
732
	        'name': 'addressid',
-
 
733
	        'value': $('p#confirmOrderText').attr('addressId'),
-
 
734
	        'type': 'hidden'
-
 
735
	    }));
-
 
736
		history.checkoutForm=newForm;
-
 
737
		setTimeout(function () {history.back();}, 5000);
-
 
738
	}else{
-
 
739
		var url = apihost + 'checkout/?user_id='+me+'&cod=0';
-
 
740
	    var newForm = $('<form>', {
-
 
741
	        'action': url,
-
 
742
	        'method':'post'
-
 
743
	    }).append($('<input>', {
-
 
744
	        'name': 'addressid',
-
 
745
	        'value': $('p#confirmOrderText').attr('addressId'),
-
 
746
	        'type': 'hidden'
-
 
747
	    })).append($('<input>', {
-
 
748
	        'name': 'paymethod',
-
 
749
	        'value': 'cap_float',
-
 
750
	        'type': 'hidden'
-
 
751
	    })).append($('<input>', {
-
 
752
	        'name': 'cart_details',
-
 
753
	        'value': localStorage.getItem('cart_details'),
-
 
754
	        'type': 'hidden'
-
 
755
	    }));
-
 
756
	    history.checkoutForm=newForm;
-
 
757
		setTimeout(function () {history.back();}, 5000);
-
 
758
	}
-
 
759
});
-
 
760
 
674
$(document).on('click','.confirmprepaid', function(){
761
$(document).on('click','.confirmprepaid', function(){
675
	$('.confirmprepaid').addClass('confirmprepaidDisabled').removeClass('confirmprepaid');
762
	$('.confirmprepaid').addClass('confirmprepaidDisabled').removeClass('confirmprepaid');
676
	$('#loadingModal').modal('show');
763
	$('#loadingModal').modal('show');
677
	confirmPrepaid();
764
	confirmPrepaid();
678
});
765
});
Line 682... Line 769...
682
	confirmCheckout();
769
	confirmCheckout();
683
});
770
});
684
$(document).on('click','button.confirmcredit', function(){
771
$(document).on('click','button.confirmcredit', function(){
685
	$('button.confirmcredit').prop( "disabled", true );
772
	$('button.confirmcredit').prop( "disabled", true );
686
	$('#loadingModal').modal('show');
773
	$('#loadingModal').modal('show');
687
	confirmCreditCheckout();
774
	handleConfirmOrder('creditoption');
-
 
775
});
-
 
776
$(document).on('click','button.confirmcod', function(){
-
 
777
	$('button.confirmcod').prop( "disabled", true );
-
 
778
	$('#loadingModal').modal('show');
-
 
779
	handleConfirmOrder('codoption');
688
});
780
});
689
 
-