Skip to content

Commit

Permalink
Merge pull request #1 from Lescano713/newBranch
Browse files Browse the repository at this point in the history
function remove product
  • Loading branch information
Lescano713 authored Aug 16, 2024
2 parents 69f54b0 + 18c7122 commit 177cef0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ function uploadingCart(array){
pAmount.textContent = product.pQuantity;
const iconRemove = document.createElement('img');
iconRemove.src = icons.removeItem;
iconRemove.addEventListener('click', e => removeProduct(product.pId))
const pPrice = document.createElement('p');
pPrice.textContent = product.pCost;
const ptotalAmount = document.createElement('p');
Expand Down Expand Up @@ -177,3 +178,15 @@ function buttonAddRemove(button,name,cost,id){
function suma(cost){
const numero = parseFloat(cost);
}

function removeProduct(id){
if (findId(id) && !productsInCart.length < 1) {
productsInCart.splice(findId(id), 1);
uploadingCart(productsInCart);
orderTotal(2)
} else {
console.log("no")
document.querySelector('section.order-section').style.background = "flex";

}
}

0 comments on commit 177cef0

Please sign in to comment.