| 794 |
rajveer |
1 |
var totalAmount=0.00;
|
|
|
2 |
$(document).ready(function(){
|
| 801 |
rajveer |
3 |
|
|
|
4 |
changeEstimate();
|
|
|
5 |
|
| 794 |
rajveer |
6 |
$('#cartTable td img.remove-quantitybttn').click(function(){
|
| 801 |
rajveer |
7 |
var prodID = $(this).parent().parent().parent().children().find("span.pro").attr("id");
|
|
|
8 |
window.location.href = "/cart/" + prodID + "?_method=delete" + "&productid="+prodID;
|
| 794 |
rajveer |
9 |
/*
|
|
|
10 |
Put Ajax call here
|
|
|
11 |
To write the way to get itemid to be removed
|
|
|
12 |
alert("Product with id " + prodID + " will be removed.");
|
|
|
13 |
*/
|
| 801 |
rajveer |
14 |
//alert("AJAX request to remove products from Cart. Product ID: " + prodID);
|
|
|
15 |
/*
|
| 794 |
rajveer |
16 |
jQuery.ajax({
|
|
|
17 |
type: "GET",
|
|
|
18 |
url: "/cart/" + prodID + "?_method=delete",
|
|
|
19 |
data: "productid="+prodID,
|
|
|
20 |
success: function(msg){
|
|
|
21 |
//alert( "Data Saved: " + msg );
|
|
|
22 |
if(msg==1){
|
|
|
23 |
// alert( "Deleted the item" );
|
|
|
24 |
}else{
|
|
|
25 |
// alert( "Not able to deleted the item" );
|
|
|
26 |
return;
|
|
|
27 |
}
|
|
|
28 |
window.location.reload();
|
|
|
29 |
}
|
|
|
30 |
});
|
|
|
31 |
var $tr = $(this).parent().parent();
|
|
|
32 |
var index = $tr.parent().children().index($tr);
|
|
|
33 |
$(this).parent().parent().remove();
|
|
|
34 |
var totalAmount=subtractionOfColumns("cartTable", 5, true);
|
|
|
35 |
$("#totalAmount").html(totalAmount);
|
| 801 |
rajveer |
36 |
*/
|
| 794 |
rajveer |
37 |
});
|
|
|
38 |
});
|
| 1190 |
varun.gupt |
39 |
|
|
|
40 |
function changeQty(obj,itempriceID,totalPriceID) {
|
|
|
41 |
var prodID = $(obj).parent().parent().parent().parent().parent().parent().children().find("span.pro").attr("id");
|
|
|
42 |
var quantity = parseInt(obj.value);
|
|
|
43 |
//alert("AJAX request to change product quantity in Cart. Product ID: " + prodID + " quantity: " + quantity);
|
|
|
44 |
|
| 1460 |
varun.gupt |
45 |
if (quantity > 5) {
|
|
|
46 |
alert("You can not order more than 5 pieces of same product.");
|
|
|
47 |
$(obj).focus();
|
|
|
48 |
}
|
|
|
49 |
else {
|
|
|
50 |
jQuery.ajax({
|
|
|
51 |
type: "POST",
|
|
|
52 |
url: "/cart/" + prodID + "?_method=put&productid=" + prodID + "&quantity=" + quantity,
|
|
|
53 |
data: "productid=" + prodID + "&quantity=" + quantity,
|
|
|
54 |
success: function(msg){
|
|
|
55 |
/* if(msg == 1) {
|
|
|
56 |
// alert( "Quantity Updates for the item" );
|
|
|
57 |
} else {
|
|
|
58 |
// alert( "Not able to update the quantity for the item" );
|
|
|
59 |
return;
|
|
|
60 |
}*/
|
|
|
61 |
window.location.reload();
|
|
|
62 |
}
|
|
|
63 |
});
|
|
|
64 |
}
|
|
|
65 |
|
| 1190 |
varun.gupt |
66 |
|
|
|
67 |
// var val=document.getElementById(itempriceID).value;
|
|
|
68 |
// var num = parseFloat(val.replace(/[^\d\.-]/g,''));
|
|
|
69 |
// var qty=parseInt(obj.value);
|
|
|
70 |
// var totalVal1=num*qty;
|
|
|
71 |
// var formated_value = $().number_format(totalVal1, {
|
|
|
72 |
// numberOfDecimals:2,
|
|
|
73 |
// decimalSeparator: '.',
|
|
|
74 |
// thousandSeparator: ',',
|
|
|
75 |
// symbol: 'Rs. '
|
|
|
76 |
// });
|
|
|
77 |
// document.getElementById(totalPriceID).innerHTML=formated_value;
|
|
|
78 |
// $("#totalAmount").html(sumOfColumns("cartTable", 5, true));
|
|
|
79 |
// changeEstimate(prodID);
|
| 794 |
rajveer |
80 |
}
|
|
|
81 |
|
|
|
82 |
function sumOfColumns(tableID, columnIndex, hasHeader) {
|
|
|
83 |
var tot = 0;
|
|
|
84 |
var inc=1;
|
| 1048 |
chandransh |
85 |
var tableElement = $("#" + tableID + " tr" + (hasHeader ? ":gt(0)" : ""));
|
|
|
86 |
var tableChildren = tableElement.children("td:nth-child(" + columnIndex + ")");
|
|
|
87 |
tableChildren.each(function() {
|
| 794 |
rajveer |
88 |
var currentVal=document.getElementById('totalPrice'+inc).innerHTML;
|
|
|
89 |
inc++;
|
|
|
90 |
var splitVal=currentVal.split("Rs.");
|
|
|
91 |
var num = parseFloat(splitVal[1].replace(/[^\d\.-]/g,''));
|
|
|
92 |
tot += parseFloat(num);
|
|
|
93 |
});
|
|
|
94 |
totalAmount=tot;
|
|
|
95 |
var formated_value = $().number_format(tot, {
|
|
|
96 |
numberOfDecimals:2,
|
|
|
97 |
decimalSeparator: '.',
|
|
|
98 |
thousandSeparator: ',',
|
|
|
99 |
symbol: 'Rs.'
|
|
|
100 |
});
|
|
|
101 |
return formated_value;
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
function subtractionOfColumns(tableID, columnIndex, hasHeader) {
|
|
|
105 |
var tot = 0;
|
|
|
106 |
$("#" + tableID + " tr" + (hasHeader ? ":gt(0)" : ""))
|
|
|
107 |
.children("td:nth-child(" + columnIndex + ")")
|
|
|
108 |
.each(function() {
|
|
|
109 |
var currentVal=$(this).html();
|
|
|
110 |
var splitVal=currentVal.split("Rs.");
|
|
|
111 |
var num = parseFloat(splitVal[1].replace(/[^\d\.-]/g,''));
|
|
|
112 |
tot += parseInt(num);
|
|
|
113 |
});
|
|
|
114 |
var formated_value = $().number_format(tot, {
|
|
|
115 |
numberOfDecimals:2,
|
|
|
116 |
decimalSeparator: '.',
|
|
|
117 |
thousandSeparator: ',',
|
|
|
118 |
symbol: 'Rs.'
|
|
|
119 |
});
|
|
|
120 |
return formated_value;
|
|
|
121 |
}
|
|
|
122 |
|
|
|
123 |
function changeEstimate(item_id) {
|
|
|
124 |
if(item_id == null ){
|
|
|
125 |
// alert("item id is null");
|
|
|
126 |
for(var i=0; ; i++){
|
|
|
127 |
|
|
|
128 |
var obj = $("#itemID"+(i+1));
|
| 801 |
rajveer |
129 |
//alert(obj);
|
|
|
130 |
var itemId = $(obj).parent().parent().find("span.pro").attr("id");
|
| 794 |
rajveer |
131 |
// alert("item id is " + itemId);
|
|
|
132 |
if(itemId == null){
|
|
|
133 |
break;
|
|
|
134 |
}
|
| 1048 |
chandransh |
135 |
changeEstimate(itemId);
|
| 794 |
rajveer |
136 |
}
|
|
|
137 |
}else{
|
|
|
138 |
jQuery.ajax({
|
|
|
139 |
type: "GET",
|
|
|
140 |
url: "/estimate/"+$("#zipcode").val()+"_"+item_id,
|
|
|
141 |
beforeSend: function(){
|
|
|
142 |
$("#days"+"_"+item_id).html("<img src='/images/loader_l.gif'>");
|
|
|
143 |
},
|
|
|
144 |
success: function(msg){
|
|
|
145 |
// alert( "delivery estimate is " + msg);
|
|
|
146 |
$("#shipping_time"+"_"+item_id).html(msg);
|
|
|
147 |
}
|
|
|
148 |
});
|
|
|
149 |
}
|
|
|
150 |
}
|