123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939 |
- function startDetails() {
- // http://127.0.0.1:5502/productdetails.html?productId=106633230000024
-
- if (window.location.search.split('=')[0] == '') {
- window.location.href = "/notfound.html";
- return;
- }
- let productId = window.location.hash.split('#')[1].split('=')[1];
- console.log(productId);
- let itemtagscombinationRes = null;
- let labels = {};
- let isThereInLabel = {};
- let currentComb = null;
-
- let colorId = 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) {
- swapSectionsVideo();
- 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 `<div id="${id}" data-specitemid="${itemid}" class="">
- <div class="row border-bottom">
- <div class="col-sm-6 bg-gray-3 py-2">
- ${name}
- </div>
- <div class="col-sm-6 py-2">
- ${des}
- </div>
- </div>
- </div>`;
-
- }
- // function getSpecsItemHTML({name,des,itemid,id}){
- // return ` <tr id="${id}" data-specitemid="${itemid}">
- // <td style="width:200px">${name}</td>
- // <td class="">${des}</td>
- // </tr>`;
- // }
-
- 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 < data.length; i++) {
- const { specificationname, specificationitemid, itemid, description } = data[i];
- if ((i + 1) % 2 == 0) {
- rightHtml += getSpecsItemHTML({
- name: specificationname, id: specificationitemid, itemid, des: description
- })
- } else {
- leftHtml += getSpecsItemHTML({
- name: specificationname, id: specificationitemid, itemid, des: description
- });
- }
-
- }
-
- $('.specContainerleft').html(leftHtml)
- $('.specContainerRight').html(rightHtml)
-
- }
-
-
- function getParentHTML(name, productid, id, isMain) {
- return `<div data-parentidgroup="${name?.replace(" ", '')}-parent" class="pb-2 groupingitems_search ${name?.replace(" ", '')}-parent">
- <h5 class="py-2 smallHeadingProductDetails">${name}</h5>
- <div class="d-flex gap-2 flex-lg-row flex-wrap ${id}container" data-tagid="${id}">
-
- </div>
- </div>`;
- }
-
- function onClickHandler(e) {
-
- $(e).parent().find('.borderselector').removeClass('borderselector');
-
- $(e).addClass('borderselector')
-
- }
-
- function getChildHTML(tagid, name, isTrue,parentid) {
-
- let blue = '#253746';
- let greenLight = '#5e7975';
- let brown = '#624839';
- let bgColor = '';
- if(name === 'Deep Sea Blue'){
- bgColor = blue;
- }else if(name == 'Desert Brown'){
- bgColor = brown;
- }else if(name == 'Eucalyptus Green'){
- bgColor = greenLight;
- }
-
- if(colorId == parentid){
- return `
- <div data-type="${tagid}-${name}" data-tagiditem="${tagid}" class="specsmallcard optiontaganwi ${isTrue ? 'borderselector' : ''} colorselector card text-center small-font cursor-pointer ">
- <span style="
- height: 25px;
- border-radius: 5px;
- width:25px;
- background: ${bgColor} !important;
- pointer-events:none;
-
- "></span>
- </div> `
- }
- return `
- <div data-type="${tagid}-${name}" data-tagiditem="${tagid}" class="specsmallcard optiontaganwi ${isTrue ? 'borderselector' : ''} card text-center small-font cursor-pointer p-3">
- ${name}
- </div> `
-
-
- }
-
- 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');
-
- currentClick = e.target;
- ;
- //searchComb();
- // getAllCombination();
- getandsetCombination();
-
- })
- });
-
- }
-
- function getandsetCombination(){
-
- let keyOption = $(currentClick).data('tagiditem');
- $('.disabled-option-item').removeClass('disabled-option-item');
- let tagsNames = [];
-
-
-
- let currOptionAvaIds = {};
-
- $('.borderselector').each(function (i,e){
- let id = $(e).data('tagiditem');
- tagsNames.push(id);
- });
-
-
- for(let i=0;i<itemtagscombinationRes.length;i++){
- let tagItems = itemtagscombinationRes[i].tagids;;
- if(tagItems.includes(keyOption)){
- let splitArr = tagItems.split('|');
- for(let j=0;j<splitArr.length;j++){
- if(keyOption){
- currOptionAvaIds[splitArr[j]] = splitArr[j];
- }
-
- }
- }
- }
-
- console.log(currOptionAvaIds);
- console.log(itemtagscombinationRes);
- let parentsArr = [];
- $('.optiontaganwi').each(function (i,e){
-
- let currParent = $(e).parents('.groupingitems_search');
-
- if(currParent.find(`[data-tagiditem="${keyOption}"]`).length==0){
- let currId = $(e).data('tagiditem');
- if(!currOptionAvaIds[currId]){
- if($(e).hasClass('borderselector')){
- parentsArr.push(currParent);
- $(e).removeClass('borderselector');
- }
- $(e).addClass('disabled-option-item');
- }
- }
- });
-
- for(let i=0;i<parentsArr.length;i++){
- let currParent = parentsArr[i];
- currParent.find('.optiontaganwi').each(function (j,e){
- let isTrue = $(e).hasClass('disabled-option-item');
- if(!isTrue){
- $(e).addClass('borderselector');
- return false;
- }
- });
- }
-
- // $('.optiontaganwi').addClass('disabled-option-item');
- let parentId = $(currentClick).parents('.groupingitems_search');
- let parentData = $(parentId).data('parentidgroup');
- let parentArr = [];
- $('.groupingitems_search').each(function (i,e){
- const curParentId = $(e).data('parentidgroup');
- if(parentData != curParentId){
- let obj = {
- name:$(e).find('.smallHeadingProductDetails').html(),
- arr:[]
- }
- $(e).find('.optiontaganwi').each(function (j,evt){
- let id = $(evt).data('tagiditem');
- obj.arr.push(id);
- });
- parentArr.push(obj);
-
- }
- })
-
- console.log(parentArr);
-
- let arrone = parentArr[0].arr;
- let arrtwo = [];
- if(parentArr.length>1){
- arrtwo = parentArr[1]?.arr;
- }
-
- let currId = keyOption;
- let ids = [];
- for(let i=0;i<arrone.length;i++){
- //let currEl = [currId,arrone[i]];
- let currEl = ``
- for(let j=0;j<arrtwo.length;j++){
- currEl = `${currId}|${arrone[i]}|${arrtwo[j]}`;
-
- ids.push(currEl);
- currEl = '';
- }
-
- }
- console.log(ids,'ids');
- let findObj = [];
- debugger
- for(let i=0;i<ids.length;i++){
-
- let curId = ids[i]
- for(let j=0;j<itemtagscombinationRes.length;j++){
- const currItem = itemtagscombinationRes[j].tagids.split('|');
- let isTrue = true;
- for(let k=0;k<currItem.length;k++){
- if(!curId.includes(currItem[k])){
- isTrue = false;
- break;
- }
- }
-
- if(isTrue){
- findObj.push(itemtagscombinationRes[j]);
- }
- }
- }
-
-
- console.log(findObj);
-
- $('.optiontaganwi').addClass('disabled-option-item');
-
- debugger;
- for(let i=0;i<findObj.length;i++){
-
- let item = findObj[i].tagids.split('|');
- for(let j=0;j<item.length;j++){
- $(`[data-tagiditem=${item[j]}]`).removeClass('disabled-option-item');
- }
-
- }
-
- $(parentId).find('.optiontaganwi').each(function (i,e){
- $(e).removeClass('disabled-option-item')
- });
-
-
- for(let i=0;i<itemtagscombinationRes.length;i++){
- let currIds = itemtagscombinationRes[i].tagids;
- let isTrue = true;
- let isPro = false;
-
- for(let j=0;j<tagsNames.length;j++){
- if(tagsNames.join().includes('106631360000128')&&(tagsNames.join().includes('106631360000132')||tagsNames.join().includes('106631360000133'))){
- isPro = true;
- }
- if(!currIds.includes(tagsNames[j])){
- isTrue = false;
- }
- }
-
- if(isTrue){
- const { quantity } = itemtagscombinationRes[i];
- if (true) {
- currentComb = itemtagscombinationRes[i];
-
- updateDetailsByObj(itemtagscombinationRes[i]);
-
- if(isPro){
- $(`[data-tagiditem="106631360000089"]`).addClass(' disabled-option-item')
- $(`[data-tagiditem="106631360000088"]`).addClass(' disabled-option-item')
- }
-
-
- } else {
-
- let name = itemtagscombinationRes[i].itemname.split('-')[0];
- $('#addtocart').addClass('disabled');
- let itemsName = name;
- $('.borderselector').each(function (i, e) {
- itemsName += ` ${$(e).html().trim()}`;
- });
-
- updateItemId(null);
-
- let defaultImg = itemtagscombinationRes[i].itemimageurl ? imgServerNameBuild(itemtagscombinationRes[i].itemimageurl) : `./dist/assets/imgs/nophoto.png`;
-
- $('.productDetailsMain > img').attr('src', defaultImg);
-
- specification_wrap_action.remove();
- $('#skudetailitem').val(-1)
- $('.productname').html(itemsName)
-
-
- $('.msgErrorDetailsItem').removeClass('d-none');
- $('.des_productdes').html('');
- $('.price').html('');
- }
-
- initAddToCart()
- return;
- }
-
- }
-
-
-
-
- // return;
-
-
-
-
- return;
- let commonTags = [];
- // $('.optiontaganwi').addClass('disabled-option-item')
-
- for(let i=0;i<tagsNames.length;i++){
- let currtagName = tagsNames[i];
- let arr = currtagItemCom(currtagName);
- commonTags.push(arr);
- }
-
-
-
- console.log(commonTags);
-
- // for(let i=0;i<commonTags.length;i++){
- // let currObj = commonTags[i];
- // for(let item in currObj){
- // console.log($(`[data-tagiditem="${item}"]`));
- // $(`[data-tagiditem="${item}"]`).removeClass('disabled-option-item')
- // }
- // }
-
- let finalAns = {};
- let arra = [];
- for(let i=0;i<commonTags.length;i++){
- let currObj = commonTags[i];
- for(let item in currObj){
- let isTrue = true;
- for(let j=0;j<commonTags.length;j++){
- if(j!=i){
- let currComb = commonTags[j];
- if(!currComb[item]){
- isTrue = false;
- }
- }
- }
- if(isTrue){
- arra.push(currObj[item])
- finalAns[currObj[item]] = currObj[item];
- $(`[data-tagiditem="${item}"]`).removeClass('disabled-option-item')
- }
- }
- }
-
- // console.log(arra);
-
-
-
-
-
-
- // for(let i=0;i<itemtagscombinationRes.length;i++){
- // let tagItems = itemtagscombinationRes[i].tagids;;
- // if(tagItems.includes(keyOption)){
- // let splitArr = tagItems.split('|');
- // for(let j=0;j<splitArr.length;j++){
- // commonTags[splitArr[j]] = splitArr[j];
- // }
- // }
- // }
-
-
-
- // for(let i=0;i<currOptionAvaIds.length;i++){
- // let currId = currOptionAvaIds[i];
- // if(parentId.find(currId).length === 0){
- // console.log(currId);
- // }
- // }
- }
-
-
-
- function currtagItemCom(keyOption){
- debugger;
- let arr = [];
- let commonTags = {};
- for(let i=0;i<itemtagscombinationRes.length;i++){
- let tagItems = itemtagscombinationRes[i].tagids;;
- if(tagItems.includes(keyOption)){
- let splitArr = tagItems.split('|');
- for(let j=0;j<splitArr.length;j++){
- if(!commonTags[splitArr[j]]){
- commonTags[splitArr[j]] = {
- keyOption,
- data:itemtagscombinationRes[i]
- };
- arr.push(splitArr[j]);
-
- }
-
- }
- }
- }
-
- return commonTags;
- }
-
-
-
- function updateDetailsByObj(obj) {
- $('.productname').html(obj.itemname);
- $('.titleproductnav').html(obj.itemname);
- let [currencySymbol, amount] = getCurrencySymbol(obj?.pricelist||0);
-
- let commingSoonText = window.location.href.toLowerCase().includes('zeno')||window.location.href.includes('fyro')
- $('.price').html(obj.pricelist ? `<span class="font-w600">${currencySymbol}${amount}</span>${commingSoonText?'<span class="mx-1 badge d-md-none bg-gradient-violet text-a-color">Pre Order Now!</span>':''}` : 'pre order now');
- 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');
- debugger;
- let productId = window.location.hash.split('#')[1]?.split('=')[1];
- let itemId = window.location.hash.split('#')[2]?.split('=')[1];
- history.replaceState(undefined, undefined, `#productId=${productId}#itemid=${obj.itemid}`)
- $('.productDetailsMain > img').attr('src', defaultImg).attr('loading','lazy');
-
- updateItemId(obj.itemid);
-
- console.log(obj,'objobjobj');
- debugger;
- 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 = [];
- $('.optiontaganwi').removeClass('disabled-option-item')
-
- $('#addtocart').removeClass('disabled');
- $('.msgErrorDetailsItem').addClass('d-none');
- $('.borderselector,border_selector').each(function (i, el) {
- console.log($(el).html())
- let val = $(el).data('tagiditem');
- valuesSelected.push(val);
- });
-
- 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 < itemtagscombinationRes.length; i++) {
- const currItem = itemtagscombinationRes[i];
- const { tagids } = currItem;
-
-
- let isTrue = true;
- let labelFilter = labelRecord;
-
- for (let i = 0; i < valuesSelected.length; i++) {
-
- if (!tagids.includes(valuesSelected[i])) {
- isTrue = false
-
- unFiler = labelFilter;
- break;
- }
- labelFilter[group[valuesSelected[i]]] = true;
- }
-
- if (isTrue) {
- // console.log(itemtagscombinationRes[i], 'itemtagscombinationRes[i]');
- const { quantity } = itemtagscombinationRes[i];
- if (quantity >= $('#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');
- let itemsName = name;
- $('.borderselector').each(function (i, e) {
- itemsName += ` ${$(e).html().trim()}`;
- });
-
- updateItemId(null);
-
- let defaultImg = itemtagscombinationRes[i].itemimageurl ? imgServerNameBuild(itemtagscombinationRes[i].itemimageurl) : `./dist/assets/imgs/nophoto.png`;
- // console.log(itemtagscombinationRes[i].itemimageurl, 'obj.itemimageurlobj.itemimageurlobj.itemimageurl');
-
- $('.productDetailsMain > img').attr('src', defaultImg);
-
- 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;
-
- }
-
- }
-
-
-
- // alert("j");
-
- 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');
- $('.msgErrorDetailsItem').removeClass('d-none');
-
- initAddToCart()
- }
-
- function getAllCombination() {
- debugger;
- const currClickAttr = $(currentClick).html().trim();
- const optionId = $(currentClick).data('tagiditem');
-
- let curr = $(currentClick).parents('.groupingitems_search').data('parentidgroup');
- $('.groupingitems_search').each(function (i, e) {
- const id = $(e).data('parentidgroup');
- if (id != curr) {
- $(e).find('.optiontaganwi').addClass('disabled-option-item');
- $(e).find('.borderselector').removeClass('borderselector');
- }
- });
-
- let ansArr = [];
- let index = 0;
- let comb = null;
- for(let i=0;i<itemtagscombinationRes.length;i++){
-
- let currIds = itemtagscombinationRes[i].tagids;
-
- if(currIds.includes(optionId)){
- currIds = currIds.split('|');
-
- for(let j=0;j<currIds.length;j++){
- debugger;
- if(index==0 &&optionId != currIds[j] ) {
- $(`[data-tagiditem="${currIds[j]}"]`).addClass('borderselector')
- comb = itemtagscombinationRes[i];
- index++;
- }
- $(`[data-tagiditem="${currIds[j]}"]`).removeClass('disabled-option-item');
-
- // $().parents('[data-tagid]').find()
- }
-
- }
-
-
-
- }
-
- // console.log(comb,'comb tag');
-
- updateDetailsByObj(comb);
-
- let currentItem = comb.tagids.split('|');
-
- for(let i=0;i<currentItem.length;i++){
- $(`[data-tagiditem="${currentItem[i]}"]`).removeClass('disabled-option-item').addClass('borderselector');
- }
-
- // history.replaceState(null, null, `#${comb.itemname}`);
- // window.location.href = `#${comb.itemname}`
- console.log(itemtagscombinationRes,'gobal');
- return;
-
-
- };
-
-
-
-
-
- async function getProductDetails(id) {
-
-
- debugger;
-
- let resData = await API_SERVICES_ACTIONS.getAPIService(`apis/v4/bizgaze/integrations/products/productattributelist/productid/${id}`, true);
-
- if (resData.isError) {
- loadingActions.removeLoader();
- alert(resData.errorMsg.message);
- return;
- }
-
- if(resData.response.result == '[]' || !resData.response.result){
- $('.barbgnav').removeClass('d-none')
- loadingActions.removeLoader();
- toasterHelper("Something Went Wrong")
- return;
- }
-
- let res = resData.response;
-
- res = JSON.parse(res.result);
- // console.log(res, 'productattributelist');
-
- if (!res) {
- loadingActions.removeLoader();
- return;
- };
-
-
-
-
- let html = '';
-
- for (let i = 0; i < res.length; i++) {
- const currItem = res[i];
- // parenttagid means under what label
- // tag id means it know unquie id
- const { parentattribute, parenttagid, tagid, attribute, productid } = currItem;
-
- if (labels[parentattribute]) {
- labels[parentattribute].items.push({
- attribute,
- tagid: tagid
- });
- } else {
- labels[parentattribute] = {
- id: parenttagid,
- items: [{
- attribute,
- tagid: tagid
- }]
- };
-
- if(parentattribute.toLowerCase() === 'colour'){
- colorId = parenttagid;
- }
- html += getParentHTML(parentattribute, productid, parenttagid, i == 0);
- }
-
- }
- $('#spec-container-details').html(html);
-
-
- console.log(labels,'labels');
-
- let childIds = [];
-
- for (let item in labels) {
- let { id, items } = labels[item];
- // $(`[data-tagid=${id}]`)
- let html = '';
-
- for (let i = 0; i < items.length; i++) {
- const { attribute, tagid } = items[i]
- childIds.push(tagid);
- group[attribute] = item;
- console.log(attribute,colorId,"s");
- html += getChildHTML(tagid, attribute, i == 0,id);
- console.log(attribute,"attributeattributeattributeattribute");
- }
- debugger;
- $(`[data-tagid="${id}"]`).html(html);
- }
- itemtagscombinationRes = await API_SERVICES_ACTIONS.getAPIService(`apis/v4/bizgaze/integrations/products/getitemwithoutbranch/productid/${id}`, true);
- itemtagscombinationRes = JSON.parse(itemtagscombinationRes.response.result);
- console.log(itemtagscombinationRes, "conductt");
-
- let itemidSearch = window.location.hash.split('#')[2]?.split('=')[1];
-
- if(!itemidSearch){
- itemidSearch = itemtagscombinationRes[0].itemid
- }
-
- let valuesSelected = [];
-
- $('.borderselector').each(function (i, el) {
-
- let val = $(el).html();
- valuesSelected.push(val.trim());
- });
- debugger;
- // let searchParams = window.location.search.split("&");
- // let skuId = window.location.hash.split('#')[2].split('=')[1];
- // skuId = skuId.split('=')[1]
- let isGo = true;
- for (let i = 0; i < itemtagscombinationRes.length; i++) {
- const currItem = itemtagscombinationRes[i];
-
- const { tagnames, sku, itemid } = currItem;
-
- isThereInLabel[tagnames] = itemtagscombinationRes[i];
- let isTrue = true;
- if (isGo) {
- // for(let i=0;i<valuesSelected.length;i++){
- // if(!tagnames.includes(valuesSelected[i])){
- // isTrue = false
- // }
- // }
- if (itemidSearch != itemid) {
- isTrue = false
- }
- // if (i != 0) {
- // isTrue = false
- // }
- if (isTrue) {
-
- // console.log(itemtagscombinationRes[i], 'itemtagscombinationRes[i]');
-
-
- currentComb = itemtagscombinationRes[i];
-
-
- updateDetailsByObj(itemtagscombinationRes[i]);
-
-
-
- isGo = false;
- let { tagnames, tagids, pricelist } = itemtagscombinationRes[i];
- tagids = tagids.split('|');
- tagnames = tagnames.split('|');
- $('.optiontaganwi').removeClass('borderselector');
-
- for (let i = 0; i < tagids.length; i++) {
-
- $(`[data-tagiditem="${tagids[i]}"]`).addClass('borderselector');
- }
-
- break;
- // tagiditem
- }
- }
- }
-
-
- if (isGo && itemtagscombinationRes.length != 0) {
-
- // console.log(itemtagscombinationRes[0]);
- let { tagnames, tagids, pricelist } = itemtagscombinationRes[0];
- tagids = tagids.split('|');
- tagnames = tagnames.split('|');
- $('.optiontaganwi').removeClass('borderselector');
- currentComb = itemtagscombinationRes[0];
- // updateItemId(itemtagscombinationRes[0].itemid);
-
- for (let i = 0; i < tagids.length; i++) {
-
- $(`[data-type="${tagids[i]}-${tagnames[i]}"]`).addClass('borderselector');
- // $(`[data-type="${tagids[i]}-Eucalyptus Green"]`).removeClass('borderselector');
- // $(`[data-type="${tagids[i]}-Desert Brown"]`).removeClass('borderselector');
- // $(`[data-type="${tagids[i]}-Deep Sea Blue"]`).removeClass('borderselector');
- }
-
- // $('.price').html(pricelist);
- // $('.des_productdes').html(itemtagscombinationRes[0].itemdescription);
- // appendSpecs(itemtagscombinationRes[0].itemid);
-
- updateDetailsByObj(itemtagscombinationRes[0]);
- //console.log(childIds);
- //
-
- }
-
-
-
- //getAllCombination()
-
-
-
- // for(let i=0;i<itemtagscombinationRes.length;i++){
- // const {tagnames} = itemtagscombinationRes[i];
-
- // }
-
- $('#spec-container-details').children().find('.specsmallcard').removeClass('specsmallcard');
-
-
-
- //getting the first borderselector in first $('.groupingitems_search')[0]
-
- let firstParentGroup = $('.groupingitems_search')[0];
- debugger;
- let optionId = $(firstParentGroup).find('.borderselector').data('tagiditem');
-
- currentClick = $(firstParentGroup).find('.borderselector')
- getandsetCombination();
- addeventlisteners();
- loadingActions.removeLoader();
- return;
-
-
- }
-
-
- }
- startDetails();
|