diff --git a/js/shop.js b/js/shop.js index edfef0d60..2f94012f2 100644 --- a/js/shop.js +++ b/js/shop.js @@ -405,6 +405,10 @@ function same_option_check(val) function price_calculate() { var it_price = parseInt($("input#it_price").val()); + + if(isNaN(it_price)) + return; + var $el_prc = $("input.io_price"); var $el_qty = $("input[name^=ct_qty]"); var $el_type = $("input[name^=io_type]"); diff --git a/lib/shop.lib.php b/lib/shop.lib.php index 42e622a9a..223624d82 100644 --- a/lib/shop.lib.php +++ b/lib/shop.lib.php @@ -1389,8 +1389,7 @@ function item_icon($it) { $icon = ''; // 품절 - $stock = get_it_stock_qty($it['it_id']); - if ($stock <= 0) + if (is_soldout($it['it_id'])) $icon .= '품절 '; if ($it['it_type1']) @@ -1768,6 +1767,73 @@ function is_used_coupon($mb_id, $cp_id) return $used; } +// 품절상품인지 체크 +function is_soldout($it_id) +{ + global $g5; + + // 상품정보 + $sql = " select it_stock_qty from {$g5['g5_shop_item_table']} where it_id = '$it_id' "; + $it = sql_fetch($sql); + + if($it['it_stock_qty'] <= 0) + return true; + + $count = 0; + $soldout = false; + + // 상품에 선택옵션 있으면.. + $sql = " select count(*) as cnt from {$g5['g5_shop_item_option_table']} where it_id = '$it_id' and io_type = '0' "; + $row = sql_fetch($sql); + + if($row['cnt']) { + $sql = " select io_id, io_type, io_stock_qty + from {$g5['g5_shop_item_option_table']} + where it_id = '$it_id' + and io_type = '0' + and io_use = '1' "; + $result = sql_query($sql); + + for($i=0; $row=sql_fetch_array($result); $i++) { + // 주문대기수량 + $sql = " select SUM(ct_qty) as qty from {$g5['g5_shop_cart_table']} + where it_id = '$it_id' + and io_id = '{$row['io_id']}' + and io_type = '{$row['io_type']}' + and ct_stock_use = 0 + and ct_status in ('주문', '입금', '준비') "; + $sum = sql_fetch($sql); + + // 옵션 재고수량 + $stock_qty = get_option_stock_qty($it_id, $row['io_id'], $row['io_type']); + + if($stock_qty - $sum['qty'] <= 0) + $count++; + } + + // 모든 선택옵션 품절이면 상품 품절 + if($i == $count) + $soldout = true; + } else { + // 주문대기수량 + $sql = " select SUM(ct_qty) as qty from {$g5['g5_shop_cart_table']} + where it_id = '$it_id' + and io_id = '' + and io_type = '0' + and ct_stock_use = 0 + and ct_status in ('주문', '입금', '준비') "; + $sum = sql_fetch($sql); + + // 상품 재고수량 + $stock_qty = get_it_stock_qty($it_id); + + if($stock_qty - $sum['qty'] <= 0) + $soldout = true; + } + + return $soldout; +} + // 상품후기 작성가능한지 체크 function check_itemuse_write($close=true) { diff --git a/mobile/shop/item.php b/mobile/shop/item.php index c9397f599..b869db922 100644 --- a/mobile/shop/item.php +++ b/mobile/shop/item.php @@ -106,12 +106,6 @@ if ($row['it_id']) { $next_href2 = ''; } -// 선택 옵션 -$option_1 = get_item_options($it['it_id'], $it['it_option_subject']); - -// 추가 옵션 -$option_2 = get_item_supply($it['it_id'], $it['it_supply_subject']); - // 관리자가 확인한 사용후기의 개수를 얻음 $sql = " select count(*) as cnt from `{$g5['g5_shop_item_use_table']}` where it_id = '{$it_id}' and is_confirm = '1' "; $row = sql_fetch($sql); @@ -130,6 +124,32 @@ $sql = " select count(*) as cnt $row = sql_fetch($sql); $item_relation_count = $row['cnt']; +// 상품품절체크 +$is_soldout = is_soldout($it['it_id']); + +// 주문가능체크 +$is_orderable = true; +if(!$it['it_use'] || $it['it_tel_inq'] || $is_soldout) + $is_orderable = false; + +if($is_orderable) { + // 선택 옵션 + $option_1 = get_item_options($it['it_id'], $it['it_option_subject']); + + // 추가 옵션 + $option_2 = get_item_supply($it['it_id'], $it['it_supply_subject']); + + // 상품 선택옵션 수 + $sql = " select count(*) as cnt from {$g5['g5_shop_item_option_table']} where it_id = '{$it['it_id']}' and io_type = '0' and io_use = '1' "; + $row = sql_fetch($sql); + $opt_count = $row['cnt']; + + // 상품 추가옵션 수 + $sql = " select count(*) as cnt from {$g5['g5_shop_item_option_table']} where it_id = '{$it['it_id']}' and io_type = '1' and io_use = '1' "; + $row = sql_fetch($sql); + $spl_count = $row['cnt']; +} + $g5['title'] = $it['it_name'].' > '.$it['ca_name']; include_once(G5_MSHOP_PATH.'/_head.php'); @@ -143,7 +163,9 @@ include G5_MSHOP_SKIN_PATH.'/navigation.skin.php'; echo '
'.stripslashes($it['it_mobile_head_html']).'
'; ?> + + - 모델 - - - + + + 판매가격 + 판매중지 + + 판매가격 전화문의 - - - @@ -117,6 +116,7 @@ if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가 + - - - +
+ +

상품의 재고가 부족하여 구매할 수 없습니다.

+ +