총금액 옆에 총수량을 넣을수 있을까요?
본문
블럭친것처럼 총금액이 나오는 좌측으로 총수량(총구매갯수) 갯수를 노출할려면 어떻게 해야 할까요?
선택옵션의 경우와 옵션없는 단일 상품 모두 총금액 옆에 추가로 총수량을 노출하고 싶은데 어디를 봐야할지 못찾겠네요...
답변 3
이건 var $el_qty = $("input[name^=ct_qty]"); 이부분을 합산해서 보여주는 소스를 추가해야 할듯 하다
어디까지 바라는 거냐? 어디를 봐야 할지 모른다고 해서 위치를 찾아 줬으면 알아서 해라
shop.js 최 하단함수를 수정하면 될듯합니다.
function price_calculate()
{
var it_price = parseInt($("input#it_price").val());
if(isNaN(it_price))
return;
var $el_prc = $("input.io_price");
var $el_qty = $("input[name^=ct_qty]");
var $el_type = $("input[name^=io_type]");
var price, type, qty, total = 0;
$el_prc.each(function(index) {
price = parseInt($(this).val());
qty = parseInt($el_qty.eq(index).val());
type = $el_type.eq(index).val();
if(type == "0") { // 선택옵션
total += (it_price + price) * qty;
} else { // 추가옵션
total += price * qty;
}
});
$("#sit_tot_price").empty().html("<span>총 금액 :</span> "+number_format(String(total))+"원");
}
또는 shop.overide.js
하단에
if (typeof price_calculate === "function") {
price_calculate = (function() {
var cached_function = price_calculate;
return function() {
if( $(".2017_renewal_itemform").length ){
var it_price = parseInt($("input#it_price").val());
if(isNaN(it_price))
return;
var $el_prc = $("input.io_price");
var $el_qty = $("input[name^=ct_qty]");
var $el_type = $("input[name^=io_type]");
var price, type, qty, total = 0;
$el_prc.each(function(index) {
price = parseInt($(this).val());
qty = parseInt($el_qty.eq(index).val());
type = $el_type.eq(index).val();
if(type == "0") { // 선택옵션
total += (it_price + price) * qty;
} else { // 추가옵션
total += price * qty;
}
});
$("#sit_tot_price").empty().html("<span>총 금액 </span><strong>"+number_format(String(total))+"</strong> 원");
} else {
cached_function.apply(this, arguments); // use .apply() to call it
}
};
}());
} //end if check function