#304 상품구입 최소 최대 수량 기능 추가

This commit is contained in:
chicpro
2013-10-07 14:46:16 +09:00
parent 43c9fa8f2a
commit 3a2ccbcc0a
7 changed files with 192 additions and 32 deletions

View File

@ -494,6 +494,32 @@ $(function(){
<label for="chk_all_it_stock_qty">전체적용</label>
</td>
</tr>
<tr>
<th scope="row"><label for="it_buy_min_qty">최소구매수량</label></th>
<td>
<?php echo help("상품 구매시 최소 구매 수량을 설정합니다."); ?>
<input type="text" name="it_buy_min_qty" value="<?php echo $it['it_buy_min_qty']; ?>" id="it_buy_min_qty" class="frm_input" size="8"> 개
</td>
<td class="group_setting">
<input type="checkbox" name="chk_ca_it_buy_min_qty" value="1" id="chk_ca_it_buy_min_qty">
<label for="chk_ca_it_buy_min_qty">분류적용</label>
<input type="checkbox" name="chk_all_it_buy_min_qty" value="1" id="chk_all_it_buy_min_qty">
<label for="chk_all_it_buy_min_qty">전체적용</label>
</td>
</tr>
<tr>
<th scope="row"><label for="it_buy_max_qty">최대구매수량</label></th>
<td>
<?php echo help("상품 구매시 최대 구매 수량을 설정합니다."); ?>
<input type="text" name="it_buy_max_qty" value="<?php echo $it['it_buy_max_qty']; ?>" id="it_buy_max_qty" class="frm_input" size="8"> 개
</td>
<td class="group_setting">
<input type="checkbox" name="chk_ca_it_buy_max_qty" value="1" id="chk_ca_it_buy_max_qty">
<label for="chk_ca_it_buy_max_qty">분류적용</label>
<input type="checkbox" name="chk_all_it_buy_max_qty" value="1" id="chk_all_it_buy_max_qty">
<label for="chk_all_it_buy_max_qty">전체적용</label>
</td>
</tr>
<tr>
<th scope="row"><label for="it_notax">상품과세 유형</label></th>
<td>

View File

@ -289,6 +289,8 @@ $sql_common = " ca_id = '$ca_id',
it_sc_price = '$it_sc_price',
it_sc_minimum = '$it_sc_minimum',
it_sc_qty = '$it_sc_qty',
it_buy_min_qty = '$it_buy_min_qty',
it_buy_max_qty = '$it_buy_max_qty',
it_head_html = '$it_head_html',
it_tail_html = '$it_tail_html',
it_mobile_head_html = '$it_mobile_head_html',
@ -437,6 +439,8 @@ if(is_checked('chk_ca_it_point')) $ca_fields .= " , it_point = '$i
if(is_checked('chk_ca_it_point_type')) $ca_fields .= " , it_point_type = '$it_point_type' ";
if(is_checked('chk_ca_it_stock_qty')) $ca_fields .= " , it_stock_qty = '$it_stock_qty' ";
if(is_checked('chk_ca_it_sendcost')) $ca_fields .= " , it_sc_type = '$it_sc_type', it_sc_method = '$it_sc_method', it_sc_price = '$it_sc_price', it_sc_minimum = '$it_sc_minimum', it_sc_qty = '$it_sc_qty' ";
if(is_checked('chk_ca_it_buy_min_qty')) $ca_fields .= " , it_buy_min_qty = '$it_buy_min_qty' ";
if(is_checked('chk_ca_it_buy_max_qty')) $ca_fields .= " , it_buy_max_qty = '$it_buy_max_qty' ";
if(is_checked('chk_ca_it_head_html')) $ca_fields .= " , it_head_html = '$it_head_html' ";
if(is_checked('chk_ca_it_tail_html')) $ca_fields .= " , it_tail_html = '$it_tail_html' ";
if(is_checked('chk_ca_it_mobile_head_html')) $ca_fields .= " , it_mobile_head_html = '$it_mobile_head_html' ";
@ -469,6 +473,8 @@ if(is_checked('chk_all_it_point')) $all_fields .= " , it_point = '
if(is_checked('chk_all_it_point_type')) $all_fields .= " , it_point_type = '$it_point_type' ";
if(is_checked('chk_all_it_stock_qty')) $all_fields .= " , it_stock_qty = '$it_stock_qty' ";
if(is_checked('chk_all_it_sendcost')) $all_fields .= " , it_sc_type = '$it_sc_type', it_sc_method = '$it_sc_method', it_sc_price = '$it_sc_price', it_sc_minimum = '$it_sc_minimum', it_sc_qty = '$it_sc_qty' ";
if(is_checked('chk_all_it_buy_min_qty')) $all_fields .= " , it_buy_min_qty = '$it_buy_min_qty' ";
if(is_checked('chk_all_it_buy_max_qty')) $all_fields .= " , it_buy_max_qty = '$it_buy_max_qty' ";
if(is_checked('chk_all_it_head_html')) $all_fields .= " , it_head_html = '$it_head_html' ";
if(is_checked('chk_all_it_tail_html')) $all_fields .= " , it_tail_html = '$it_tail_html' ";
if(is_checked('chk_all_it_mobile_head_html')) $all_fields .= " , it_mobile_head_html = '$it_mobile_head_html' ";

View File

@ -553,4 +553,11 @@ if(!sql_query(" select ca_cert_use from {$g5['g5_shop_category_table']} limit 1
ADD `ca_cert_use` tinyint(4) NOT NULL DEFAULT '0' AFTER `ca_mb_id`,
ADD `ca_adult_use` tinyint(4) NOT NULL DEFAULT '0' AFTER `ca_cert_use` ", true);
}
// 최소 최대구매수량 필드추가
if(!sql_query(" select it_buy_min_qty from {$g5['g5_shop_item_table']} limit 1 ", false)) {
sql_query(" ALTER TABLE `{$g5['g5_shop_item_table']}`
ADD `it_buy_min_qty` int(11) NOT NULL DEFAULT '0' AFTER `it_sc_qty`,
ADD `it_buy_max_qty` int(11) NOT NULL DEFAULT '0' AFTER `it_buy_min_qty` ", true);
}
?>

View File

@ -211,23 +211,46 @@ if ($row['it_id']) {
</td>
</tr>
<?php } ?>
<?php if($default['de_send_cost_case'] == '개별' && $it['it_sc_type'] != 0) { ?>
<tr>
<th><label for="ct_send_cost">배송비결제</label></th>
<td>
<?php
if($it['it_sc_method'] == 2) {
?>
<select name="ct_send_cost" id="ct_send_cost">
<option value="0">주문시 결제</option>
<option value="1">수령후 지불</option>
</select>
<?php
<?php
$ct_send_cost_label = '배송비결제';
if($default['de_send_cost_case'] == '무료')
$sc_method = '무료배송';
else
$sc_method = '주문시 결제';
if($it['it_sc_type'] == 1)
$sc_method = '무료배송';
else if($it['it_sc_type'] > 1) {
if($it['it_sc_method'] == 1)
$sc_method = '수령후 지불';
else if($it['it_sc_method'] == 2) {
$ct_send_cost_label = '<label for="ct_send_cost">배송비결제</label>';
$sc_method = '<select name="ct_send_cost" id="ct_send_cost">
<option value="0">주문시 결제</option>
<option value="1">수령후 지불</option>
</select>';
}
?>
</td>
</tr>
<?php } ?>
else
$sc_method = '주문시 결제';
}
?>
<tr>
<th><?php echo $ct_send_cost_label; ?></th>
<td><?php echo $sc_method; ?></td>
</tr>
<?php if($it['it_buy_min_qty']) { ?>
<tr>
<th>최소구매수량</th>
<td><?php echo number_format($it['it_buy_min_qty']); ?> 개<td>
</tr>
<?php } ?>
<?php if($it['it_buy_max_qty']) { ?>
<tr>
<th>최대구매수량</th>
<td><?php echo number_format($it['it_buy_max_qty']); ?> 개<td>
</tr>
<?php } ?>
</tbody>
</table>
@ -278,7 +301,11 @@ if ($row['it_id']) {
<?php } // 전화문의가 아닐 경우 끝?>
<div id="sit_sel_option">
<?php if(!$option_1 && !$option_2) { ?>
<?php
if(!$option_1 && !$option_2) {
if(!$it['it_buy_min_qty'])
$it['it_buy_min_qty'] = 1;
?>
<ul id="sit_opt_added">
<li class="sit_opt_list">
<input type="hidden" name="io_type[<?php echo $it_id; ?>][]" value="0">
@ -289,7 +316,7 @@ if ($row['it_id']) {
<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[<?php echo $it_id; ?>][]" value="1" class="frm_input" size="5">
<input type="text" name="ct_qty[<?php echo $it_id; ?>][]" value="<?php echo $it['it_buy_min_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>
</div>
@ -429,8 +456,13 @@ function fitem_submit(f)
return false;
}
var val, result = true;
$("input[name^=ct_qty]").each(function() {
var val, io_type, result = true;
var sum_qty = 0;
var min_qty = parseInt(<?php echo $it['it_buy_min_qty']; ?>);
var max_qty = parseInt(<?php echo $it['it_buy_max_qty']; ?>);
var $el_type = $("input[name^=io_type]");
$("input[name^=ct_qty]").each(function(index) {
val = $(this).val();
if(val.length < 1) {
@ -450,12 +482,26 @@ function fitem_submit(f)
result = false;
return false;
}
io_type = $el_type.eq(index).val();
if(io_type == "0")
sum_qty += parseInt(val);
});
if(!result) {
return false;
}
if(min_qty > 0 && sum_qty < min_qty) {
alert("선택옵션 개수 총합 "+number_format(String(min_qty))+"개 이상 주문해 주십시오.");
return false;
}
if(max_qty > 0 && sum_qty > max_qty) {
alert("선택옵션 개수 총합 "+number_format(String(max_qty))+"개 이하로 주문해 주십시오.");
return false;
}
return true;
}
</script>

View File

@ -3,7 +3,7 @@ include_once('./_common.php');
$it_id = $_POST['it_id'];
$sql = " select it_id, it_option_subject, it_supply_subject, it_price, it_point, it_point_type from {$g5['g5_shop_item_table']} where it_id = '$it_id' and it_use = '1' ";
$sql = " select * from {$g5['g5_shop_item_table']} where it_id = '$it_id' and it_use = '1' ";
$it = sql_fetch($sql);
$it_point = get_item_point($it);
@ -123,8 +123,13 @@ if($option_2) {
<script>
function formcheck(f)
{
var val, result = true;
$("li input[name^=ct_qty]").each(function() {
var val, io_type, result = true;
var sum_qty = 0;
var min_qty = parseInt(<?php echo $it['it_buy_min_qty']; ?>);
var max_qty = parseInt(<?php echo $it['it_buy_max_qty']; ?>);
var $el_type = $("input[name^=io_type]");
$("input[name^=ct_qty]").each(function(index) {
val = $(this).val();
if(val.length < 1) {
@ -144,12 +149,27 @@ function formcheck(f)
result = false;
return false;
}
io_type = $el_type.eq(index).val();
if(io_type == "0")
sum_qty += parseInt(val);
});
if(!result)
if(!result) {
return false;
}
f.submit();
if(min_qty > 0 && sum_qty < min_qty) {
alert("선택옵션 개수 총합 "+number_format(String(min_qty))+"개 이상 주문해 주십시오.");
return false;
}
if(max_qty > 0 && sum_qty > max_qty) {
alert("선택옵션 개수 총합 "+number_format(String(max_qty))+"개 이하로 주문해 주십시오.");
return false;
}
return true;
}
</script>
<!-- } 장바구니 옵션 끝 -->

View File

@ -96,6 +96,21 @@ else // 장바구니에 담기
if(!$it['it_id'])
alert('상품정보가 존재하지 않습니다.');
// 최소, 최대 수량 체크
if($it['it_buy_min_qty'] || $it['it_buy_max_qty']) {
$sum_qty = 0;
for($k=0; $k<$opt_count; $k++) {
if($_POST['io_type'][$it_id][$k] == 0)
$sum_qty += $_POST['ct_qty'][$it_id][$k];
}
if($it['it_buy_min_qty'] > 0 && $sum_qty < $it['it_buy_min_qty'])
alert($it['it_name'].'의 선택옵션 개수 총합 '.number_format($it['it_buy_min_qty']).'개 이상 주문해 주십시오.');
if($it['it_buy_max_qty'] > 0 && $sum_qty > $it['it_buy_max_qty'])
alert($it['it_name'].'의 선택옵션 개수 총합 '.number_format($it['it_buy_max_qty']).'개 이하로 주문해 주십시오.');
}
// 옵션정보를 얻어서 배열에 저장
$opt_list = array();
$sql = " select * from {$g5['g5_shop_item_option_table']} where it_id = '$it_id' order by io_no asc ";
@ -125,8 +140,10 @@ else // 장바구니에 담기
$sql = " select SUM(ct_qty) as cnt from {$g5['g5_shop_cart_table']}
where it_id = '$it_id'
and od_id = '$tmp_cart_id'
and io_id = '$io_id' ";
and io_id = '$io_id'
and io_type = '$io_type'
and ct_stock_use = 0
and ct_status in ('주문', '준비') ";
$row = sql_fetch($sql);
$sum_qty = $row['cnt'];

View File

@ -210,6 +210,8 @@ $sns_share_links .= get_sns_share_link('googleplus', $sns_url, $sns_title, G5_SH
</tr>
<?php } ?>
<?php
$ct_send_cost_label = '배송비결제';
if($default['de_send_cost_case'] == '무료')
$sc_method = '무료배송';
else
@ -221,6 +223,7 @@ $sns_share_links .= get_sns_share_link('googleplus', $sns_url, $sns_title, G5_SH
if($it['it_sc_method'] == 1)
$sc_method = '수령후 지불';
else if($it['it_sc_method'] == 2) {
$ct_send_cost_label = '<label for="ct_send_cost">배송비결제</label>';
$sc_method = '<select name="ct_send_cost" id="ct_send_cost">
<option value="0">주문시 결제</option>
<option value="1">수령후 지불</option>
@ -231,9 +234,21 @@ $sns_share_links .= get_sns_share_link('googleplus', $sns_url, $sns_title, G5_SH
}
?>
<tr>
<th><label for="ct_send_cost">배송비결제</label></th>
<th><?php echo $ct_send_cost_label; ?></th>
<td><?php echo $sc_method; ?></td>
</tr>
<?php if($it['it_buy_min_qty']) { ?>
<tr>
<th>최소구매수량</th>
<td><?php echo number_format($it['it_buy_min_qty']); ?> 개<td>
</tr>
<?php } ?>
<?php if($it['it_buy_max_qty']) { ?>
<tr>
<th>최대구매수량</th>
<td><?php echo number_format($it['it_buy_max_qty']); ?> 개<td>
</tr>
<?php } ?>
</tbody>
</table>
@ -288,7 +303,11 @@ $sns_share_links .= get_sns_share_link('googleplus', $sns_url, $sns_title, G5_SH
<!-- 선택된 옵션 시작 { -->
<section id="sit_sel_option">
<h3>선택된 옵션</h3>
<?php if(!$option_1 && !$option_2) { ?>
<?php
if(!$option_1 && !$option_2) {
if(!$it['it_buy_min_qty'])
$it['it_buy_min_qty'] = 1;
?>
<ul id="sit_opt_added">
<li class="sit_opt_list">
<input type="hidden" name="io_type[<?php echo $it_id; ?>][]" value="0">
@ -299,7 +318,7 @@ $sns_share_links .= get_sns_share_link('googleplus', $sns_url, $sns_title, G5_SH
<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[<?php echo $it_id; ?>][]" value="1" class="frm_input" size="5">
<input type="text" name="ct_qty[<?php echo $it_id; ?>][]" value="<?php echo $it['it_buy_min_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>
</div>
@ -419,8 +438,13 @@ function fitem_submit(f)
return false;
}
var val, result = true;
$("input[name^=ct_qty]").each(function() {
var val, io_type, result = true;
var sum_qty = 0;
var min_qty = parseInt(<?php echo $it['it_buy_min_qty']; ?>);
var max_qty = parseInt(<?php echo $it['it_buy_max_qty']; ?>);
var $el_type = $("input[name^=io_type]");
$("input[name^=ct_qty]").each(function(index) {
val = $(this).val();
if(val.length < 1) {
@ -440,12 +464,26 @@ function fitem_submit(f)
result = false;
return false;
}
io_type = $el_type.eq(index).val();
if(io_type == "0")
sum_qty += parseInt(val);
});
if(!result) {
return false;
}
if(min_qty > 0 && sum_qty < min_qty) {
alert("선택옵션 개수 총합 "+number_format(String(min_qty))+"개 이상 주문해 주십시오.");
return false;
}
if(max_qty > 0 && sum_qty > max_qty) {
alert("선택옵션 개수 총합 "+number_format(String(max_qty))+"개 이하로 주문해 주십시오.");
return false;
}
return true;
}
</script>