added direct to cart page. fixed bug in product details page. added qty valid.

This commit is contained in:
2023-04-25 14:20:22 +05:30
rodzic 7823781020
commit e922bb6b35
11 zmienionych plików z 210 dodań i 50 usunięć
+50 -8
Wyświetl plik
@@ -1,5 +1,9 @@
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.search.split('=')[1].split('&')[0];
console.log(productId);
let itemtagscombinationRes = null;
@@ -12,7 +16,7 @@ function startDetails(){
let currentClick = null;
debugger;
if(productId){
getProductDetails(productId);
getProductDetails(productId);
appendSpecs(productId)
}else{
window.location.href = "/notfound.html"
@@ -40,34 +44,71 @@ function startDetails(){
}
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>`;
return ` <tr id="${id}" data-specitemid="${itemid}">
<td style="width:200px">${name}</td>
<td class="">${des}</td>
</tr>`;
}
// 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];
html += getSpecsItemHTML({
name:specificationname,id:specificationitemid,itemid,des:description
});
if((i+1)%2 == 0){
rightHtml += getSpecsItemHTML({
name:specificationname,id:specificationitemid,itemid,des:description
})
}else{
leftHtml += getSpecsItemHTML({
name:specificationname,id:specificationitemid,itemid,des:description
});
}
}
debugger;
$('.append-specs').html(html)
$('.specContainerleft').html(leftHtml)
$('.specContainerRight').html(rightHtml)
}
@@ -116,6 +157,7 @@ function startDetails(){
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');
@@ -343,7 +385,7 @@ debugger;
});
debugger;
let searchParams = window.location.search.split("&");
let skuId = window.location.hash.split('=')[1];
let skuId = window.location.hash.split('#')[1].split('=')[1];
// skuId = skuId.split('=')[1]
let isGo = true;
for(let i=0;i<itemtagscombinationRes.length;i++){