| Line 4... |
Line 4... |
| 4 |
loadingHtml: '<center><img src="/img/ajax-loader.gif" alt="Loading" /></center>',
|
4 |
loadingHtml: '<center><img src="/img/ajax-loader.gif" alt="Loading" /></center>',
|
| 5 |
autoTriggerUntil: 3,
|
5 |
autoTriggerUntil: 3,
|
| 6 |
padding: 20,
|
6 |
padding: 20,
|
| 7 |
});
|
7 |
});
|
| 8 |
}
|
8 |
}
|
| - |
|
9 |
if($('.storeminprice').length>0) {
|
| - |
|
10 |
var globalminprice = 9999999;
|
| - |
|
11 |
var globalminsku;
|
| - |
|
12 |
$('.storeminprice').each(function(){
|
| - |
|
13 |
var that = $(this);
|
| - |
|
14 |
$.ajax({
|
| - |
|
15 |
url: '/store_products/getliveprice/'+$(this).data('bundle_id')+'/'+$(this).data('id'),
|
| - |
|
16 |
// Tell jQuery we're expecting JSONP
|
| - |
|
17 |
dataType: "json",
|
| - |
|
18 |
// Tell YQL what we want and that we want JSON
|
| - |
|
19 |
method: 'get',
|
| - |
|
20 |
// Work with the response
|
| - |
|
21 |
success: function( response ) {
|
| - |
|
22 |
if(response.success){
|
| - |
|
23 |
var i = 0;
|
| - |
|
24 |
var minpriceindex = 0;
|
| - |
|
25 |
var minprice = response.products[0]['available_price'];
|
| - |
|
26 |
var minpriceurl = response.products[0]['marketPlaceUrl'];
|
| - |
|
27 |
if(response.products.length>0){
|
| - |
|
28 |
//More than one products in store
|
| - |
|
29 |
var variants = [];
|
| - |
|
30 |
// var i = 0;
|
| - |
|
31 |
for(var i in response.products){
|
| - |
|
32 |
if(response.products[i].available_price && response.products[i].available_price < globalminprice) {
|
| - |
|
33 |
globalminprice = response.products[i].available_price;
|
| - |
|
34 |
globalminsku = response.products[i]._id;
|
| - |
|
35 |
}
|
| - |
|
36 |
if(response.products[i].available_price <= minprice) {
|
| - |
|
37 |
minprice = response.products[i].available_price;
|
| - |
|
38 |
minpriceindex = i;
|
| - |
|
39 |
}
|
| - |
|
40 |
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});
|
| - |
|
41 |
}
|
| - |
|
42 |
if(i>0){
|
| - |
|
43 |
var variantslink = $('<span class="variants">+ '+i+' Options</span>');
|
| - |
|
44 |
$(that).parent().append(variantslink);
|
| - |
|
45 |
$(variantslink).data('variants',variants)
|
| - |
|
46 |
}
|
| - |
|
47 |
}
|
| - |
|
48 |
$(that).html(minprice);
|
| - |
|
49 |
$('#sku-'+$(that).data('id')).data('id',response.products[minpriceindex]['_id']).removeClass('hidden');
|
| - |
|
50 |
console.log(globalminprice+' '+globalminsku);
|
| - |
|
51 |
$('#bestprice').html(globalminprice);
|
| - |
|
52 |
$('#beststorelink').data('id',globalminsku).removeClass('hidden');
|
| - |
|
53 |
$('#bestpricecontainer').removeClass('hidden');
|
| - |
|
54 |
if(!response.products[0].available_price){
|
| - |
|
55 |
$(that).parent().parent().remove();
|
| - |
|
56 |
}
|
| - |
|
57 |
}else{
|
| - |
|
58 |
$(that).parent().parent().remove();
|
| - |
|
59 |
}
|
| - |
|
60 |
},
|
| - |
|
61 |
error : function() {
|
| - |
|
62 |
$(that).parent().parent().remove();
|
| - |
|
63 |
}
|
| - |
|
64 |
});
|
| - |
|
65 |
});
|
| - |
|
66 |
}
|
| - |
|
67 |
$(document).on('click','.variants',function(){
|
| - |
|
68 |
$('.storeproductinfo').empty();
|
| - |
|
69 |
var variants = $(this).data('variants');
|
| - |
|
70 |
for(var i in variants){
|
| - |
|
71 |
console.log(variants[i]);
|
| - |
|
72 |
var row = $('<div class="row storeproductinfo"><div class="col-xs-4">'+variants[i].source_product_name+'</div><div class="col-xs-4">'+variants[i].available_price+'</div><div class="col-xs-4"><button class="btn btn-primary btn-xs viewproduct" type="button" data-id="'+variants[i].id+'">Visit Store</button></div></div>');
|
| - |
|
73 |
$('#storeproducts').parent().append(row);
|
| - |
|
74 |
}
|
| - |
|
75 |
$('#variantModal').modal();
|
| - |
|
76 |
});
|
| 9 |
$('.categorytab').on('click','.categorytabcontrol.active',function(){
|
77 |
$('.categorytab').on('click','.categorytabcontrol.active',function(){
|
| 10 |
$(this).toggleClass('active');
|
78 |
$(this).toggleClass('active');
|
| 11 |
$('#preferences-'+$(this).data('id')).addClass('hidden');
|
79 |
$('#preferences-'+$(this).data('id')).addClass('hidden');
|
| 12 |
$(this).parent().parent().children().find('.savecategorypreferences',0).removeClass('savecategorypreferences').addClass('editcategorypreferences').html('Edit').removeClass('btn-success');
|
80 |
$(this).parent().parent().children().find('.savecategorypreferences',0).removeClass('savecategorypreferences').addClass('editcategorypreferences').html('Edit').removeClass('btn-success');
|
| 13 |
});
|
81 |
});
|
| Line 43... |
Line 111... |
| 43 |
}
|
111 |
}
|
| 44 |
}
|
112 |
}
|
| 45 |
});
|
113 |
});
|
| 46 |
ga('send', 'event', 'preferences', 'update', me);
|
114 |
ga('send', 'event', 'preferences', 'update', me);
|
| 47 |
});
|
115 |
});
|
| 48 |
$('.row').on('click','.viewproduct',function(e){
|
116 |
// $('.row').on('click','.viewproduct',function(e){
|
| - |
|
117 |
$(document).on('click','.viewproduct',function(e){
|
| 49 |
$('#loadingModal').modal();
|
118 |
$('#loadingModal').modal();
|
| - |
|
119 |
console.log($(this).data('id'));
|
| 50 |
var url = apihost+"clicks/add/"+me+"/"+$(this).data('id');
|
120 |
var url = apihost+"clicks/add/"+me+"/"+$(this).data('id');
|
| 51 |
$.ajax({
|
121 |
$.ajax({
|
| 52 |
url: url,
|
122 |
url: url,
|
| 53 |
// The name of the callback parameter, as specified by the YQL service
|
123 |
// The name of the callback parameter, as specified by the YQL service
|
| 54 |
jsonp: "callback",
|
124 |
jsonp: "callback",
|