Subversion Repositories SmartDukaan

Rev

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

Rev 14150 Rev 14215
Line 8... Line 8...
8
		});
8
		});
9
	}
9
	}
10
	if($('.storeminprice').length>0) {
10
	if($('.storeminprice').length>0) {
11
		var globalminprice = 9999999;
11
		var globalminprice = 9999999;
12
		var globalminsku;
12
		var globalminsku;
-
 
13
		var inStock = false;
13
		$('.storeminprice').each(function(){
14
		$('.storeminprice').each(function(){
14
			var that = $(this);			
15
			var that = $(this);			
15
			$.ajax({
16
			$.ajax({
16
				url: '/store_products/getliveprice/'+$(this).data('bundle_id')+'/'+$(this).data('id'),
17
				url: '/store_products/getliveprice/'+$(this).data('bundle_id')+'/'+$(this).data('id'),
17
				// Tell jQuery we're expecting JSONP
18
				// Tell jQuery we're expecting JSONP
Line 20... Line 21...
20
				method: 'get',
21
				method: 'get',
21
				// Work with the response
22
				// Work with the response
22
				success: function( response ) {
23
				success: function( response ) {
23
					if(response.success){
24
					if(response.success){
24
						var i = 0;	
25
						var i = 0;	
25
						var minpriceindex = 0;										
26
						var minpriceindex = 0;				
-
 
27
						if(response.products[i].in_stock == 1){inStock = true;}
26
						var minprice = response.products[0]['available_price'];
28
						var minprice = response.products[0]['available_price'];
27
						var minpriceurl = response.products[0]['marketPlaceUrl'];
29
						var minpriceurl = response.products[0]['marketPlaceUrl'];
28
						if(response.products.length>0){
30
						if(response.products.length>0){
29
							//More than one products in store
31
							//More than one products in store
30
							var variants = [];
32
							var variants = [];
31
							// var i = 0;
33
							// var i = 0;
32
							for(var i in response.products){
34
							for(var i in response.products){	
-
 
35
								if(response.products[i].in_stock == 1){inStock = true;}						
-
 
36
								console.log(response.products[i]);
33
								if(response.products[i].available_price && response.products[i].available_price < globalminprice) {
37
								if(response.products[i].available_price && response.products[i].available_price < globalminprice) {
34
									globalminprice = response.products[i].available_price;
38
									globalminprice = response.products[i].available_price;
35
									globalminsku = response.products[i]._id;
39
									globalminsku = response.products[i]._id;
36
								}
40
								}
37
								if(response.products[i].available_price <= minprice) {
41
								if(response.products[i].available_price <= minprice) {
Line 45... Line 49...
45
								var variantslink = $('<span class="variants">+ '+i+' Options</span>');
49
								var variantslink = $('<span class="variants">+ '+i+' Options</span>');
46
								$(that).parent().append(variantslink);							
50
								$(that).parent().append(variantslink);							
47
								$(variantslink).data('variants',variants)
51
								$(variantslink).data('variants',variants)
48
							}
52
							}
49
						}
53
						}
-
 
54
						if(inStock){
50
						$(that).html(minprice);
55
							$(that).html(minprice);
51
						$('#sku-'+$(that).data('id')).data('id',response.products[minpriceindex]['_id']).removeClass('hidden');
56
							$('#sku-'+$(that).data('id')).data('id',response.products[minpriceindex]['_id']).removeClass('hidden');
52
						console.log(globalminprice+' '+globalminsku);
57
							console.log(globalminprice+' '+globalminsku);
53
						if(globalminprice != 9999999) {
58
							if(globalminprice != 9999999) {
54
							$('#bestprice').html(globalminprice);
59
								$('#bestprice').html(globalminprice);
55
							$('#beststorelink').data('id',globalminsku).removeClass('hidden');
60
								$('#beststorelink').data('id',globalminsku).removeClass('hidden');
56
							$('#bestpricecontainer').removeClass('hidden');
61
								$('#bestpricecontainer').removeClass('hidden');
-
 
62
							}
-
 
63
						}else{
-
 
64
							$(that).parent().parent().remove();	
57
						}
65
						}
58
						if(!response.products[0].available_price){
66
						if(!response.products[0].available_price){
59
							$(that).parent().parent().remove();	
67
							$(that).parent().parent().remove();	
60
						}
68
						}
61
					}else{
69
					}else{
Line 306... Line 314...
306
		$('#cat-'+$(this).data('id')).toggleClass('hidden');
314
		$('#cat-'+$(this).data('id')).toggleClass('hidden');
307
	});
315
	});
308
	$(document).on('click','.refresh',function(){
316
	$(document).on('click','.refresh',function(){
309
		document.location.reload();
317
		document.location.reload();
310
	});
318
	});
-
 
319
	$(document).on('click','.hasmoretext',function(){
-
 
320
		$('#fulltext').html($(this).data('fulltext'));
-
 
321
		$('#fullTextModal').modal();
-
 
322
	});
311
});
323
});