diff --git a/VamPa/src/main/webapp/WEB-INF/views/cart.jsp b/VamPa/src/main/webapp/WEB-INF/views/cart.jsp index f31dd6d..c7e1c73 100644 --- a/VamPa/src/main/webapp/WEB-INF/views/cart.jsp +++ b/VamPa/src/main/webapp/WEB-INF/views/cart.jsp @@ -95,6 +95,11 @@
| + @@ -274,25 +280,58 @@ $(document).ready(function(){ /* 종합 정보 섹션 정보 삽입 */ + setTotalInfo(); + +}); + +/* 체크여부에따른 종합 정보 변화 */ +$(".individual_cart_checkbox").on("change", function(){ + /* 총 주문 정보 세팅(배송비, 총 가격, 마일리지, 물품 수, 종류) */ + setTotalInfo($(".cart_info_td")); +}); + +/* 체크박스 전체 선택 */ +$(".all_check_input").on("click", function(){ + + /* 체크박스 체크/해제 */ + if($(".all_check_input").prop("checked")){ + $(".individual_cart_checkbox").attr("checked", true); + } else{ + $(".individual_cart_checkbox").attr("checked", false); + } + + /* 총 주문 정보 세팅(배송비, 총 가격, 마일리지, 물품 수, 종류) */ + setTotalInfo($(".cart_info_td")); + +}); + + +/* 총 주문 정보 세팅(배송비, 총 가격, 마일리지, 물품 수, 종류) */ +function setTotalInfo(){ + let totalPrice = 0; // 총 가격 let totalCount = 0; // 총 갯수 let totalKind = 0; // 총 종류 let totalPoint = 0; // 총 마일리지 let deliveryPrice = 0; // 배송비 - let finalTotalPrice = 0; // 최종 가격(총 가격 + 배송비) + let finalTotalPrice = 0; // 최종 가격(총 가격 + 배송비) + $(".cart_info_td").each(function(index, element){ - // 총 가격 - totalPrice += parseInt($(element).find(".individual_totalPrice_input").val()); - // 총 갯수 - totalCount += parseInt($(element).find(".individual_bookCount_input").val()); - // 총 종류 - totalKind += 1; - // 총 마일리지 - totalPoint += parseInt($(element).find(".individual_totalPoint_input").val()); + if($(element).find(".individual_cart_checkbox").is(":checked") === true){ //체크여부 + // 총 가격 + totalPrice += parseInt($(element).find(".individual_totalPrice_input").val()); + // 총 갯수 + totalCount += parseInt($(element).find(".individual_bookCount_input").val()); + // 총 종류 + totalKind += 1; + // 총 마일리지 + totalPoint += parseInt($(element).find(".individual_totalPoint_input").val()); + } - }); + }); + /* 배송비 결정 */ if(totalPrice >= 30000){ @@ -301,12 +340,12 @@ $(document).ready(function(){ deliveryPrice = 0; } else { deliveryPrice = 3000; - } + } - /* 최종 가격 */ - finalTotalPrice = totalPrice + deliveryPrice; + finalTotalPrice = totalPrice + deliveryPrice; + + /* ※ 세자리 컴마 Javscript Number 객체의 toLocaleString() */ - /* 값 삽입 */ // 총 가격 $(".totalPrice_span").text(totalPrice.toLocaleString()); // 총 갯수 @@ -319,8 +358,9 @@ $(document).ready(function(){ $(".delivery_price").text(deliveryPrice); // 최종 가격(총 가격 + 배송비) $(".finalTotalPrice_span").text(finalTotalPrice.toLocaleString()); - -}); +} + + |