특정 상품 무료 배송 설정

매출이 오르면 내리는 수수료! 지금 수수료센터에서 전자결제(PG)수수료 비교견적 신청해 보세요!
특정 상품 무료 배송 설정

QA

특정 상품 무료 배송 설정

본문

안녕하세요, 영카트로 쇼핑몰 운영중입니다.

 

특정 상품만 배송비 무료로 설정을 하고 싶은데, 

 

php 코드로 조건을 추가해보려고합니다.

 

shop.lib.php 파일에

 

// 배송비 구함

function get_sendcost($cart_id, $selected=1, $isplus=0)

{

    global $default, $g5, $member;

 

    $send_cost = 0;

    $total_price = 0;

    $total_send_cost = 0;

    $diff = 0;

 

    // Check if the specific product with it_id '1657161464' is in the cart

    $sql = "SELECT COUNT(*) AS count

            FROM {$g5['g5_shop_cart_table']}

            WHERE od_id = '$cart_id'

              AND ct_send_cost = '0'

              AND ct_status IN ('쇼핑', '주문', '입금대기', '결제완료', '배송준비중', '배송완료')

              AND ct_select = '$selected'

              AND it_id = '1657161464'";

    $result = sql_fetch($sql);

 

   // If the specific product is found, set $return_cost to 0

    if ($result['count'] > 0) {

        $return_cost = 0;

        return $return_cost;

    }

   

    $sql = " select distinct it_id

                from {$g5['g5_shop_cart_table']}

                where od_id = '$cart_id'

                  and ct_send_cost = '0'

                  and ct_status IN ( '쇼핑', '주문','입금대기','결제완료','배송준비중','배송완료' )

                  and ct_select = '$selected' ";

 

    $result = sql_query($sql);

    for($i=0; $sc=sql_fetch_array($result); $i++) {

        // 합계

        $sql = " select SUM(IF(io_type = 1, (io_price * ct_qty), ((ct_price + io_price) * ct_qty))) as price,

                        SUM(ct_qty) as qty

                    from {$g5['g5_shop_cart_table']}

                    where it_id = '{$sc['it_id']}'

                      and od_id = '$cart_id'

                      and ct_status IN ( '쇼핑', '주문','입금대기','결제완료','배송준비중','배송완료' )

                      and ct_select = '$selected'";

        $sum = sql_fetch($sql);

 

        $send_cost = get_item_sendcost($sc['it_id'], $sum['price'], $sum['qty'], $cart_id);

 

        if($send_cost > 0)

            $total_send_cost += $send_cost;

 

        if($default['de_send_cost_case'] == '차등' && $send_cost == -1) {

            $total_price += $sum['price'];

            $diff++;

        }

    }

 

    $send_cost = 0;

    if($default['de_send_cost_case'] == '차등' && $total_price >= 0 && $diff > 0) {

        // 금액별차등 : 여러단계의 배송비 적용 가능

        $send_cost_limit = explode(";", $default['de_send_cost_limit']);

        $send_cost_list  = explode(";", $default['de_send_cost_list']);

        $send_cost = 0;

        for ($k=0; $k<count($send_cost_limit); $k++) {

            // 총판매금액이 배송비 상한가 보다 작다면

                if ($isplus == 1) {

                    $send_cost_limit[$k] += 300;

                }

            if ($total_price < preg_replace('/[^0-9]/', '', $send_cost_limit[$k])) {

                $send_cost = preg_replace('/[^0-9]/', '', $send_cost_list[$k]);

                break;

            }

        }

    }

 

    if($total_send_cost + $send_cost < 0) {

        $return_cost = 0;

    } else {

        $return_cost = $total_send_cost + $send_cost;

    }

 

    return $return_cost;

}

 

코드에서

 

    // Check if the specific product with it_id '1657161464' is in the cart

    $sql = "SELECT COUNT(*) AS count

            FROM {$g5['g5_shop_cart_table']}

            WHERE od_id = '$cart_id'

              AND ct_send_cost = '0'

              AND ct_status IN ('쇼핑', '주문', '입금대기', '결제완료', '배송준비중', '배송완료')

              AND ct_select = '$selected'

              AND it_id = '1657161464'";

    $result = sql_fetch($sql);

 

   // If the specific product is found, set $return_cost to 0

    if ($result['count'] > 0) {

        $return_cost = 0;

        return $return_cost;

    }

 

이부분을 추가한 부분인데, 상품 아이디가 '1657161464' 인 경우에는

배송비를 0원으로 지정하는 코드를 넣어봤는데, 사용해도 될지 조언 부탁드립니다.

이 질문에 댓글 쓰기 :

답변 2

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

회원로그인

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