배송비가 계속 추가되는 문제 해결 부탁드립니다. 채택완료
안녕하세요.
영카트5를 사용중입니다.
관리자페이지에서 기본환경이나 각 상품란에서 설정을 해도 배송비를 무료로 설정할때(이때 배송비가 추가되지 않음) 빼고는 제대로 작동하지 않네요.
예: 10만원이하 무료배송 설정후 상품을 장바구니에 담으면 담을때마다 10만원 이하에서도 기본배송비가 추가됨.
또, 몇개 이상주문시 배송비 추가설정도 마찬가지고요.
아래에서(?) 10만원이하(설정한 값)에서 단 1회만 배송비가 추가되도록 수정방법을 부탁드립니다.
"board\lib\shop.lib.php"
// 배송비 구함
function get_sendcost($cart_id, $selected=1)
{
global $default, $g5;
$send_cost = 0;
$total_price = 0;
$total_send_cost = 0;
$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'];
}
$send_cost = 0;
if($default['de_send_cost_case'] == '차등' && $total_price > 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 ($total_price < preg_replace('/[^0-9]/', '', $send_cost_limit[$k])) {
$send_cost = preg_replace('/[^0-9]/', '', $send_cost_list[$k]);
break;
}
}
}
return ($total_send_cost + $send_cost);
}
// 상품별 배송비
function get_item_sendcost($it_id, $price, $qty, $cart_id)
{
global $g5, $default;
$sql = " select it_id, it_sc_type, it_sc_method, it_sc_price, it_sc_minimum, it_sc_qty
from {$g5['g5_shop_cart_table']}
where it_id = '$it_id'
and od_id = '$cart_id'
order by ct_id
limit 1 ";
$ct = sql_fetch($sql);
if(!$ct['it_id'])
return 0;
if($ct['it_sc_type'] > 1) {
if($ct['it_sc_type'] == 2) { // 조건부무료
if($price >= $ct['it_sc_minimum'])
$sendcost = 0;
else
$sendcost = $ct['it_sc_price'];
} else if($ct['it_sc_type'] == 3) { // 유료배송
$sendcost = $ct['it_sc_price'];
} else { // 수량별 부과
if(!$ct['it_sc_qty'])
$ct['it_sc_qty'] = 1;
$q = ceil((int)$qty / (int)$ct['it_sc_qty']);
$sendcost = (int)$ct['it_sc_price'] * $q;
}
} else if($ct['it_sc_type'] == 1) { // 무료배송
$sendcost = 0;
} else {
$sendcost = -1;
}
return $sendcost;
}
// 가격비교 사이트 상품 배송비
function get_item_sendcost2($it_id, $price, $qty)
{
global $g5, $default;
$sql = " select it_id, it_sc_type, it_sc_method, it_sc_price, it_sc_minimum, it_sc_qty
from {$g5['g5_shop_item_table']}
where it_id = '$it_id' ";
$it = sql_fetch($sql);
if(!$it['it_id'])
return 0;
$sendcost = 0;
// 쇼핑몰 기본설정을 사용할 때
if($it['it_sc_type'] == 0)
{
if($default['de_send_cost_case'] == '차등') {
// 금액별차등 : 여러단계의 배송비 적용 가능
$send_cost_limit = explode(";", $default['de_send_cost_limit']);
$send_cost_list = explode(";", $default['de_send_cost_list']);
for ($k=0; $k<count($send_cost_limit); $k++) {
// 총판매금액이 배송비 상한가 보다 작다면
if ($price < preg_replace('/[^0-9]/', '', $send_cost_limit[$k])) {
$sendcost = preg_replace('/[^0-9]/', '', $send_cost_list[$k]);
break;
}
}
}
}
else
{
if($it['it_sc_type'] > 1) {
if($it['it_sc_type'] == 2) { // 조건부무료
if($price >= $it['it_sc_minimum'])
$sendcost = 0;
else
$sendcost = $it['it_sc_price'];
} else if($it['it_sc_type'] == 3) { // 유료배송
$sendcost = $it['it_sc_price'];
} else { // 수량별 부과
if(!$it['it_sc_qty'])
$it['it_sc_qty'] = 1;
$q = ceil((int)$qty / (int)$it['it_sc_qty']);
$sendcost = (int)$it['it_sc_price'] * $q;
}
} else if($it['it_sc_type'] == 1) { // 무료배송
$sendcost = 0;
}
}
return $sendcost;
}
아래는 다른페이지 입니다.
"board\shop\cartupdate.php"
/ 배송비결제
if($it['it_sc_type'] == 1)
$ct_send_cost = 2; // 무료
else if($it['it_sc_type'] > 1 && $it['it_sc_method'] == 1)
$ct_send_cost = 1; // 착불
$sql .= $comma."( '$tmp_cart_id', '{$member['mb_id']}', '{$it['it_id']}', '".addslashes($it['it_name'])."', '{$it['it_sc_type']}', '{$it['it_sc_method']}', '{$it['it_sc_price']}', '{$it['it_sc_minimum']}', '{$it['it_sc_qty']}', '쇼핑', '{$it['it_price']}', '$point', '0', '0', '$io_value', '$ct_qty', '{$it['it_notax']}', '$io_id', '$io_type', '$io_price', '".G5_TIME_YMDHIS."', '$REMOTE_ADDR', '$ct_send_cost', '$sw_direct', '$ct_select', '$ct_select_time' )";
$comma = ' , ';
$ct_count++;
}
if($ct_count > 0)
sql_query($sql);
}
}
혹시 몰라서 비슷한 내용이 있는 페이지도 추가할께요...
"board\orderupgrade.php"
// cart 테이블에 상품의 배송비관련 정보 기록
$sql = " select ct_id, it_id from {$g5['g5_shop_cart_table']} order by ct_id ";
$result = sql_query($sql);
for($i=0; $row=sql_fetch_array($result); $i++) {
$sql = " select it_id, it_sc_type, it_sc_method, it_sc_price, it_sc_minimum, it_sc_qty
from {$g5['g5_shop_item_table']}
where it_id = '{$row['it_id']}' ";
$it = sql_fetch($sql);
if(!$it['it_id'])
continue;
$sql = " update {$g5['g5_shop_cart_table']}
set it_sc_type = '{$it['it_sc_type']}',
it_sc_method = '{$it['it_sc_method']}',
it_sc_price = '{$it['it_sc_price']}',
it_sc_minimum = '{$it['it_sc_minimum']}',
it_sc_qty = '{$it['it_sc_qty']}'
where ct_id = '{$row['ct_id']}' ";
sql_query($sql);
}
}
"board\adm\shop_admin\ajax.orderitem.php"
switch($row['ct_send_cost'])
{
case 1:
$ct_send_cost = '착불';
break;
case 2:
$ct_send_cost = '무료';
break;
default:
$ct_send_cost = '선불';
break;
}
// 조건부무료
if($row['it_sc_type'] == 2) {
$sendcost = get_item_sendcost($row['it_id'], $sum['price'], $sum['qty'], $s_cart_id);
if($sendcost == 0)
$ct_send_cost = '무료';
$save_it_id = $row['it_id'];
}
for($k=0; $opt=sql_fetch_array($res); $k++) {
if($opt['io_type'])
$opt_price = $opt['io_price'];
else
$opt_price = $opt['ct_price'] + $opt['io_price'];
// 소계
$ct_price['stotal'] = $opt_price * $opt['ct_qty'];
$ct_point['stotal'] = $opt['ct_point'] * $opt['ct_qty'];
?>
<tr>
<?php if($k == 0) { ?>
<td class="td_itname" rowspan="<?php echo $rowspan; ?>">
<a href="./itemform.php?w=u&it_id=<?php echo $row['it_id']; ?>"><?php echo $image; ?> <?php echo stripslashes($row['it_name']); ?></a>
<?php if($od['od_tax_flag'] && $row['ct_notax']) echo '[비과세상품]'; ?>
</td>
<?php } ?>
<td class="td_itopt_tl">
<?php echo $opt['ct_option']; ?>
</td>
<td class="td_mngsmall"><?php echo $opt['ct_status']; ?></td>
<td class="td_cntsmall"><?php echo $opt['ct_qty']; ?></td>
<td class="td_num"><?php echo number_format($opt_price); ?></td>
<td class="td_num"><?php echo number_format($ct_price['stotal']); ?></td>
<td class="td_num"><?php echo number_format($opt['cp_price']); ?></td>
<td class="td_num"><?php echo number_format($ct_point['stotal']); ?></td>
<td class="td_sendcost_by"><?php echo $ct_send_cost; ?></td>
</tr>
<?php
}
?>
<?php
}
?>
</tbody>
</table>
</div>
</section>
답변 1개
상품마다 배송비 설정이 적용되어 있으면 상품마다 배송비가 부과됩니다.
총 구입 금액을 기준으로 무료 배송을 처리하시려면 각 상품의 배송비 설정은
'쇼핑몰 기본설정 사용'으로 설정하시고 쇼핑몰 설정의 배송비 설정을
'금액별 차등' 으로 설정하셔야 합니다.
배송비 설정은 다음 매뉴얼을 참고하시기 바랍니다.
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인