added direct to cart page. fixed bug in product details page. added qty valid.
Этот коммит содержится в:
поставляемый
@@ -275,6 +275,12 @@ function initLogin() {
|
||||
window.localStorage.setItem("Useremail", userEmail);
|
||||
//window.localStorage.setItem("Userpassword", userPassword);
|
||||
window.localStorage.setItem("isaccountCreated", true);
|
||||
const isCartAdded = localStorage.getItem(CART_ADD);
|
||||
if(isCartAdded){
|
||||
localStorage.removeItem(CART_ADD);
|
||||
window.location.href = `/selectdelivery.html`;
|
||||
return;
|
||||
}
|
||||
window.location.href = `./index.html`;
|
||||
} else {
|
||||
// toasterOpts();
|
||||
|
||||
поставляемый
+1
-1
@@ -30,7 +30,7 @@ let nav_html = `
|
||||
</div>
|
||||
<div class="same-style header-cart">
|
||||
<a class="cart-active1 position-relative" href="./shopping-cart.html"><i class="fa-solid fa-cart-shopping"></i>
|
||||
<span class="position-absolute cartnumcount d-none" style="top:-27%;right:-80%">0</span>
|
||||
<span class="position-absolute cartnumcount d-none" style="top:-15%;right:-115%">0</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
поставляемый
+1
-1
@@ -29,7 +29,7 @@ let nav_html = `
|
||||
<a href="./myaccount.html" class="my_avatar"><i class="fa-solid fa-user"></i></a>
|
||||
</div>
|
||||
<div class="same-style header-cart">
|
||||
<a class="cart-active1" href="#"><i class="fa-solid fa-cart-shopping"></i></a>
|
||||
<a class="cart-active1" href="/shopping-cart.html"><i class="fa-solid fa-cart-shopping"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
поставляемый
+50
-8
@@ -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++){
|
||||
|
||||
поставляемый
+15
-4
@@ -112,8 +112,9 @@ function initAddToCart(){
|
||||
const data = getCartData();
|
||||
|
||||
let id = window.location.search.split('=')[1];
|
||||
const qty = parseInt($('#addtocart').data('qty'));
|
||||
if(!data){
|
||||
|
||||
|
||||
let cartObj = {};
|
||||
debugger;
|
||||
|
||||
@@ -122,7 +123,8 @@ function initAddToCart(){
|
||||
price:$('.price').html(),
|
||||
quantity:$('#quantity').val(),
|
||||
img:$('.productDetailsMain img').attr('src'),
|
||||
sku:$('#skudetailitem').val()
|
||||
sku:$('#skudetailitem').val(),
|
||||
totalQty:qty
|
||||
}
|
||||
|
||||
|
||||
@@ -146,7 +148,8 @@ function initAddToCart(){
|
||||
price:price,
|
||||
quantity: parseInt(data[sku].quantity)+parseInt(quantity),
|
||||
img:img,
|
||||
sku:sku
|
||||
sku:sku,
|
||||
totalQty:qty
|
||||
}
|
||||
addtoCart(data);
|
||||
}else{
|
||||
@@ -155,7 +158,8 @@ function initAddToCart(){
|
||||
price:price,
|
||||
quantity:parseInt(quantity),
|
||||
img:img,
|
||||
sku:sku
|
||||
sku:sku,
|
||||
totalQty:qty
|
||||
}
|
||||
addtoCart(data);
|
||||
}
|
||||
@@ -170,6 +174,13 @@ function initAddToCart(){
|
||||
$('#addtocart').html('Add to cart')
|
||||
$('#addtocart').off().click((e)=>{
|
||||
debugger
|
||||
$('.insufficientqty').addClass('d-none');
|
||||
const qty = parseInt($('#addtocart').data('qty'));
|
||||
debugger;
|
||||
if(parseInt($('#quantity').val())>qty){
|
||||
$('.insufficientqty').removeClass('d-none');
|
||||
return;
|
||||
}
|
||||
$('#addtocart').off().click(function (el){
|
||||
window.location.href = '/shopping-cart.html';
|
||||
|
||||
|
||||
поставляемый
+43
-7
@@ -5,6 +5,17 @@ function shoppingCartInit() {
|
||||
|
||||
shoppingCartAppend();
|
||||
|
||||
let insufficientQtyActions = {
|
||||
moreQtyAdd(e){
|
||||
$(e.target).parents('.mainselectcontainer').find('.insufficientqty').removeClass('d-none');
|
||||
},
|
||||
|
||||
moreQtyRemove(e){
|
||||
$(e.target).parents('.mainselectcontainer').find('.insufficientqty').addClass('d-none');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function shoppingCartAppend() {
|
||||
let data = getCartData();
|
||||
|
||||
@@ -47,13 +58,23 @@ function shoppingCartInit() {
|
||||
$('.quantitySelect').each(function (i, element) {
|
||||
if (!$(element).hasClass('d-none')) {
|
||||
$(element).off().change(function (e) {
|
||||
insufficientQtyActions.moreQtyRemove(e);
|
||||
let num = e.target.value;
|
||||
if (num == 5) {
|
||||
$(e.target).parents('.mainselectcontainer').find('.inputcartaddmore').removeClass('d-none');
|
||||
$(e.target).addClass('d-none');
|
||||
$(e.target).parents('.mainselectcontainer').find('.inputcartaddmore button').off().click(function (item) {
|
||||
const val = $(item.target).parent().find('input').val()
|
||||
const val = $(item.target).parent().find('input').val();
|
||||
debugger;
|
||||
let totalQty = $(this).parents('.mainselectcontainer').data('qty');
|
||||
|
||||
if(val<=0 || totalQty< val){
|
||||
insufficientQtyActions.moreQtyAdd(e);
|
||||
return;
|
||||
}
|
||||
|
||||
let id = $(item.target).parents('.mainselectcontainer').data('id');
|
||||
|
||||
updateCartQuantity(id, val);
|
||||
// $(item.target).parents('.mainselectcontainer').find('.inputcartaddmore').addClass('d-none');
|
||||
// $(e.target).removeClass('d-none');
|
||||
@@ -62,6 +83,11 @@ function shoppingCartInit() {
|
||||
|
||||
})
|
||||
} else {
|
||||
const val = $(item.target).parent().find('input').val();
|
||||
if(val<=0 || totalQty< val){
|
||||
insufficientQtyActions.moreQtyAdd(e);
|
||||
return;
|
||||
}
|
||||
let id = $(e.target).parents('.mainselectcontainer').data('id');
|
||||
updateCartQuantity(id, num);
|
||||
setLengthCart();
|
||||
@@ -70,7 +96,17 @@ function shoppingCartInit() {
|
||||
});
|
||||
} else {
|
||||
$(element).parents('.mainselectcontainer').find('.inputcartaddmore button').off().click(function (item) {
|
||||
debugger;
|
||||
|
||||
const val = $(item.target).parent().find('input').val()
|
||||
let totalQty = $(this).parents('.mainselectcontainer').data('qty');
|
||||
|
||||
if(val<=0 || totalQty< val){
|
||||
insufficientQtyActions.moreQtyAdd(item);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let id = $(item.target).parents('.mainselectcontainer').data('id');
|
||||
updateCartQuantity(id, val);
|
||||
// $(item.target).parents('.mainselectcontainer').find('.inputcartaddmore').addClass('d-none');
|
||||
@@ -132,11 +168,11 @@ function shoppingCartInit() {
|
||||
});
|
||||
}
|
||||
|
||||
function getQuantityHTML(value, id) {
|
||||
return `<div data-id="${id}" class="mainselectcontainer w-100">
|
||||
function getQuantityHTML(value,totalQty, id) {
|
||||
return `<div data-id="${id}" data-qty="${totalQty}" class="mainselectcontainer w-100">
|
||||
<div class="w-50">
|
||||
|
||||
<select class="quantitySelect form-select ${value >= 5 ? 'd-none' : ''}" value="${value}">
|
||||
<select class="quantitySelect form-select ${value >= 5 ? 'd-none' : ''}" value="${value}">
|
||||
<option ${value == 1 ? 'selected="selected"' : null} value="1">
|
||||
1
|
||||
</option>
|
||||
@@ -159,11 +195,11 @@ function shoppingCartInit() {
|
||||
<input min="1" class="form-control" style="max-width:100px" value="${value <= 5 ? '5' : value}" type="number" />
|
||||
<button class="btn border-none bg-info">Add</button>
|
||||
</div>
|
||||
|
||||
<div class="text-danger pt-2 insufficientqty d-none">Insufficient quantity</div>
|
||||
</div>`
|
||||
}
|
||||
|
||||
function shoppingCartDesktopHTML({ id, img, name, price, description, quantity, total }) {
|
||||
function shoppingCartDesktopHTML({ id, img, name, price, description, quantity, total,totalQty }) {
|
||||
const [currencySymbol,amt] = getCurrencySymbol(price);
|
||||
return `
|
||||
<div class="row bg-white border-bottom py-4 d-flex justify-content-center align-items-center">
|
||||
@@ -179,7 +215,7 @@ function shoppingCartInit() {
|
||||
</div>
|
||||
<div class="col-md-2 ">
|
||||
|
||||
${getQuantityHTML(quantity, id)}
|
||||
${getQuantityHTML(quantity,totalQty, id)}
|
||||
</div>
|
||||
<div class="col-md-2 ">
|
||||
<div class="d-flex justify-content-between w-100">
|
||||
|
||||
поставляемый
+1
-1
@@ -14,7 +14,7 @@ function shuffleArray(array) {
|
||||
function getCurrencySymbol(value=0) {
|
||||
let type = 'INR'
|
||||
if (type) {
|
||||
const ans = new Intl.NumberFormat('en-US', { style: 'currency', currency: type }).format(value);;
|
||||
const ans = new Intl.NumberFormat('en-IN', { style: 'currency', currency: type }).format(value);;
|
||||
const res = ans.split(/(\D+)/);
|
||||
const currencySymbol = res[1];
|
||||
const amount = res.slice(2,res.length).join('')
|
||||
|
||||
Ссылка в новой задаче
Block a user