#270 cartupdate 코드 간소화
This commit is contained in:
24
js/shop.js
24
js/shop.js
@ -50,7 +50,7 @@ $(function() {
|
||||
var sel_count = $("select[name='it_option[]']").size();
|
||||
var idx = $("select[name='it_option[]']").index($(this));
|
||||
var val = $(this).val();
|
||||
var it_id = $("input[name=it_id]").val();
|
||||
var it_id = $("input[name='it_id[]']").val();
|
||||
|
||||
// 선택값이 없을 경우 하위 옵션은 disabled
|
||||
if(val == "") {
|
||||
@ -161,7 +161,7 @@ $(function() {
|
||||
$("#sit_sel_option li button").live("click", function() {
|
||||
var mode = $(this).text();
|
||||
var this_qty, max_qty = 9999, min_qty = 1;
|
||||
var $el_qty = $(this).closest("li").find("input[name='ct_qty[]']");
|
||||
var $el_qty = $(this).closest("li").find("input[name^=ct_qty]");
|
||||
var stock = parseInt($(this).closest("li").find("input[name='io_stock[]']").val());
|
||||
|
||||
switch(mode) {
|
||||
@ -221,7 +221,7 @@ $(function() {
|
||||
});
|
||||
|
||||
// 수량직접입력
|
||||
$("input[name='ct_qty[]']").live("keyup", function() {
|
||||
$("input[name^=ct_qty]").live("keyup", function() {
|
||||
var val= $(this).val();
|
||||
|
||||
if(val != "") {
|
||||
@ -328,6 +328,7 @@ function sel_supply_process($el, add_exec)
|
||||
// 선택된 옵션 출력
|
||||
function add_sel_option(type, id, option, price, stock)
|
||||
{
|
||||
var item_code = $("input[name='it_id[]']").val();
|
||||
var opt = "";
|
||||
var li_class = "sit_opt_list";
|
||||
if(type)
|
||||
@ -340,14 +341,14 @@ function add_sel_option(type, id, option, price, stock)
|
||||
opt_prc = "("+number_format(String(price))+"원)";
|
||||
|
||||
opt += "<li class=\""+li_class+"\">\n";
|
||||
opt += "<input type=\"hidden\" name=\"io_type[]\" value=\""+type+"\">\n";
|
||||
opt += "<input type=\"hidden\" name=\"io_id[]\" value=\""+id+"\">\n";
|
||||
opt += "<input type=\"hidden\" name=\"io_value[]\" value=\""+option+"\">\n";
|
||||
opt += "<input type=\"hidden\" name=\"io_type["+item_code+"][]\" value=\""+type+"\">\n";
|
||||
opt += "<input type=\"hidden\" name=\"io_id["+item_code+"][]\" value=\""+id+"\">\n";
|
||||
opt += "<input type=\"hidden\" name=\"io_value["+item_code+"][]\" value=\""+option+"\">\n";
|
||||
opt += "<input type=\"hidden\" name=\"io_price[]\" value=\""+price+"\">\n";
|
||||
opt += "<input type=\"hidden\" name=\"io_stock[]\" value=\""+stock+"\">\n";
|
||||
opt += "<span class=\"sit_opt_subj\">"+option+"</span>\n";
|
||||
opt += "<span class=\"sit_opt_prc\">"+opt_prc+"</span>\n";
|
||||
opt += "<div><input type=\"text\" name=\"ct_qty[]\" value=\"1\" class=\"frm_input\" size=\"5\">\n";
|
||||
opt += "<div><input type=\"text\" name=\"ct_qty["+item_code+"][]\" value=\"1\" class=\"frm_input\" size=\"5\">\n";
|
||||
opt += "<button type=\"button\" class=\"sit_qty_plus btn_frmline\">증가</button>\n";
|
||||
opt += "<button type=\"button\" class=\"sit_qty_minus btn_frmline\">감소</button>\n";
|
||||
opt += "<button type=\"button\" class=\"sit_opt_del btn_frmline\">삭제</button></div>\n";
|
||||
@ -387,7 +388,7 @@ function add_sel_option(type, id, option, price, stock)
|
||||
function same_option_check(val)
|
||||
{
|
||||
var result = false;
|
||||
$("input[name='io_value[]']").each(function() {
|
||||
$("input[name^=io_value]").each(function() {
|
||||
if(val == $(this).val()) {
|
||||
result = true;
|
||||
return false;
|
||||
@ -404,9 +405,9 @@ function same_option_check(val)
|
||||
function price_calculate()
|
||||
{
|
||||
var it_price = parseInt($("input[name=it_price]").val());
|
||||
var $el_prc = $("input[name='io_price[]']");
|
||||
var $el_qty = $("input[name='ct_qty[]']");
|
||||
var $el_type = $("input[name='io_type[]']");
|
||||
var $el_prc = $("input[name^=io_price]");
|
||||
var $el_qty = $("input[name^=ct_qty]");
|
||||
var $el_type = $("input[name^=io_type]");
|
||||
var price, type, qty, total = 0;
|
||||
|
||||
$el_prc.each(function(index) {
|
||||
@ -421,7 +422,6 @@ function price_calculate()
|
||||
}
|
||||
});
|
||||
|
||||
$("input[name=total_price]").val(total);
|
||||
$("#sit_tot_price").empty().html("총 금액 : "+number_format(String(total))+"원");
|
||||
}
|
||||
|
||||
|
||||
@ -162,7 +162,7 @@ else
|
||||
<div id="sit">
|
||||
|
||||
<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_id[]" value="<?php echo $it['it_id']; ?>">
|
||||
<input type="hidden" name="sw_direct">
|
||||
<input type="hidden" name="url">
|
||||
|
||||
@ -404,15 +404,15 @@ else
|
||||
<?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_type[<?php echo $it_id; ?>][]" value="0">
|
||||
<input type="hidden" name="io_id[<?php echo $it_id; ?>][]" value="">
|
||||
<input type="hidden" name="io_value[<?php echo $it_id; ?>][]" 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">
|
||||
<input type="text" name="ct_qty[<?php echo $it_id; ?>][]" 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>
|
||||
|
||||
@ -61,11 +61,14 @@ include_once(G4_MSHOP_PATH.'/_head.php');
|
||||
{
|
||||
?>
|
||||
품절
|
||||
<input type="hidden" name="it_id[<?php echo $i; ?>]">
|
||||
<?php } else { //품절이 아니면 체크할수 있도록한다 ?>
|
||||
<input type="checkbox" name="it_id[<?php echo $i; ?>]" value="<?php echo $row['it_id']; ?>" onclick="out_cd_check(this, '<?php echo $out_cd; ?>');">
|
||||
<input type="checkbox" name="chk_it_id[<?php echo $i; ?>]" value="1" onclick="out_cd_check(this, '<?php echo $out_cd; ?>');">
|
||||
<?php } ?>
|
||||
<input type="hidden" name="ct_qty[<?php echo $i; ?>]" value="1">
|
||||
<input type="hidden" name="it_id[<?php echo $i; ?>]" value="<?php echo $row['it_id']; ?>">
|
||||
<input type="hidden" name="io_type[<?php echo $row['it_id']; ?>][0]" value="0">
|
||||
<input type="hidden" name="io_id[<?php echo $row['it_id']; ?>][0]" value="">
|
||||
<input type="hidden" name="io_value[<?php echo $row['it_id']; ?>][0]" value="<?php echo $row['it_name']; ?>">
|
||||
<input type="hidden" name="ct_qty[<?php echo $row['it_id']; ?>][0]" value="1">
|
||||
</td>
|
||||
<td class="td_smallmng"><a href="<?php echo G4_SHOP_URL; ?>/wishupdate.php?w=d&wi_id=<?php echo $row['wi_id']; ?>">삭제</a></td>
|
||||
</tr>
|
||||
|
||||
@ -26,12 +26,9 @@ if(!mysql_num_rows($result))
|
||||
<!-- 장바구니 옵션 시작 { -->
|
||||
<form name="foption" method="post" action="<?php echo G4_SHOP_URL; ?>/cartupdate.php" onsubmit="return formcheck(this);">
|
||||
<input type="hidden" name="act" value="optionmod">
|
||||
<input type="hidden" name="it_id" value="<?php echo $it['it_id']; ?>">
|
||||
<input type="hidden" name="it_id[]" value="<?php echo $it['it_id']; ?>">
|
||||
<input type="hidden" name="it_price" value="<?php echo $row2['ct_price']; ?>">
|
||||
<input type="hidden" name="it_name" value="<?php echo $row2['it_name']; ?>">
|
||||
<input type="hidden" name="it_point" value="<?php echo $it_point; ?>">
|
||||
<input type="hidden" name="ct_send_cost" value="<?php echo $row2['ct_send_cost']; ?>">
|
||||
<input type="hidden" name="total_price" value="">
|
||||
<input type="hidden" name="sw_direct">
|
||||
<?php
|
||||
$option_1 = get_item_options($it['it_id'], $it['it_option_subject']);
|
||||
@ -96,16 +93,15 @@ if($option_2) {
|
||||
$cls = 'spl';
|
||||
?>
|
||||
<li class="sit_<?php echo $cls; ?>_list">
|
||||
<input type="hidden" name="ct_id[]" value="<?php echo $row['ct_id']; ?>">
|
||||
<input type="hidden" name="io_type[]" value="<?php echo $row['io_type']; ?>">
|
||||
<input type="hidden" name="io_id[]" value="<?php echo $row['io_id']; ?>">
|
||||
<input type="hidden" name="io_value[]" value="<?php echo $row['ct_option']; ?>">
|
||||
<input type="hidden" name="io_type[<?php echo $it['it_id']; ?>][]" value="<?php echo $row['io_type']; ?>">
|
||||
<input type="hidden" name="io_id[<?php echo $it['it_id']; ?>][]" value="<?php echo $row['io_id']; ?>">
|
||||
<input type="hidden" name="io_value[<?php echo $it['it_id']; ?>][]" value="<?php echo $row['ct_option']; ?>">
|
||||
<input type="hidden" name="io_price[]" value="<?php echo $row['io_price']; ?>">
|
||||
<input type="hidden" name="io_stock[]" value="<?php echo $it_stock_qty; ?>">
|
||||
<span class="sit_opt_subj"><?php echo $row['ct_option']; ?></span>
|
||||
<span class="sit_opt_prc"><?php echo $io_price; ?></span>
|
||||
<div>
|
||||
<input type="text" name="ct_qty[]" value="<?php echo $row['ct_qty']; ?>" class="frm_input" size="5">
|
||||
<input type="text" name="ct_qty[<?php echo $it['it_id']; ?>][]" value="<?php echo $row['ct_qty']; ?>" 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>
|
||||
<button type="button" class="btn_frmline">삭제</button>
|
||||
@ -128,7 +124,7 @@ if($option_2) {
|
||||
function formcheck(f)
|
||||
{
|
||||
var val, result = true;
|
||||
$("li input[name='ct_qty[]']").each(function() {
|
||||
$("li input[name^=ct_qty]").each(function() {
|
||||
val = $(this).val();
|
||||
|
||||
if(val.length < 1) {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
include_once('./_common.php');
|
||||
|
||||
//print_r2($_POST); exit;
|
||||
// print_r2($_POST); exit;
|
||||
|
||||
// uq_id 설정
|
||||
set_unique_id($sw_direct);
|
||||
@ -74,217 +74,45 @@ else if ($act == "seldelete") // 선택삭제
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ($act == "multi") // 여러개의 상품이 한꺼번에 들어옴.
|
||||
{
|
||||
$fldcnt = count($_POST['it_id']);
|
||||
$arr_item = array();
|
||||
|
||||
// 재고등을 검사
|
||||
$error = "";
|
||||
for ($i=0; $i<$fldcnt; $i++)
|
||||
{
|
||||
if ($_POST['it_id'][$i] == "" || $_POST['ct_qty'][$i] <= 0) { continue; }
|
||||
|
||||
//옵션있는 상품은 건너뜀
|
||||
$arr_item[$i]['opt_skip'] = 0;
|
||||
$sql = " select count(*) as cnt from {$g4['shop_item_option_table']} where it_id = '{$_POST['it_id'][$i]}' and io_type = '0' ";
|
||||
$tmp = sql_fetch($sql);
|
||||
if($tmp['cnt']) {
|
||||
$arr_item[$i]['opt_skip'] = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
// 상품정보
|
||||
$sql = " select * from {$g4['shop_item_table']} where it_id = '{$_POST['it_id'][$i]}' ";
|
||||
$it = sql_fetch($sql);
|
||||
if(!$it['it_id'])
|
||||
continue;
|
||||
|
||||
$arr_item[$i]['id'] = $it['it_id'];
|
||||
$arr_item[$i]['name'] = $it['it_name'];
|
||||
$arr_item[$i]['price'] = get_price($it);
|
||||
$arr_item[$i]['point'] = $config['cf_use_point'] ? get_item_point($it) : 0;
|
||||
$arr_item[$i]['notax'] = $it['it_notax'];
|
||||
|
||||
// 이미 장바구니에 있는 같은 상품의 수량합계를 구한다.
|
||||
$sql = " select SUM(ct_qty) as cnt from {$g4['shop_cart_table']} where it_id = '{$_POST['it_id'][$i]}' and uq_id = '$tmp_uq_id' ";
|
||||
$row = sql_fetch($sql);
|
||||
$sum_qty = $row['cnt'];
|
||||
|
||||
// 재고 구함
|
||||
$it_stock_qty = get_it_stock_qty($_POST['it_id'][$i]);
|
||||
if ($_POST['ct_qty'][$i] + $sum_qty > $it_stock_qty) {
|
||||
$error .= "{$_POST['it_name'][$i]} 의 재고수량이 부족합니다. 현재 재고수량 : $it_stock_qty\\n\\n";
|
||||
}
|
||||
}
|
||||
|
||||
// 오류가 있다면 오류메세지 출력
|
||||
if ($error != "") { alert($error); }
|
||||
|
||||
$ct_count = 0;
|
||||
$comma = '';
|
||||
$sql = " INSERT INTO {$g4['shop_cart_table']}
|
||||
( uq_id, mb_id, it_id, it_name, ct_status, ct_price, ct_point, ct_point_use, ct_stock_use, ct_option, ct_qty, ct_num, ct_notax, io_id, io_type, io_price, ct_time, ct_ip, ct_send_cost, ct_direct, ct_select )
|
||||
VALUES ";
|
||||
$ct_select = 0;
|
||||
if($sw_direct)
|
||||
$ct_select = 1;
|
||||
|
||||
for ($i=0; $i<$fldcnt; $i++)
|
||||
{
|
||||
if ($_POST['it_id'][$i] == "" || $_POST['ct_qty'][$i] <= 0) continue;
|
||||
|
||||
// 옵션있는 상품이라면 건너뜀
|
||||
if($arr_item[$i]['opt_skip'])
|
||||
continue;
|
||||
|
||||
// 동일옵션의 상품이 있으면 수량 더함
|
||||
$sql2 = " select ct_id
|
||||
from {$g4['shop_cart_table']}
|
||||
where uq_id = '$tmp_uq_id'
|
||||
and it_id = '{$_POST['it_id'][$i]}'
|
||||
and ct_status = '쇼핑' ";
|
||||
$row2 = sql_fetch($sql2);
|
||||
if($row2['ct_id']) {
|
||||
$sql3 = " update {$g4['shop_cart_table']}
|
||||
set ct_qty = ct_qty + {$_POST['ct_qty'][$i]}
|
||||
where ct_id = '{$row2['ct_id']}' ";
|
||||
sql_query($sql3);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$sql .= $comma."( '$tmp_uq_id', '{$member['mb_id']}', '{$arr_item[$i]['id']}', '{$arr_item[$i]['name']}', '쇼핑', '{$arr_item[$i]['price']}', '{$arr_item[$i]['point']}', '0', '0', '{$arr_item[$i]['name']}', '{$_POST['ct_qty'][$i]}', '0', '{$arr_item[$i]['notax']}', '', '0', '0', '".G4_TIME_YMDHIS."', '$REMOTE_ADDR', '$ct_send_cost', '$sw_direct', '$ct_select' )";
|
||||
$comma = ' , ';
|
||||
$ct_count++;
|
||||
}
|
||||
|
||||
if($ct_count > 0)
|
||||
sql_query($sql);
|
||||
}
|
||||
else if ($act == "optionmod") // 장바구니에서 옵션변경
|
||||
{
|
||||
if (!$_POST['it_id'])
|
||||
alert('장바구니에 담을 상품을 선택하여 주십시오.');
|
||||
|
||||
$option_count = count($_POST['io_id']);
|
||||
|
||||
if($_POST['io_type'][0] != 0)
|
||||
alert('상품의 선택옵션을 선택해 주십시오.');
|
||||
|
||||
if($option_count) {
|
||||
for($i=0; $i<count($_POST['ct_qty']); $i++) {
|
||||
if ($_POST['ct_qty'][$i] < 1)
|
||||
alert('수량은 1 이상 입력해 주십시오.');
|
||||
}
|
||||
|
||||
// 상품정보
|
||||
$sql = " select * from {$g4['shop_item_table']} where it_id = '{$_POST['it_id']}' ";
|
||||
$it = sql_fetch($sql);
|
||||
if(!$it['it_id'])
|
||||
alert('상품정보가 존재하지 않습니다.');
|
||||
|
||||
// 옵션정보를 얻어서 배열에 저장
|
||||
$opt_list = array();
|
||||
$sql = " select * from {$g4['shop_item_option_table']} where it_id = '{$_POST['it_id']}' and io_use = '1' order by io_no asc ";
|
||||
$result = sql_query($sql);
|
||||
for($i=0; $row=sql_fetch_array($result); $i++) {
|
||||
$opt_list[$row['io_type']][$row['io_id']]['id'] = $row['io_id'];
|
||||
$opt_list[$row['io_type']][$row['io_id']]['price'] = $row['io_price'];
|
||||
$opt_list[$row['io_type']][$row['io_id']]['stock'] = $row['io_stock_qty'];
|
||||
}
|
||||
|
||||
// 포인트
|
||||
$point = 0;
|
||||
if($config['cf_use_point'])
|
||||
$point = get_item_point($it);
|
||||
|
||||
//--------------------------------------------------------
|
||||
// 재고 검사
|
||||
//--------------------------------------------------------
|
||||
// 이미 장바구니에 있는 같은 상품의 수량합계를 구한다.
|
||||
for($i=0; $i<$option_count; $i++) {
|
||||
$sql = " select SUM(ct_qty) as cnt from {$g4['shop_cart_table']}
|
||||
where it_id = '{$_POST['it_id']}'
|
||||
and uq_id = '$tmp_uq_id'
|
||||
and io_id = '{$_POST['io_id'][$i]}' ";
|
||||
$row = sql_fetch($sql);
|
||||
$sum_qty = $row['cnt'];
|
||||
|
||||
// 재고 구함
|
||||
$ct_qty = $_POST['ct_qty'][$i];
|
||||
if(!$_POST['io_id'][$i])
|
||||
$it_stock_qty = get_it_stock_qty($_POST['it_id']);
|
||||
else
|
||||
$it_stock_qty = get_option_stock_qty($_POST['it_id'], $_POST['io_id'][$i], $_POST['io_type'][$i]);
|
||||
|
||||
if ($ct_qty + $sum_qty > $it_stock_qty)
|
||||
{
|
||||
alert($_POST['io_value'][$i]." 의 재고수량이 부족합니다.\\n\\n현재 재고수량 : " . number_format($it_stock_qty) . " 개");
|
||||
}
|
||||
}
|
||||
//--------------------------------------------------------
|
||||
|
||||
// 기존 장바구니 자료를 먼저 삭제
|
||||
sql_query(" delete from {$g4['shop_cart_table']} where uq_id = '$tmp_uq_id' and it_id = '$it_id' ");
|
||||
|
||||
// 장바구니에 Insert
|
||||
$comma = '';
|
||||
$sql = " INSERT INTO {$g4['shop_cart_table']}
|
||||
( uq_id, mb_id, it_id, it_name, ct_status, ct_price, ct_point, ct_point_use, ct_stock_use, ct_option, ct_qty, ct_num, ct_notax, io_id, io_type, io_price, ct_time, ct_ip, ct_direct, ct_send_cost )
|
||||
VALUES ";
|
||||
|
||||
for($i=0; $i<$option_count; $i++) {
|
||||
$opt_id = $_POST['io_id'][$i];
|
||||
$opt_type = $_POST['io_type'][$i];
|
||||
|
||||
// 옵션테이블에 정보가 없으면 건너뜀
|
||||
if($opt_id && !$opt_list[$opt_type][$opt_id]['id'])
|
||||
continue;
|
||||
|
||||
$opt_price = $opt_list[$opt_type][$opt_id]['price'];
|
||||
$opt_qty = $_POST['ct_qty'][$i];
|
||||
|
||||
$sql .= $comma."( '$tmp_uq_id', '{$member['mb_id']}', '{$it['it_id']}', '{$it['it_name']}', '쇼핑', '{$it['it_price']}', '$point', '0', '0', '{$_POST['io_value'][$i]}', '$opt_qty', '$i', '{$it['it_notax']}', '$opt_id', '$opt_type', '$opt_price', '".G4_TIME_YMDHIS."', '$REMOTE_ADDR', '$sw_direct', '$ct_send_cost' )";
|
||||
$comma = ' , ';
|
||||
}
|
||||
|
||||
sql_query($sql);
|
||||
} else {
|
||||
// 기존 장바구니 자료 삭제
|
||||
sql_query(" delete from {$g4['shop_cart_table']} where uq_id = '$tmp_uq_id' and it_id = '$it_id' ");
|
||||
}
|
||||
}
|
||||
else // 장바구니에 담기
|
||||
{
|
||||
if (!$_POST['it_id'])
|
||||
$count = count($_POST['it_id']);
|
||||
if ($count < 1)
|
||||
alert('장바구니에 담을 상품을 선택하여 주십시오.');
|
||||
|
||||
$option_count = count($_POST['io_id']);
|
||||
if($option_count) {
|
||||
if($_POST['io_type'][0] != 0)
|
||||
for($i=0; $i<$count; $i++) {
|
||||
// 보관함의 상품을 담을 때 체크되지 않은 상품 건너뜀
|
||||
if($act == 'multi' && !$_POST['chk_it_id'][$i])
|
||||
continue;
|
||||
|
||||
$it_id = $_POST['it_id'][$i];
|
||||
$opt_count = count($_POST['io_id'][$it_id]);
|
||||
|
||||
if($opt_count && $_POST['io_type'][$it_id][0] != 0)
|
||||
alert('상품의 선택옵션을 선택해 주십시오.');
|
||||
|
||||
for($i=0; $i<count($_POST['ct_qty']); $i++) {
|
||||
if ($_POST['ct_qty'][$i] < 1)
|
||||
for($k=0; $k<$opt_count; $k++) {
|
||||
if ($_POST['ct_qty'][$it_id][$k] < 1)
|
||||
alert('수량은 1 이상 입력해 주십시오.');
|
||||
}
|
||||
|
||||
// 상품정보
|
||||
$total_price = 0;
|
||||
$sql = " select * from {$g4['shop_item_table']} where it_id = '{$_POST['it_id']}' ";
|
||||
$sql = " select * from {$g4['shop_item_table']} where it_id = '$it_id' ";
|
||||
$it = sql_fetch($sql);
|
||||
if(!$it['it_id'])
|
||||
alert('상품정보가 존재하지 않습니다.');
|
||||
|
||||
// 옵션정보를 얻어서 배열에 저장
|
||||
$opt_list = array();
|
||||
$sql = " select * from {$g4['shop_item_option_table']} where it_id = '{$_POST['it_id']}' and io_use = '1' order by io_no asc ";
|
||||
$sql = " select * from {$g4['shop_item_option_table']} where it_id = '$it_id' order by io_no asc ";
|
||||
$result = sql_query($sql);
|
||||
for($i=0; $row=sql_fetch_array($result); $i++) {
|
||||
$lst_count = 0;
|
||||
for($k=0; $row=sql_fetch_array($result); $k++) {
|
||||
$opt_list[$row['io_type']][$row['io_id']]['id'] = $row['io_id'];
|
||||
$opt_list[$row['io_type']][$row['io_id']]['use'] = $row['io_use'];
|
||||
$opt_list[$row['io_type']][$row['io_id']]['price'] = $row['io_price'];
|
||||
$opt_list[$row['io_type']][$row['io_id']]['stock'] = $row['io_stock_qty'];
|
||||
$lst_count++;
|
||||
}
|
||||
|
||||
// 포인트
|
||||
@ -296,35 +124,44 @@ else // 장바구니에 담기
|
||||
// 재고 검사
|
||||
//--------------------------------------------------------
|
||||
// 이미 장바구니에 있는 같은 상품의 수량합계를 구한다.
|
||||
for($i=0; $i<$option_count; $i++) {
|
||||
for($k=0; $k<$opt_count; $k++) {
|
||||
$io_id = $_POST['io_id'][$it_id][$k];
|
||||
$io_type = $_POST['io_type'][$it_id][$k];
|
||||
$io_value = $_POST['io_value'][$it_id][$k];
|
||||
|
||||
$sql = " select SUM(ct_qty) as cnt from {$g4['shop_cart_table']}
|
||||
where it_id = '{$_POST['it_id']}'
|
||||
where it_id = '$it_id'
|
||||
and uq_id = '$tmp_uq_id'
|
||||
and io_id = '{$_POST['io_id'][$i]}' ";
|
||||
and io_id = '$io_id' ";
|
||||
$row = sql_fetch($sql);
|
||||
$sum_qty = $row['cnt'];
|
||||
|
||||
// 재고 구함
|
||||
$ct_qty = $_POST['ct_qty'][$i];
|
||||
if(!$_POST['io_id'][$i])
|
||||
$it_stock_qty = get_it_stock_qty($_POST['it_id']);
|
||||
$ct_qty = $_POST['ct_qty'][$it_id][$k];
|
||||
if(!$io_id)
|
||||
$it_stock_qty = get_it_stock_qty($it_id);
|
||||
else
|
||||
$it_stock_qty = get_option_stock_qty($_POST['it_id'], $_POST['io_id'][$i], $_POST['io_type'][$i]);
|
||||
$it_stock_qty = get_option_stock_qty($it_id, $io_id, $io_type);
|
||||
|
||||
if ($ct_qty + $sum_qty > $it_stock_qty)
|
||||
{
|
||||
alert($_POST['io_value'][$i]." 의 재고수량이 부족합니다.\\n\\n현재 재고수량 : " . number_format($it_stock_qty) . " 개");
|
||||
alert($io_value." 의 재고수량이 부족합니다.\\n\\n현재 재고수량 : " . number_format($it_stock_qty) . " 개");
|
||||
}
|
||||
}
|
||||
//--------------------------------------------------------
|
||||
|
||||
// 바로구매에 있던 장바구니 자료를 지운다.
|
||||
sql_query(" delete from {$g4['shop_cart_table']} where uq_id = '$tmp_uq_id' and ct_direct = 1 ", false);
|
||||
if($i == 0)
|
||||
sql_query(" delete from {$g4['shop_cart_table']} where uq_id = '$tmp_uq_id' and ct_direct = 1 ", false);
|
||||
|
||||
// 옵션수정일 때 기존 장바구니 자료를 먼저 삭제
|
||||
if($act == 'optionmod')
|
||||
sql_query(" delete from {$g4['shop_cart_table']} where uq_id = '$tmp_uq_id' and it_id = '$it_id' ");
|
||||
|
||||
// 장바구니에 Insert
|
||||
$sql = " select ct_num
|
||||
from {$g4['shop_cart_table']}
|
||||
where it_id = '{$_POST['it_id']}'
|
||||
where it_id = '$it_id'
|
||||
and uq_id = '$tmp_uq_id'
|
||||
order by ct_num desc ";
|
||||
$row = sql_fetch($sql);
|
||||
@ -344,35 +181,39 @@ else // 장바구니에 담기
|
||||
( uq_id, mb_id, it_id, it_name, ct_status, ct_price, ct_point, ct_point_use, ct_stock_use, ct_option, ct_qty, ct_num, ct_notax, io_id, io_type, io_price, ct_time, ct_ip, ct_send_cost, ct_direct, ct_select )
|
||||
VALUES ";
|
||||
|
||||
for($i=0; $i<$option_count; $i++) {
|
||||
$opt_id = $_POST['io_id'][$i];
|
||||
$opt_type = $_POST['io_type'][$i];
|
||||
for($k=0; $k<$opt_count; $k++) {
|
||||
$io_id = $_POST['io_id'][$it_id][$k];
|
||||
$io_type = $_POST['io_type'][$it_id][$k];
|
||||
$io_value = $_POST['io_value'][$it_id][$k];
|
||||
|
||||
// 옵션테이블에 정보가 없으면 건너뜀
|
||||
if($opt_id && !$opt_list[$opt_type][$opt_id]['id'])
|
||||
// 옵션정보가 존재하는데 선택된 옵션이 없으면 건너뜀
|
||||
if($lst_count && $io_id == '')
|
||||
continue;
|
||||
|
||||
$opt_price = $opt_list[$opt_type][$opt_id]['price'];
|
||||
$opt_qty = $_POST['ct_qty'][$i];
|
||||
// 구매할 수 없는 옵션은 건너뜀
|
||||
if($io_id && !$opt_list[$io_type][$io_id]['use'])
|
||||
continue;
|
||||
|
||||
$io_price = $opt_list[$io_type][$io_id]['price'];
|
||||
$ct_qty = $_POST['ct_qty'][$it_id][$k];
|
||||
|
||||
// 동일옵션의 상품이 있으면 수량 더함
|
||||
$sql2 = " select ct_id
|
||||
from {$g4['shop_cart_table']}
|
||||
where uq_id = '$tmp_uq_id'
|
||||
and it_id = '{$_POST['it_id']}'
|
||||
and io_id = '{$_POST['io_id'][$i]}'
|
||||
and it_id = '$it_id'
|
||||
and io_id = '$io_id'
|
||||
and ct_status = '쇼핑' ";
|
||||
$row2 = sql_fetch($sql2);
|
||||
if($row2['ct_id']) {
|
||||
$sql3 = " update {$g4['shop_cart_table']}
|
||||
set ct_qty = ct_qty + {$_POST['ct_qty'][$i]}
|
||||
set ct_qty = ct_qty + '$ct_qty'
|
||||
where ct_id = '{$row2['ct_id']}' ";
|
||||
sql_query($sql3);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$sql .= $comma."( '$tmp_uq_id', '{$member['mb_id']}', '{$it['it_id']}', '{$it['it_name']}', '쇼핑', '{$it['it_price']}', '$point', '0', '0', '{$_POST['io_value'][$i]}', '$opt_qty', '$ct_num', '{$it['it_notax']}', '$opt_id', '$opt_type', '$opt_price', '".G4_TIME_YMDHIS."', '$REMOTE_ADDR', '$ct_send_cost', '$sw_direct', '$ct_select' )";
|
||||
$sql .= $comma."( '$tmp_uq_id', '{$member['mb_id']}', '{$it['it_id']}', '{$it['it_name']}', '쇼핑', '{$it['it_price']}', '$point', '0', '0', '$io_value', '$ct_qty', '$ct_num', '{$it['it_notax']}', '$io_id', '$io_type', '$io_price', '".G4_TIME_YMDHIS."', '$REMOTE_ADDR', '$ct_send_cost', '$sw_direct', '$ct_select' )";
|
||||
$comma = ' , ';
|
||||
$ct_num++;
|
||||
$ct_count++;
|
||||
|
||||
@ -162,7 +162,7 @@ else
|
||||
<div id="sit">
|
||||
|
||||
<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_id[]" value="<?php echo $it['it_id']; ?>">
|
||||
<input type="hidden" name="sw_direct">
|
||||
<input type="hidden" name="url">
|
||||
|
||||
@ -400,15 +400,15 @@ else
|
||||
<?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_type[<?php echo $it_id; ?>][]" value="0">
|
||||
<input type="hidden" name="io_id[<?php echo $it_id; ?>][]" value="">
|
||||
<input type="hidden" name="io_value[<?php echo $it_id; ?>][]" 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">
|
||||
<input type="text" name="ct_qty[<?php echo $it_id; ?>][]" 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>
|
||||
|
||||
@ -61,11 +61,14 @@ include_once('./_head.php');
|
||||
{
|
||||
?>
|
||||
품절
|
||||
<input type="hidden" name="it_id[<?php echo $i; ?>]" >
|
||||
<?php } else { //품절이 아니면 체크할수 있도록한다 ?>
|
||||
<input type="checkbox" name="it_id[<?php echo $i; ?>]" value="<?php echo $row['it_id']; ?>" onclick="out_cd_check(this, '<?php echo $out_cd; ?>');">
|
||||
<input type="checkbox" name="chk_it_id[<?php echo $i; ?>]" value="1" onclick="out_cd_check(this, '<?php echo $out_cd; ?>');">
|
||||
<?php } ?>
|
||||
<input type="hidden" name="ct_qty[<?php echo $i; ?>]" value="1">
|
||||
<input type="hidden" name="it_id[<?php echo $i; ?>]" value="<?php echo $row['it_id']; ?>">
|
||||
<input type="hidden" name="io_type[<?php echo $row['it_id']; ?>][0]" value="0">
|
||||
<input type="hidden" name="io_id[<?php echo $row['it_id']; ?>][0]" value="">
|
||||
<input type="hidden" name="io_value[<?php echo $row['it_id']; ?>][0]" value="<?php echo $row['it_name']; ?>">
|
||||
<input type="hidden" name="ct_qty[<?php echo $row['it_id']; ?>][0]" value="1">
|
||||
</td>
|
||||
<td class="sod_ws_img"><?php echo $image; ?></td>
|
||||
<td><a href="./item.php?it_id=<?php echo $row['it_id']; ?>"><?php echo stripslashes($row['it_name']); ?></a></td>
|
||||
|
||||
Reference in New Issue
Block a user