채택완료

상품포인트 계산할때 $trunc

2017-04-11 (화) 18:34:58 5,814

shop.lib.php 에서

// 상품포인트
function get_item_point($it, $io_id='', $trunc=10)
{
    global $g5;

    $it_point = 0;

    if($it['it_point_type'] > 0) {
        $it_price = $it['it_price'];

        if($it['it_point_type'] == 2 && $io_id) {
            $sql = " select io_id, io_price
                        from {$g5['g5_shop_item_option_table']}
                        where it_id = '{$it['it_id']}'
                          and io_id = '$io_id'
                          and io_type = '0'
                          and io_use = '1' ";
            $opt = sql_fetch($sql);

            if($opt['io_id'])
                $it_price += $opt['io_price'];
        }

        $it_point = ceil(($it_price * ($it['it_point'] / 100) / $trunc)) * $trunc;
    } else {
        $it_point = $it['it_point'];
    }

    return $it_point;
}

부분에서

$it_point = ceil(($it_price * ($it['it_point'] / 100) / $trunc)) * $trunc;

$trunc를 왜 나눴다가 다시 곱하는걸까요? 

|

답변 1개

채택된 답변
+20 포인트

10자리 절삭 하기위한 부분인데 

포인트가 96 나오면 90 이렇게 지급하게 됩니다.

function get_item_point($it, $io_id='', $trunc=1) 이렇게 변경하시면 

 

1자리까지 지급하고요


답변을 작성하려면 로그인이 필요합니다.