Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

Commit

Permalink
네이버페이 배송비 계산 코드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
chicpro committed Jul 28, 2016
1 parent a29c328 commit ccf6d9c
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion lib/naverpay.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function __construct($options, $send_cost)

function get_sendcost()
{
global $g5;
global $g5, $default;

$options = $this->options;
$send_cost = $this->send_cost;
Expand All @@ -29,6 +29,9 @@ function get_sendcost()

$cost = 0;
$cnt = 0;
$diff = 0;
$total_price = 0;
$diff_cost = 0;

foreach($keys as $it_id) {
$it = sql_fetch(" select * from {$g5['g5_shop_item_table']} where it_id = '$it_id' ");
Expand Down Expand Up @@ -71,9 +74,32 @@ function get_sendcost()
}
} else if($it['it_sc_type'] == 1) { // 무료배송
$cost += 0;
} else {
if($default['de_send_cost_case'] == '차등') {
$total_price += $price;
$diff++;
} else {
$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']);

for ($k=0; $k<count($send_cost_limit); $k++) {
// 총판매금액이 배송비 상한가 보다 작다면
if ($total_price < preg_replace('/[^0-9]/', '', $send_cost_limit[$k])) {
$diff_cost = preg_replace('/[^0-9]/', '', $send_cost_list[$k]);
break;
}
}
}

$cost += $diff_cost;

// 모두 착불상품이면
if(count($keys) == $cnt && $cnt > 0)
return array('type' => 'ONDELIVERY', 'cost' => 0);
Expand Down

0 comments on commit ccf6d9c

Please sign in to comment.