Last Update: May 06, 2024 |
Online Shop Prices
Retail Prices
' +
'
' +
' ' +
''+product.title+'' +
' '+product.description+''+
' ' +
''+product.branch.branchName+' ('+product.distance+ ' away)'+
'' +
'' +
'
RM '+product.sellingPrice+'' +
'Call Now >'+whatsapphtml+
'
' +
'
' ;
if (product.isUsedItem){
isUsedAva = true;
ulUsed.append(li);
} else{
isInStoreAva = true;
ulInstore.append(li);
}
var data = {};
data['productId'] = product.id;
data['branchId'] = product.branchId;
$.ajax({
type: "GET",
dataType: 'json', //retunr data is javascript object
url: 'index.php?app=retail&act=getProductVouchers',
data: data,
success: function(data){
if (data.status == 200){
var discount = data.highestDiscount;
if (parseFloat(discount) > 0){
$('#'+product.id+product.branchId+'_voucher').show();
$('#'+product.id+product.branchId+'_voucher').append('RM'+discount+' Off Voucher');
if (!isNaN($('#'+product.id+product.branchId+'_price').attr("data-price")) && !isNaN(discount))
$('#'+product.id+product.branchId+'_price').html('RM '+ (parseFloat( $('#'+product.id+product.branchId+'_price').attr("data-price") ) - parseFloat(discount)).toString() +'*');
}
}
},
complete: function(){
}
});
if(i 3) $('#div-instoremore').show();
$("#instoreprice_ul li:gt(2)").hide();
getBoostedProduct();
if (!isUsedAva){
if (GeoLocChecked)
ulUsed.append('
No Result Found for your selected location! More Nearby Stores Coming Soon.');
else
ulUsed.append('
No Result Found for your selected location! Please click here to find Nearby store.');
} else {
$('#btnusedproducts').show();
}
if (!isInStoreAva){
if (GeoLocChecked)
ulInstore.append('
No Result Found for your selected location! More Nearby Stores Coming Soon.
');
else
ulInstore.append('
Please click here to find Nearby stores.');
}
if (isFirstLoad && GeoLocChecked){
if (isInStoreAva){
openTab(event, 'instoreprice');
} else if (isUsedAva){
openTab(event, 'usedproducts');
} else if (isOnlineAva) {
openTab(event, 'onlineprice');
} else {
openTab(event, 'instoreprice');
}
}
isFirstLoad = false;
ulInstore.append('');
ulUsed.append('');
// alert(obj.nearbyProduct);
},
complete: function(){
$('.loading-image').hide();
},
fail: function(request, status, error){
alert('fail:'+ status);
}
});
}
function getBoostedProduct(){
var form = $("#nearbyproducts");
//alert('data: '+form.serialize());
$.ajax({
type: "GET",
dataType: 'json', //retunr data is javascript object
url: 'index.php?app=retail&act=getBoostedProduct',
data: form.serialize(), // serializes the form's elements.
success: function(data)
{
if (data.status == 200){
var productImgUrl = '';
var productFullImgUrl = '';
var whatsapphtml = '';
var shopUrl = '';
var inStoreBranchImp = [];
var inStoreProdImp = [];
if (data.hasOwnProperty("product")){
var product = data.product;
if (product.hasOwnProperty('isCustomImageUsed') && product.isCustomImageUsed == true){
productImgUrl = product.thumbnailUrlCustom;
productFullImgUrl = product.imageUrlCustom;
} else {
productImgUrl = product.imageUrl;
productFullImgUrl = product.imageUrl;
}
if (product.branch.hasOwnProperty('technaveCustomUrl') && product.branch.technaveCustomUrl != ''){
shopUrl = '/shop/'+product.branch.technaveCustomUrl;
} else {
shopUrl = '/index.php?app=shop&act=product&branchId='+product.branchId+'&productId='+product.id;
}
if (product.distance '+
'
WhatsApp >';
}
var li = '
Ads
' ;
if (ulInstore){
ulInstore.prepend(li);
}
var data = {};
data['productId'] = product.id;
data['branchId'] = product.branchId;
$.ajax({
type: "GET",
dataType: 'json', //retunr data is javascript object
url: 'index.php?app=retail&act=getProductVouchers',
data: data,
success: function(data){
if (data.status == 200){
var discount = data.highestDiscount;
if (parseFloat(discount) > 0){
$('#'+product.id+product.branchId+'_voucher').show();
$('#'+product.id+product.branchId+'_voucher').append('RM'+discount+' Off Voucher');
if (!isNaN($('#'+product.id+product.branchId+'_price').attr("data-price")) && !isNaN(discount))
$('#'+product.id+product.branchId+'_price').html('RM '+ (parseFloat( $('#'+product.id+product.branchId+'_price').attr("data-price") ) - parseFloat(discount)).toString() +'*');
}
}
},
complete: function(){
}
});
inStoreBranchImp.push(product.branchId);
inStoreProdImp.push(product.id);
var jsonObj = {type:"IMPRESSION", productIds:inStoreProdImp, branchIds:inStoreBranchImp};
var jsonstr = JSON.stringify(jsonObj);
//console.log(jsonstr);
$.ajax({
type: "POST",
url: "index.php?app=retail&act=retailstats",
// The key needs to match your method's input parameter (case-sensitive).
data: jsonstr,
contentType: "application/json; charset=utf-8",
dataType: "json",
async:true,
success: function(data){console.log(data);},
failure: function(errMsg) {}
});
}
}
},
complete: function(){},
fail: function(request, status, error){}
});
}
$(document).ready(function(){
$( "#btninstoreprice" ).click(function() {
geolocate();
});
$('#nearbyproducts').bind('keydown', function(e) {
if (e.keyCode == 13) {
e.preventDefault();
}
});
});
// Bias the autocomplete object to the user's geographical location,
// as supplied by the browser's 'navigator.geolocation' object.
var GeoLocChecked = false;
function geolocate() {
GeoLocChecked = true;
$('#div-loc-msg').hide();
ulInstore.empty();
ulUsed.empty();
$('#div-instoremore').hide();
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(geoSuccess, geoError);
} else {
$('#div-loc-msg').show();
$.cookie("loc_allow", "0",{expires : 365});
}
}
var geoSuccess = function(position) {
$.cookie("loc_allow", "1",{expires : 365});
var geolocation = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
var circle = new google.maps.Circle({
center: geolocation,
radius: position.coords.accuracy
});
autocomplete.setBounds(circle.getBounds());
document.getElementById('latitude').value = position.coords.latitude;
document.getElementById('longitude').value = position.coords.longitude;
getNearByProducts();
document.getElementById('autocomplete').value = 'Your current location';
};
var geoError = function(error) {
$('#div-loc-msg').show();
$.cookie("loc_allow", "0",{expires : 365});
switch(error.code) {
case error.PERMISSION_DENIED:
$('#loc-error-msg').innerHTML = " ";
break;
case error.POSITION_UNAVAILABLE:
$('#loc-error-msg').innerHTML = "Location information is unavailable.";
break;
case error.TIMEOUT:
$('#loc-error-msg').innerHTML = "Request to get user location timed out.";
break;
case error.UNKNOWN_ERROR:
$('#loc-error-msg').innerHTML = "An unknown error occurred.";
break;
}
};
function moreRetailOffers(){
$('#instoreprice .list_pic li').show();
$('#div-instoremore').hide();
return false;
}
function addViewStats(productID){
var jsonObj = {type:"VIEW", productIds:[productID], branchIds:[]};
var jsonstr = JSON.stringify(jsonObj);
//console.log(jsonstr);
$.ajax({
type: "POST",
url: "index.php?app=retail&act=retailstats",
// The key needs to match your method's input parameter (case-sensitive).
data: jsonstr,
contentType: "application/json; charset=utf-8",
dataType: "json",
async:true,
success: function(data){console.log(data);},
failure: function(errMsg) {}
});
return true;
}