code added
这个提交包含在:
+11
-5
@@ -105,7 +105,7 @@ function updateSummaryPriceAdd(){
|
||||
}
|
||||
|
||||
function initAddToCart(){
|
||||
|
||||
debugger;
|
||||
addEventListeners();
|
||||
|
||||
function addToCartFun(){
|
||||
@@ -124,7 +124,9 @@ function initAddToCart(){
|
||||
quantity:$('#quantity').val(),
|
||||
img:$('.productDetailsMain img').attr('src'),
|
||||
sku:$('#skudetailitem').val(),
|
||||
totalQty:qty
|
||||
totalQty:qty,
|
||||
productid:$('#productidtag').val(),
|
||||
itemid:$('#itemidtag').val()
|
||||
}
|
||||
|
||||
|
||||
@@ -149,7 +151,9 @@ function initAddToCart(){
|
||||
quantity: parseInt(data[sku].quantity)+parseInt(quantity),
|
||||
img:img,
|
||||
sku:sku,
|
||||
totalQty:qty
|
||||
totalQty:qty,
|
||||
productid:$('#productidtag').val(),
|
||||
itemid:$('#itemidtag').val()
|
||||
}
|
||||
addtoCart(data);
|
||||
}else{
|
||||
@@ -159,13 +163,15 @@ function initAddToCart(){
|
||||
quantity:parseInt(quantity),
|
||||
img:img,
|
||||
sku:sku,
|
||||
totalQty:qty
|
||||
totalQty:qty,
|
||||
productid:$('#productidtag').val(),
|
||||
itemid:$('#itemidtag').val()
|
||||
}
|
||||
addtoCart(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
debugger;
|
||||
setLengthCart();
|
||||
|
||||
}
|
||||
|
||||
+32
-14
@@ -4,6 +4,7 @@ debugger;
|
||||
function shoppingCartInit() {
|
||||
|
||||
shoppingCartAppend();
|
||||
let DELETE_FILTER = null;
|
||||
|
||||
let insufficientQtyActions = {
|
||||
moreQtyAdd(e){
|
||||
@@ -40,6 +41,7 @@ function shoppingCartInit() {
|
||||
$('.emptyShow').removeClass('d-none');
|
||||
}
|
||||
setLengthCart();
|
||||
console.log(products,'products');
|
||||
for (let product in products) {
|
||||
|
||||
html += shoppingCartDesktopHTML({ ...products[product], total: products[product].quantity * products[product].price, id: product });
|
||||
@@ -118,6 +120,26 @@ function shoppingCartInit() {
|
||||
}
|
||||
});
|
||||
|
||||
$('.removeitemcartmodal').off('click').click(function (){
|
||||
|
||||
|
||||
setCartData( DELETE_FILTER );
|
||||
setLengthCart();
|
||||
shoppingCartAppend();
|
||||
|
||||
let len = Object.keys(DELETE_FILTER).length
|
||||
if(!len){
|
||||
|
||||
$('.checkoutbtn').addClass('d-none');
|
||||
$('.emptyShow').removeClass('d-none');
|
||||
}else{
|
||||
$('.checkoutbtn').removeClass('d-none');
|
||||
$('.emptyShow').addClass('d-none');
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
$('.btndeletecart').each(function (i, element) {
|
||||
$(element).click(function (e) {
|
||||
const cardId = $(e.target).data('cartid');
|
||||
@@ -127,24 +149,20 @@ function shoppingCartInit() {
|
||||
debugger;
|
||||
const products = data;
|
||||
const productsFilter = {};
|
||||
|
||||
$('#modalremovecart').html(products[cardId].name);
|
||||
for (let product in products) {
|
||||
if (product != cardId) productsFilter[product] = products[product];
|
||||
}
|
||||
|
||||
|
||||
data = productsFilter;
|
||||
let len = Object.keys(data).length
|
||||
if(!len){
|
||||
|
||||
$('.checkoutbtn').addClass('d-none');
|
||||
$('.emptyShow').removeClass('d-none');
|
||||
}else{
|
||||
$('.checkoutbtn').removeClass('d-none');
|
||||
$('.emptyShow').addClass('d-none');
|
||||
}
|
||||
setCartData(data);
|
||||
setLengthCart();
|
||||
shoppingCartAppend();
|
||||
console.log(data);
|
||||
DELETE_FILTER = data;
|
||||
// setCartData(data);
|
||||
// setLengthCart();
|
||||
// shoppingCartAppend();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -199,14 +217,14 @@ function shoppingCartInit() {
|
||||
</div>`
|
||||
}
|
||||
|
||||
function shoppingCartDesktopHTML({ id, img, name, price, description, quantity, total,totalQty }) {
|
||||
function shoppingCartDesktopHTML({ id, img, name, price, description, quantity, total,totalQty,productid,itemid }) {
|
||||
const [currencySymbol,amt] = getCurrencySymbol(price);
|
||||
return `
|
||||
<div class="row bg-white border-bottom py-4 d-flex justify-content-center align-items-center">
|
||||
<div class="col-md-2 text-center"><img src="${img}" alt="${name}" class="img-fluid"></div>
|
||||
<div class="col-md-4 ">
|
||||
|
||||
<a class="text-decoration-none text-blue fw-600 cursor-pointer" href="/productdetails.html?productId=${id}">${name}</a>
|
||||
<a class="text-decoration-none text-blue fw-600 cursor-pointer" href="productdetails.html?productId=${productid}#itemid=${itemid}">${name}</a>
|
||||
<small>${description||''}</small>
|
||||
<span class="badge d-none text-bg-warning">8 Offers ></span>
|
||||
</div>
|
||||
@@ -222,7 +240,7 @@ function shoppingCartInit() {
|
||||
<p class="fw-bold m-0"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-currency-rupee" viewBox="0 0 16 16">
|
||||
<path d="M4 3.06h2.726c1.22 0 2.12.575 2.325 1.724H4v1.051h5.051C8.855 7.001 8 7.558 6.788 7.558H4v1.317L8.437 14h2.11L6.095 8.884h.855c2.316-.018 3.465-1.476 3.688-3.049H12V4.784h-1.345c-.08-.778-.357-1.335-.793-1.732H12V2H4v1.06Z"/>
|
||||
</svg>${total}</p>
|
||||
<span class="btndeletecart cursor-pointer fw-500 text-danger" data-cartid="${id}">x</span>
|
||||
<span class="btndeletecart cursor-pointer fw-500 text-danger" data-cartid="${id}" data-bs-toggle="modal" data-bs-target="#deletecartmodal">x</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="warrenty-sec px-3 sec-space-4 d-none">
|
||||
|
||||
在新工单中引用
屏蔽一个用户