영카트 수량 증가시 자동계산되는 부분 질문입니다.

영카트 수량 증가시 자동계산되는 부분 질문입니다.

QA

영카트 수량 증가시 자동계산되는 부분 질문입니다.

본문

영카트 관리자  '쇼핑몰관리'에 'de_aaa_sale'필드를 만들어 특정금액을 입력하게 했습니다.

shop.override.js 파일에서 자동 금액계산 부분에 특정금액이포함되어 계산되게 하려하는데 'de_aaa_sale'에 넣은 값을 어떻게 불러와야 되는지요?

 

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;
                        }
                            total = total - de_aaa_sale;
                    });

                    $("#sit_tot_price").empty().html("<span>TOTAL </span><strong> $ "+String(total));

                } else {
                    cached_function.apply(this, arguments); // use .apply() to call it
                }
               
            };
        }());
    }   //end if check function

이 질문에 댓글 쓰기 :

답변 2

de_aaa_sale 값이 없어서 그럴꺼에요.

 

스크립트 구문에 de_aaa_sale 값이 0보다 클경우에만 실행.

if(de_aaa_sale > 0){

 total = total - de_aaa_sale;

}

 

그리고 값이 잘넘어 오는지 확인하시려면 콘솔로그로 찍어보세요.

console.log(de_aaa_sale);

1. 스크립트 구문 수정

 

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());

                    var de_aaa_sale = parseInt($("input#de_aaa_sale").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;
                        }
                            total = total - de_aaa_sale;
                    });

                    $("#sit_tot_price").empty().html("<span>TOTAL </span><strong> $ "+String(total));

                } else {
                    cached_function.apply(this, arguments); // use .apply() to call it
                }
               
            };
        }());
    }   //end if check function

 

2. /skin/shop/basic/item.form.skin.php 파일에 히든값(de_aaa_sale) 추가

 

<tr>
   <th scope="row">판매가격</th>
   <td>
    <strong><?php echo display_price(get_price($it)); ?></strong>
    <input type="hidden" id="it_price" value="<?php echo get_price($it); ?>">

    <input type="hidden" id="de_aaa_sale" value="<?php echo get_price($it['de_aaa_sale']); ?>">
    </td>
</tr>

 

 

답변을 작성하시기 전에 로그인 해주세요.
전체 54
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT