판매가격 소수점 변경출력

판매가격 소수점 변경출력

QA

판매가격 소수점 변경출력

본문

영카트에서 디비는 모두 float로 했습니다

그랬더니 

판매가를 보면 $55.00 으로 나옵니다 실제 입력은 55.4 로 했습니다

아마도

<?php echo display_price(get_price($it)); ?> 에서 number_format 을 적용해야 할 것 같은데

계속 적용이 안됩니다

 

number_format(가격,2) 하면 소수점 두자리가 나올 것 같은데 어디에 적용을 해야 하는지요?

이 질문에 댓글 쓰기 :

답변 4

/lib/shop.lib.php 파일에서 해당 함수 2개를 수정하시면 될꺼에요.

display_price() , get_price()

 

ex)


// 금액 표시
function display_price($price, $tel_inq=false)
{
    if ($tel_inq)
        $price = '전화문의';
    else
        $price = '$'.number_format($price, 2);
    return $price;
}

// 금액표시
// $it : 상품 배열
function get_price($it)
{
    global $member;
    if ($it['it_tel_inq']) return '전화문의';
    $price = $it['it_price'];
    return floatval($price);
}

lib/shop.lib.php파일을 여시고

먼저, function get_price($it) 함수에서 return (int)$price; 이것에서 (int)를 제거하세요.

그리고 function display_price($price, $tel_inq=false) 함수에서

number_format($price, 0).'원'; 이넘을 number_format($price, 2).'원';

 

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

회원로그인

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