영카트5 추가옵션부분을 체크박스형태로 변경할려고합니다. 어떻게해야되나요?
본문
영카트5 추가옵션부분을 체크박스로 할려고하는데요 어떻게 해야되나요?
팁에 있는 내용으로 했더니 적용이 안되서요!
/lib/shop.lib.php
// 상품 추가옵션
function get_item_supply($it_id, $subject)
{
global $g5;
if(!$it_id || !$subject)
return '';
$sql = " select * from {$g5['g5_shop_item_option_table']} where io_type = '1' and it_id = '$it_id' and io_use = '1' order by io_no asc ";
$result = sql_query($sql);
if(!sql_num_rows($result))
return '';
$str = '';
$subj = explode(',', $subject);
$subj_count = count($subj);
$options = array();
// 옵션항목 배열에 저장
for($i=0; $row=sql_fetch_array($result); $i++) {
$opt_id = explode(chr(30), $row['io_id']);
if($opt_id[0] && !array_key_exists($opt_id[0], $options))
$options[$opt_id[0]] = array();
if(strlen($opt_id[1])) {
if($row['io_price'] >= 0)
$price = ' + '.number_format($row['io_price']).'원';
else
$price = ' '.number_format($row['io_price']).'원';
$io_stock_qty = get_option_stock_qty($it_id, $row['io_id'], $row['io_type']);
if($io_stock_qty < 1)
$soldout = ' [품절]';
else
$soldout = '';
$options[$opt_id[0]][] = '<option value="'.$opt_id[1].','.$row['io_price'].','.$io_stock_qty.'">'.$opt_id[1].$price.$soldout.'</option>';
}
}
// 옵션항목 만들기
for($i=0; $i<$subj_count; $i++) {
$opt = $options[$subj[$i]];
$opt_count = count($opt);
if($opt_count) {
$seq = $i + 1;
$str .= '<tr>'.PHP_EOL;
$str .= '<th><label for="it_supply_'.$seq.'">'.$subj[$i].'</label></th>'.PHP_EOL;
$select = '<select id="it_supply_'.$seq.'" class="it_supply">'.PHP_EOL;
$select .= '<option value="">선택</option>'.PHP_EOL;
for($k=0; $k<$opt_count; $k++) {
$opt_val = $opt[$k];
if($opt_val) {
$select .= $opt_val.PHP_EOL;
}
}
$select .= '</select>'.PHP_EOL;
$str .= '<td class="td_sit_sel">'.$select.'</td>'.PHP_EOL;
$str .= '</tr>'.PHP_EOL;
}
}
return $str;
}
function print_item_options($it_id, $cart_id)
{
global $g5;
$sql = " select ct_option, ct_qty, io_price
from {$g5['g5_shop_cart_table']} where it_id = '$it_id' and od_id = '$cart_id' order by io_type asc, ct_id asc ";
$result = sql_query($sql);
$str = '';
for($i=0; $row=sql_fetch_array($result); $i++) {
if($i == 0)
$str .= '<ul>'.PHP_EOL;
$price_plus = '';
if($row['io_price'] >= 0)
$price_plus = '+';
$str .= '<li>'.get_text($row['ct_option']).' '.$row['ct_qty'].'개 ('.$price_plus.display_price($row['io_price']).')</li>'.PHP_EOL;
}
if($i > 0)
$str .= '</ul>';
return $str;
}
이부분도 수정을 했는데 적용이 안되서요
/js/shop.js
// 추가옵션
/* 가상커서 ctrl keyup 이베트 대응 */
/*
$(document).on("keyup", "select.it_supply", function(e) {
var $el = $(this);
var code = e.keyCode;
var val = $(this).val();
supply_add = false;
if(code == 17) {
if(val == "")
return;
sel_supply_process($el, true);
}
});
*/
/* 키보드 접근 후 옵션 선택 Enter keydown 이벤트 대응 */
$(document).on("keydown", "select.it_supply", function(e) {
var $el = $(this);
var code = e.keyCode;
var val = $(this).val();
supply_add = false;
if(code == 13) {
if(val == "")
return;
sel_supply_process($el, true);
}
});
if(isAndroid) {
$(document).on("touchend", "select.it_supply", function() {
supply_add = true;
});
} else {
$(document).on("mouseup", "select.it_supply", function() {
supply_add = true;
});
}
$(document).on("change", "select.it_supply", function() {
var $el = $(this);
var val = $(this).val();
if(val == "")
return;
if(supply_add)
sel_supply_process($el, true);
});
// 수량변경 및 삭제
$(document).on("click", "#sit_sel_option li button", 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 stock = parseInt($(this).closest("li").find("input.io_stock").val());
switch(mode) {
case "+":
this_qty = parseInt($el_qty.val().replace(/[^0-9]/, "")) + 1;
if(this_qty > stock) {
alert("재고수량 보다 많은 수량을 구매할 수 없습니다.");
this_qty = stock;
}
if(this_qty > max_qty) {
this_qty = max_qty;
alert("최대 구매수량은 "+number_format(String(max_qty))+" 입니다.");
}
$el_qty.val(this_qty);
price_calculate();
break;
case "-":
this_qty = parseInt($el_qty.val().replace(/[^0-9]/, "")) - 1;
if(this_qty < min_qty) {
this_qty = min_qty;
alert("최소 구매수량은 "+number_format(String(min_qty))+" 입니다.");
}
$el_qty.val(this_qty);
price_calculate();
break;
case "삭제":
if(confirm("선택하신 옵션항목을 삭제하시겠습니까?")) {
var $el = $(this).closest("li");
var del_exec = true;
if($("#sit_sel_option .sit_spl_list").size() > 0) {
// 선택옵션이 하나이상인지
if($el.hasClass("sit_opt_list")) {
if($(".sit_opt_list").size() <= 1)
del_exec = false;
}
}
if(del_exec) {
$el.closest("li").remove();
price_calculate();
} else {
alert("선택옵션은 하나이상이어야 합니다.");
return false;
}
}
break;
default:
alert("올바른 방법으로 이용해 주십시오.");
break;
}
});
답변을 작성하시기 전에 로그인 해주세요.