From 7608b5d3b3131a216748a1226c3de9a83c624848 Mon Sep 17 00:00:00 2001 From: chicpro Date: Fri, 24 May 2013 13:46:14 +0900 Subject: [PATCH] =?UTF-8?q?=EC=98=B5=EC=85=98=20=EB=AA=A8=EB=91=90=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20=ED=9B=84=20=EB=8B=A4=EC=8B=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shop/item.php | 106 ++++++++++++++++++++++++++------------------------ 1 file changed, 56 insertions(+), 50 deletions(-) diff --git a/shop/item.php b/shop/item.php index 45b585542..8fb18c8c8 100644 --- a/shop/item.php +++ b/shop/item.php @@ -437,8 +437,58 @@ else var price = info[1]; var stock = info[2]; - add_sel_option(1, id, option, price, stock); + if(!same_option_check(option)) + add_sel_option(1, id, option, price, stock); }); + + // 수량변경 및 삭제 + $("#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 stock = parseInt($(this).closest("li").find("input[name='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("선택하신 옵션항목을 삭제하시겠습니까?")) { + $(this).closest("li").remove(); + price_calculate(); + } + break; + + default: + alert("올바른 방법으로 이용해 주십시오."); + break; + } + }); + + // 수량직접입력 }); // 선택된 옵션 출력 @@ -473,59 +523,15 @@ else $("#sit_sel_option").html(""); $("#sit_sel_option > ul").html(opt); } else{ - $("#sit_sel_option > ul li:last").after(opt); + if($("#sit_sel_option > ul li").size() < 1) + $("#sit_sel_option > ul").html(opt); + else + $("#sit_sel_option > ul li:last").after(opt); } price_calculate(); } - // 수량변경 및 삭제 - $("#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 stock = parseInt($(this).closest("li").find("input[name='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("선택하신 옵션항목을 삭제하시겠습니까?")) { - $(this).closest("li").remove(); - price_calculate(); - } - break; - - default: - alert("올바른 방법으로 이용해 주십시오."); - break; - } - }); - // 동일선택옵션있는지 function same_option_check(val) { @@ -538,7 +544,7 @@ else }); if(result) - alert(val+" 은(는) 이미 선택하신 옵션입니다."); + alert(val+" 은(는) 이미 추가하신 옵션상품입니다."); return result; }