| Line 1... |
Line 1... |
| 1 |
function loadCartPageDetails(){
|
1 |
function loadCartPageDetails(){
|
| 2 |
var payable = $('div.cartgrandtotal span.pull-right').text().split(" ");
|
- |
|
| 3 |
payable = payable[2];
|
- |
|
| 4 |
if(parseInt(payable)>0){
|
- |
|
| 5 |
$('button.checkoutbtn').prop( "disabled", false );
|
- |
|
| 6 |
}else{
|
- |
|
| 7 |
$('button.checkoutbtn').prop( "disabled", true );
|
- |
|
| 8 |
}
|
- |
|
| 9 |
var input = $('input#refresh').val();
|
2 |
var input = $('input#refresh').val();
|
| 10 |
|
- |
|
| 11 |
if(input == 'yes'){
|
3 |
if(input == 'yes'){
|
| 12 |
$('#cartLoadingModal').modal('show');
|
4 |
$('#cartLoadingModal').modal('show');
|
| 13 |
var cart_details = localStorage.getItem('cart_details');
|
5 |
var cart_details = localStorage.getItem('cart_details');
|
| 14 |
if(cart_details!=undefined){
|
6 |
if(cart_details!=undefined){
|
| 15 |
var cartDetailsObj = JSON.parse(cart_details);
|
7 |
var cartDetailsObj = JSON.parse(cart_details);
|
| 16 |
var totalCartValue = cartDetailsObj.totalCartValue;
|
- |
|
| 17 |
var totalCartQuantity = cartDetailsObj.totalCartQuantity;
|
- |
|
| 18 |
var cartItems = cartDetailsObj.cartItems;
|
- |
|
| 19 |
var shippingCharges =cartDetailsObj.shippingCharges;
|
- |
|
| 20 |
var totalSkus = cartDetailsObj.totalSkus;
|
- |
|
| 21 |
$.each(cartDetailsObj.cartItems, function(key,val) {
|
8 |
$.each(cartDetailsObj.cartItems, function(key,val) {
|
| 22 |
$("div.number-spinner button[data-id='"+key+"']").closest('.number-spinner').find('input').val(val.quantity);
|
9 |
$("div.number-spinner button[data-id='"+key+"']").closest('.number-spinner').find('input').val(val.quantity);
|
| 23 |
$("span.lineitemqty[data-id='"+key+"']").text(val.quantity);
|
10 |
$("span.lineitemqty[data-id='"+key+"']").text(val.quantity);
|
| 24 |
$("span.packQuantity[data-id='"+key+"']").text(val.quantity*$("span.packQuantity[data-id='"+key+"']").data('pack'));
|
11 |
$("span.packQuantity[data-id='"+key+"']").text(val.quantity*$("span.packQuantity[data-id='"+key+"']").data('pack'));
|
| 25 |
$("span.lineitemtotal[data-id='"+key+"']").text(' ₹ '+ (parseInt(val.quantity)*parseInt(val.unitprice)).toString());
|
12 |
$("span.lineitemtotal[data-id='"+key+"']").text(' ₹ '+ (parseInt(val.quantity)*parseInt(val.unitprice)).toString());
|
| 26 |
});
|
13 |
});
|
| 27 |
$('div.cartitemstotal span.itemstotal').text('₹ '+numberWithCommas(totalCartValue));
|
- |
|
| 28 |
$('div.cartitemstotal span.shippingval').text('₹ '+numberWithCommas(shippingCharges));
|
- |
|
| 29 |
var payable = 0;
|
- |
|
| 30 |
if(shippingCharges>0){
|
- |
|
| 31 |
if(totalCartValue>0){
|
14 |
renderCartDerivedValues();
|
| 32 |
$('.cartitemstotal').removeClass('hidden');
|
- |
|
| 33 |
payable = parseInt(shippingCharges)+parseInt(totalCartValue);
|
- |
|
| 34 |
}else{
|
- |
|
| 35 |
payable = 0;
|
- |
|
| 36 |
}
|
- |
|
| 37 |
}else{
|
- |
|
| 38 |
payable = parseInt(totalCartValue);
|
- |
|
| 39 |
$('.cartitemstotal').addClass('hidden');
|
- |
|
| 40 |
}
|
- |
|
| 41 |
$('div.cartgrandtotal span.pull-right').text('₹ '+numberWithCommas(payable));
|
- |
|
| 42 |
|
- |
|
| 43 |
if(payable>0){
|
- |
|
| 44 |
$('button.checkoutbtn').prop( "disabled", false );
|
- |
|
| 45 |
}else{
|
- |
|
| 46 |
$('button.checkoutbtn').prop( "disabled", true );
|
- |
|
| 47 |
}
|
- |
|
| 48 |
var estimateString = $('div.popover-markup').data('str');
|
- |
|
| 49 |
if(estimateString!="Can't ship here"){
|
- |
|
| 50 |
$('div.cartdetailscard').find('div, input, textarea, button, select').each(function () {
|
- |
|
| 51 |
$(this).prop('disabled', false);
|
- |
|
| 52 |
});
|
- |
|
| 53 |
}else{
|
- |
|
| 54 |
$('div.cartdetailscard').find('div, input, textarea, button, select').each(function () {
|
- |
|
| 55 |
$(this).prop('disabled', true);
|
- |
|
| 56 |
});
|
- |
|
| 57 |
}
|
- |
|
| 58 |
$('#cartLoadingModal').modal('hide');
|
15 |
$('#cartLoadingModal').modal('hide');
|
| 59 |
}else{
|
16 |
}else{
|
| 60 |
$('#cartLoadingModal').modal('show');
|
- |
|
| 61 |
window.location.href = apihost + 'cartdetails/?user_id='+me;
|
17 |
window.location.href = apihost + 'cartdetails/?user_id='+me;
|
| 62 |
}
|
18 |
}
|
| 63 |
}else{
|
19 |
}else{
|
| 64 |
$('input#refresh').val('yes');
|
20 |
$('input#refresh').val('yes');
|
| 65 |
var estimateString = $('div.popover-markup').data('str');
|
21 |
var estimateString = $('div.popover-markup').data('str');
|
| 66 |
if(estimateString!="Can't ship here"){
|
- |
|
| 67 |
$('div.cartdetailscard').find('div, input, textarea, button, select').each(function () {
|
- |
|
| 68 |
$(this).prop('disabled', false);
|
- |
|
| 69 |
});
|
- |
|
| 70 |
var cart_details = localStorage.getItem('cart_details');
|
22 |
var cart_details = localStorage.getItem('cart_details');
|
| 71 |
|
- |
|
| 72 |
localStorage.removeItem('cart_details');
|
- |
|
| 73 |
if(cart_details!=undefined){
|
23 |
if(cart_details!=undefined){
|
| 74 |
var totalCartValue = 0;
|
- |
|
| 75 |
var totalCartQuantity = 0;
|
- |
|
| 76 |
var cartItems = {};
|
- |
|
| 77 |
var jsonObjToBeStored = {};
|
- |
|
| 78 |
var shippingCharges = 0;
|
- |
|
| 79 |
var totalSkus = 0;
|
- |
|
| 80 |
|
- |
|
| 81 |
totalCartValue = $('.cartitemstotal').data('itemtotal');
|
- |
|
| 82 |
shippingCharges = $('.cartitemstotal').data('shipping');
|
- |
|
| 83 |
|
- |
|
| 84 |
$('.number-spinner').each(function (index, val) {
|
- |
|
| 85 |
var element = $(val);
|
- |
|
| 86 |
var quantity = element.find("input").val();
|
- |
|
| 87 |
if(parseInt(quantity)>0){
|
- |
|
| 88 |
var sku = element.find("button[data-dir='up']").data('id');
|
- |
|
| 89 |
var price = element.find("button[data-dir='up']").data('price');
|
- |
|
| 90 |
|
- |
|
| 91 |
var bulkpricing = $(".number-spinner button[data-id='"+index+"']").data('bulkpricing');
|
- |
|
| 92 |
if (bulkpricing != undefined && bulkpricing.length != 0){
|
- |
|
| 93 |
for(var i=0;i<bulkpricing.length;i++)
|
- |
|
| 94 |
{
|
- |
|
| 95 |
if(val.quantity<bulkpricing[i]['quantity']){
|
- |
|
| 96 |
break;
|
- |
|
| 97 |
}
|
- |
|
| 98 |
else{
|
- |
|
| 99 |
price = bulkpricing[i]['price'];
|
- |
|
| 100 |
}
|
- |
|
| 101 |
}
|
- |
|
| 102 |
}
|
- |
|
| 103 |
|
- |
|
| 104 |
var catalogItemId = element.find("button[data-dir='up']").data('identifier');
|
- |
|
| 105 |
var prodname = $(this).data('name');
|
- |
|
| 106 |
var brandname = $(this).data('brand');
|
- |
|
| 107 |
var itemDetail = {};
|
24 |
loadCartDetails();
|
| 108 |
totalCartQuantity = totalCartQuantity + parseInt(quantity);
|
- |
|
| 109 |
totalSkus = totalSkus +1;
|
- |
|
| 110 |
itemDetail['quantity']=parseInt(quantity);
|
- |
|
| 111 |
itemDetail['unitprice']=parseInt(price);
|
- |
|
| 112 |
itemDetail['productname']=prodname;
|
- |
|
| 113 |
itemDetail['brand']=brandname;
|
- |
|
| 114 |
itemDetail['catalogItemId'] = catalogItemId.toString();
|
- |
|
| 115 |
cartItems[sku.toString()]=itemDetail;
|
- |
|
| 116 |
}
|
- |
|
| 117 |
});
|
- |
|
| 118 |
|
- |
|
| 119 |
jsonObjToBeStored['totalCartQuantity'] = totalCartQuantity;
|
- |
|
| 120 |
jsonObjToBeStored['totalCartValue'] = totalCartValue;
|
- |
|
| 121 |
jsonObjToBeStored['cartItems'] = cartItems;
|
- |
|
| 122 |
jsonObjToBeStored['shippingCharges'] = shippingCharges;
|
- |
|
| 123 |
jsonObjToBeStored['totalSkus'] = totalSkus;
|
- |
|
| 124 |
localStorage.setItem('cart_details',JSON.stringify(jsonObjToBeStored));
|
- |
|
| 125 |
}
|
25 |
}
|
| 126 |
}else{
|
- |
|
| 127 |
var cart_details = localStorage.getItem('cart_details');
|
- |
|
| 128 |
if(cart_details!=undefined){
|
- |
|
| 129 |
var cartDetailsObj = JSON.parse(cart_details);
|
- |
|
| 130 |
var totalCartValue = cartDetailsObj.totalCartValue
|
- |
|
| 131 |
var totalCartQuantity = cartDetailsObj.totalCartQuantity
|
- |
|
| 132 |
var cartItems = cartDetailsObj.cartItems
|
- |
|
| 133 |
var jsonObjToBeStored = {};
|
- |
|
| 134 |
var shippingCharges = $('.cartitemstotal').data('shipping');
|
- |
|
| 135 |
var totalSkus = cartDetailsObj.totalSkus
|
- |
|
| 136 |
$('.number-spinner').each(function (index, val) {
|
- |
|
| 137 |
var element = $(val);
|
- |
|
| 138 |
var quantity = element.find("input").val();
|
- |
|
| 139 |
var estimate = element.data('estimate');
|
26 |
if(estimateString=="Can't ship here"){
|
| 140 |
var catalogItemId = element.find("button[data-dir='up']").data('identifier');
|
- |
|
| 141 |
if(parseInt(quantity)==0 && estimate==""){
|
- |
|
| 142 |
var sku = element.find("button[data-dir='up']").data('id');
|
- |
|
| 143 |
var price = element.find("button[data-dir='up']").data('price');
|
- |
|
| 144 |
var bulkpricing = $(".number-spinner button[data-id='"+index+"']").data('bulkpricing');
|
- |
|
| 145 |
if (bulkpricing != undefined && bulkpricing.length != 0){
|
- |
|
| 146 |
for(var i=0;i<bulkpricing.length;i++)
|
- |
|
| 147 |
{
|
- |
|
| 148 |
if(val.quantity<bulkpricing[i]['quantity']){
|
- |
|
| 149 |
break;
|
- |
|
| 150 |
}
|
- |
|
| 151 |
else{
|
- |
|
| 152 |
price = bulkpricing[i]['price'];
|
- |
|
| 153 |
}
|
- |
|
| 154 |
}
|
- |
|
| 155 |
}
|
- |
|
| 156 |
var prodname = $(this).data('name');
|
- |
|
| 157 |
var brandname = $(this).data('brand');
|
- |
|
| 158 |
var itemDetail = cartDetailsObj.cartItems[sku.toString()];
|
- |
|
| 159 |
if(itemDetail==undefined){
|
- |
|
| 160 |
itemDetail = {};
|
- |
|
| 161 |
itemDetail['quantity']=parseInt(quantity);
|
- |
|
| 162 |
itemDetail['unitprice']=parseInt(price);
|
- |
|
| 163 |
itemDetail['productname']=prodname;
|
- |
|
| 164 |
itemDetail['brand']=brandname;
|
- |
|
| 165 |
itemDetail['catalogItemId'] = catalogItemId.toString();
|
- |
|
| 166 |
cartItems[sku.toString()] = itemDetail;
|
- |
|
| 167 |
}else{
|
- |
|
| 168 |
totalCartValue = totalCartValue - (itemDetail.quantity*itemDetail.unitprice);
|
- |
|
| 169 |
totalSkus = totalSkus -1;
|
- |
|
| 170 |
totalCartQuantity = totalCartQuantity - itemDetail.quantity;
|
- |
|
| 171 |
itemDetail.quantity = 0;
|
- |
|
| 172 |
itemDetail.unitprice = parseInt(price);
|
- |
|
| 173 |
if(!itemDetail.hasOwnProperty('catalogItemId')){
|
- |
|
| 174 |
itemDetail['catalogItemId'] = catalogItemId.toString();
|
- |
|
| 175 |
}
|
- |
|
| 176 |
cartItems[sku.toString()] = itemDetail;
|
- |
|
| 177 |
}
|
- |
|
| 178 |
}
|
- |
|
| 179 |
});
|
- |
|
| 180 |
if(parseInt(totalCartValue)>1000){
|
- |
|
| 181 |
shippingCharges = 0;
|
- |
|
| 182 |
}else if(parseInt(totalCartValue)>=500 && parseInt(totalCartValue)<1000){
|
- |
|
| 183 |
shippingCharges = 50;
|
- |
|
| 184 |
}else if(parseInt(totalCartValue)>0 && parseInt(totalCartValue)<500){
|
- |
|
| 185 |
shippingCharges = 100;
|
- |
|
| 186 |
}else{
|
- |
|
| 187 |
shippingCharges = 0;
|
- |
|
| 188 |
}
|
- |
|
| 189 |
cartDetailsObj.totalCartQuantity = totalCartQuantity;
|
- |
|
| 190 |
cartDetailsObj.totalCartValue = totalCartValue;
|
- |
|
| 191 |
cartDetailsObj.cartItems = cartItems;
|
- |
|
| 192 |
cartDetailsObj.shippingCharges = shippingCharges;
|
- |
|
| 193 |
cartDetailsObj.totalSkus = totalSkus;
|
- |
|
| 194 |
localStorage.setItem('cart_details',JSON.stringify(cartDetailsObj));
|
- |
|
| 195 |
}
|
- |
|
| 196 |
$('div.cartdetailscard').find('div, input, textarea, button, select').each(function () {
|
27 |
$('div.cartdetailscard').find('div, input, textarea, button, select').each(function () {
|
| 197 |
$(this).prop('disabled', true);
|
28 |
$(this).prop('disabled', true);
|
| 198 |
});
|
29 |
});
|
| 199 |
}
|
30 |
}
|
| 200 |
}
|
31 |
}
|
| 201 |
|
- |
|
| 202 |
if(!$('div.cartitemstotal').hasClass('hidden')){
|
32 |
if(!$('div.cartitemstotal').hasClass('hidden')){
|
| 203 |
$('div.scroll').attr('style', 'margin-bottom: 176px');
|
33 |
$('div.scroll').attr('style', 'margin-bottom: 176px');
|
| 204 |
}else{
|
34 |
}else{
|
| 205 |
$('div.scroll').attr('style', 'margin-bottom: 100px');
|
35 |
$('div.scroll').attr('style', 'margin-bottom: 100px');
|
| 206 |
}
|
36 |
}
|
| 207 |
/*
|
- |
|
| 208 |
var currentShippingCharges = $('div.cartitemstotal span.shippingval').text().split(" ");
|
- |
|
| 209 |
currentShippingCharges = parseInt(currentShippingCharges[1]);
|
- |
|
| 210 |
var currentItemTotal = $('div.cartitemstotal span.itemstotal').text().split(" ");
|
- |
|
| 211 |
currentItemTotal = currentItemTotal[1].toString();
|
- |
|
| 212 |
currentItemTotal = currentItemTotal.split(',').join("");
|
- |
|
| 213 |
currentItemTotal = parseFloat(currentItemTotal);
|
- |
|
| 214 |
if(currentShippingCharges>0){
|
- |
|
| 215 |
if(currentItemTotal>0){
|
- |
|
| 216 |
var additionalAmount = 1000.0-currentItemTotal;
|
- |
|
| 217 |
additionalAmount = additionalAmount.toFixed();
|
- |
|
| 218 |
$('span.cartheader').attr('style', 'font-size: 8pt;padding-left: 18px;');
|
- |
|
| 219 |
$('span.cartheader').text('');
|
- |
|
| 220 |
$("<a class='addMoreItems' href='/categories/linkdeal/3?filtertype=exclusive'><u>Add more items worth <span style='color:#ff0000;'>₹ "+additionalAmount+"</span> for Free Shipping</u></a>").appendTo('span.cartheader');
|
- |
|
| 221 |
}else{
|
- |
|
| 222 |
$('span.cartheader').text('');
|
- |
|
| 223 |
$('span.cartheader').attr('style', 'font-size: 12pt;padding-left: 30px;');
|
- |
|
| 224 |
$('span.cartheader').text('Cart Details');
|
- |
|
| 225 |
}
|
- |
|
| 226 |
}else{
|
- |
|
| 227 |
$('span.cartheader').text('');
|
- |
|
| 228 |
$('span.cartheader').attr('style', 'font-size: 12pt;padding-left: 30px;');
|
- |
|
| 229 |
$('span.cartheader').text('Cart Details');
|
- |
|
| 230 |
}*/
|
- |
|
| 231 |
|
- |
|
| 232 |
}
|
37 |
}
|
| 233 |
|
38 |
|
| 234 |
$(function(){
|
39 |
$(function(){
|
| 235 |
loadCartPageDetails();
|
40 |
loadCartPageDetails();
|
| 236 |
});
|
41 |
});
|
| Line 239... |
Line 44... |
| 239 |
btn = $(this);
|
44 |
btn = $(this);
|
| 240 |
input = btn.closest('.number-spinner').find('input');
|
45 |
input = btn.closest('.number-spinner').find('input');
|
| 241 |
oldValue = btn.closest('.number-spinner').find('input').val().trim(),
|
46 |
oldValue = btn.closest('.number-spinner').find('input').val().trim(),
|
| 242 |
newVal = 0;
|
47 |
newVal = 0;
|
| 243 |
btn.closest('.number-spinner').find('button').prop("disabled", false);
|
48 |
btn.closest('.number-spinner').find('button').prop("disabled", false);
|
| 244 |
var totalCartQuantity = 0;
|
- |
|
| 245 |
var totalCartValue = 0;
|
- |
|
| 246 |
var shippingCharges;
|
- |
|
| 247 |
var cartDetailsObj;
|
- |
|
| 248 |
var jsonObjToBeStored = {};
|
- |
|
| 249 |
var cartItems = {};
|
- |
|
| 250 |
var totalSkus = 0;
|
- |
|
| 251 |
var cart_details = localStorage.getItem('cart_details');
|
- |
|
| 252 |
if(cart_details!=undefined){
|
- |
|
| 253 |
cartDetailsObj = JSON.parse(cart_details);
|
- |
|
| 254 |
totalCartQuantity = cartDetailsObj.totalCartQuantity;
|
- |
|
| 255 |
totalCartValue = cartDetailsObj.totalCartValue;
|
- |
|
| 256 |
cartItems = cartDetailsObj.cartItems;
|
- |
|
| 257 |
}
|
- |
|
| 258 |
var inc = 0;
|
49 |
var inc = 0;
|
| 259 |
var dec = 0;
|
50 |
var dec = 0;
|
| 260 |
var sku = btn.data('id');
|
51 |
var sku = btn.data('id');
|
| 261 |
var unitPrice = btn.data('price');
|
52 |
var unitPrice = btn.data('price');
|
| 262 |
var prodname = btn.data('name');
|
53 |
var prodname = btn.data('name');
|
| Line 277... |
Line 68... |
| 277 |
if((parseInt(input.val())== 0 || parseInt(input.val())< minBuyQuantity) && (parseInt(input.attr('max')) >= minBuyQuantity)){
|
68 |
if((parseInt(input.val())== 0 || parseInt(input.val())< minBuyQuantity) && (parseInt(input.attr('max')) >= minBuyQuantity)){
|
| 278 |
inc = minBuyQuantity - parseInt(input.val());
|
69 |
inc = minBuyQuantity - parseInt(input.val());
|
| 279 |
newVal = parseInt(oldValue) + inc;
|
70 |
newVal = parseInt(oldValue) + inc;
|
| 280 |
}
|
71 |
}
|
| 281 |
else{
|
72 |
else{
|
| 282 |
// inc = quantityStep;
|
- |
|
| 283 |
// newVal = parseInt(oldValue) + inc;
|
- |
|
| 284 |
|
- |
|
| 285 |
inc = quantityStep;
|
73 |
inc = quantityStep;
|
| 286 |
if(parseInt(oldValue)< minBuyQuantity+(quantityStep*4)){
|
74 |
if(parseInt(oldValue)< minBuyQuantity+(quantityStep*4)){
|
| 287 |
|
- |
|
| 288 |
newVal = parseInt(oldValue) + inc;
|
75 |
newVal = parseInt(oldValue) + inc;
|
| 289 |
}
|
76 |
}
|
| 290 |
else if(parseInt(oldValue)< minBuyQuantity+(quantityStep*28)){
|
77 |
else if(parseInt(oldValue)< minBuyQuantity+(quantityStep*28)){
|
| 291 |
var minqty = minBuyQuantity;
|
78 |
var minqty = minBuyQuantity;
|
| 292 |
if((parseInt(oldValue)+quantityStep) % quantityStep == 0 ){minqty = 0;}
|
79 |
if((parseInt(oldValue)+quantityStep) % quantityStep == 0 ){minqty = 0;}
|
| Line 296... |
Line 83... |
| 296 |
}
|
83 |
}
|
| 297 |
else{
|
84 |
else{
|
| 298 |
inc = minqty+ (5*quantityStep) - (parseInt(oldValue) % (5*quantityStep));
|
85 |
inc = minqty+ (5*quantityStep) - (parseInt(oldValue) % (5*quantityStep));
|
| 299 |
newVal =minqty+ 5*quantityStep+ parseInt(oldValue) - (parseInt(oldValue) % (5*quantityStep));
|
86 |
newVal =minqty+ 5*quantityStep+ parseInt(oldValue) - (parseInt(oldValue) % (5*quantityStep));
|
| 300 |
}
|
87 |
}
|
| 301 |
// newVal = parseInt(oldValue)+ (5*quantityStep);
|
- |
|
| 302 |
}
|
88 |
}
|
| 303 |
else{
|
89 |
else{
|
| 304 |
var minqty = minBuyQuantity;
|
90 |
var minqty = minBuyQuantity;
|
| 305 |
if((parseInt(oldValue)+quantityStep) % quantityStep == 0){minqty = 0;}
|
91 |
if((parseInt(oldValue)+quantityStep) % quantityStep == 0){minqty = 0;}
|
| 306 |
if(parseInt(oldValue) % (quantityStep*10) == 0){
|
92 |
if(parseInt(oldValue) % (quantityStep*10) == 0){
|
| Line 309... |
Line 95... |
| 309 |
}
|
95 |
}
|
| 310 |
else{
|
96 |
else{
|
| 311 |
inc = (10*quantityStep) - (parseInt(oldValue) % (10*quantityStep)) +minqty;
|
97 |
inc = (10*quantityStep) - (parseInt(oldValue) % (10*quantityStep)) +minqty;
|
| 312 |
newVal =10*quantityStep + parseInt(oldValue) - (parseInt(oldValue) % (10*quantityStep)) +minqty;
|
98 |
newVal =10*quantityStep + parseInt(oldValue) - (parseInt(oldValue) % (10*quantityStep)) +minqty;
|
| 313 |
}
|
99 |
}
|
| 314 |
// newVal = parseInt(oldValue)+ (10*quantityStep);
|
- |
|
| 315 |
}
|
100 |
}
|
| 316 |
|
101 |
|
| 317 |
|
102 |
|
| 318 |
if(newVal>parseInt(input.attr('max'))){
|
103 |
if(newVal>parseInt(input.attr('max'))){
|
| 319 |
// inc = parseInt(input.attr('max')) - parseInt(oldValue);
|
- |
|
| 320 |
// newVal = parseInt(oldValue) + inc;
|
- |
|
| 321 |
var minqty = minBuyQuantity;
|
104 |
var minqty = minBuyQuantity;
|
| 322 |
if((parseInt(oldValue)+quantityStep) % quantityStep == 0){minqty = 0;}
|
105 |
if((parseInt(oldValue)+quantityStep) % quantityStep == 0){minqty = 0;}
|
| 323 |
newVal = parseInt(input.attr('max')) - (newVal - parseInt(input.attr('max'))) % (minqty +quantityStep);
|
106 |
newVal = parseInt(input.attr('max')) - (newVal - parseInt(input.attr('max'))) % (minqty +quantityStep);
|
| 324 |
inc = newVal - parseInt(oldValue);
|
107 |
inc = newVal - parseInt(oldValue);
|
| 325 |
maxquantflag = true
|
108 |
maxquantflag = true
|
| 326 |
}
|
109 |
}
|
| 327 |
}
|
110 |
}
|
| 328 |
// if(parseInt(input.val())<5){
|
- |
|
| 329 |
// inc = 1;
|
- |
|
| 330 |
// newVal = parseInt(oldValue) + inc;
|
- |
|
| 331 |
// }else{
|
- |
|
| 332 |
// inc = 5-(parseInt(input.val())%5);
|
- |
|
| 333 |
// newVal = parseInt(oldValue) + inc;
|
- |
|
| 334 |
// if(newVal>parseInt(input.attr('max'))){
|
- |
|
| 335 |
// inc = parseInt(input.attr('max')) - parseInt(oldValue);
|
- |
|
| 336 |
// newVal = parseInt(oldValue) + inc;
|
- |
|
| 337 |
// }
|
- |
|
| 338 |
// }
|
- |
|
| 339 |
}else{
|
111 |
}else{
|
| 340 |
newVal = parseInt(oldValue);
|
112 |
newVal = parseInt(oldValue);
|
| 341 |
btn.prop("disabled", true);
|
113 |
btn.prop("disabled", true);
|
| 342 |
}
|
114 |
}
|
| 343 |
if(newVal==parseInt(input.attr('max')) || maxquantflag == true){
|
115 |
if(newVal==parseInt(input.attr('max')) || maxquantflag == true){
|
| 344 |
input.attr('style', 'border: 2px solid #ff0000');
|
116 |
input.attr('style', 'border: 2px solid #ff0000');
|
| 345 |
}else{
|
117 |
}else{
|
| 346 |
input.attr('style', 'border: 1px solid #CCCCCC');
|
118 |
input.attr('style', 'border: 1px solid #CCCCCC');
|
| 347 |
}
|
119 |
}
|
| 348 |
totalCartQuantity = totalCartQuantity + inc;
|
- |
|
| 349 |
} else {
|
120 |
} else {
|
| 350 |
if ( input.attr('min') == undefined || parseInt(input.val()) > parseInt(input.attr('min')) ) {
|
121 |
if ( input.attr('min') == undefined || parseInt(input.val()) > parseInt(input.attr('min')) ) {
|
| 351 |
// dec = 1;
|
- |
|
| 352 |
dec = quantityStep;
|
122 |
dec = quantityStep;
|
| 353 |
newVal = parseInt(oldValue) - dec;
|
123 |
newVal = parseInt(oldValue) - dec;
|
| 354 |
var minBuyQtyDiff = parseInt(oldValue) - minBuyQuantity;
|
124 |
var minBuyQtyDiff = parseInt(oldValue) - minBuyQuantity;
|
| 355 |
if(minBuyQtyDiff ==0){
|
125 |
if(minBuyQtyDiff ==0){
|
| 356 |
dec = minBuyQuantity;
|
126 |
dec = minBuyQuantity;
|
| Line 365... |
Line 135... |
| 365 |
if(newVal==parseInt(input.attr('min'))){
|
135 |
if(newVal==parseInt(input.attr('min'))){
|
| 366 |
input.attr('style', 'border: 2px solid #5bc0de');
|
136 |
input.attr('style', 'border: 2px solid #5bc0de');
|
| 367 |
}else{
|
137 |
}else{
|
| 368 |
input.attr('style', 'border: 1px solid #CCCCCC');
|
138 |
input.attr('style', 'border: 1px solid #CCCCCC');
|
| 369 |
}
|
139 |
}
|
| 370 |
totalCartQuantity = totalCartQuantity - dec;
|
- |
|
| 371 |
}
|
140 |
}
|
| 372 |
$("span.lineitemqty[data-id='"+sku+"']").text(newVal);
|
141 |
$("span.lineitemqty[data-id='"+sku+"']").text(newVal);
|
| 373 |
btn.closest('.number-spinner').find('input').val(newVal);
|
142 |
btn.closest('.number-spinner').find('input').val(newVal);
|
| 374 |
|
143 |
|
| 375 |
|
144 |
|
| 376 |
if (bulkpricing != undefined && bulkpricing.length != 0){
|
145 |
if (bulkpricing != undefined && bulkpricing.length != 0){
|
| 377 |
// bulkpricing = bulkpricing.sort(function(a, b){
|
- |
|
| 378 |
// return a.quantity - b.quantity;
|
- |
|
| 379 |
// });
|
- |
|
| 380 |
|
- |
|
| 381 |
for(var i=0;i<bulkpricing.length;i++)
|
146 |
for(var i=0;i<bulkpricing.length;i++)
|
| 382 |
{
|
147 |
{
|
| 383 |
if(newVal<bulkpricing[i]['quantity']){
|
148 |
if(newVal<bulkpricing[i]['quantity']){
|
| 384 |
break;
|
149 |
break;
|
| 385 |
}
|
150 |
}
|
| Line 392... |
Line 157... |
| 392 |
$("span.lineitemprice[data-id='"+sku+"']").text(unitPrice);
|
157 |
$("span.lineitemprice[data-id='"+sku+"']").text(unitPrice);
|
| 393 |
|
158 |
|
| 394 |
|
159 |
|
| 395 |
$("span.packQuantity[data-id='"+sku+"']").text(newVal*$("span.packQuantity[data-id='"+sku+"']").data('pack'));
|
160 |
$("span.packQuantity[data-id='"+sku+"']").text(newVal*$("span.packQuantity[data-id='"+sku+"']").data('pack'));
|
| 396 |
$("span.lineitemtotal[data-id='"+sku+"']").text(' ₹ '+ (parseInt(newVal)*parseInt(unitPrice)).toString());
|
161 |
$("span.lineitemtotal[data-id='"+sku+"']").text(' ₹ '+ (parseInt(newVal)*parseInt(unitPrice)).toString());
|
| 397 |
if(cartDetailsObj==undefined){
|
- |
|
| 398 |
jsonObjToBeStored['totalCartQuantity'] = totalCartQuantity;
|
- |
|
| 399 |
totalCartValue = totalCartValue + (unitPrice * newVal);
|
- |
|
| 400 |
jsonObjToBeStored['totalCartValue'] = totalCartValue;
|
- |
|
| 401 |
var itemDetail = {};
|
162 |
loadCartDetails();
|
| 402 |
itemDetail['quantity']=newVal;
|
- |
|
| 403 |
itemDetail['unitprice']=unitPrice;
|
- |
|
| 404 |
itemDetail['productname']=prodname;
|
- |
|
| 405 |
itemDetail['brand']=brandname;
|
- |
|
| 406 |
itemDetail['catalogItemId'] = catalogItemId.toString();
|
- |
|
| 407 |
cartItems[sku.toString()]=itemDetail;
|
- |
|
| 408 |
jsonObjToBeStored['cartItems']=cartItems;
|
- |
|
| 409 |
if(parseInt(totalCartQuantity)>=5){
|
- |
|
| 410 |
shippingCharges = 30*totalCartQuantity;
|
- |
|
| 411 |
}else {
|
- |
|
| 412 |
shippingCharges = 60*totalCartQuantity;
|
- |
|
| 413 |
}
|
- |
|
| 414 |
$.each( cartItems, function(itemId,value){
|
- |
|
| 415 |
if(value['quantity']>0){
|
- |
|
| 416 |
totalSkus = totalSkus +1;
|
- |
|
| 417 |
}
|
- |
|
| 418 |
});
|
- |
|
| 419 |
jsonObjToBeStored['totalSkus']=totalSkus;
|
- |
|
| 420 |
jsonObjToBeStored['shippingCharges'] = shippingCharges;
|
- |
|
| 421 |
localStorage.setItem('cart_details',JSON.stringify(jsonObjToBeStored));
|
- |
|
| 422 |
}else{
|
- |
|
| 423 |
cartDetailsObj.totalCartQuantity = totalCartQuantity;
|
- |
|
| 424 |
var itemDetail = cartItems[sku.toString()];
|
- |
|
| 425 |
if(itemDetail==undefined){
|
- |
|
| 426 |
var itemDetail = {};
|
- |
|
| 427 |
itemDetail['quantity']=newVal;
|
- |
|
| 428 |
itemDetail['unitprice']=unitPrice;
|
- |
|
| 429 |
itemDetail['productname']=prodname;
|
- |
|
| 430 |
itemDetail['brand']=brandname;
|
- |
|
| 431 |
itemDetail['catalogItemId'] = catalogItemId.toString();
|
- |
|
| 432 |
totalCartValue = totalCartValue + (unitPrice * newVal);
|
- |
|
| 433 |
cartItems[sku.toString()]=itemDetail;
|
- |
|
| 434 |
}else{
|
- |
|
| 435 |
totalCartValue = totalCartValue - (cartItems[sku.toString()].quantity * cartItems[sku.toString()].unitprice) + (unitPrice * newVal);
|
- |
|
| 436 |
if(newVal==0){
|
- |
|
| 437 |
cartItems[sku.toString()].quantity = 0;
|
- |
|
| 438 |
cartItems[sku.toString()].unitprice = unitPrice;
|
- |
|
| 439 |
}else{
|
- |
|
| 440 |
cartItems[sku.toString()].quantity = newVal;
|
- |
|
| 441 |
cartItems[sku.toString()].unitprice = unitPrice;
|
- |
|
| 442 |
}
|
- |
|
| 443 |
|
- |
|
| 444 |
}
|
- |
|
| 445 |
$.each( cartItems, function(itemId,value){
|
- |
|
| 446 |
if(value['quantity']>0){
|
- |
|
| 447 |
totalSkus = totalSkus +1;
|
- |
|
| 448 |
}
|
- |
|
| 449 |
});
|
- |
|
| 450 |
cartDetailsObj.totalCartValue = totalCartValue;
|
- |
|
| 451 |
cartDetailsObj.cartItems = cartItems;
|
- |
|
| 452 |
cartDetailsObj.totalSkus = totalSkus;
|
- |
|
| 453 |
if(parseInt(totalCartQuantity)>=5){
|
- |
|
| 454 |
shippingCharges = 30*totalCartQuantity;
|
- |
|
| 455 |
}else {
|
- |
|
| 456 |
shippingCharges = 60*totalCartQuantity;
|
- |
|
| 457 |
}
|
- |
|
| 458 |
cartDetailsObj.shippingCharges = shippingCharges;
|
- |
|
| 459 |
localStorage.setItem('cart_details',JSON.stringify(cartDetailsObj));
|
- |
|
| 460 |
}
|
- |
|
| 461 |
$('div.cartitemstotal span.itemstotal').text('₹ '+numberWithCommas(totalCartValue));
|
- |
|
| 462 |
$('div.cartitemstotal span.shippingval').text('₹ '+numberWithCommas(shippingCharges));
|
- |
|
| 463 |
var payable = 0;
|
- |
|
| 464 |
if(shippingCharges>0){
|
- |
|
| 465 |
if(totalCartValue>0){
|
163 |
renderCartDerivedValues();
|
| 466 |
$('.cartitemstotal').removeClass('hidden');
|
- |
|
| 467 |
$('span.cartheader').attr('style', 'font-size: 8pt;padding-left: 18px;');
|
- |
|
| 468 |
$('span.cartheader').text('');
|
- |
|
| 469 |
payable = parseInt(shippingCharges)+parseInt(totalCartValue);
|
- |
|
| 470 |
}else{
|
- |
|
| 471 |
payable = 0;
|
- |
|
| 472 |
$('span.cartheader').text('');
|
- |
|
| 473 |
$('span.cartheader').attr('style', 'font-size: 12pt;padding-left: 30px;');
|
- |
|
| 474 |
$('span.cartheader').text('Cart Details');
|
- |
|
| 475 |
}
|
- |
|
| 476 |
}else{
|
- |
|
| 477 |
payable = parseInt(totalCartValue);
|
- |
|
| 478 |
$('span.cartheader').attr('style', 'font-size: 12pt;padding-left: 30px;');
|
- |
|
| 479 |
$('span.cartheader').text('');
|
- |
|
| 480 |
$('span.cartheader').text('Cart Details');
|
- |
|
| 481 |
$('.cartitemstotal').addClass('hidden');
|
- |
|
| 482 |
}
|
- |
|
| 483 |
$('div.cartgrandtotal span.pull-right').text('₹ '+numberWithCommas(payable));
|
- |
|
| 484 |
|
- |
|
| 485 |
if(payable>0){
|
- |
|
| 486 |
$('button.checkoutbtn').prop( "disabled", false );
|
- |
|
| 487 |
}else{
|
- |
|
| 488 |
$('button.checkoutbtn').prop( "disabled", true );
|
- |
|
| 489 |
}
|
- |
|
| 490 |
if(!$('div.cartitemstotal').hasClass('hidden')){
|
- |
|
| 491 |
$('div.scroll').attr('style', 'margin-bottom: 176px');
|
- |
|
| 492 |
}else{
|
- |
|
| 493 |
$('div.scroll').attr('style', 'margin-bottom: 100px');
|
- |
|
| 494 |
}
|
- |
|
| 495 |
});
|
164 |
});
|
| 496 |
|
165 |
|
| 497 |
function numberWithCommas(x) {
|
166 |
function numberWithCommas(x) {
|
| 498 |
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
167 |
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
| 499 |
}
|
168 |
}
|
| Line 640... |
Line 309... |
| 640 |
$(document).on('click','span.clearItem',function(){
|
309 |
$(document).on('click','span.clearItem',function(){
|
| 641 |
var itemId = $(this).attr('sku');
|
310 |
var itemId = $(this).attr('sku');
|
| 642 |
var cart_details = localStorage.getItem('cart_details');
|
311 |
var cart_details = localStorage.getItem('cart_details');
|
| 643 |
if(cart_details!=undefined){
|
312 |
if(cart_details!=undefined){
|
| 644 |
var cartDetailsObj = JSON.parse(cart_details);
|
313 |
var cartDetailsObj = JSON.parse(cart_details);
|
| 645 |
if(cartDetailsObj.totalSkus==1){
|
314 |
var item = cartDetailsObj.cartItems[itemId];
|
| 646 |
var item = cartDetailsObj.cartItems[itemId];
|
315 |
$("div.card[sku='"+itemId+"']").addClass("hidden");
|
| 647 |
if(item!=undefined){
|
316 |
$(this).next().find('input').val(0);
|
| 648 |
var currentQty = parseInt(item.quantity);
|
317 |
$(this).next().find("button[data-dir='up']").data('estimate', '');
|
| 649 |
if(currentQty==0){
|
318 |
$("span.packQuantity[data-id='"+itemId+"']").text(0);
|
| 650 |
$("div.card[sku='"+itemId+"']").addClass("hidden");
|
319 |
$("span.lineitemtotal[data-id='"+itemId+"']").text(' ₹ '+ 0);
|
| 651 |
$("#cartloader").addClass('hidden');
|
320 |
if($('div.card:visible').length==0){
|
| 652 |
}else{
|
- |
|
| 653 |
clearCart();
|
321 |
clearCart();
|
| 654 |
$("span.clearCart").removeClass('clearCart');
|
322 |
$("span.clearCart").removeClass('clearCart');
|
| 655 |
}
|
- |
|
| 656 |
}else{
|
- |
|
| 657 |
$("div.card[sku='"+itemId+"']").addClass("hidden");
|
- |
|
| 658 |
$("#cartloader").addClass('hidden');
|
- |
|
| 659 |
}
|
- |
|
| 660 |
}else{
|
323 |
}else{
|
| 661 |
$("#cartloader").removeClass('hidden');
|
324 |
loadCartDetails();
|
| 662 |
var item = cartDetailsObj.cartItems[itemId];
|
325 |
renderCartDerivedValues();
|
| - |
|
326 |
}
|
| - |
|
327 |
}
|
| - |
|
328 |
});
|
| - |
|
329 |
|
| 663 |
if(item!=undefined){
|
330 |
function loadCartDetails(){
|
| - |
|
331 |
cartItems = {};
|
| - |
|
332 |
oldCartItems = JSON.parse(localStorage.getItem('cart_details')).cartItems;
|
| - |
|
333 |
$('.number-spinner').each(function (index, val) {
|
| 664 |
var currentQty = parseInt(item.quantity);
|
334 |
var element = $(val);
|
| 665 |
var unitPrice = parseInt(item.unitprice);
|
335 |
var quantity = element.find("input").val();
|
| - |
|
336 |
|
| 666 |
cartDetailsObj.totalSkus = cartDetailsObj.totalSkus -1;
|
337 |
var dataElement = element.find("button[data-dir='up']")
|
| 667 |
cartDetailsObj.totalCartQuantity = cartDetailsObj.totalCartQuantity - currentQty;
|
338 |
var estimate = dataElement.data('estimate');
|
| 668 |
var totalCartValue = cartDetailsObj.totalCartValue - (currentQty*unitPrice);
|
339 |
var catalogItemId = dataElement.data('identifier');
|
| 669 |
cartDetailsObj.totalCartValue = totalCartValue;
|
340 |
var sku = dataElement.data('id');
|
| 670 |
var shippingCharges;
|
341 |
var price = dataElement.data('price');
|
| - |
|
342 |
var bulkpricing = dataElement.data('bulkpricing');
|
| 671 |
if(parseInt(totalCartValue)>1000){
|
343 |
var prodname = dataElement.data('name');
|
| 672 |
shippingCharges = 0;
|
344 |
var brandname = dataElement.data('brand');
|
| - |
|
345 |
|
| 673 |
}else if(parseInt(totalCartValue)>=500 && parseInt(totalCartValue)<1000){
|
346 |
if (bulkpricing != undefined && bulkpricing.length != 0){
|
| 674 |
shippingCharges = 50;
|
347 |
for(var i=0;i<bulkpricing.length;i++)
|
| - |
|
348 |
{
|
| 675 |
}else if(parseInt(totalCartValue)>0 && parseInt(totalCartValue)<500){
|
349 |
if(val.quantity<bulkpricing[i]['quantity']){
|
| 676 |
shippingCharges = 100;
|
350 |
break;
|
| - |
|
351 |
}
|
| 677 |
}else{
|
352 |
else{
|
| 678 |
shippingCharges = 0;
|
353 |
price = bulkpricing[i]['price'];
|
| 679 |
}
|
354 |
}
|
| 680 |
cartDetailsObj.shippingCharges = shippingCharges;
|
- |
|
| 681 |
|
355 |
}
|
| 682 |
$('div.cartitemstotal span.itemstotal').text('₹ '+numberWithCommas(totalCartValue));
|
- |
|
| 683 |
$('div.cartitemstotal span.shippingval').text('₹ '+numberWithCommas(shippingCharges));
|
- |
|
| 684 |
var payable = 0;
|
356 |
}
|
| 685 |
if(shippingCharges>0){
|
357 |
itemDetail = {};
|
| 686 |
if(totalCartValue>0){
|
358 |
if (estimate=="-1") {
|
| 687 |
$('.cartitemstotal').removeClass('hidden');
|
359 |
itemDetail['quantity']=oldCartItems[sku.toString()].quantity
|
| - |
|
360 |
} else {
|
| 688 |
$('span.cartheader').attr('style', 'font-size: 8pt;padding-left: 18px;');
|
361 |
itemDetail['quantity']=parseInt(quantity);
|
| - |
|
362 |
}
|
| 689 |
$('span.cartheader').text('');
|
363 |
itemDetail['unitprice']=parseInt(price);
|
| 690 |
payable = parseInt(shippingCharges)+parseInt(totalCartValue);
|
364 |
itemDetail['productname']=prodname;
|
| 691 |
}else{
|
- |
|
| 692 |
payable = 0;
|
365 |
itemDetail['brand']=brandname;
|
| 693 |
$('span.cartheader').text('');
|
366 |
itemDetail['catalogItemId'] = catalogItemId.toString();
|
| 694 |
$('span.cartheader').attr('style', 'font-size: 12pt;padding-left: 30px;');
|
367 |
itemDetail['category'] = dataElement.data('category');
|
| 695 |
$('span.cartheader').text('Cart Details');
|
368 |
cartItems[sku.toString()] = itemDetail;
|
| 696 |
}
|
369 |
});
|
| 697 |
}else{
|
370 |
setCartDetails(cartItems);
|
| - |
|
371 |
}
|
| - |
|
372 |
|
| 698 |
payable = parseInt(totalCartValue);
|
373 |
function setCartDetails(cartItems) {
|
| 699 |
$('span.cartheader').attr('style', 'font-size: 12pt;padding-left: 30px;');
|
374 |
var cartDetailsObj = {};
|
| 700 |
$('span.cartheader').text('');
|
375 |
cartDetailsObj.totalCartQuantity = 0;
|
| 701 |
$('span.cartheader').text('Cart Details');
|
376 |
cartDetailsObj.totalCartValue = 0;
|
| 702 |
$('.cartitemstotal').addClass('hidden');
|
377 |
cartDetailsObj.mobileCount = 0;
|
| 703 |
}
|
- |
|
| 704 |
$('div.cartgrandtotal span.pull-right').text('₹ '+numberWithCommas(payable));
|
378 |
cartDetailsObj.totalSkus = 0;
|
| 705 |
|
- |
|
| 706 |
if(payable>0){
|
379 |
cartDetailsObj.shippingCharges = 0;
|
| 707 |
$('button.checkoutbtn').prop( "disabled", false );
|
380 |
cartDetailsObj.accessoryShippingCharges = 0;
|
| 708 |
}else{
|
381 |
cartDetailsObj.cartItems = cartItems;
|
| 709 |
$('button.checkoutbtn').prop( "disabled", true );
|
382 |
cartDetailsObj.mobileCount = 0;
|
| 710 |
}
|
- |
|
| 711 |
if(!$('div.cartitemstotal').hasClass('hidden')){
|
383 |
for(itemId in cartItems) {
|
| 712 |
$('div.scroll').attr('style', 'margin-bottom: 176px');
|
384 |
item = cartItems[itemId];
|
| 713 |
}else{
|
385 |
if(item.quantity > 0){
|
| 714 |
$('div.scroll').attr('style', 'margin-bottom: 100px');
|
386 |
cartDetailsObj.totalCartQuantity += item.quantity;
|
| - |
|
387 |
cartDetailsObj.totalSkus += 1;
|
| 715 |
}
|
388 |
}
|
| 716 |
cartDetailsObj.cartItems[itemId].quantity = 0;
|
389 |
cartDetailsObj.totalCartValue += item.quantity*item.unitprice;
|
| 717 |
localStorage.setItem('cart_details',JSON.stringify(cartDetailsObj));
|
- |
|
| 718 |
$("div.card[sku='"+itemId+"']").addClass("hidden");
|
390 |
if(item.category=='Mobile Phone' || item.category=='Tablet') {
|
| 719 |
$("#cartloader").addClass('hidden');
|
391 |
cartDetailsObj.mobileCount += item.quantity;
|
| 720 |
}else{
|
392 |
} else {
|
| 721 |
$("div.card[sku='"+itemId+"']").addClass("hidden");
|
393 |
cartDetailsObj.accessoryShippingCharges = 100;
|
| 722 |
$("#cartloader").addClass('hidden');
|
- |
|
| 723 |
}
|
- |
|
| 724 |
|
- |
|
| 725 |
}
|
394 |
}
|
| 726 |
}
|
395 |
}
|
| 727 |
});
|
- |
|
| 728 |
|
396 |
if(cartDetailsObj.mobileCount<5){
|
| - |
|
397 |
cartDetailsObj.shippingCharges = cartDetailsObj.accessoryShippingCharges + 60*cartDetailsObj.mobileCount;
|
| - |
|
398 |
} else {
|
| - |
|
399 |
cartDetailsObj.shippingCharges = cartDetailsObj.accessoryShippingCharges + 30*cartDetailsObj.mobileCount;
|
| - |
|
400 |
}
|
| - |
|
401 |
localStorage.setItem('cart_details',JSON.stringify(cartDetailsObj));
|
| - |
|
402 |
}
|
| - |
|
403 |
|
| - |
|
404 |
function renderCartDerivedValues(){
|
| - |
|
405 |
var cart_details = localStorage.getItem('cart_details');
|
| - |
|
406 |
var cartDetailsObj = JSON.parse(cart_details);
|
| - |
|
407 |
var totalCartValue = cartDetailsObj.totalCartValue;
|
| - |
|
408 |
var totalCartQuantity = cartDetailsObj.totalCartQuantity;
|
| - |
|
409 |
var cartItems = cartDetailsObj.cartItems;
|
| - |
|
410 |
var shippingCharges =cartDetailsObj.shippingCharges;
|
| - |
|
411 |
var totalSkus = cartDetailsObj.totalSkus;
|
| - |
|
412 |
|
| - |
|
413 |
$('div.cartitemstotal span.itemstotal').text('₹ '+numberWithCommas(totalCartValue));
|
| - |
|
414 |
$('div.cartitemstotal span.shippingval').text('₹ '+numberWithCommas(shippingCharges));
|
| - |
|
415 |
var payable = 0;
|
| - |
|
416 |
if(shippingCharges>0){
|
| - |
|
417 |
if(totalCartValue>0){
|
| - |
|
418 |
$('.cartitemstotal').removeClass('hidden');
|
| - |
|
419 |
payable = parseInt(shippingCharges)+parseInt(totalCartValue);
|
| - |
|
420 |
}else{
|
| - |
|
421 |
payable = 0;
|
| - |
|
422 |
}
|
| - |
|
423 |
}else{
|
| - |
|
424 |
payable = parseInt(totalCartValue);
|
| - |
|
425 |
$('.cartitemstotal').addClass('hidden');
|
| - |
|
426 |
}
|
| - |
|
427 |
$('div.cartgrandtotal span.pull-right').text('₹ '+numberWithCommas(payable));
|
| - |
|
428 |
|
| - |
|
429 |
if(payable>0){
|
| - |
|
430 |
$('button.checkoutbtn').prop( "disabled", false );
|
| - |
|
431 |
}else{
|
| - |
|
432 |
$('button.checkoutbtn').prop( "disabled", true );
|
| - |
|
433 |
}
|
| - |
|
434 |
var estimateString = $('div.popover-markup').data('str');
|
| - |
|
435 |
if(estimateString!="Can't ship here"){
|
| - |
|
436 |
$('div.cartdetailscard').find('div, input, textarea, button, select').each(function () {
|
| - |
|
437 |
$(this).prop('disabled', false);
|
| - |
|
438 |
});
|
| - |
|
439 |
}else{
|
| - |
|
440 |
$('div.cartdetailscard').find('div, input, textarea, button, select').each(function () {
|
| - |
|
441 |
$(this).prop('disabled', true);
|
| - |
|
442 |
});
|
| - |
|
443 |
}
|
| - |
|
444 |
}
|
| - |
|
445 |
|
| 729 |
|
446 |
|