Subversion Repositories SmartDukaan

Rev

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

Rev 18314 Rev 18433
Line 83... Line 83...
83
					var element = $(val);
83
					var element = $(val);
84
					var quantity = element.find("input").val();
84
					var quantity = element.find("input").val();
85
					if(parseInt(quantity)>0){
85
					if(parseInt(quantity)>0){
86
						var sku = element.find("button[data-dir='up']").data('id');
86
						var sku = element.find("button[data-dir='up']").data('id');
87
						var price = element.find("button[data-dir='up']").data('price');
87
						var price = element.find("button[data-dir='up']").data('price');
-
 
88
						
-
 
89
						var bulkpricing = $(".number-spinner button[data-id='"+index+"']").data('bulkpricing');
-
 
90
						if (bulkpricing != undefined && bulkpricing.length != 0){
-
 
91
					    	for(var i=0;i<bulkpricing.length;i++)
-
 
92
					    		{
-
 
93
					    			if(val.quantity<bulkpricing[i]['quantity']){
-
 
94
					    				break;
-
 
95
					    			}
-
 
96
					    			else{
-
 
97
					    				price = bulkpricing[i]['price'];
-
 
98
					    			}
-
 
99
					    		}
-
 
100
					    }
-
 
101
						
88
						var catalogItemId = element.find("button[data-dir='up']").data('identifier');
102
						var catalogItemId = element.find("button[data-dir='up']").data('identifier');
89
						var prodname = $(this).data('name');
103
						var prodname = $(this).data('name');
90
					    var brandname = $(this).data('brand');
104
					    var brandname = $(this).data('brand');
91
						var itemDetail = {};
105
						var itemDetail = {};
92
						totalCartQuantity = totalCartQuantity + parseInt(quantity);
106
						totalCartQuantity = totalCartQuantity + parseInt(quantity);
Line 123... Line 137...
123
					var estimate = element.data('estimate');
137
					var estimate = element.data('estimate');
124
					var catalogItemId = element.find("button[data-dir='up']").data('identifier');
138
					var catalogItemId = element.find("button[data-dir='up']").data('identifier');
125
					if(parseInt(quantity)==0 && estimate==""){
139
					if(parseInt(quantity)==0 && estimate==""){
126
						var sku = element.find("button[data-dir='up']").data('id');
140
						var sku = element.find("button[data-dir='up']").data('id');
127
						var price = element.find("button[data-dir='up']").data('price');
141
						var price = element.find("button[data-dir='up']").data('price');
-
 
142
						var bulkpricing = $(".number-spinner button[data-id='"+index+"']").data('bulkpricing');
-
 
143
						if (bulkpricing != undefined && bulkpricing.length != 0){
-
 
144
					    	for(var i=0;i<bulkpricing.length;i++)
-
 
145
					    		{
-
 
146
					    			if(val.quantity<bulkpricing[i]['quantity']){
-
 
147
					    				break;
-
 
148
					    			}
-
 
149
					    			else{
-
 
150
					    				price = bulkpricing[i]['price'];
-
 
151
					    			}
-
 
152
					    		}
-
 
153
					    }
128
						var prodname = $(this).data('name');
154
						var prodname = $(this).data('name');
129
					    var brandname = $(this).data('brand');
155
					    var brandname = $(this).data('brand');
130
						var itemDetail = cartDetailsObj.cartItems[sku.toString()];
156
						var itemDetail = cartDetailsObj.cartItems[sku.toString()];
131
						if(itemDetail==undefined){
157
						if(itemDetail==undefined){
132
							itemDetail = {};
158
							itemDetail = {};
Line 232... Line 258...
232
    var sku = btn.data('id');
258
    var sku = btn.data('id');
233
    var unitPrice = btn.data('price');
259
    var unitPrice = btn.data('price');
234
    var prodname = btn.data('name');
260
    var prodname = btn.data('name');
235
    var brandname = btn.data('brand');
261
    var brandname = btn.data('brand');
236
    var catalogItemId = btn.data('identifier');
262
    var catalogItemId = btn.data('identifier');
-
 
263
    var minBuyQuantity = btn.data('minquantity');
-
 
264
    if(minBuyQuantity == "" || minBuyQuantity == undefined){
-
 
265
    	minBuyQuantity =1;
-
 
266
    }
-
 
267
    var quantityStep = btn.data('quantitystep');
-
 
268
    if(quantityStep == "" || quantityStep == undefined){
-
 
269
    	quantityStep =1;
-
 
270
    }
-
 
271
    var bulkpricing = btn.data('bulkpricing');
237
    if (btn.attr('data-dir') == 'up') {
272
    if (btn.attr('data-dir') == 'up') {
238
		if ( input.attr('max') == undefined || parseInt(input.val()) < parseInt(input.attr('max')) ) {
273
		if ( input.attr('max') == undefined || parseInt(input.val()) < parseInt(input.attr('max')) ) {
-
 
274
			if((parseInt(input.val())== 0 || parseInt(input.val())< minBuyQuantity) && (parseInt(input.attr('max')) >= minBuyQuantity)){	
239
			if(parseInt(input.val())<5){
275
				inc = minBuyQuantity - parseInt(input.val());
240
				inc = 1;
-
 
241
				newVal = parseInt(oldValue) + inc;
276
				newVal = parseInt(oldValue) + inc;
-
 
277
			}
242
			}else{
278
			else{
243
				inc = 5-(parseInt(input.val())%5);
279
				inc = quantityStep;
244
				newVal = parseInt(oldValue) + inc;
280
				newVal = parseInt(oldValue) + inc;
245
				if(newVal>parseInt(input.attr('max'))){
281
				if(newVal>parseInt(input.attr('max'))){
246
					inc = parseInt(input.attr('max')) - parseInt(oldValue);
282
					inc = parseInt(input.attr('max')) - parseInt(oldValue);
247
					newVal = parseInt(oldValue) + inc;
283
					newVal = parseInt(oldValue) + inc;
248
				}
284
				}
249
			}
285
			}
-
 
286
//			if(parseInt(input.val())<5){
-
 
287
//				inc = 1;
-
 
288
//				newVal = parseInt(oldValue) + inc;
-
 
289
//			}else{
-
 
290
//				inc = 5-(parseInt(input.val())%5);
-
 
291
//				newVal = parseInt(oldValue) + inc;
-
 
292
//				if(newVal>parseInt(input.attr('max'))){
-
 
293
//					inc = parseInt(input.attr('max')) - parseInt(oldValue);
-
 
294
//					newVal = parseInt(oldValue) + inc;
-
 
295
//				}
-
 
296
//			}
250
		}else{
297
		}else{
251
			newVal = parseInt(oldValue);
298
			newVal = parseInt(oldValue);
252
			btn.prop("disabled", true);
299
			btn.prop("disabled", true);
253
		}
300
		}
254
		if(newVal==parseInt(input.attr('max'))){
301
		if(newVal==parseInt(input.attr('max'))){
Line 257... Line 304...
257
			input.attr('style', 'border: 1px solid #CCCCCC');
304
			input.attr('style', 'border: 1px solid #CCCCCC');
258
		}
305
		}
259
		totalCartQuantity = totalCartQuantity + inc;
306
		totalCartQuantity = totalCartQuantity + inc;
260
	} else {
307
	} else {
261
		if ( input.attr('min') == undefined || parseInt(input.val()) > parseInt(input.attr('min')) ) {
308
		if ( input.attr('min') == undefined || parseInt(input.val()) > parseInt(input.attr('min')) ) {
262
		    dec = 1;
309
//		    dec = 1;
-
 
310
			dec = quantityStep;
263
			newVal = parseInt(oldValue) - dec;
311
			newVal = parseInt(oldValue) - dec;
-
 
312
			var minBuyQtyDiff = parseInt(oldValue) - minBuyQuantity;
-
 
313
			if(minBuyQtyDiff ==0){
-
 
314
				dec = minBuyQuantity;
-
 
315
				newVal = parseInt(oldValue) - dec;
-
 
316
			}else if(dec>minBuyQtyDiff){
-
 
317
				dec = minBuyQtyDiff;
-
 
318
				newVal = parseInt(oldValue) - dec;
-
 
319
			}
264
		}else{
320
		}else{
265
			btn.prop("disabled", true);
321
			btn.prop("disabled", true);
266
		}
322
		}
267
		if(newVal==parseInt(input.attr('min'))){
323
		if(newVal==parseInt(input.attr('min'))){
268
			input.attr('style', 'border: 2px solid #5bc0de');
324
			input.attr('style', 'border: 2px solid #5bc0de');
Line 271... Line 327...
271
		}
327
		}
272
		totalCartQuantity = totalCartQuantity - dec;
328
		totalCartQuantity = totalCartQuantity - dec;
273
	}
329
	}
274
    $("span.lineitemqty[data-id='"+sku+"']").text(newVal);
330
    $("span.lineitemqty[data-id='"+sku+"']").text(newVal);
275
	btn.closest('.number-spinner').find('input').val(newVal);
331
	btn.closest('.number-spinner').find('input').val(newVal);
-
 
332
	
-
 
333
	
-
 
334
	if (bulkpricing != undefined && bulkpricing.length != 0){
-
 
335
		bulkpricing = bulkpricing.sort(function(a, b){
-
 
336
		    return a.quantity - b.quantity;
-
 
337
		});
-
 
338
    	for(var i=0;i<bulkpricing.length;i++)
-
 
339
    		{
-
 
340
    			if(newVal<bulkpricing[i]['quantity']){
-
 
341
    				break;
-
 
342
    			}
-
 
343
    			else{
-
 
344
    				
-
 
345
    				unitPrice = bulkpricing[i]['price'];
-
 
346
    			}
-
 
347
    		}
-
 
348
    }
-
 
349
	$("span.lineitemprice[data-id='"+sku+"']").text(unitPrice);
-
 
350
 
-
 
351
	
276
	$("span.packQuantity[data-id='"+sku+"']").text(newVal*$("span.packQuantity[data-id='"+sku+"']").data('pack'));
352
	$("span.packQuantity[data-id='"+sku+"']").text(newVal*$("span.packQuantity[data-id='"+sku+"']").data('pack'));
277
	$("span.lineitemtotal[data-id='"+sku+"']").text(' ₹ '+ (parseInt(newVal)*parseInt(unitPrice)).toString());
353
	$("span.lineitemtotal[data-id='"+sku+"']").text(' ₹ '+ (parseInt(newVal)*parseInt(unitPrice)).toString());
278
	if(cartDetailsObj==undefined){
354
	if(cartDetailsObj==undefined){
279
		jsonObjToBeStored['totalCartQuantity'] = totalCartQuantity;
355
		jsonObjToBeStored['totalCartQuantity'] = totalCartQuantity;
280
		totalCartValue = totalCartValue + (unitPrice * newVal);
356
		totalCartValue = totalCartValue + (unitPrice * newVal);