function updateList() {
	$(".cart-products").empty();
	var cartTotal = 0.00;
	var storedItems = JSON.parse(localStorage.getItem("items"));
	// update number of items in cart in badge icon
	if (storedItems != null) {
		$(".badge").text(storedItems.length);
		storedItems.forEach( function(storedItem) {
			// calculate cart total from price and quantity
			var total = (parseInt(storedItem.quantity) * parseFloat(storedItem.price)).toFixed(2);
			cartTotal += parseFloat(total);
			// dynamically add html based on number of storedItems
			var cartItem = `<div class="cart-item">
								<img src="` + storedItem.image + `" alt="" class="item-img" id="cart-image"/>
								<div class="item-description">
									<div class="left-descript">
										<h3 id="cart-name">` + storedItem.name + `</h3>
										<span id="cart-flavors"> Additional Flavors: ` + storedItem.firstFlavor + " , " + storedItem.secFlavor +  `</span>
										<p id="price-row"> Price: $<span id="cart-price">` + storedItem.price + `</span> each </p>
										<p id="quantity-row"> Quantity: &nbsp; <span id="cart-quantity">` + storedItem.quantity + `</span></p>
									</div>
									<div class="right-descript">
										<p>Total: $<span id="cart-total">` + total + `</span></p>
										<h3> <span class="small-button hover"> <a href="javascript:void(0);" class="pink" id="remove"><span id="remove-id">` + storedItem.id + `</span> Remove</a></span></h3>
									</div>
								</div> 
							</div>
							<span class="divider" ><hr/></span>`;
			$(".cart-products").append(cartItem);
		});
		
		// dynamically calculate checkout information
		cartTotal = cartTotal.toFixed(2);
		var tax = (cartTotal * 0.085).toFixed(2);
		var shipping = (cartTotal * 0.15).toFixed(2);
		$("#total").text(cartTotal);
		$("#tax").text(tax);
		$("#shipping").text(shipping);
		var grandTotal = parseFloat(cartTotal) + parseFloat(shipping) + parseFloat(tax);
		$("#grand-total").text(grandTotal.toFixed(2));
	}
}
// this function is called every time user edits storedItems (add/remove)
this function is called every time user edits storedItems (add/remove)
this function is called every time user edits storedItems ( add / remove )
function updateList() {
	$(".cart-products").empty();
	var cartTotal = 0.00;
	var storedItems = JSON.parse(localStorage.getItem("items"));
	if (storedItems != null) {
		$(".badge").text(storedItems.length);
		storedItems.forEach( function(storedItem) {
			var total = (parseInt(storedItem.quantity) * parseFloat(storedItem.price)).toFixed(2);
			cartTotal += parseFloat(total);
			var cartItem = `<div class="cart-item">
								<img src="` + storedItem.image + `" alt="" class="item-img" id="cart-image"/>
								<div class="item-description">
									<div class="left-descript">
										<h3 id="cart-name">` + storedItem.name + `</h3>
										<span id="cart-flavors"> Additional Flavors: ` + storedItem.firstFlavor + " , " + storedItem.secFlavor +  `</span>
										<p id="price-row"> Price: $<span id="cart-price">` + storedItem.price + `</span> each </p>
										<p id="quantity-row"> Quantity: &nbsp; <span id="cart-quantity">` + storedItem.quantity + `</span></p>
									</div>
									<div class="right-descript">
										<p>Total: $<span id="cart-total">` + total + `</span></p>
										<h3> <span class="small-button hover"> <a href="javascript:void(0);" class="pink" id="remove"><span id="remove-id">` + storedItem.id + `</span> Remove</a></span></h3>
									</div>
								</div> 
							</div>
							<span class="divider" ><hr/></span>`;
			$(".cart-products").append(cartItem);
		});
		cartTotal = cartTotal.toFixed(2);
		var tax = (cartTotal * 0.085).toFixed(2);
		var shipping = (cartTotal * 0.15).toFixed(2);
		$("#total").text(cartTotal);
		$("#tax").text(tax);
		$("#shipping").text(shipping);
		var grandTotal = parseFloat(cartTotal) + parseFloat(shipping) + parseFloat(tax);
		$("#grand-total").text(grandTotal.toFixed(2));
	}
}
function updateList ( ) { $ ( ".cart-products" ) . empty ( ) ; var cartTotal = 0.00 ; var storedItems = JSON . parse ( localStorage . getItem ( "items" ) ) ; if ( storedItems != null ) { $ ( ".badge" ) . text ( storedItems . length ) ; storedItems . forEach ( function ( storedItem ) { var total = ( parseInt ( storedItem . quantity ) * parseFloat ( storedItem . price ) ) . toFixed ( 2 ) ; cartTotal += parseFloat ( total ) ; var cartItem = ` ` + storedItem . image + ` ` + storedItem . name + ` ` + storedItem . firstFlavor + " , " + storedItem . secFlavor + ` ` + storedItem . price + ` ` + storedItem . quantity + ` ` + total + ` ` + storedItem . id + ` ` ; $ ( ".cart-products" ) . append ( cartItem ) ; } ) ; cartTotal = cartTotal . toFixed ( 2 ) ; var tax = ( cartTotal * 0.085 ) . toFixed ( 2 ) ; var shipping = ( cartTotal * 0.15 ) . toFixed ( 2 ) ; $ ( "#total" ) . text ( cartTotal ) ; $ ( "#tax" ) . text ( tax ) ; $ ( "#shipping" ) . text ( shipping ) ; var grandTotal = parseFloat ( cartTotal ) + parseFloat ( shipping ) + parseFloat ( tax ) ; $ ( "#grand-total" ) . text ( grandTotal . toFixed ( 2 ) ) ; } }
this function is called every time user edits storedItems (add/remove)
this function is called every time user edits storedItems ( add / remove )
// update number of items in cart in badge icon // calculate cart total from price and quantity // dynamically add html based on number of storedItems // dynamically calculate checkout information