#209 주문폼에 쿠폰 선택 기능 추가 작업

This commit is contained in:
chicpro
2013-06-07 18:04:35 +09:00
parent b6aa16deac
commit b304aa143b
10 changed files with 1310 additions and 114 deletions

View File

@ -254,4 +254,15 @@ if(!$result) {
KEY `mb_id` (`mb_id`)
)", false);
}
// 쿠폰관련필드 추가
$sql = " select cp_amount from {$g4['shop_cart_table']} limit 1 ";
$result = sql_query($sql, false);
if(!$result) {
sql_query(" ALTER TABLE `{$g4['shop_cart_table']}`
ADD `cp_amount` INT(11) NOT NULL DEFAULT '0' AFTER `ct_point` ", false);
sql_query(" ALTER TABLE `{$g4['shop_order_table']}`
ADD `od_coupon` INT(11) NOT NULL DEFAULT '0' AFTER `od_dc_amount`,
ADD `od_send_coupon` INT(11) NOT NULL DEFAULT '0' AFTER `od_send_cost` ", false);
}
?>

View File

@ -63,6 +63,7 @@ CREATE TABLE IF NOT EXISTS `shop_cart` (
`ct_history` text NOT NULL,
`ct_price` int(11) NOT NULL DEFAULT '0',
`ct_point` int(11) NOT NULL DEFAULT '0',
`cp_amount` int(11) NOT NULL DEFAULT '0',
`ct_point_use` tinyint(4) NOT NULL DEFAULT '0',
`ct_stock_use` tinyint(4) NOT NULL DEFAULT '0',
`ct_option` varchar(255) NOT NULL DEFAULT '',
@ -588,6 +589,7 @@ CREATE TABLE IF NOT EXISTS `shop_order` (
`od_b_addr2` varchar(100) NOT NULL DEFAULT '',
`od_memo` text NOT NULL,
`od_send_cost` int(11) NOT NULL DEFAULT '0',
`od_send_coupon` int(11) NOT NULL DEFAULT '0',
`od_temp_bank` int(11) NOT NULL DEFAULT '0',
`od_temp_card` int(11) NOT NULL DEFAULT '0',
`od_temp_hp` int(11) NOT NULL,
@ -602,6 +604,7 @@ CREATE TABLE IF NOT EXISTS `shop_order` (
`od_hp_time` datetime NOT NULL,
`od_cancel_card` int(11) NOT NULL DEFAULT '0',
`od_dc_amount` int(11) NOT NULL DEFAULT '0',
`od_coupon` int(11) NOT NULL DEFAULT '0',
`od_refund_amount` int(11) NOT NULL DEFAULT '0',
`od_shop_memo` text NOT NULL,
`dl_id` int(11) NOT NULL DEFAULT '0',

View File

@ -1139,6 +1139,28 @@ function get_coupon_id()
return $str;
}
// array_map() 대체
function array_add_callback($func, $array)
{
if(!$func) {
return;
}
if(is_array($array)) {
foreach($array as $key => $value) {
if(is_array($value)) {
$array[$key] = array_add_callback($func, $value);
} else {
$array[$key] = call_user_func($func, $value);
}
}
} else {
$array = call_user_func($func, $array);
}
return $array;
}
//==============================================================================
// 쇼핑몰 함수 모음 끝
//==============================================================================

View File

@ -29,18 +29,269 @@ if (G4_IS_MOBILE) {
$g4['title'] = '장바구니';
include_once('./_head.php');
$s_uq_id = get_session('ss_uq_id');
?>
<script src="<?php echo G4_JS_URL; ?>/shop.js"></script>
<div id="sod_bsk">
<form name="frmcartlist" id="sod_bsk_list" method="post">
<table class="basic_tbl">
<thead>
<tr>
<th scope="col">상품이미지</th>
<th scope="col">상품명</th>
<th scope="col">총수량</th>
<th scope="col">판매가</th>
<th scope="col">소계</th>
<th scope="col">포인트</th>
<th scope="col"><input type="checkbox" name="ct_all" value="1"></th>
</tr>
</thead>
<tbody>
<?php
$s_page = 'cart.php';
$s_uq_id = get_session('ss_uq_id');
include G4_SHOP_PATH.'/cartsub.inc.php';
$tot_point = 0;
$tot_sell_amount = 0;
$tot_cancel_amount = 0;
$goods = $goods_it_id = "";
$goods_count = -1;
// $s_uq_id 로 현재 장바구니 자료 쿼리
$sql = " select a.ct_id,
a.it_id,
a.it_name,
a.ct_price,
a.ct_point,
a.ct_qty,
a.ct_status,
b.ca_id,
b.ca_id2,
b.ca_id3
from {$g4['shop_cart_table']} a left join {$g4['shop_item_table']} b on ( a.it_id = b.it_id )
where a.uq_id = '$s_uq_id'
and a.ct_num = '0' ";
if($default['de_cart_keep_term']) {
$ctime = date('Y-m-d H:i:s', G4_SERVER_TIME - ($default['de_cart_keep_term'] * 86400));
$sql .= " and a.ct_time > '$ctime' ";
}
$sql .= " order by a.ct_id ";
$result = sql_query($sql);
$good_info = '';
for ($i=0; $row=mysql_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_point * ct_qty) as point,
SUM(ct_qty) as qty
from {$g4['shop_cart_table']}
where it_id = '{$row['it_id']}'
and uq_id = '$s_uq_id' ";
$sum = sql_fetch($sql);
if ($i==0) { // 계속쇼핑
$continue_ca_id = $row['ca_id'];
}
$a1 = '<a href="./item.php?it_id='.$row['it_id'].'"><b>';
$a2 = '</b></a>';
$image = get_it_image($row['it_id'], 70, 70);
$it_name = $a1 . stripslashes($row['it_name']) . $a2;
$it_options = print_item_options($row['it_id'], $s_uq_id);
if($it_options) {
$mod_options = '<div class="sod_option_btn"><button type="button" class="mod_options">선택사항수정</button></div>';
$it_name .= '<div class="sod_bsk_itopt">'.$it_options.'</div>';
}
$point = $sum['point'];
$sell_amount = $sum['price'];
?>
<tr>
<td class="sod_bsk_img"><?php echo $image; ?></td>
<td>
<input type="hidden" name="it_id[<?php echo $i; ?>]" value="<?php echo $row['it_id']; ?>">
<input type="hidden" name="it_name[<?php echo $i; ?>]" value="<?php echo get_text($row['it_name']); ?>">
<?php echo $it_name.$mod_options; ?>
</td>
<td class="td_num"><?php echo number_format($sum['qty']); ?></td>
<td class="td_bignum"><?php echo number_format($row['ct_price']); ?></td>
<td class="td_bignum"><span id="sell_amount_<?php echo $i; ?>"><?php echo number_format($sell_amount); ?></span></td>
<td class="td_bignum"><?php echo number_format($point); ?></td>
<td class="td_smallmng"><input type="checkbox" name="ct_chk[<?php echo $i; ?>]" value="1"></td>
</tr>
<?php
if ($row['ct_status'] == '취소' || $row['ct_status'] == '반품' || $row['ct_status'] == '품절') {
$tot_cancel_amount += $sell_amount;
}
else {
$tot_point += $point;
$tot_sell_amount += $sell_amount;
}
} // for 끝
if ($i == 0) {
echo '<tr><td colspan="7" class="empty_table">장바구니에 담긴 상품이 없습니다.</td></tr>';
} 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]) {
$send_cost = $send_cost_list[$k];
break;
}
}
}
}
?>
</tbody>
</table>
<?php if ($goods_count) $goods .= ' 외 '.$goods_count.'건'; ?>
<?php
// 배송비가 0 보다 크다면 (있다면)
if ($send_cost > 0)
{
?>
<div id="sod_bsk_dvr" class="sod_bsk_tot">
<span>배송비</span>
<strong><?php echo number_format($send_cost); ?> 원</strong>
</div>
<?php } ?>
<?php
// 총계 = 주문상품금액합계 + 배송비
$tot_amount = $tot_sell_amount + $send_cost;
if ($tot_amount > 0) {
?>
<div id="sod_bsk_cnt" class="sod_bsk_tot">
<span>총계</span>
<strong><?php echo number_format($tot_amount); ?> 원 <?php echo number_format($tot_point); ?> 점</strong>
</div>
<?php } ?>
<div id="sod_bsk_act">
<?php if ($i == 0) { ?>
<a href="<?php echo G4_SHOP_URL; ?>/" class="btn01">쇼핑 계속하기</a>
<?php } else { ?>
<input type="hidden" name="url" value="./orderform.php">
<input type="hidden" name="records" value="<?php echo $i; ?>">
<input type="hidden" name="act" value="">
<p>장바구니의 상품을 주문하시려면 <strong>주문하기</strong>를 클릭하세요. <strong>비우기</strong>는 장바구니의 상품을 모두 비웁니다.</p>
<a href="<?php echo G4_SHOP_URL; ?>/list.php?ca_id=<?php echo $continue_ca_id; ?>" class="btn01">쇼핑 계속하기</a>
<a href="javascript:form_check('buy');" class="btn02">주문하기</a>
<a href="javascript:form_check('seldelete');" class="btn01">선택삭제</a>
<a href="javascript:form_check('alldelete');" class="btn01">비우기</a>
<?php } ?>
</div>
</form>
</div>
<script>
$(function() {
var close_btn_idx;
// 선택사항수정
$(".mod_options").click(function() {
var it_id = $(this).closest("tr").find("input[name^=it_id]").val();
var $this = $(this);
close_btn_idx = $(".mod_options").index($(this));
winMask(); // 모달 윈도우 배경 출력
$.post(
"./cartoption.php",
{ it_id: it_id },
function(data) {
$("#mod_option_frm").remove();
$this.after("<div id=\"mod_option_frm\"></div>");
$("#mod_option_frm").html(data);
price_calculate();
}
);
});
// 모두선택
$("input[name=ct_all]").click(function() {
if($(this).is(":checked"))
$("input[name^=ct_chk]").attr("checked", true);
else
$("input[name^=ct_chk]").attr("checked", false);
});
// 옵션수정 닫기
$("#mod_option_close").live("click", function() {
$("#mod_option_frm").remove();
$("#win_mask, .window").hide();
$(".mod_options").eq(close_btn_idx).focus();
});
$("#win_mask").click(function () {
$("#mod_option_frm").remove();
$("#win_mask").hide();
$(".mod_options").eq(close_btn_idx).focus();
});
});
function form_check(act) {
var f = document.frmcartlist;
var cnt = f.records.value;
if (act == "buy")
{
f.act.value = act;
<?php
if (get_session('ss_mb_id')) // 회원인 경우
{
echo "f.action = './orderform.php';";
echo "f.submit();";
}
else
echo "document.location.href = '".G4_BBS_URL."/login.php?url=".urlencode(G4_SHOP_URL."/orderform.php")."';";
?>
}
else if (act == "alldelete")
{
f.act.value = act;
f.action = "./cartupdate.php";
f.submit();
}
else if (act == "seldelete")
{
if($("input[name^=ct_chk]:checked").size() < 1) {
alert("삭제하실 상품을 하나이상 선택해 주십시오.");
return false;
}
f.act.value = act;
f.action = "./cartupdate.php";
f.submit();
}
return true;
}
</script>
<?php
include_once('./_tail.php');
?>

View File

@ -153,6 +153,8 @@ for ($i=0; $row=mysql_fetch_array($result); $i++)
<td>
<input type="hidden" name="it_id[<?php echo $i; ?>]" value="<?php echo $row['it_id']; ?>">
<input type="hidden" name="it_name[<?php echo $i; ?>]" value="<?php echo get_text($row['it_name']); ?>">
<input type="hidden" name="cp_id[<?php echo $i; ?>]" value="">
<input type="hidden" name="cp_amount[<?php echo $i; ?>]" value="">
<?php echo $it_name.$mod_options; ?>
</td>
<td class="td_num"><?php echo number_format($sum['qty']); ?></td>
@ -160,7 +162,7 @@ for ($i=0; $row=mysql_fetch_array($result); $i++)
<?php if($s_page == 'orderform.php') { ?>
<td><?php echo $cp_button; ?></td>
<?php } ?>
<td class="td_bignum"><?php echo number_format($sell_amount); ?></td>
<td class="td_bignum"><span id="sell_amount_<?php echo $i; ?>"><?php echo number_format($sell_amount); ?></span></td>
<td class="td_bignum"><?php echo number_format($point); ?></td>
<?php
@ -267,8 +269,8 @@ if ($tot_amount > 0) {
</form>
<?php
if ($s_page == 'cart.php') {
if ($i != 0) {
if ($i != 0) {
if ($s_page == 'cart.php') {
?>
<script>
$(function() {
@ -355,6 +357,83 @@ function form_check(act) {
return true;
}
</script>
<?php
}
if($s_page == 'orderform.php') {
?>
<script>
$(function() {
var item_index;
$(".od_coupon_btn").click(function() {
var $this = $(this);
$("#it_coupon_frm").remove();
item_index = $(".od_coupon_btn").index($this);
var it_id = $("input[name^=it_id]:eq("+item_index+")").val();
$.post(
"./orderitemcoupon.php",
{ it_id: it_id },
function(data) {
$this.after(data);
}
);
});
$(".cp_apply").live("click", function() {
var $el = $(this).closest("li");
var cp_id = $el.find("input[name='f_cp_id[]']").val();
var amount = $el.find("input[name='f_cp_amt[]']").val();
var subj = $el.find("input[name='f_cp_subj[]']").val();
var sell_amount;
// 이미 사용한 쿠폰이 있는지
var cp_dup = false;
var cp_dup_idx;
$("input[name^=cp_id]").each(function(index) {
var id = $(this).val();
if(id == cp_id) {
cp_dup_idx = index;
cp_dup = true;
return false;
}
});
if(cp_dup) {
var it_name = $("input[name='it_name["+cp_dup_idx+"]']").val();
if(!confirm(subj+ "쿠폰은 "+it_name+"에 사용되었습니다.\n"+it_name+"의 쿠폰을 취소한 후 적용하시겠습니까?")) {
return false;
} else {
var $dup_sell_el = $("#sell_amount_"+cp_dup_idx);
var $dup_amount_el = $("input[name='cp_amount["+cp_dup_idx+"]']");
sell_amount = parseInt($dup_sell_el.text().replace(/[^0-9]/g, ""));
var cp_amount = parseInt($dup_amount_el.val());
var org_sell = sell_amount + cp_amount;
$dup_sell_el.text(number_format(String(org_sell)));
$dup_amount_el.val("");
$("input[name='cp_id["+cp_dup_idx+"]']").val("");
}
}
var $s_el = $("#sell_amount_"+item_index);
sell_amount = parseInt($s_el.text().replace(/[^0-9]/g, ""));
sell_amount = sell_amount - parseInt(amount);
$s_el.text(number_format(String(sell_amount)));
$("input[name='cp_id["+item_index+"]']").val(cp_id);
$("input[name='cp_amount["+item_index+"]']").val(amount);
$("#it_coupon_frm").remove();
});
$("#it_coupon_close").live("click", function() {
$("#it_coupon_frm").remove();
});
});
</script>
<?php
}
}

64
shop/ordercoupon.php Normal file
View File

@ -0,0 +1,64 @@
<?php
include_once('./_common.php');
if($is_guest)
exit;
$amount = $_POST['amount'];
// 쿠폰정보
$sql = " select *
from {$g4['shop_coupon_table']}
where mb_id = '{$member['mb_id']}'
and cp_method = '2'
and cp_start <= '".G4_TIME_YMD."'
and cp_end >= '".G4_TIME_YMD."'
and cp_used = '0'
and cp_minimum <= '$amount' ";
$result = sql_query($sql);
$count = mysql_num_rows($result);
?>
<div id="od_coupon_frm">
<?php if($count > 0) { ?>
<ul>
<li>
<span>쿠폰명</span>
<span>할인금액</span>
<span>적용</span>
</li>
<?php
for($i=0; $row=sql_fetch_array($result); $i++) {
$dc = 0;
if($row['cp_type']) {
$dc = floor(($amount * ($row['cp_amount'] / 100)) / $row['cp_trunc']) * $row['cp_trunc'];
} else {
$dc = $row['cp_amount'];
}
if($row['cp_maximum'] && $dc > $row['cp_maximum'])
$dc = $row['cp_maximum'];
?>
<li>
<input type="hidden" name="o_cp_id[]" value="<?php echo $row['cp_id']; ?>">
<input type="hidden" name="o_cp_amt[]" value="<?php echo $dc; ?>">
<span><?php echo get_text($row['cp_subject']); ?></span>
<span><?php echo number_format($dc); ?></span>
<span><button type="button" class="od_cp_apply">적용</button></span>
</li>
<?php
}
?>
</ul>
<?php
} else {
echo '사용할 수 있는 쿠폰이 없습니다.';
}
?>
<div>
<button type="button" id="od_coupon_close">닫기</button>
<?php if($count > 0) { ?>
<button type="button" id="od_coupon_cancel">쿠폰적용취소</button>
<?php } ?>
</div>
</div>

View File

@ -28,106 +28,279 @@ include_once('./_head.php');
// 새로운 주문번호 생성
$od_id = get_uniqid();
set_session('ss_order_uniqid', $od_id);
$s_uq_id = $tmp_uq_id;
$order_action_url = G4_HTTPS_SHOP_URL.'/orderformupdate.php';
if (file_exists('./settle_'.$default['de_card_pg'].'.inc.php')) {
include './settle_'.$default['de_card_pg'].'.inc.php';
}
?>
<div id="sod_frm">
<?php
/* ============================================================================== */
/* = Javascript source Include = */
/* = -------------------------------------------------------------------------- = */
/* = ※ 필수 = */
/* = -------------------------------------------------------------------------- = */
?>
<script src="<?php echo $g_conf_js_url; ?>"></script>
<?php
/* = -------------------------------------------------------------------------- = */
/* = Javascript source Include END = */
/* ============================================================================== */
?>
<script>
/* 플러그인 설치(확인) */
StartSmartUpdate();
<?php
$s_page = 'orderform.php';
$s_uq_id = $tmp_uq_id;
/* 해당 스크립트는 타브라우져에서 적용이 되지 않습니다.
if( document.Payplus.object == null )
{
openwin = window.open( "chk_plugin.html", "chk_plugin", "width=420, height=100, top=300, left=300" );
}
*/
echo '<p>주문하실 상품을 확인하세요.</p>';
include_once('./cartsub.inc.php');
/* Payplus Plug-in 실행 */
function jsf__pay( form )
{
var RetVal = false;
if (file_exists('./settle_'.$default['de_card_pg'].'.inc.php')) {
include './settle_'.$default['de_card_pg'].'.inc.php';
/* Payplus Plugin 실행 */
if ( MakePayMessage( form ) == true )
{
openwin = window.open( "./kcp/proc_win.html", "proc_win", "width=449, height=209, top=300, left=300" );
RetVal = true ;
}
$good_mny = (int)$tot_sell_amount + (int)$send_cost;
$order_action_url = G4_HTTPS_SHOP_URL.'/orderformupdate.php';
?>
<?php
/* ============================================================================== */
/* = Javascript source Include = */
/* = -------------------------------------------------------------------------- = */
/* = ※ 필수 = */
/* = -------------------------------------------------------------------------- = */
?>
<script src="<?php echo $g_conf_js_url; ?>"></script>
<?php
/* = -------------------------------------------------------------------------- = */
/* = Javascript source Include END = */
/* ============================================================================== */
?>
<script>
/* 플러그인 설치(확인) */
StartSmartUpdate();
/* 해당 스크립트는 타브라우져에서 적용이 되지 않습니다.
if( document.Payplus.object == null )
else
{
openwin = window.open( "chk_plugin.html", "chk_plugin", "width=420, height=100, top=300, left=300" );
}
*/
/* Payplus Plug-in 실행 */
function jsf__pay( form )
{
var RetVal = false;
/* Payplus Plugin 실행 */
if ( MakePayMessage( form ) == true )
{
openwin = window.open( "./kcp/proc_win.html", "proc_win", "width=449, height=209, top=300, left=300" );
RetVal = true ;
}
else
{
/* res_cd와 res_msg변수에 해당 오류코드와 오류메시지가 설정됩니다.
ex) 고객이 Payplus Plugin에서 취소 버튼 클릭시 res_cd=3001, res_msg=사용자 취소
값이 설정됩니다.
*/
res_cd = document.forderform.res_cd.value ;
res_msg = document.forderform.res_msg.value ;
}
return RetVal ;
}
// Payplus Plug-in 설치 안내
function init_pay_button()
{
/*
if( document.Payplus.object == null )
document.getElementById("display_setup_message").style.display = "block" ;
else
document.getElementById("display_pay_button").style.display = "block" ;
/* res_cd와 res_msg변수에 해당 오류코드와 오류메시지가 설정됩니다.
ex) 고객이 Payplus Plugin에서 취소 버튼 클릭시 res_cd=3001, res_msg=사용자 취소
값이 설정됩니다.
*/
// 체크 방법이 변경
if( GetPluginObject() == null ){
document.getElementById("display_setup_message").style.display = "block" ;
}
else{
document.getElementById("display_pay_button").style.display = "block" ;
}
res_cd = document.forderform.res_cd.value ;
res_msg = document.forderform.res_msg.value ;
}
/*
* 인터넷 익스플로러와 파이어폭스(사파리, 크롬.. 등등)는 javascript 파싱법이 틀리기 때문에 object 가 인식 전에 실행 되는 문제
* 기존에는 onload 부분에 추가를 했지만 setTimeout 부분에 추가
* setTimeout 에 2번째 변수 0은 딜레이 시간 0은 딜래이 없음을 의미
* - 김민수 - 20101018 -
*/
setTimeout("init_pay_button();",300);
</script>
return RetVal ;
}
// Payplus Plug-in 설치 안내
function init_pay_button()
{
/*
if( document.Payplus.object == null )
document.getElementById("display_setup_message").style.display = "block" ;
else
document.getElementById("display_pay_button").style.display = "block" ;
*/
// 체크 방법이 변경
if( GetPluginObject() == null ){
document.getElementById("display_setup_message").style.display = "block" ;
}
else{
document.getElementById("display_pay_button").style.display = "block" ;
}
}
/*
* 인터넷 익스플로러와 파이어폭스(사파리, 크롬.. 등등)는 javascript 파싱법이 틀리기 때문에 object 가 인식 전에 실행 되는 문제
* 기존에는 onload 부분에 추가를 했지만 setTimeout 부분에 추가
* setTimeout 에 2번째 변수 0은 딜레이 시간 0은 딜래이 없음을 의미
* - 김민수 - 20101018 -
*/
setTimeout("init_pay_button();",300);
</script>
<form name="forderform" method="post" action="<?php echo $order_action_url; ?>" onsubmit="return forderform_check(this);" autocomplete="off">
<div id="sod_frm">
<p>주문하실 상품을 확인하세요.</p>
<table class="basic_tbl">
<thead>
<tr>
<th scope="col">상품이미지</th>
<th scope="col">상품명</th>
<th scope="col">총수량</th>
<th scope="col">판매가</th>
<th scope="col">쿠폰</th>
<th scope="col">소계</th>
<th scope="col">포인트</th>
</tr>
</thead>
<tbody>
<?php
$tot_point = 0;
$tot_sell_amount = 0;
$tot_cancel_amount = 0;
$goods = $goods_it_id = "";
$goods_count = -1;
// $s_uq_id 로 현재 장바구니 자료 쿼리
$sql = " select a.ct_id,
a.it_id,
a.it_name,
a.ct_price,
a.ct_point,
a.ct_qty,
a.ct_status,
b.ca_id,
b.ca_id2,
b.ca_id3
from {$g4['shop_cart_table']} a left join {$g4['shop_item_table']} b on ( a.it_id = b.it_id )
where a.uq_id = '$s_uq_id'
and a.ct_num = '0' ";
if($default['de_cart_keep_term']) {
$ctime = date('Y-m-d H:i:s', G4_SERVER_TIME - ($default['de_cart_keep_term'] * 86400));
$sql .= " and a.ct_time > '$ctime' ";
}
$sql .= " order by a.ct_id ";
$result = sql_query($sql);
$good_info = '';
for ($i=0; $row=mysql_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_point * ct_qty) as point,
SUM(ct_qty) as qty
from {$g4['shop_cart_table']}
where it_id = '{$row['it_id']}'
and uq_id = '$s_uq_id' ";
$sum = sql_fetch($sql);
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($s_page == 'orderform.php' && $default['de_escrow_use']) {
if ($i>0)
$good_info .= chr(30);
$good_info .= "seq=".($i+1).chr(31);
$good_info .= "ordr_numb={$od_id}_".sprintf("%04d", $i).chr(31);
$good_info .= "good_name=".addslashes($row['it_name']).chr(31);
$good_info .= "good_cntx=".$row['ct_qty'].chr(31);
$good_info .= "good_amtx=".$row['ct_price'].chr(31);
}
$image = get_it_image($row['it_id'], 50, 50);
$it_name = '<b>' . stripslashes($row['it_name']) . '</b>';
$it_options = print_item_options($row['it_id'], $s_uq_id);
if($it_options) {
$it_name .= '<div class="sod_bsk_itopt">'.$it_options.'</div>';
}
$point = $sum['point'];
$sell_amount = $sum['price'];
// 쿠폰
if($is_member) {
$cp_button = '';
$sql = " select count(*) as cnt
from {$g4['shop_coupon_table']}
where mb_id = '{$member['mb_id']}'
and cp_used = '0'
and cp_start <= '".G4_TIME_YMD."'
and cp_end >= '".G4_TIME_YMD."'
and (
( cp_method = '0' and cp_target = '{$row['it_id']}' )
OR
( cp_method = '1' and ( cp_target IN ( '{$row['ca_id']}', '{$row['ca_id2']}', '{$row['ca_id3']}' ) ) )
) ";
$cp = sql_fetch($sql);
if($cp['cnt'])
$cp_button = '<button type="button" class="it_coupon_btn">적용</button>';
}
?>
<tr>
<td class="sod_bsk_img"><?php echo $image; ?></td>
<td>
<input type="hidden" name="it_id[<?php echo $i; ?>]" value="<?php echo $row['it_id']; ?>">
<input type="hidden" name="it_name[<?php echo $i; ?>]" value="<?php echo get_text($row['it_name']); ?>">
<input type="hidden" name="it_amount[<?php echo $i; ?>]" value="<?php echo $sell_amount; ?>">
<input type="hidden" name="cp_id[<?php echo $i; ?>]" value="">
<input type="hidden" name="cp_amount[<?php echo $i; ?>]" value="0">
<?php echo $it_name.$mod_options; ?>
</td>
<td class="td_num"><?php echo number_format($sum['qty']); ?></td>
<td class="td_bignum"><?php echo number_format($row['ct_price']); ?></td>
<td><?php echo $cp_button; ?></td>
<td class="td_bignum"><span id="sell_amount_<?php echo $i; ?>"><?php echo number_format($sell_amount); ?></span></td>
<td class="td_bignum"><?php echo number_format($point); ?></td>
</tr>
<?php
$tot_point += $point;
$tot_sell_amount += $sell_amount;
} // for 끝
if ($i == 0) {
echo '<tr><td colspan="7" class="empty_table">장바구니에 담긴 상품이 없습니다.</td></tr>';
} 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]) {
$send_cost = $send_cost_list[$k];
break;
}
}
}
}
?>
</tbody>
</table>
<?php if ($goods_count) $goods .= ' 외 '.$goods_count.'건'; ?>
<?php
// 배송비가 0 보다 크다면 (있다면)
if ($send_cost > 0)
{
?>
<div id="sod_bsk_dvr" class="sod_bsk_tot">
<span>배송비</span>
<strong><?php echo number_format($send_cost); ?> 원</strong>
</div>
<?php } ?>
<?php
// 총계 = 주문상품금액합계 + 배송비
$tot_amount = $tot_sell_amount + $send_cost;
if ($tot_amount > 0) {
?>
<div id="sod_bsk_cnt" class="sod_bsk_tot">
<span>총계</span>
<strong><span id="ct_tot_amount"><?php echo number_format($tot_amount); ?></span> 원 <?php echo number_format($tot_point); ?> 점</strong>
</div>
<?php } ?>
<form name="forderform" method="post" action="<?php echo $order_action_url; ?>" onsubmit="return forderform_check(this);" autocomplete="off">
<input type="hidden" name="od_amount" value="<?php echo $tot_sell_amount; ?>">
<input type="hidden" name="org_od_amount" value="<?php echo $tot_sell_amount; ?>">
<input type="hidden" name="od_send_cost" value="<?php echo $send_cost; ?>">
<input type="hidden" name="org_send_cost" value="<?php echo $send_cost; ?>">
<?php
/* ============================================================================== */
@ -152,7 +325,7 @@ set_session('ss_order_uniqid', $od_id);
<input type="hidden" name="pay_method" value="">
<input type="hidden" name="ordr_idxx" value="<?php echo $od_id; ?>">
<input type="hidden" name="good_name" value="<?php echo $goods; ?>">
<input type="hidden" name="good_mny" value="<?php echo $good_mny; ?>">
<input type="hidden" name="good_mny" value="<?php echo $tot_amount; ?>">
<input type="hidden" name="buyr_name" value="">
<input type="hidden" name="buyr_mail" value="">
<input type="hidden" name="buyr_tel1" value="">
@ -473,9 +646,64 @@ set_session('ss_order_uniqid', $od_id);
</table>
</section>
<?php
if($is_member) {
// 주문쿠폰
$sql = " select count(*) as cnt
from {$g4['shop_coupon_table']}
where mb_id = '{$member['mb_id']}'
and cp_method = '2'
and cp_start <= '".G4_TIM_YMD."'
and cp_end >= '".G4_TIME_YMD."'
and cp_used = '0' ";
$row = sql_fetch($sql);
$oc_cnt = $row['cnt'];
if($send_cost > 0) {
// 배송비쿠폰
$sql = " select count(*) as cnt
from {$g4['shop_coupon_table']}
where mb_id = '{$member['mb_id']}'
and cp_method = '3'
and cp_start <= '".G4_TIM_YMD."'
and cp_end >= '".G4_TIME_YMD."'
and cp_used = '0' ";
$row = sql_fetch($sql);
$sc_cnt = $row['cnt'];
}
}
?>
<section id="sod_frm_pay">
<h2>결제정보</h2>
<table class="frm_tbl">
<tbody>
<?php if($oc_cnt > 0) { ?>
<tr>
<th scope="row">결제할인쿠폰</th>
<td>
<input type="hidden" name="od_cp_id" value="">
<button type="button" id="od_coupon_btn">쿠폰적용</button>
</td>
</tr>
<?php } ?>
<?php if($sc_cnt > 0) { ?>
<tr>
<th scope="row">배송비할인쿠폰</th>
<td>
<input type="hidden" name="sc_cp_id" value="">
<button type="button" id="sc_coupon_btn">쿠폰적용</button>
</td>
</tr>
<?php } ?>
<tr>
<th>총 주문금액</th>
<td><span id="od_tot_amount"><?php echo number_format($tot_amount); ?></span>원</td>
</tr>
</tbody>
</table>
<?php
if (!$default['de_card_point'])
echo '<p><strong>무통장입금</strong> 이외의 결제 수단으로 결제하시는 경우 포인트를 적립해드리지 않습니다.</p>';
@ -543,7 +771,8 @@ set_session('ss_order_uniqid', $od_id);
if ($temp_point > $member_mileage)
$temp_point = $member_mileage;
?>
<p>보유마일리지(<?php echo display_point($member['mb_mileage']); ?>)중 <strong>최대 <?php echo display_point($temp_point); ?></strong>까지 사용 가능 (주문금액 <?php echo $default['de_point_per']; ?>%)</p>
<p>보유마일리지(<?php echo display_point($member['mb_mileage']); ?>)중 <strong id="use_max_point">최대 <?php echo display_point($temp_point); ?></strong>까지 사용 가능 (주문금액 <?php echo $default['de_point_per']; ?>%)</p>
<input type="hidden" name="max_temp_point" value="<?php echo $temp_point; ?>">
<label for="od_temp_point">사용 포인트</label>
<input type="text" name="od_temp_point" value="0" id="od_temp_point" class="frm_input" size="10">점 (100점 단위로 입력하세요.)
<?php
@ -564,7 +793,8 @@ set_session('ss_order_uniqid', $od_id);
if ($temp_point > $member_point)
$temp_point = $member_point;
?>
<p>보유포인트(<?php echo display_point($member['mb_point']); ?>)중 <strong>최대 <?php echo display_point($temp_point); ?></strong>까지 사용 가능 (주문금액 <?php echo $default['de_point_per']; ?>%)</p>
<p>보유포인트(<?php echo display_point($member['mb_point']); ?>)중 <strong id="use_max_point">최대 <?php echo display_point($temp_point); ?></strong>까지 사용 가능 (주문금액 <?php echo $default['de_point_per']; ?>%)</p>
<input type="hidden" name="max_temp_point" value="<?php echo $temp_point; ?>">
<label for="od_temp_point">사용 포인트</label>
<input type="text" name="od_temp_point" value="0" id="od_temp_point" class="frm_input" size="10">점 (100점 단위로 입력하세요.)
<?php
@ -674,6 +904,252 @@ set_session('ss_order_uniqid', $od_id);
</div>
<script>
$(function() {
var item_index;
$(".it_coupon_btn").click(function() {
var $this = $(this);
$("#it_coupon_frm").remove();
item_index = $(".it_coupon_btn").index($this);
var it_id = $("input[name='it_id["+item_index+"]']").val();
$.post(
"./orderitemcoupon.php",
{ it_id: it_id },
function(data) {
$this.after(data);
}
);
});
$(".cp_apply").live("click", function() {
var $el = $(this).closest("li");
var cp_id = $el.find("input[name='f_cp_id[]']").val();
var amount = $el.find("input[name='f_cp_amt[]']").val();
var subj = $el.find("input[name='f_cp_subj[]']").val();
var sell_amount;
// 이미 사용한 쿠폰이 있는지
var cp_dup = false;
var cp_dup_idx;
$("input[name^=cp_id]").each(function(index) {
var id = $(this).val();
if(id == cp_id) {
cp_dup_idx = index;
cp_dup = true;
return false;
}
});
if(cp_dup) {
var it_name = $("input[name='it_name["+cp_dup_idx+"]']").val();
if(!confirm(subj+ "쿠폰은 "+it_name+"에 사용되었습니다.\n"+it_name+"의 쿠폰을 취소한 후 적용하시겠습니까?")) {
return false;
} else {
coupon_cancel(cp_dup_idx);
}
}
var $s_el = $("#sell_amount_"+item_index);
sell_amount = parseInt($("input[name='it_amount["+item_index+"]']").val());
sell_amount = sell_amount - parseInt(amount);
$s_el.text(number_format(String(sell_amount)));
$("input[name='cp_id["+item_index+"]']").val(cp_id);
$("input[name='cp_amount["+item_index+"]']").val(amount);
calculate_total_amount();
$("#it_coupon_frm").remove();
$(".it_coupon_btn").eq(item_index).focus();
});
$("#it_coupon_close").live("click", function() {
$("#it_coupon_frm").remove();
$(".it_coupon_btn").eq(item_index).focus();
});
$("#it_coupon_cancel").live("click", function() {
coupon_cancel(item_index);
calculate_total_amount();
$("#it_coupon_frm").remove();
$(".it_coupon_btn").eq(item_index).focus();
});
$("#od_coupon_btn").click(function() {
$("#od_coupon_frm").remove();
var $this = $(this);
var amount = parseInt($("input[name=org_od_amount]").val());
var send_cost = parseInt($("input[name=org_send_cost]").val());
$.post(
"./ordercoupon.php",
{ amount: (amount + send_cost) },
function(data) {
$this.after(data);
}
);
});
$(".od_cp_apply").live("click", function() {
var $el = $(this).closest("li");
var cp_id = $el.find("input[name='o_cp_id[]']").val();
var amount = parseInt($el.find("input[name='o_cp_amt[]']").val());
var od_amount = parseInt($("input[name=org_od_amount]").val());
var send_cost = $("input[name=org_send_cost]").val();
$("input[name=od_send_cost]").val(send_cost);
$("input[name=sc_cp_id]").val("");
$("input[name=od_amount]").val(od_amount - amount);
$("input[name=od_cp_id]").val(cp_id);
calculate_order_amount();
$("#od_coupon_frm").remove();
$("#od_coupon_btn").focus();
});
$("#od_coupon_close").live("click", function() {
$("#od_coupon_frm").remove();
$("#od_coupon_btn").focus();
});
$("#od_coupon_cancel").live("click", function() {
var org_amount = $("input[name=org_od_amount]").val();
$("input[name=od_amount]").val(org_amount);
calculate_order_amount();
$("#od_coupon_frm").remove();
$("#od_coupon_btn").focus();
});
$("#sc_coupon_btn").click(function() {
$("#sc_coupon_frm").remove();
var $this = $(this);
var amount = parseInt($("input[name=od_amount]").val());
var send_cost = parseInt($("input[name=org_send_cost]").val());
$.post(
"./ordersendcostcoupon.php",
{ amount: (amount + send_cost), send_cost: send_cost },
function(data) {
$this.after(data);
}
);
});
$(".sc_cp_apply").live("click", function() {
var $el = $(this).closest("li");
var cp_id = $el.find("input[name='s_cp_id[]']").val();
var amount = parseInt($el.find("input[name='s_cp_amt[]']").val());
var send_cost = parseInt($("input[name=org_send_cost]").val());
$("input[name=od_send_cost]").val(send_cost - amount);
$("input[name=sc_cp_id]").val(cp_id);
calculate_order_amount();
$("#sc_coupon_frm").remove();
$("#sc_coupon_btn").focus();
});
$("#sc_coupon_close").live("click", function() {
$("#sc_coupon_frm").remove();
$("#sc_coupon_btn").focus();
});
$("#sc_coupon_cancel").live("click", function() {
var send_cost = $("input[name=org_send_cost]").val();
$("input[name=od_send_cost]").val(send_cost);
calculate_order_amount();
$("#sc_coupon_frm").remove();
$("#sc_coupon_btn").focus();
});
$("#od_settle_bank").bind("click", function() {
$("[name=od_deposit_name]").val( $("[name=od_b_name]").val() );
$("#settle_bank").show();
});
$("#od_settle_iche,#od_settle_card,#od_settle_vbank,#od_settle_hp").bind("click", function() {
$("#settle_bank").hide();
});
});
function coupon_cancel(idx)
{
var $dup_sell_el = $("#sell_amount_"+idx);
var $dup_amount_el = $("input[name='cp_amount["+idx+"]']");
var org_sell_amount = $("input[name='it_amount["+idx+"]']").val();
$dup_sell_el.text(number_format(String(org_sell_amount)));
$dup_amount_el.val(0);
$("input[name='cp_id["+idx+"]']").val("");
}
function calculate_total_amount()
{
var $it_amt = $("input[name^=it_amount]");
var $cp_amt = $("input[name^=cp_amount]");
var tot_sell_amount = sell_amount = 0;
var it_amount, cp_amount;
var send_cost = parseInt($("input[name=org_send_cost]").val());
$it_amt.each(function(index) {
it_amount = parseInt($(this).val());
cp_amount = parseInt($cp_amt.eq(index).val());
sell_amount += (it_amount - cp_amount);
});
tot_sell_amount = sell_amount + send_cost;
$("#ct_tot_amount").text(number_format(String(tot_sell_amount)));
$("input[name=good_mny]").val(tot_sell_amount);
$("input[name=od_amount]").val(sell_amount);
$("input[name=org_od_amount]").val(sell_amount);
$("input[name=od_send_cost]").val(send_cost);
<?php if($od_cnt > 0) { ?>
$("input[name=od_cp_id]").val("");
<?php } ?>
<?php if($sc_cnt > 0) { ?>
$("input[name=sc_cp_id]").val("");
<?php } ?>
$("input[name=od_temp_point]").val(0);
<?php if($temp_point > 0 && $is_member) { ?>
calculate_temp_point();
<?php } ?>
calculate_order_amount();
}
function calculate_order_amount()
{
var sell_amount = parseInt($("input[name=od_amount]").val());
var send_cost = parseInt($("input[name=od_send_cost]").val());
var tot_amount = sell_amount + send_cost;
$("input[name=good_mny]").val(tot_amount);
$("#od_tot_amount").text(number_format(String(tot_amount)));
<?php if($temp_point > 0 && $is_member) { ?>
calculate_temp_point();
<?php } ?>
}
function calculate_temp_point()
{
<?php
if($default['de_mileage_use']) {
$point = (int)$member_mileage;
} else {
$point = (int)$member_point;
}
?>
var sell_amount = parseInt($("input[name=od_amount]").val());
var send_cost = parseInt($("input[name=od_send_cost]").val());
var point_per = <?php echo $default['de_point_per']; ?>;
var temp_point = parseInt((sell_amount + send_cost) * (point_per / 100) / 100) * 100;
var point = <?php echo $point; ?>
if(temp_point > point)
temp_point = point;
$("#use_max_point").text("최대 "+number_format(String(temp_point))+"점");
$("input[name=max_temp_point]").val(temp_point);
}
function forderform_check(f)
{
errmsg = "";
@ -748,7 +1224,7 @@ function forderform_check(f)
}
var tot_amount = <?php echo (int)$tot_amount; ?>;
var max_point = <?php echo (int)$temp_point; ?>;
var max_point = parseInt(f.max_temp_point.value);
var temp_point = 0;
if (typeof(f.od_temp_point) != "undefined") {
@ -875,17 +1351,6 @@ function gumae2baesong(f)
f.od_b_addr1.value = f.od_addr1.value;
f.od_b_addr2.value = f.od_addr2.value;
}
$(function() {
$("#od_settle_bank").bind("click", function() {
$("[name=od_deposit_name]").val( $("[name=od_b_name]").val() );
$("#settle_bank").show();
});
$("#od_settle_iche,#od_settle_card,#od_settle_vbank,#od_settle_hp").bind("click", function() {
$("#settle_bank").hide();
});
});
</script>
<?php

View File

@ -3,11 +3,15 @@ include_once('./_common.php');
if(get_magic_quotes_gpc())
{
$_GET = array_map("stripslashes", $_GET);
$_POST = array_map("stripslashes", $_POST);
//$_GET = array_map("stripslashes", $_GET);
//$_POST = array_map("stripslashes", $_POST);
$_GET = array_add_callback("stripslashes", $_GET);
$_POST = array_add_callback("stripslashes", $_POST);
}
$_GET = array_map("mysql_real_escape_string", $_GET);
$_POST = array_map("mysql_real_escape_string", $_POST);
//$_GET = array_map("mysql_real_escape_string", $_GET);
//$_POST = array_map("mysql_real_escape_string", $_POST);
$_GET = array_add_callback("mysql_real_escape_string", $_GET);
$_POST = array_add_callback("mysql_real_escape_string", $_POST);
// 장바구니가 비어있는가?
if (get_session("ss_direct"))
@ -57,7 +61,88 @@ $i_temp_point = (int)$_POST['od_temp_point'];
$sql = " select SUM(IF(io_type = 1, (io_price * ct_qty), ((ct_price + io_price) * ct_qty))) as od_amount
from {$g4['shop_cart_table']} where uq_id = '$tmp_uq_id' ";
$row = sql_fetch($sql);
if ((int)$row['od_amount'] !== $i_amount) {
$tot_ct_amount = $row['od_amount'];
// 쿠폰금액계산
$tot_cp_amount = 0;
if($is_member) {
// 상품쿠폰
$tot_it_cp_amount = $tot_od_cp_amount = 0;
$it_cp_cnt = count($_POST['cp_id']);
for($i=0; $i<$it_cp_cnt; $i++) {
$cid = $_POST['cp_id'][$i];
$it_id = $_POST['it_id'][$i];
$sql = " select cp_id, cp_type, cp_amount, cp_trunc, cp_minimum, cp_maximum
from {$g4['shop_coupon_table']}
where cp_id = '$cid'
and mb_id = '{$member['mb_id']}'
and cp_target = '$it_id'
and cp_start <= '".G4_TIME_YMD."'
and cp_end >= '".G4_TIME_YMD."'
and cp_used = '0'
and cp_method IN ( 0, 1 ) ";
$cp = sql_fetch($sql);
if(!$cp['cp_id'])
continue;
// 상품금액
$sql = " select SUM( IF(io_type = '1', io_price * ct_qty, (ct_price + io_price) * ct_qty)) as sum_price
from {$g4['shop_cart_table']}
where uq_id = '$tmp_uq_id'
and it_id = '$it_id' ";
$ct = sql_fetch($sql);
$item_price = $ct['sum_price'];
if($cp['cp_minimum'] > $item_price)
continue;
$dc = 0;
if($cp['cp_type']) {
$dc = floor(($item_price * ($cp['cp_amount'] / 100)) / $cp['cp_trunc']) * $cp['cp_trunc'];
} else {
$dc = $cp['cp_amount'];
}
if($cp['cp_maximum'] && $dc > $cp['cp_maximum'])
$dc = $cp['cp_maximum'];
$tot_it_cp_amount += $dc;
}
$tot_od_amount = $tot_ct_amount - $tot_it_cp_amount;
// 주문쿠폰
if($_POST['od_cp_id']) {
$sql = " select cp_id, cp_type, cp_amount, cp_trunc, cp_minimum, cp_maximum
from {$g4['shop_coupon_table']}
where cp_id = '{$_POST['od_cp_id']}'
and mb_id = '{$member['mb_id']}'
and cp_start <= '".G4_TIME_YMD."'
and cp_end >= '".G4_TIME_YMD."'
and cp_used = '0'
and cp_method = '2' ";
$cp = sql_fetch($sql);
$dc = 0;
if($cp['cp_id'] && ($cp['cp_minimum'] <= $tot_od_amount)) {
if($cp['cp_type']) {
$dc = floor(($tot_od_amount * ($cp['cp_amount'] / 100)) / $cp['cp_trunc']) * $cp['cp_trunc'];
} else {
$dc = $cp['cp_amount'];
}
if($cp['cp_maximum'] && $dc > $cp['cp_maximum'])
$dc = $cp['cp_maximum'];
$tot_od_cp_amount = $dc;
$tot_od_amount -= $tot_od_cp_amount;
}
}
$tot_cp_amount = $tot_it_cp_amount + $tot_od_cp_amount;
}
if ((int)($row['od_amount'] - $tot_cp_amount) !== $i_amount) {
die("Error.");
}
@ -79,12 +164,46 @@ if ($default['de_send_cost_case'] == "없음") {
}
}
}
if ((int)$send_cost !== $i_send_cost) {
$tot_sc_cp_amount = 0;
if($is_member) {
// 배송쿠폰
if($_POST['sc_cp_id']) {
$sql = " select cp_id, cp_type, cp_amount, cp_trunc, cp_minimum, cp_maximum
from {$g4['shop_coupon_table']}
where cp_id = '{$_POST['sc_cp_id']}'
and mb_id = '{$member['mb_id']}'
and cp_start <= '".G4_TIME_YMD."'
and cp_end >= '".G4_TIME_YMD."'
and cp_used = '0'
and cp_method = '3' ";
$cp = sql_fetch($sql);
$dc = 0;
if($cp['cp_id'] && ($cp['cp_minimum'] <= $tot_od_amount)) {
if($cp['cp_type']) {
$dc = floor(($tot_od_amount * ($cp['cp_amount'] / 100)) / $cp['cp_trunc']) * $cp['cp_trunc'];
} else {
$dc = $cp['cp_amount'];
}
if($cp['cp_maximum'] && $dc > $cp['cp_maximum'])
$dc = $cp['cp_maximum'];
if($dc > $send_cost)
$dc = $send_cost;
$tot_sc_cp_amount = $dc;
}
}
}
if ((int)($send_cost - $tot_sc_cp_amount) !== $i_send_cost) {
die("Error..");
}
// 결제포인트가 상이함
$tot_amount = $tot_sell_amount + $send_cost;
$tot_amount = $tot_od_amount + ($send_cost - $tot_sc_cp_amount);
// 회원이면서 포인트사용이면
$temp_point = 0;
if($default['de_mileage_use']) {
@ -324,6 +443,39 @@ include_once(G4_SHOP_PATH.'/kcp/pp_ax_hub_result.php');
$od_memo = nl2br(htmlspecialchars2(stripslashes($od_memo))) . "&nbsp;";
// 쿠폰사용내역기록
if($is_member) {
$it_cp_cnt = count($_POST['cp_id']);
for($i=0; $i<$it_cp_cnt; $i++) {
$cid = $_POST['cp_id'][$i];
$sql = " update {$g4['shop_coupon_table']}
set cp_used = '1'
where cp_id = '$cid'
and mb_id = '{$member['mb_id']}'
and cp_method IN ( 0, 1 ) ";
sql_query($sql);
}
if($_POST['od_cp_id']) {
$sql = " update {$g4['shop_coupon_table']}
set cp_used = '1'
where cp_id = '{$_POST['od_cp_id']}'
and mb_id = '{$member['mb_id']}'
and cp_method = '2' ";
sql_query($sql);
}
if($_POST['sc_cp_id']) {
$sql = " update {$g4['shop_coupon_table']}
set cp_used = '1'
where cp_id = '{$_POST['sc_cp_id']}'
and mb_id = '{$member['mb_id']}'
and cp_method = '3' ";
sql_query($sql);
}
}
include_once(G4_SHOP_PATH.'/ordermail1.inc.php');
include_once(G4_SHOP_PATH.'/ordermail2.inc.php');

81
shop/orderitemcoupon.php Normal file
View File

@ -0,0 +1,81 @@
<?php
include_once('./_common.php');
if($is_guest)
exit;
// 상품정보
$it_id = $_POST['it_id'];
$sql = " select it_id, ca_id, ca_id2, ca_id3 from {$g4['shop_item_table']} where it_id = '$it_id' ";
$it = sql_fetch($sql);
// 상품 총 금액
$uq_id = get_session('ss_uq_id');
$sql = " select SUM( IF(io_type = '1', io_price * ct_qty, (ct_price + io_price) * ct_qty)) as sum_price
from {$g4['shop_cart_table']}
where uq_id = '$uq_id'
and it_id = '$it_id' ";
$ct = sql_fetch($sql);
$item_price = $ct['sum_price'];
// 쿠폰정보
$sql = " select *
from {$g4['shop_coupon_table']}
where mb_id = '{$member['mb_id']}'
and cp_used = '0'
and cp_start <= '".G4_TIME_YMD."'
and cp_end >= '".G4_TIME_YMD."'
and cp_minimum <= '$item_price'
and (
( cp_method = '0' and cp_target = '{$it['it_id']}' )
OR
( cp_method = '1' and ( cp_target IN ( '{$it['ca_id']}', '{$it['ca_id2']}', '{$it['ca_id3']}' ) ) )
) ";
$result = sql_query($sql);
$count = mysql_num_rows($result);
?>
<div id="it_coupon_frm">
<?php if($count > 0) { ?>
<ul>
<li>
<span>쿠폰명</span>
<span>할인금액</span>
<span>적용</span>
</li>
<?php
for($i=0; $row=sql_fetch_array($result); $i++) {
$dc = 0;
if($row['cp_type']) {
$dc = floor(($item_price * ($row['cp_amount'] / 100)) / $row['cp_trunc']) * $row['cp_trunc'];
} else {
$dc = $row['cp_amount'];
}
if($row['cp_maximum'] && $dc > $row['cp_maximum'])
$dc = $row['cp_maximum'];
?>
<li>
<input type="hidden" name="f_cp_id[]" value="<?php echo $row['cp_id']; ?>">
<input type="hidden" name="f_cp_amt[]" value="<?php echo $dc; ?>">
<input type="hidden" name="f_cp_subj[]" value="<?php echo $row['cp_subject']; ?>">
<span><?php echo get_text($row['cp_subject']); ?></span>
<span><?php echo number_format($dc); ?></span>
<span><button type="button" class="cp_apply">적용</button></span>
</li>
<?php
}
?>
</ul>
<?php
} else {
echo '사용할 수 있는 쿠폰이 없습니다.';
}
?>
<div>
<button type="button" id="it_coupon_close">닫기</button>
<?php if($count > 0) { ?>
<button type="button" id="it_coupon_cancel">쿠폰적용취소</button>
<?php } ?>
</div>
</div>

View File

@ -0,0 +1,68 @@
<?php
include_once('./_common.php');
if($is_guest)
exit;
$amount = $_POST['amount'];
$send_cost = $_POST['send_cost'];
// 쿠폰정보
$sql = " select *
from {$g4['shop_coupon_table']}
where mb_id = '{$member['mb_id']}'
and cp_method = '3'
and cp_start <= '".G4_TIME_YMD."'
and cp_end >= '".G4_TIME_YMD."'
and cp_used = '0'
and cp_minimum <= '$amount' ";
$result = sql_query($sql);
$count = mysql_num_rows($result);
?>
<div id="sc_coupon_frm">
<?php if($count > 0) { ?>
<ul>
<li>
<span>쿠폰명</span>
<span>할인금액</span>
<span>적용</span>
</li>
<?php
for($i=0; $row=sql_fetch_array($result); $i++) {
$dc = 0;
if($row['cp_type']) {
$dc = floor(($send_cost * ($row['cp_amount'] / 100)) / $row['cp_trunc']) * $row['cp_trunc'];
} else {
$dc = $row['cp_amount'];
}
if($row['cp_maximum'] && $dc > $row['cp_maximum'])
$dc = $row['cp_maximum'];
if($dc > $send_cost)
$dc = $send_cost;
?>
<li>
<input type="hidden" name="s_cp_id[]" value="<?php echo $row['cp_id']; ?>">
<input type="hidden" name="s_cp_amt[]" value="<?php echo $dc; ?>">
<span><?php echo get_text($row['cp_subject']); ?></span>
<span><?php echo number_format($dc); ?></span>
<span><button type="button" class="sc_cp_apply">적용</button></span>
</li>
<?php
}
?>
</ul>
<?php
} else {
echo '사용할 수 있는 쿠폰이 없습니다.';
}
?>
<div>
<button type="button" id="sc_coupon_close">닫기</button>
<?php if($count > 0) { ?>
<button type="button" id="sc_coupon_cancel">쿠폰적용취소</button>
<?php } ?>
</div>
</div>