function startDetails(){
// http://127.0.0.1:5502/productdetails.html?productId=106633230000024
if(window.location.search.split('=')[0] == ''){
window.location.href = "/notfound.html";
return;
}
debugger;
let productId = window.location.href.split('=')[1].split('&')[0].split('#')[0];
console.log(productId);
let itemtagscombinationRes = null;
let labels = {};
let isThereInLabel = {};
let currentComb = null;
let group = {};
let loadingActions = {
addLoader(){
$('.loadingCall').removeClass('d-none');
$('.mainContanierProduct').addClass('d-none');
},
removeLoader(){
$('.loadingCall').addClass('d-none');
$('.mainContanierProduct').removeClass('d-none');
}
}
let currentClick = null;
if(productId){
loadingActions.addLoader();
updateProductId(productId);
getProductDetails(productId);
appendSpecs(productId)
}else{
window.location.href = "/notfound.html"
}
function updateProductId(val){
$('#productidtag').val(val);
}
function updateItemId(val){
$('#itemidtag').val(val);
}
let specification_wrap_action = {
remove(){
$('.specification-wrap').addClass('d-none');
},
add(){
$('.specification-wrap').removeClass('d-none');
}
}
let description_action = {
addVal(value){
$('.description-wrap > p').html(value);
},
removeVal(value){
$('.description-wrap > p').html('');
}
}
function getSpecsItemHTML({name,des,itemid,id}){
return `
`;
return `
${name} |
${des} |
`;
}
// function getSpecsItemHTML({name,des,itemid,id}){
// return `
// ${name} |
// ${des} |
//
`;
// }
async function appendSpecs(id){
let resData = await API_SERVICES_ACTIONS.getAPIService(`apis/v4/bizgaze/integrations/products/itemspecifications/itemid/${id}`,true);
if(resData.isError){
$('.productdetailstabs').addClass('d-none');
$('.specContainerleft').html('')
$('.specContainerRight').html('')
return;
}
$('.productdetailstabs ').removeClass('d-none');
const res = resData.response;
console.log(JSON.parse(res.result));
const data = JSON.parse(res.result);
console.log(data);
let html = '';
let leftHtml = '';
let rightHtml = '';
if(data.length == 0){
$('.productdetailstabs ').addClass('d-none');
$('.specContainerleft').html('')
$('.specContainerRight').html('')
return;
}
for(let i=0;i
${name}
`;
}
function onClickHandler(e) {
$(e).parent().find('.borderselector').removeClass('borderselector');
$(e).addClass('borderselector')
}
function getChildHTML(tagid,name,isTrue){
return `
${name}
`
}
function addeventlisteners(){
$('.optiontaganwi').each(function (i,el){
$(el).click(function (e){
$('#quantity').val(1)
$(e.target).parent().find('.borderselector').removeClass('borderselector');
$(e.target).addClass('borderselector')
searchComb();
currentClick = e.target;
// getAllCombination();
})
});
}
function updateDetailsByObj(obj){
$('.productname').html(obj.itemname);
let [currencySymbol, amount] = getCurrencySymbol(obj?.pricelist||0);
$('.price').html(obj.pricelist ?`${currencySymbol}${amount}`:'');
appendSpecs(obj.itemid)
$('#skudetailitem').val(obj.sku)
$('.des_productdes').html(obj.itemdescription);
$('#addtocart').attr('data-qty',obj.quantity);
let defaultImg = obj.itemimageurl ? imgServerNameBuild(obj.itemimageurl): `./dist/assets/imgs/nophoto.png`;
console.log(obj.itemimageurl,'obj.itemimageurlobj.itemimageurlobj.itemimageurl');
$('.productDetailsMain > img').attr('src',defaultImg);
updateItemId(obj.itemid);
if (!obj.pricelist || !obj.quantity) {
$('.buynow').attr('disabled', true);
$('#addtocart').attr('disabled', true);
} else {
$('.buynow').attr('disabled', false);
$('#addtocart').attr('disabled', false);
}
}
function searchComb(){
let valuesSelected = [];
$('#addtocart').removeClass('disabled');
$('.msgErrorDetailsItem').addClass('d-none');
$('.borderselector').each(function (i,el){
let val = $(el).html();
valuesSelected.push(val.trim());
});
let labelRecord = {};
for(let label in labels){
labelRecord[label] = false;
}
console.log(labelRecord);
specification_wrap_action.add();
console.log(group);
let unFiler = null;
for(let i=0;i=$('#quantity').val() && quantity>=1){
currentComb = itemtagscombinationRes[i];
// $('.productname').html(itemtagscombinationRes[i].itemname)
// $('.price').html(itemtagscombinationRes[i].pricelist);
// location.hash = itemtagscombinationRes[i].itemname.trim();
// appendSpecs(itemtagscombinationRes[i].itemid)
history.replaceState(null, null, `#itemid=${itemtagscombinationRes[i].itemid}#${itemtagscombinationRes[i].itemname.trim()}`);
// $('#skudetailitem').val(itemtagscombinationRes[i].sku)
// $('.des_productdes').html(itemtagscombinationRes[i].itemdescription);
updateDetailsByObj(itemtagscombinationRes[i]);
}else{
let name = itemtagscombinationRes[i].itemname.split('-')[0];
$('#addtocart').addClass('disabled');
$('.buynow').attr('disabled', true);
let itemsName = name;
$('.borderselector').each(function (i,e){
itemsName += ` ${$(e).html().trim()}`;
});
updateItemId(null);
specification_wrap_action.remove();
$('#skudetailitem').val(-1)
$('.productname').html(itemsName)
history.replaceState(null, null, `#`);
$('.msgErrorDetailsItem').removeClass('d-none');
$('.des_productdes').html('');
$('.price').html('');
}
initAddToCart()
return;
}
}
let name = itemtagscombinationRes[0].itemname.split('-')[0];
let itemsName = name;
$('.borderselector').each(function (i,e){
itemsName += `- ${$(e).html().trim()}`;
})
specification_wrap_action.remove();
$('.productname').html(itemsName)
$('#skudetailitem').val(-1)
$('.price').html('');
$('#addtocart').addClass('disabled');
$('.buynow').attr('disabled', true);
$('.msgErrorDetailsItem').removeClass('d-none');
initAddToCart()
}
function getAllCombination(){
const currClickAttr = $(currentClick).html().trim();
let isThere = [];
for(let item in isThereInLabel){
let {tagnames} = isThereInLabel[item];
if(tagnames.includes(currClickAttr)){
isThere.push( isThereInLabel[item])
}
}
let selected = [];
$('.borderselector').each(function (i,e){
selected.push($(e).html().trim())
});
// console.log(selected);
// console.log(isThere);
let ishashObj = {};
for(let i=0;i