테스트 사이트 - 개발 중인 베타 버전입니다

상품별 무료배송 사용, 기본배송 정책 지킴

· 12년 전 · 218 · 1
예전에 관리자분께서 남겨주신 글들을 찾아서 해결했습니다.
감사합니다.

다른 분들을 위해 정리해 보았습니다.

30,000원 미만 배송비 3,000원 기본 설정 후
개별 상품에 무료배송 체크한 후 결제시 무료배송 체크된 상품의 경우, 3만원미만이라도 배송비가 책정되지 않습니다.
 
아래 순서대로 하시면 됩니다. 관리자님 오류 있으면 좀 잡아 주세요.. ^^

1. 상품테이블에 무료배송 필드를 하나 추가합니다.
ALTER TABLE `yc4_item` ADD `it_free_baesong` TINYINT NOT NULL ;

2. adm/shop_admin/itemform.php 에 아래 무료배송 체크란 추가 (가격아래에 넣었습니다.)
 
<tr class=ht>
    <td>무료배송</td>
    <td colspan='3'>
        <input type=checkbox name=it_free_baesong value='1' <?=($it[it_free_baesong] ? "checked" : "")?>> 무료배송
    </td>
</tr>


3. adm/shop_admin/itemformupdate.php 에 아래 코드 추가 (it_tel_inq      = '$it_tel_inq', 아래에 코드 추가)

                it_tel_inq      = '$it_tel_inq',
                it_free_baesong  = '$it_free_baesong',
                ";


4. shop/cartsub.inc.php 를 아래 코드로 수정


// $s_on_uid 로 현재 장바구니 자료 쿼리
$sql = " select a.ct_id,
                a.it_opt1,
                a.it_opt2,
                a.it_opt3,
                a.it_opt4,
                a.it_opt5,
                a.it_opt6,
                a.ct_amount,
                a.ct_point,
                a.ct_qty,
                a.ct_status,
                b.it_id,
                b.it_name,
                b.it_free_baesong,
                b.ca_id
          from $g4[yc4_cart_table] a,
                $g4[yc4_item_table] b
          where a.on_uid = '$s_on_uid'
            and a.it_id  = b.it_id
          order by a.ct_id ";
$result = sql_query($sql);
for ($i=0; $row=mysql_fetch_array($result); $i++)
{
    if (!$goods)
    {
        //$goods = addslashes($row[it_name]);
        //$goods = get_text($row[it_name]);
        $goods = preg_replace("/\'|\"|\||\,|\&|\;/", "", $row[it_name]);
        $goods_it_id = $row[it_id];
    }
    $goods_count++;

    if ($i==0) { // 계속쇼핑
        $continue_ca_id = $row[ca_id];
    }

    if ($s_page == "cart.php" || $s_page == "orderinquiryview.php") { // 링크를 붙이고
        $a1 = "<a href='./item.php?it_id=$row[it_id]'>";
        $a2 = "</a>";
        $image = get_it_image($row[it_id]."_s", 50, 50, $row[it_id]);
    } else { // 붙이지 않고
        $a1 = "";
        $a2 = "";
        $image = get_it_image($row[it_id]."_s", 50, 50);
    }

    $it_name = $a1 . stripslashes($row[it_name]) . $a2 . "<br>";
    $it_name .= print_item_options($row[it_id], $row[it_opt1], $row[it_opt2], $row[it_opt3], $row[it_opt4], $row[it_opt5], $row[it_opt6]);

    $point      = $row[ct_point] * $row[ct_qty];
    $sell_amount = $row[ct_amount] * $row[ct_qty];

    if ($i > 0)
        echo "<tr><td colspan='$colspan' height=1 bgcolor=#E7E9E9></td></tr>";
                                     
    echo "<tr>";
    echo "<td align=left style='padding:5px;'>$image</td><td>";
    echo "<input type=hidden name='ct_id[$i]'    value='$row[ct_id]'>";
    echo "<input type=hidden name='it_id[$i]'    value='$row[it_id]'>";
    echo "<input type=hidden name='ap_id[$i]'    value='$row[ap_id]'>";
    echo "<input type=hidden name='bi_id[$i]'    value='$row[bi_id]'>";
    echo "<input type=hidden name='it_name[$i]'  value='".get_text($row[it_name])."'>";
    echo $it_name;
    echo "</td>";

    // 수량, 입력(수량)
    if ($s_page == "cart.php")
        echo "<td align=center><input type=text id='ct_qty_{$i}' name='ct_qty[{$i}]' value='$row[ct_qty]' size=4 maxlength=6 class=ed style='text-align:right;' autocomplete='off'></td>";
    else
        echo "<td align=center>$row[ct_qty]</td>";

    echo "<td align=right>" . number_format($row[ct_amount]) . "</td>";
    echo "<td align=right>" . number_format($sell_amount) . "</td>";
    echo "<td align=right>" . number_format($point) . "&nbsp;</td>";

    if ($s_page == "cart.php")
        echo "<td align=center><a href='./cartupdate.php?w=d&ct_id=$row[ct_id]'><img src='$g4[shop_img_path]/btn_del.gif' border='0' align=absmiddle alt='삭제'></a></td>";
    else if ($s_page == "orderinquiryview.php")
    {
        switch($row[ct_status])
        {
            case '주문' : $icon = "<img src='$g4[shop_img_path]/status01.gif'>"; break;
            case '준비' : $icon = "<img src='$g4[shop_img_path]/status02.gif'>"; break;
            case '배송' : $icon = "<img src='$g4[shop_img_path]/status03.gif'>"; break;
            case '완료' : $icon = "<img src='$g4[shop_img_path]/status04.gif'>"; break;
            default    : $icon = $row[ct_status]; break;
        }
        echo "<td align=center>$icon</td>";
    }

    echo "</tr>";
    echo "<tr><td colspan='$colspan' class=dotline></td></tr>";

    //$tot_point      += $point;
    //$tot_sell_amount += $sell_amount;

    if ($row[ct_status] == '취소' || $row[ct_status] == '반품' || $row[ct_status] == '품절') {
        $tot_cancel_amount += $sell_amount;
    }
    else {
        $tot_point      += $point;
        $tot_sell_amount += $sell_amount;
    }

    if (!$row[it_free_baesong]) {
        $baesong_amount += $sell_amount;
    }
}

if ($goods_count)
    $goods .= " 외 {$goods_count}건";

if ($i == 0) {
    echo "<tr>";
    echo "<td colspan='$colspan' align=center height=100><span class=textpoint>장바구니가 비어 있습니다.</span></td>";
    echo "</tr>";
} else {
    // 배송비가 넘어왔다면
    if ($_POST[od_send_cost]) {
        $send_cost = (int)$_POST[od_send_cost];
    } else {
        // 배송비 계산
        if ($default[de_send_cost_case] == "없음")
            $send_cost = 0;
        else {
            // 배송비 상한 : 여러단계의 배송비 적용 가능
            $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 ($tot_sell_amount < $send_cost_limit[$k]) {
                if ($tot_sell_amount < $send_cost_limit[$k] && $baesong_amount > 0) {
                    $send_cost = $send_cost_list[$k];
                    break;
                }
            }
        }


        // 이미 주문된 내역을 보여주는것이므로 배송비를 주문서에서 얻는다.
이 위부분까지..

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

댓글 1개

감사합니다

게시글 목록

번호 제목
1790
1788
1786
1782
1780
1778
1767
1762
1754
1748
1739
1736
1735
1731
1717
1712
1704
1700
1696
1682