| 1463 |
varun.gupt |
1 |
var totalAmount = 0.00;
|
|
|
2 |
|
| 794 |
rajveer |
3 |
$(document).ready(function(){
|
| 801 |
rajveer |
4 |
|
| 1463 |
varun.gupt |
5 |
changeEstimate();
|
| 1190 |
varun.gupt |
6 |
|
| 1463 |
varun.gupt |
7 |
$('#cartTable td img.remove-quantitybttn').click(function(){
|
|
|
8 |
var prodID = $(this).parent().parent().parent().children().find("span.pro").attr("id");
|
|
|
9 |
window.location.href = "/cart/" + prodID + "?_method=delete" + "&productid=" + prodID;
|
|
|
10 |
});
|
|
|
11 |
});
|
|
|
12 |
|
| 1190 |
varun.gupt |
13 |
function changeQty(obj,itempriceID,totalPriceID) {
|
|
|
14 |
var prodID = $(obj).parent().parent().parent().parent().parent().parent().children().find("span.pro").attr("id");
|
|
|
15 |
var quantity = parseInt(obj.value);
|
|
|
16 |
|
| 1460 |
varun.gupt |
17 |
if (quantity > 5) {
|
|
|
18 |
alert("You can not order more than 5 pieces of same product.");
|
|
|
19 |
$(obj).focus();
|
|
|
20 |
}
|
|
|
21 |
else {
|
|
|
22 |
jQuery.ajax({
|
|
|
23 |
type: "POST",
|
|
|
24 |
url: "/cart/" + prodID + "?_method=put&productid=" + prodID + "&quantity=" + quantity,
|
|
|
25 |
data: "productid=" + prodID + "&quantity=" + quantity,
|
|
|
26 |
success: function(msg){
|
|
|
27 |
window.location.reload();
|
|
|
28 |
}
|
|
|
29 |
});
|
|
|
30 |
}
|
| 794 |
rajveer |
31 |
}
|
|
|
32 |
|
| 1463 |
varun.gupt |
33 |
function sumOfColumns(tableID, columnIndex, hasHeader) {
|
|
|
34 |
var tot = 0;
|
|
|
35 |
var inc = 1;
|
|
|
36 |
var tableElement = $("#" + tableID + " tr" + (hasHeader ? ":gt(0)" : ""));
|
|
|
37 |
var tableChildren = tableElement.children("td:nth-child(" + columnIndex + ")");
|
|
|
38 |
|
|
|
39 |
tableChildren.each(function() {
|
|
|
40 |
var currentVal = document.getElementById('totalPrice' + inc).innerHTML;
|
|
|
41 |
inc ++;
|
|
|
42 |
var splitVal = currentVal.split("Rs.");
|
|
|
43 |
var num = parseFloat(splitVal[1].replace(/[^\d\.-]/g,''));
|
|
|
44 |
tot += parseFloat(num);
|
|
|
45 |
});
|
|
|
46 |
totalAmount = tot;
|
|
|
47 |
var formated_value = $().number_format(tot, {
|
|
|
48 |
numberOfDecimals:2,
|
|
|
49 |
decimalSeparator: '.',
|
|
|
50 |
thousandSeparator: ',',
|
|
|
51 |
symbol: 'Rs.'
|
|
|
52 |
});
|
|
|
53 |
return formated_value;
|
| 794 |
rajveer |
54 |
}
|
|
|
55 |
|
|
|
56 |
function subtractionOfColumns(tableID, columnIndex, hasHeader) {
|
| 1463 |
varun.gupt |
57 |
var tot = 0;
|
|
|
58 |
|
|
|
59 |
$("#" + tableID + " tr" + (hasHeader ? ":gt(0)" : "")).children("td:nth-child(" + columnIndex + ")").each(function(){
|
|
|
60 |
var currentVal=$(this).html();
|
|
|
61 |
var splitVal=currentVal.split("Rs.");
|
|
|
62 |
var num = parseFloat(splitVal[1].replace(/[^\d\.-]/g,''));
|
|
|
63 |
tot += parseInt(num);
|
|
|
64 |
});
|
|
|
65 |
|
|
|
66 |
var formated_value = $().number_format(tot, {
|
|
|
67 |
numberOfDecimals: 2,
|
|
|
68 |
decimalSeparator: '.',
|
|
|
69 |
thousandSeparator: ',',
|
|
|
70 |
symbol: 'Rs.'
|
|
|
71 |
});
|
|
|
72 |
return formated_value;
|
| 794 |
rajveer |
73 |
}
|
|
|
74 |
|
| 1463 |
varun.gupt |
75 |
function changeEstimate(item_id) {
|
|
|
76 |
if(item_id == null ) {
|
|
|
77 |
for(var i = 0; ; i ++) {
|
|
|
78 |
var obj = $("#itemID" + (i + 1));
|
|
|
79 |
var itemId = $(obj).parent().parent().find("span.pro").attr("id");
|
|
|
80 |
if(itemId == null) {
|
|
|
81 |
break;
|
|
|
82 |
}
|
|
|
83 |
changeEstimate(itemId);
|
|
|
84 |
}
|
|
|
85 |
} else {
|
|
|
86 |
jQuery.ajax({
|
|
|
87 |
type: "GET",
|
|
|
88 |
url: "/estimate/" + $("#zipcode").val() + "_" + item_id,
|
|
|
89 |
beforeSend: function(){
|
|
|
90 |
$("#days" + "_" + item_id).html("<img src='/images/loader_l.gif'>");
|
|
|
91 |
},
|
|
|
92 |
success: function(msg){
|
|
|
93 |
$("#shipping_time" + "_" + item_id).html(msg);
|
|
|
94 |
}
|
|
|
95 |
});
|
|
|
96 |
}
|
|
|
97 |
}
|