Subversion Repositories SmartDukaan

Rev

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

Rev 14345 Rev 14357
Line 35... Line 35...
35
			url: '/store_products/getliveprice/'+$(that).data('bundle_id')+'/'+$(that).data('id'),
35
			url: '/store_products/getliveprice/'+$(that).data('bundle_id')+'/'+$(that).data('id'),
36
			// Tell jQuery we're expecting JSONP
36
			// Tell jQuery we're expecting JSONP
37
			dataType: "json",
37
			dataType: "json",
38
			// Tell YQL what we want and that we want JSON			
38
			// Tell YQL what we want and that we want JSON			
39
			method: 'get',
39
			method: 'get',
40
			timeout: 180000,
40
			// timeout: 180000,
41
			// Work with the response
41
			// Work with the response
42
			success: function( response ) {
42
			success: function( response ) {
43
				if(response.success){
43
				if(response.success){
44
					var i = 0;	
44
					var i = 0;	
45
					var minpriceindex = 0;				
45
					var minpriceindex = 0;				
Line 50... Line 50...
50
						//More than one products in store
50
						//More than one products in store
51
						var variants = [];
51
						var variants = [];
52
						// var i = 0;
52
						// var i = 0;
53
						for(var i in response.products){	
53
						for(var i in response.products){	
54
							if(response.products[i].in_stock == 1){inStock = true;}						
54
							if(response.products[i].in_stock == 1){inStock = true;}						
55
							console.log(response.products[i]);
55
							// console.log(response.products[i]);
56
							if(response.products[i].available_price && response.products[i].available_price < globalminprice) {
56
							if(response.products[i].available_price && response.products[i].available_price < globalminprice) {
57
								globalminprice = response.products[i].available_price;
57
								globalminprice = response.products[i].available_price;
58
								globalminsku = response.products[i]._id;
58
								globalminsku = response.products[i]._id;
59
							}
59
							}
60
							if(response.products[i].available_price <= minprice) {
60
							if(response.products[i].available_price <= minprice) {
61
								minprice = response.products[i].available_price;
61
								minprice = response.products[i].available_price;
62
								minpriceindex = i;
62
								minpriceindex = i;
63
							} 
63
							} 
64
							console.log(response);
64
							// console.log(response);
65
							variants.push({'available_price' : response.products[i].available_price, 'url' : response.products[i].marketPlaceUrl,'source_product_name' : response.products[i].source_product_name,'id' : response.products[i]._id});
65
							variants.push({'available_price' : response.products[i].available_price, 'url' : response.products[i].marketPlaceUrl,'source_product_name' : response.products[i].source_product_name,'id' : response.products[i]._id});
66
						}
66
						}
67
						if(i>0){
67
						if(i>0){
68
							var variantslink = $('<span class="variants">+ '+i+' Options</span>');
68
							var variantslink = $('<span class="variants">+ '+i+' Options</span>');
69
							$(that).parent().append(variantslink);							
69
							$(that).parent().append(variantslink);							
Line 71... Line 71...
71
						}
71
						}
72
					}
72
					}
73
					if(inStock){
73
					if(inStock){
74
						$(that).html(minprice);
74
						$(that).html(minprice);
75
						$('#sku-'+$(that).data('id')).data('id',response.products[minpriceindex]['_id']).removeClass('hidden');
75
						$('#sku-'+$(that).data('id')).data('id',response.products[minpriceindex]['_id']).removeClass('hidden');
76
						console.log(globalminprice+' '+globalminsku);
76
						// console.log(globalminprice+' '+globalminsku);
77
						if(globalminprice != 9999999) {
77
						if(globalminprice != 9999999) {
78
							$('#bestprice').html(globalminprice);
78
							$('#bestprice').html(globalminprice);
79
							$('#beststorelink').data('id',globalminsku).removeClass('hidden');
79
							$('#beststorelink').data('id',globalminsku).removeClass('hidden');
80
							$('#bestpricecontainer').removeClass('hidden');
80
							$('#bestpricecontainer').removeClass('hidden');
81
						}
81
						}
Line 91... Line 91...
91
			},
91
			},
92
			error : function() {
92
			error : function() {
93
				$(that).parent().parent().remove();
93
				$(that).parent().parent().remove();
94
			}
94
			}
95
		});
95
		});
96
	}
96
	};
97
	$(document).on('click','.variants',function(){
97
	$(document).on('click','.variants',function(){
98
		$('.storeproductinfo').empty();
98
		$('.storeproductinfo').empty();
99
		var variants = $(this).data('variants');	
99
		var variants = $(this).data('variants');	
100
		$('#variantscount').html(variants.length);
100
		$('#variantscount').html(variants.length);
101
		for(var i in variants){
101
		for(var i in variants){