#176 모바일 쇼핑몰 옵션 기능 수정

This commit is contained in:
chicpro
2013-05-29 10:14:27 +09:00
parent 73052f642d
commit e0bb9069bd
4 changed files with 219 additions and 218 deletions

View File

@ -14,19 +14,21 @@ else
$colspan = 6;
?>
<script src="<?php echo G4_JS_URL; ?>/shop.js"></script>
<form name="frmcartlist" 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">포인트</th>
<?php
if ($s_page == 'cart.php') {
echo '<th scope="col">포인트</th>';
echo '<th scope="col">삭제</th>';
echo '<th scope="col"><input type="checkbox" name="ct_all" value="1"></th>';
}
?>
</tr>
@ -42,30 +44,32 @@ $goods_count = -1;
// $s_uq_id 로 현재 장바구니 자료 쿼리
$sql = " select a.ct_id,
a.it_id,
a.it_name,
a.it_opt1,
a.it_opt2,
a.it_opt3,
a.it_opt4,
a.it_opt5,
a.it_opt6,
a.ct_price,
a.ct_point,
a.ct_qty,
a.ct_status,
b.it_id,
b.ca_id
from {$g4['shop_cart_table']} a,
{$g4['shop_item_table']} b
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.it_id = b.it_id
order by a.ct_id ";
and a.ct_num = '0'
order by a.ct_order, 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]);
@ -101,41 +105,36 @@ for ($i=0; $row=mysql_fetch_array($result); $i++)
}
$it_name = $a1 . stripslashes($row['it_name']) . $a2;
if ($row['it_opt1'] || $row['it_opt2'] || $row['it_opt3'] || $row['it_opt4'] || $row['it_opt5'] || $row['it_opt6']) { // 상품에 옵션이 있다면
$it_name .= '<div class="sod_bsk_itopt">'.print_item_options($row['it_id'], $row['it_opt1'], $row['it_opt2'], $row['it_opt3'], $row['it_opt4'], $row['it_opt5'], $row['it_opt6']).'</div>';
$it_options = print_item_options($row['it_id'], $s_uq_id);
if($it_options) {
$mod_options = '';
if($s_page == 'cart.php')
$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 = $row['ct_point'] * $row['ct_qty'];
$sell_amount = $row['ct_price'] * $row['ct_qty'];
$point = $sum['point'];
$sell_amount = $sum['price'];
?>
<tr>
<td class="sod_bsk_img"><?php echo $image; ?></td>
<td>
<input type="hidden" name="ct_id[<?php echo $i; ?>]" value="<?php echo $row['ct_id']; ?>">
<input type="hidden" name="it_id[<?php echo $i; ?>]" value="<?php echo $row['it_id']; ?>">
<input type="hidden" name="ap_id[<?php echo $i; ?>]" value="<?php echo $row['ap_id']; ?>">
<input type="hidden" name="bi_id[<?php echo $i; ?>]" value="<?php echo $row['bi_id']; ?>">
<input type="hidden" name="it_name[<?php echo $i; ?>]" value="<?php echo get_text($row['it_name']); ?>">
<?php echo $it_name; ?>
<?php echo $it_name.$mod_options; ?>
</td>
<?php
// 수량, 입력(수량)
if ($s_page == "cart.php")
echo '<td class="td_num"><input type="text" name="ct_qty['.$i.']" value="'.$row['ct_qty'].'" id="ct_qty_'.$i.'" class="frm_input" size="4" maxlength="6" autocomplete="off"></td>';
else
echo '<td class="td_num">'.$row['ct_qty'].'</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"><?php echo number_format($sell_amount); ?></td>
<td class="td_num"><?php echo number_format($sum['point']); ?></td>
<?php
if ($s_page == 'cart.php') {
echo '<td class="td_bignum"><?php echo number_format($point); ?></td>';
echo '<td class="td_smallmng"><a href="'.G4_SHOP_URL.'/cartupdate.php?act=d&amp;ct_id='.$row['ct_id'].'">삭제</a></td>';
}
if ($s_page == 'cart.php')
echo '<td class="td_smallmng"><input type="checkbox" name="ct_chk['.$i.']" value="1"></td>';
else if ($s_page == 'orderinquiryview.php')
echo '<td class="td_smallmng">'.$row['ct_status'].'</td>';
?>
</tr>
@ -224,7 +223,7 @@ if ($tot_amount > 0) {
<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('allupdate');" class="btn01">수량변경</a>
<a href="javascript:form_check('seldelete');" class="btn01">선택삭제</a>
<a href="javascript:form_check('alldelete');" class="btn01">비우기</a>
<?php } ?>
</div>
@ -237,6 +236,51 @@ if ($s_page == 'cart.php') {
if ($i != 0) {
?>
<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;
@ -248,7 +292,7 @@ function form_check(act) {
<?php
if (get_session('ss_mb_id')) // 회원인 경우
{
echo "f.action = '".G4_SHOP_URL."/orderform.php';";
echo "f.action = './orderform.php';";
echo "f.submit();";
}
else
@ -258,40 +302,18 @@ function form_check(act) {
else if (act == "alldelete")
{
f.act.value = act;
f.action = "<?php echo G4_SHOP_URL; ?>/cartupdate.php";
f.action = "./cartupdate.php";
f.submit();
}
else if (act == "allupdate")
else if (act == "seldelete")
{
for (i=0; i<cnt; i++)
{
//if (f.elements("ct_qty[" + i + "]").value == "")
if (document.getElementById('ct_qty_'+i).value == '')
{
alert("수량을 입력해 주십시오.");
//f.elements("ct_qty[" + i + "]").focus();
document.getElementById('ct_qty_'+i).focus();
return;
}
//else if (isNaN(f.elements("ct_qty[" + i + "]").value))
else if (isNaN(document.getElementById('ct_qty_'+i).value))
{
alert("수량을 숫자로 입력해 주십시오.");
//f.elements("ct_qty[" + i + "]").focus();
document.getElementById('ct_qty_'+i).focus();
return;
}
//else if (f.elements("ct_qty[" + i + "]").value < 1)
else if (document.getElementById('ct_qty_'+i).value < 1)
{
alert("수량은 1 이상 입력해 주십시오.");
//f.elements("ct_qty[" + i + "]").focus();
document.getElementById('ct_qty_'+i).focus();
return;
}
if($("input[name^=ct_chk]:checked").size() < 1) {
alert("삭제하실 상품을 하나이상 선택해 주십시오.");
return false;
}
f.act.value = act;
f.action = "<?php echo G4_SHOP_URL; ?>/cartupdate.php";
f.action = "./cartupdate.php";
f.submit();
}

View File

@ -154,6 +154,7 @@ function pg_anchor_m($anc_id) {
<?php } ?>
<script src="<?php echo G4_JS_URL; ?>/md5.js"></script>
<script src="<?php echo G4_JS_URL; ?>/shop.js"></script>
<?php
if (G4_HTTPS_DOMAIN)
@ -167,6 +168,7 @@ else
<form name="fitem" action="<?php echo $action_url; ?>" method="post">
<input type="hidden" name="it_id" value="<?php echo $it['it_id']; ?>">
<input type="hidden" name="it_name" value="<?php echo $it['it_name']; ?>">
<input type="hidden" name="total_price" value="">
<input type="hidden" name="sw_direct">
<input type="hidden" name="url">
@ -280,22 +282,6 @@ else
</tr>
<?php } ?>
<?php
// 선택옵션 출력
for ($i=1; $i<=6; $i++)
{
// 옵션에 문자가 존재한다면
$str = get_item_options(trim($it['it_opt'.$i.'_subject']), trim($it['it_opt'.$i]), $i);
if ($str)
{
echo '<tr>'.PHP_EOL;
echo '<th scope="row"><label for="sit_opt_'.$i.'">'.$it['it_opt'.$i.'_subject'].'</label></th>'.PHP_EOL;
echo '<td style="word-break:break-all;">'.$str.'</td>'.PHP_EOL;
echo '</tr>'.PHP_EOL;
}
}
?>
<?php if (!$it['it_gallery']) { // 갤러리 형식이라면 가격, 구매하기 출력하지 않음 ?>
<?php if ($it['it_tel_inq']) { // 전화문의일 경우 ?>
@ -307,18 +293,16 @@ else
<?php } else { // 전화문의가 아닐 경우?>
<?php if ($it['it_cust_price']) { // 1.00.03?>
<tr>
<th scope="row"><label for="disp_cust_price">시중가격</label></th>
<td>
<input type="text" name="disp_cust_price" value="<?php echo number_format($it['it_cust_price']); ?>" id="disp_cust_price" readonly class="sit_ov_ro" size="8"> 원
</td>
<th scope="row">시중가격</th>
<td><?php echo display_price($it['it_cust_price']); ?></td>
</tr>
<?php } // 전화문의 끝?>
<tr>
<th scope="row"><label for="disp_sell_price">판매가격</label></th>
<th scope="row">판매가격</th>
<td>
<input type="text" name="disp_sell_price" id="disp_sell_price" readonly class="sit_ov_ro" size="8"> 원
<input type="hidden" name="it_price" value="0">
<?php echo number_format($it['it_price']); ?> 원
<input type="hidden" name="it_price" value="<?php echo get_price($it); ?>">
</td>
</tr>
@ -335,26 +319,93 @@ else
<tr>
<th scope="row"><label for="disp_point">포인트</label></th>
<td>
<input type="text" name="disp_point" id="disp_point" readonly class="sit_ov_ro" size="8"> 점
<input type="hidden" name="it_point" value="0">
<?php echo number_format($it['it_point']); ?> 점
<input type="hidden" name="it_point" value="<?php echo $it['it_point']; ?>">
</td>
</tr>
<?php } ?>
<tr>
<th scope="row">수량</th>
<td>
<input type="text" name="ct_qty" value="1" class="sit_ov_input" size="4" maxlength="4" autocomplete="off" onkeyup="amount_change()">
<button type="button" onclick="javascript:qty_add(+1);" class="btn_frmline"><span class="sound_only">수량 1개 </span>증가</button>
<button type="button" onclick="javascript:qty_add(-1);" class="btn_frmline"><span class="sound_only">수량 1개 </span>감소</button>
</td>
</tr>
<?php } ?>
<?php } ?>
</tbody>
</table>
<?php
$option_1 = get_item_options($it['it_id'], $it['it_option_subject']);
if($option_1) {
?>
<section>
<h3>선택옵션</h3>
<table class="sit_ov_tbl">
<colgroup>
<col class="grid_3">
<col>
</colgroup>
<tbody>
<?php // 선택옵션
echo $option_1;
?>
</tbody>
</table>
<div class="sit_sel_btn">
<button type="button" id="sit_selopt_submit" class="btn_frmline">추가</button>
</div>
</section>
<?php
}
?>
<?php
$option_2 = get_item_supply($it['it_id'], $it['it_supply_subject']);
if($option_2) {
?>
<section>
<h3>추가옵션</h3>
<table class="sit_ov_tbl">
<colgroup>
<col class="grid_3">
<col>
</colgroup>
<tbody>
<?php // 추가옵션
echo $option_2;
?>
</tbody>
</table>
</section>
<?php
}
?>
<?php } ?>
<?php } ?>
<div id="sit_sel_option">
<?php if(!$option_1 && !$option_2) { ?>
<ul id="sit_opt_added">
<li class="sit_opt_list">
<input type="hidden" name="io_type[]" value="0">
<input type="hidden" name="io_id[]" value="">
<input type="hidden" name="io_value[]" value="<?php echo $it['it_name']; ?>">
<input type="hidden" name="io_price[]" value="0">
<input type="hidden" name="io_stock[]" value="<?php echo $it['it_stock_qty']; ?>">
<span class="sit_opt_subj"><?php echo $it['it_name']; ?></span>
<span class="sit_opt_prc">(+0원)</span>
<div>
<input type="text" name="ct_qty[]" value="1" class="frm_input" size="5">
<button type="button" class="sit_qty_plus btn_frmline">증가</button>
<button type="button" class="sit_qty_minus btn_frmline">감소</button>
</div>
</li>
</ul>
<script>
$(function() {
price_calculate();
});
</script>
<?php } ?>
</div>
<div id="sit_tot_price"></div>
<ul id="sit_ov_btn">
<?php if (!$it['it_tel_inq'] && !$it['it_gallery']) { ?>
<li><a href="javascript:fitemcheck(document.fitem, 'direct_buy');" id="sit_btn_buy">바로구매</a></li>
@ -563,86 +614,6 @@ else
$(".item_relation_count").text("<?php echo $item_relation_count; ?>");
});
function qty_add(num)
{
var f = document.fitem;
var qty = parseInt(f.ct_qty.value);
if (num < 0 && qty <= 1)
{
alert("수량은 1 이상만 가능합니다.");
qty = 1;
}
else if (num > 0 && qty >= 9999)
{
alert("수량은 9999 이하만 가능합니다.");
qty = 9999;
}
else
{
qty = qty + num;
}
f.ct_qty.value = qty;
amount_change();
}
function get_amount(data)
{
var str = data.split(";");
var num = parseInt(str[1]);
if (isNaN(num)) {
return 0;
} else {
return num;
}
}
function amount_change()
{
var basic_amount = parseInt("<?php echo get_price($it); ?>");
var basic_point = parseFloat("<?php echo $it['it_point']; ?>");
var cust_amount = parseFloat("<?php echo $it['it_cust_price']; ?>");
var f = document.fitem;
var opt1 = 0;
var opt2 = 0;
var opt3 = 0;
var opt4 = 0;
var opt5 = 0;
var opt6 = 0;
var ct_qty = 0;
if (typeof(f.ct_qty) != 'undefined')
ct_qty = parseInt(f.ct_qty.value);
if (typeof(f.it_opt1) != 'undefined') opt1 = get_amount(f.it_opt1.value);
if (typeof(f.it_opt2) != 'undefined') opt2 = get_amount(f.it_opt2.value);
if (typeof(f.it_opt3) != 'undefined') opt3 = get_amount(f.it_opt3.value);
if (typeof(f.it_opt4) != 'undefined') opt4 = get_amount(f.it_opt4.value);
if (typeof(f.it_opt5) != 'undefined') opt5 = get_amount(f.it_opt5.value);
if (typeof(f.it_opt6) != 'undefined') opt6 = get_amount(f.it_opt6.value);
var amount = basic_amount + opt1 + opt2 + opt3 + opt4 + opt5 + opt6;
var point = parseInt(basic_point);
if (typeof(f.it_price) != 'undefined')
f.it_price.value = amount;
if (typeof(f.disp_sell_price) != 'undefined')
f.disp_sell_price.value = number_format(String(amount * ct_qty));
if (typeof(f.disp_cust_price) != 'undefined')
f.disp_cust_price.value = number_format(String(cust_amount * ct_qty));
if (typeof(f.it_point) != 'undefined') {
f.it_point.value = point;
f.disp_point.value = number_format(String(point * ct_qty));
}
}
<?php if (!$it['it_gallery']) { echo "amount_change();"; } // 처음시작시 한번 실행 ?>
// 바로구매 또는 장바구니 담기
function fitemcheck(f, act)
{
@ -653,16 +624,10 @@ else
return;
}
for (i=1; i<=6; i++)
if($(".sit_opt_list").size() < 1)
{
if (typeof(f.elements["it_opt"+i]) != 'undefined')
{
if (f.elements["it_opt"+i].value == '선택') {
alert(f.elements["it_opt"+i+"_subject"].value + '을(를) 선택하여 주십시오.');
f.elements["it_opt"+i].focus();
return;
}
}
alert("상품의 선택옵션을 선택해 주십시오.");
return;
}
if (act == "direct_buy") {
@ -671,22 +636,31 @@ else
f.sw_direct.value = 0;
}
if (!f.ct_qty.value) {
alert("수량을 입력해 주십시오.");
f.ct_qty.focus();
return;
} else if (isNaN(f.ct_qty.value)) {
alert("수량을 숫자로 입력해 주십시오.");
f.ct_qty.select();
f.ct_qty.focus();
return;
} else if (parseInt(f.ct_qty.value) < 1) {
alert("수량은 1 이상 입력해 주십시오.");
f.ct_qty.focus();
return;
}
var val, result = true;
$("input[name='ct_qty[]']").each(function() {
val = $(this).val();
amount_change();
if(val.length < 1) {
alert("수량을 입력해 주십시오.");
result = false;
return false;
}
if(val.replace(/[0-9]/g, "").length > 0) {
alert("수량은 숫자로 입력해 주십시오.");
result = false;
return false;
}
if(parseInt(val.replace(/[^0-9]/g, "")) < 1) {
alert("수량은 1이상 입력해 주십시오.");
result = false;
return false;
}
});
if(!result)
return;
f.submit();
}

View File

@ -26,22 +26,26 @@ if (get_cart_count($tmp_uq_id) == 0)// 장바구니에 담기
$error = "";
// 장바구니 상품 재고 검사
// 1.03.07 : and a.it_id = b.it_id : where 조건문에 이 부분 추가
$sql = " select a.it_id,
a.ct_qty,
a.it_name
from {$g4['shop_cart_table']} a,
{$g4['shop_item_table']} b
where a.uq_id = '$tmp_uq_id'
and a.it_id = b.it_id ";
$sql = " select it_id,
ct_qty,
it_name,
io_id,
io_type,
ct_option
from {$g4['shop_cart_table']}
where uq_id = '$tmp_uq_id' ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++)
{
// 상품에 대한 현재고수량
$it_stock_qty = (int)get_it_stock_qty($row['it_id']);
if($row['io_id']) {
$it_stock_qty = (int)get_option_stock_qty($row['it_id'], $row['io_id'], $row['io_type']);
} else {
$it_stock_qty = (int)get_it_stock_qty($row['it_id']);
}
// 장바구니 수량이 재고수량보다 많다면 오류
if ($row['ct_qty'] > $it_stock_qty)
$error .= "{$row['it_name']} 의 재고수량이 부족합니다. 현재고수량 : $it_stock_qty\\n\\n";
$error .= "{$row['ct_option']} 의 재고수량이 부족합니다. 현재고수량 : $it_stock_qty\\n\\n";
}
if ($error != "")
@ -56,7 +60,8 @@ $i_temp_point = (int)$_POST['od_temp_point'];
// 주문금액이 상이함
$sql = " select SUM(ct_price * ct_qty) as od_amount from {$g4['shop_cart_table']} where uq_id = '$tmp_uq_id' ";
$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) {
die("Error.");