///// !!!!!!!!!!! 이 파일 수정시 동시에 fnOption_list.js 파일도 같이 고쳐야함 joonyus !!!!!!!!!!!!!!! //상품 기본 정보 var _goodUid = $("input[name='guid']").val(); var _goodTitle = $("input[name='title']").val(); var _goodPrice = $("input[name='price']").val(); var _goodStock = $("input[name='stock']").val(); //상품 옵션 정보 var _nChkOpt_useFlag = $("input[name='nChkOpt_useFlag']").val(); var _nChkOPt_count = parseInt($("input[name='nChkOPt_count']").val()); var _nChkOpt_type = $("input[name='nChkOpt_type']").val(); var _nChkStock_type = $("input[name='nChkStock_type']").val(); var _nChkMultiOpt_useFlag = $("input[name='nChkMultiOpt_useFlag']").val(); var _nChkMultiOpt_EA = $("input[name='nChkMultiOpt_EA']").val(); var _nChkMultiOpt_Price = $("input[name='nChkMultiOpt_Price']").val(); var _nChkTextOpt_useFlag = $("input[name='nChkTextOpt_useFlag']").val(); var _nChkAddGoods_useFlag = $("input[name='nChkAddGoods_useFlag']").val(); var img_path = $("input[name='img_path']").val(); //레이어 기본값 var currOptIdx = 0; ///''20171226 joonyus 단위구매추가 var _minEa= parseInt($("input[name='minEa']").val()); var _buyUnit=parseInt($("input[name='buyUnit']").val()); var _IsUnit=$("input[name='IsUnit']").val(); var _EaType=$("input[name='EaType']").val(); //A: 전체계산 B: 개별계산 var _IsPlusOne=$("input[name='IsPlusOne']").val(); // 20180205 joonyus 1+1 옵션체크 var _IsPlusOne_Select_check=false; //''20180712 joonyus 최대구매수량 설정 var _MaxEa=parseInt($("input[name='MaxEa']").val()); var _IsMaxBuy=$("input[name='IsMaxBuy']").val(); //20191029 joonyus 리워드 구매자 할인설정 추가 var _I_Reward_UserID=$("input[name='I_Reward_UserID']").val(); $(document).ready(function(){ //옵션x 이면 레이어를 노출한다. if ( _nChkOpt_useFlag == "F" ){ fnSetAddOptionLayer("none", _goodUid, _goodTitle, _goodPrice, "", "", 0, 0, "", _goodStock); fnSetTotalGoodsPrice(); //총 상품금액 구하기 } // 20180531 kyh 최초 옵션이 활성화되야, 분리형에서 다음 옵션에 대해, 체크할 수 있음. $("select[name='itemUid']").each(function(index){ $(this).prop("selectedIndex",0); $(this).selectmenu("refresh"); }); }); //추가상품 옵션 선택시 function fnSetAddOpt(e){ var _optType = "addopt"; var _optUid = $(e).attr("data-optuid"); var _optName = $(e).attr("data-optname"); var _optReq = $(e).attr("data-optreq"); var goodUid = $(e).find("option:selected").val(); var itemName = "└ " + $(e).find("option:selected").attr("data-itemname"); var itemPrice = $(e).find("option:selected").attr("data-itemprice"); var itemStock = parseInt($(e).find("option:selected").attr("data-itemstock")); if (goodUid != "0"){ fnSetAddOptionLayer(_optType, goodUid, itemName, itemPrice, "", "", 0, _optUid, _optName, itemStock); fnSetTotalGoodsPrice(); //총 상품금액 구하기 //초기화 $("#optSel, #optSel_dy").find("select[name='addGoodsUid']").each(function(index){ $(this).prop("selectedIndex",0); $(this).selectmenu("refresh"); }); } } //옵션 없는 상품, 수량만 조정 //기본옵션 A 선택시 : 분리형 function fnSetOptTypeA(e, strDELIMITER){ var this_ID = $(e).closest("div.optSel").attr("id"); //jings3, 더블opt추가 var optType = "opt"; var optCount = 0; var optStock = 0; //옵션 조합의 재고수량 var optPrice = 0; //옵션 조합의 가격 var itemUids = ""; var itemValues = ""; var arrOptUid = new Array(); //옵션 uid 배열 var arrOptName = new Array(); //옵션 이름 배열 var arrItemUid = new Array(); //아이템 uid 배열 var arrItemName = new Array(); //아이템 이름 배열 $("#"+ this_ID +" select[name='itemUid'] option:selected").each(function(index){ var optUid = $(this).parent().attr("data-optuid"); var optName = $(this).parent().attr("data-optname"); var itemUid = $(this).val(); var itemValue = $(this).text(); if (itemUid <= 0 ){ alert(""+ fnLANG("/jscript/fnOption.js",1) +""); return false; } if (itemUid > 0 ){ optCount += 1; //선택된 옵션의 배열 저장 arrOptUid[index] = optUid; arrOptName[index] = optName; arrItemUid[index] = itemUid; arrItemName[index] = itemValue; if ( _nChkOPt_count == optCount ) { itemUids += itemUid; itemValues += itemValue; } else { itemUids += itemUid + strDELIMITER; itemValues += itemValue + strDELIMITER; } } }); if ( _nChkOPt_count == optCount ){ var rt = true; //재고, 가격 추출 ajax(S) $.ajax({ url : "/common/ajax/exec_getItemInfo.asp", data : "guid=" + _goodUid + "&itemUids=" + itemUids + "&optType="+ _nChkOpt_type, async : false, //동기처리 error : function(html){ //alert('오류입니다.'); }, success : function(html){ if (html == "fail") { alert(""+ fnLANG("/jscript/fnOption.js",2) +""); rt = false; return false; }else{ optStock = parseInt(html.split("|")[0]); optPrice = parseInt(html.split("|")[1]); if ( _nChkStock_type == "F" && optStock <= 0){ alert(""+ fnLANG("/jscript/fnOption.js",3) +""); rt = false; return false; } } } }); //재고, 가격 추출 ajax(E) //레이어생성(S) var tHtml = ""; var tHtml_dy = ""; tHtml_dy = "

"; for (i=0;i < _nChkOPt_count ;i++ ){ /*############# org 선택옵션 레이어 정보 ####//(S)*/ tHtml += " "; tHtml += " "; tHtml += " "; tHtml += " "+ arrOptName[i] +" : "+ arrItemName[i]; tHtml += "
"; /*############# org 선택옵션 레이어 정보 ####//(E)*/ /*############# 우측 동적 선택옵션 레이어 정보 ####//(S)*/ tHtml_dy += arrOptName[i] +" : "+ arrItemName[i] + " "; /*############# 우측 동적 선택옵션 레이어 정보 ####//(E)*/ } tHtml += " ( + ₱ "+ formatComma(optPrice,3) +" )"; tHtml_dy += "

"; //레이어생성(E) //190514|wjy 옵션이 중복해서 들어가는 오류 수정 var itemCount = $('.selected_option').length; var valOpt = new Array(); var valOpt2 = new Array(); for (j = 1; j <= itemCount ; j++ ) { var itemCount2 = $('.selected_option').eq(j-1).find(".opt_info_cls").length; for (f=0;f < itemCount2 ;f++ ){ chkoptUid = $('.selected_option').eq(j-1).find("input[name=optUid]").eq(f-1).val(); chkoptItemUid = $('.selected_option').eq(j-1).find("input[name=optItemUid]").eq(f-1).val(); valOpt[f] = chkoptUid+"||"+chkoptItemUid } for (i=0;i < _nChkOPt_count ;i++ ){ valOpt2[i] = arrOptUid[i]+"||"+arrItemUid[i] } if (String(valOpt.sort()) == String(valOpt2.sort())) { alert(""+ fnLANG("/jscript/fnOption.js",4) +""); rt = false; } } //재고 파악 후 레이어 그리기(S) if (rt){ fnSetAddOptionLayer(optType, _goodUid, _goodTitle, _goodPrice, tHtml, tHtml_dy, optPrice, "", "", optStock); fnSetTotalGoodsPrice(); //총 상품금액 구하기 } //재고 파악 후 레이어 그리기(E) //초기화 // $(".select_fild").selectmenu("refresh"); } //초기화 $( "#"+this_ID ).find("select[name='itemUid']").each(function(index){ $(this).prop("selectedIndex",0); $(this).selectmenu("refresh"); }); //초기화 $("#"+this_ID).find("textarea[name='textOpt_Value']").each(function(index){ $(this).val(""); }); } // 20180531 kyh 분리형 마지막 이전 옵션 선택 시 function fnSetOptStock(e, strDELIMITER){ var this_ID = $(e).closest("div.optSel").attr("id"); //jings3, 더블opt추가 var optCount = 0; var itemUids = ""; var arrItemUid = new Array(); //아이템 uid 배열 ///20180711 joonyus 순차옵션선택 체크에 필요함 var selectCnt=$("#"+ this_ID +" select[name='itemUid']").length; selectCnt=selectCnt-1; $("#"+ this_ID +" select[name='itemUid'] option:selected").each(function(index){ var itemUid = $(this).val(); if (selectCnt>index) ///20180711 joonyus 순차옵션선택 체크에 필요함 { if (itemUid <= 0 ){ alert(""+ fnLANG("/jscript/fnOption.js",5) +""); $("select[name='itemUid']").each(function(index){ $(this).prop("selectedIndex",0); $(this).selectmenu("refresh"); }); return false; }else{ if ( $("#"+ this_ID +" select[name='itemUid']").eq(index + 1).val() == "0" ){ $("#"+ this_ID +" select[name='itemUid']").eq(index + 1).prop("selectedIndex",0); $("#"+ this_ID +" select[name='itemUid']").eq(index + 1).selectmenu("refresh"); } } } if (itemUid > 0 ){ optCount += 1; //선택된 옵션의 배열 저장 arrItemUid[index] = itemUid; if ( _nChkOPt_count == optCount ) { itemUids += itemUid; } else { itemUids += itemUid + strDELIMITER; } } }); var this_ = $(e).attr("id"); // 현재 id $.ajax({ url : "/common/ajax/exec_getItemStock.asp", data : "guid=" + _goodUid + "&itemUids=" + itemUids + "&optType="+ _nChkOpt_type, async : false, //동기처리 error : function(data){ //alert('오류입니다.'); }, success : function(data){ if (data != "") { $('.ui-menu-item').css('display', 'block'); $("#"+ this_ID +" select[name='itemUid'] option").each(function(index){ var thisValue = $(this).val(); var dataSplit = data.split(","); for ( var i in dataSplit ) { if (thisValue == dataSplit[i]){ $('#'+this_ID+' select option').each(function(j){ if (thisValue == $(this).val()){ var selectID = $(this).parent().attr('id'); // ui-id-2 $('#'+selectID+' option').each(function(x){ if (Number(thisValue) == Number($(this).val())) { $('#'+selectID+'-menu li').eq(x).css('display', 'none'); } }); } }); } } }); } } }); ////// 20180711 joonyus 분리형 재고수량 노출추가 S $.ajax({ url : "/common/ajax/exec_getOptItemStock.asp", data : "guid=" + _goodUid + "&itemUids=" + itemUids + "&optType="+ _nChkOpt_type, async : false, //동기처리 error : function(data){ //alert('오류입니다.'); }, success : function(data){ if (data != "") { $("#"+ this_ID +" select[name='itemUid'] option").each(function(index){ var thisValue = $(this).val(); var dataSplit = data.split(","); for ( var i in dataSplit ) { var Iteminfo=dataSplit[i]; var ItemSplit = Iteminfo.split("^^"); var setItemUid=ItemSplit[0]; var setItemStock=ItemSplit[1]; var setItemState=ItemSplit[2]; var setItemOptPrice=ItemSplit[4]; ///20180827 joonyus 옵션가추가 // console.log("setItemUid "+setItemUid); // console.log("setItemStock "+setItemStock); // console.log("setItemState "+setItemState); if (thisValue == setItemUid){ $('#'+this_ID+' select option').each(function(j){ if (thisValue == $(this).val()){ var selectID = $(this).parent().attr('id'); // ui-id-2 $('#'+selectID+' option').each(function(x){ // ///20191212 joonyus 초기화 추가 START // $('#'+selectID+' option').eq(x).attr('disabled', 'false'); // $('#'+selectID+'-menu li ').eq(x).attr("aria-disabled","false"); // $('#'+selectID+'-menu li > div').eq(x).removeClass( "nostock" ); // $('#'+selectID+'-menu li ').eq(x).removeClass( "ui-state-disabled" ); // ///20191212 joonyus 초기화 추가 END //var ori_txt=$(this).val().text(); ori_txt="" if (Number(thisValue) == Number($(this).val())) { ori_txt=$('#'+selectID+' option').eq(x).text(); result_txt=ori_txt+""+ fnLANG("/jscript/fnOption.js",6) +""+formatComma(setItemStock,3)+")"; if (_nChkStock_type=="F"){ if(setItemStock==0 || setItemState=="F"){ result_txt=ori_txt+""+ fnLANG("/jscript/fnOption.js",7) +""; $('#'+selectID+'-menu li > div').eq(x).addClass( "nostock" ); $('#'+selectID+' option').eq(x).attr('disabled', 'true'); $('#'+selectID+'-menu li ').eq(x).attr("aria-disabled","true"); $('#'+selectID+'-menu li ').eq(x).addClass( "ui-state-disabled" ); } }else{ if (setItemState=="F") ///품절상태일경우 { result_txt=ori_txt+""+ fnLANG("/jscript/fnOption.js",8) +""; $('#'+selectID+'-menu li > div').eq(x).addClass( "nostock" ); $('#'+selectID+' option').eq(x).prop('disabled', 'true'); $('#'+selectID+'-menu li ').eq(x).prop("aria-disabled","true"); $('#'+selectID+'-menu li > div').eq(x).addClass( "nostock" ); $('#'+selectID+'-menu li ').eq(x).addClass( "ui-state-disabled" ); }else{ result_txt=ori_txt; } } if (setItemOptPrice>0) ///20180827 joonyus 옵션가추가 { result_txt=result_txt+""+ fnLANG("/jscript/fnOption.js",9) +"+"+formatComma(setItemOptPrice,3)+")"; } $('#'+selectID+'-menu li > div').eq(x).html(result_txt); } }); } }); } } }); } } }); ////// 20180711 joonyus 분리형 재고수량 노출추가 E } //기본옵션 type B 선택시 : 일체형 function fnSetOptTypeB(e, strDELIMITER){ var optType = "opt"; var itemUids = ""; var itemValues = ""; var itemDisabled = ""; var stockUid = ""; var tHtml = ""; var tHtml_dy = ""; var itemStock = 0; var itemPrice = 0; var arrOptUid = new Array(); //옵션 uid 배열 var arrOptName = new Array(); //옵션 이름 배열 var arrItemUid = new Array(); //아이템 uid 배열 var arrItemName = new Array(); //아이템 이름 배열 var optUids = $(e).attr("data-optuid"); var optNames = $(e).attr("data-optname"); // console.log('optUids='+optUids+', optNames='+optNames) stockUid = $(e).val(); itemUids = $(e).find("option:selected").attr("data-itemuids"); itemValues = $(e).find("option:selected").attr("data-itemvalues"); // console.log('stockUid='+stockUid+', itemUids='+itemUids+', itemValues='+itemValues) if (stockUid > 0) { //재고, 가격 추출 ajax(S) $.ajax({ url : "/common/ajax/exec_getItemInfo.asp", data : "guid=" + _goodUid + "&stockUid=" + stockUid + "&optType="+ _nChkOpt_type, async : false, //전역 처리 error : function(html){ //alert('오류입니다.'); }, success : function(html){ if (html == "fail") { alert(""+ fnLANG("/jscript/fnOption.js",10) +""); return false; } else { itemStock = parseInt(html.split("|")[0]); itemPrice = parseInt(html.split("|")[1]); if ( _nChkStock_type == "F" && itemStock == 0 ) { alert(""+ fnLANG("/jscript/fnOption.js",11) +""); return false; } } } }); //재고, 가격 추출 ajax(E) //레이어생성(S) var tHtml = ""; var tHtml_dy = ""; for (i=0;i < _nChkOPt_count ;i++ ){ arrOptUid[i] = optUids.split("|:|")[i]; arrOptName[i] = optNames.split("|:|")[i]; arrItemUid[i] = itemUids.split("|:|")[i]; arrItemName[i] = itemValues.split("|:|")[i]; tHtml += " "; tHtml += " "; tHtml += " "; tHtml += ""+ fnLANG("/jscript/fnOption.js",12) +""+ arrOptName[i] +" : "+ arrItemName[i]; tHtml += "
"; } tHtml += " "; tHtml += ""+ fnLANG("/jscript/fnOption.js",13) +""+ formatComma(itemPrice,3) +" )"; tHtml += "
"; tHtml_dy=tHtml; ///20190424 joonyus 오른쪽 선택된 옵션명 나오게 추가.. //레이어생성(E) //190514|wjy 옵션이 중복해서 들어가는 오류 수정 var itemCount = $('.selected_option').length; var valOpt = new Array(); var valOpt2 = new Array(); for (j = 1; j <= itemCount ; j++ ) { var itemCount2 = $('.selected_option').eq(j-1).find(".opt_info_cls").length; for (f=0;f < itemCount2 ;f++ ){ chkoptUid = $('.selected_option').eq(j-1).find("input[name=optUid]").eq(f-1).val(); chkoptItemUid = $('.selected_option').eq(j-1).find("input[name=optItemUid]").eq(f-1).val(); valOpt[f] = chkoptUid+"||"+chkoptItemUid } for (i=0;i < _nChkOPt_count ;i++ ){ valOpt2[i] = arrOptUid[i]+"||"+arrItemUid[i] } if (String(valOpt.sort()) == String(valOpt2.sort())) { alert(""+ fnLANG("/jscript/fnOption.js",14) +""); itemStock = 0; } } //재고 파악 후 레이어 그리기(S) if (itemStock > 0 ){ fnSetAddOptionLayer(optType, _goodUid, _goodTitle, _goodPrice, tHtml, tHtml_dy, itemPrice, "", "", itemStock); fnSetTotalGoodsPrice(); //총 상품금액 구하기 } //재고 파악 후 레이어 그리기(E) } //end stockUid //초기화 $("#optSel, #optSel_dy").find("select[name='itemUid']").each(function(index){ $(this).prop("selectedIndex",0); $(this).selectmenu("refresh"); }); //초기화 $("#optSel, #optSel_dy").find("textarea[name='textOpt_Value']").each(function(index){ $(this).val(""); }); } ////20180208 joonyus 1+1 function fnSetOptTypeC(e, strDELIMITER){ var optType = ""; var optCount = 0; var optStock = 0; //옵션 조합의 재고수량 var optPrice = 0; //옵션 조합의 가격 var itemUids = ""; var itemValues = ""; var arrOptUid = new Array(); //옵션 uid 배열 var arrOptName = new Array(); //옵션 이름 배열 var arrItemUid = new Array(); //아이템 uid 배열 var arrItemName = new Array(); //아이템 이름 배열 $("#optSel select[name='itemUid'] option:selected").each(function(index){ var optUid = $(this).parent().attr("data-optuid"); var optName = $(this).parent().attr("data-optname"); var item_optName = $(this).attr("data-itemvalues"); var itemUid = $(this).attr("data-itemuids"); if (itemUid <= 0 && index==0){ alert(""+ fnLANG("/jscript/fnOption.js",15) +""); return false; } if (itemUid > 0 ){ optCount += 1; //선택된 옵션의 배열 저장 arrOptUid[index] = optUid; arrOptName[index] = optName; arrItemUid[index] = itemUid; arrItemName[index] = item_optName; } }); if ( optCount == 2 ) { var rt = true; for (i=0;i < optCount ;i++ ) { //재고, 가격 추출 ajax(S) $.ajax({ url : "/common/ajax/exec_getItemInfo.asp", data : "guid=" + _goodUid + "&itemUids=" + arrItemUid[i] + "&optType=A", async : false, //전역 처리 error : function(html){ //alert('오류입니다.'); }, success : function(html){ if (html == "fail") { alert(""+ fnLANG("/jscript/fnOption.js",16) +""); rt = false; return false; } else { optStock = parseInt(html.split("|")[0]); optPrice = parseInt(html.split("|")[1]); if ( _nChkStock_type == "F" && optStock <= 0){ alert(""+ fnLANG("/jscript/fnOption.js",17) +""); rt = false; return false; } } } }); } //재고, 가격 추출 ajax(E) //레이어생성(S) var tHtml = ""; var tHtml_dy = "

"; for (i=0;i < optCount ;i++ ){ /*############# org 선택옵션 레이어 정보 ####//(S)*/ tHtml += " "; tHtml += " "; tHtml += " "; tHtml += " "+ arrOptName[i] +" : "+ arrItemName[i]; tHtml += "
"; /*############# org 선택옵션 레이어 정보 ####//(E)*/ /*############# 우측 동적 선택옵션 레이어 정보 ####//(S)*/ tHtml_dy += arrOptName[i] +" : "+ arrItemName[i] + " "; /*############# 우측 동적 선택옵션 레이어 정보 ####//(E)*/ } tHtml += " ( + ₱ "+ formatComma(optPrice,3) +" )"; tHtml_dy += "

"; //레이어생성(E) if (rt){ _IsPlusOne_Select_check=true; fnSetAddOptionLayer(optType, _goodUid, _goodTitle, _goodPrice, tHtml, tHtml_dy, optPrice, "", "", optStock); fnSetTotalGoodsPrice(); //총 상품금액 구하기 } //초기화 //초기화 $("#optSel, #optSel_dy").find("select[name='itemUid']").each(function(index){ $(this).prop("selectedIndex",0); $(this).selectmenu("refresh"); }); } } //텍스트영역 입력시 function fnSetTextOptValue(e){ var p = $("#optList").find("div.textOpt").last(); //입력할 레이어 var p_dy = $("#optList_dy").find("div.textOpt").last(); //우측동적 옵션영역,jings3 /* # 클릭obj의 INDEX구하기, jings3, 2018-04-06 //(s)#*/ var $parent1 = $(e).closest(".optSel"); var $parent2 = $(e).closest(".textarea_option"); var myIndex = $("textarea[name='textOpt_Value']").index(e); //입력 영역 /* # 클릭obj의 INDEX구하기, jings3, 2018-04-06 //(e)#*/ var index = myIndex; //입력 영역 var value = $(e).val(); var optUid = $(e).attr("data-uid"); // var optTitle = $(e).attr("data-name"); var optPrice = parseFloat($(e).attr("data-price")); if ( value == "" ){ optPrice = 0; optUid = ""; } //해당 필드 수정 $(p).find( "#textOptUid_"+ index ).val(optUid); $(p).find( "#textOptPrice_"+ index ).val(optPrice); $(p).find( "#textOptValue_"+ index ).val(value); $(p_dy).find( "#textOptValue_"+ index ).val(value); //우측동적 옵션 영역 , jings3 fnSetTotalGoodsPrice(); //총 상품금액 구하기 } //기본 레이어 생성/추가 function fnSetAddOptionLayer(optType, goodUid, goodsTitle, goodPrice, optHtml, optHtml_dy, optPrice, optUid, optName, itemStock){ // console.log('optType='+optType+', goodUid='+goodUid+', goodsTitle='+goodsTitle+', goodPrice='+goodPrice) // console.log(optHtml) // console.log('optPrice='+optPrice+', optUid='+optUid+', optName='+optName+', itemStock='+itemStock) // optType = opt, addopt, none currOptIdx += 1; if (!optType){ //없으면 optType = ""; } if (!optName){ //없으면 optName = ""; } if (!optUid){ //없으면 optUid = 0; } if (!goodPrice){ //없으면 goodPrice = 0; }else { goodPrice = parseInt(goodPrice); } if (!optHtml){ //없으면 optHtml = ""; } if (!optHtml_dy){ //없으면 optHtml_dy = ""; } if (!optPrice){ //없으면 optPrice = 0; } else { optPrice = parseInt(optPrice); } if (!itemStock){ //없으면 itemStock = 0; }else{ itemStock = parseInt(itemStock); } if (_nChkStock_type == "T"){ //무제한이면 itemStock = 10000; } var tTextOptCount = 0; var tCount = parseInt($("input[name='OptLayerCount']").val()); $("input[name='OptLayerCount']").val( tCount + 1 ); /*############# org 선택옵션 레이어 정보 ####//(S)*/ var tHtml = ""; tHtml += "
"; tHtml += " "; tHtml += " "; tHtml += " "; tHtml += " "; tHtml += " "; tHtml += " "; tHtml += " "; tHtml += " "; tHtml += " Product Name : "+ goodsTitle +"
"; if (optType == "addopt"){ tHtml += " Additional Product Name : "+ optName +"
"; } //추가옵션인경우 노출 안한다. if ( optType != 'addopt'){ //기본 옵션 보여주기 tHtml += optHtml; //텍스트옵션 tTextOptCount = $("textarea[name='textOpt_Value']", $("#optSel")).size(); if ( tTextOptCount != 0){ tHtml += "
"; for (i=0;i"; tHtml += " "+optReqTitle + optTitle +""; tHtml += " "+ optPrice +""; tHtml += " "; tHtml += " "; tHtml += "
"; tHtml += " "; } tHtml += "
"; //텍스트옵션 } } //end optType var bEa=1; var readonly=""; if (_IsUnit=="T"){ if ( optType != 'addopt') bEa=_minEa; readonly="readonly"; } tHtml += " "; tHtml += "
"; tHtml += " \"minus\""; tHtml += " "; tHtml += " \"plus\""; tHtml += "
"; tHtml += " "+ formatComma(goodPrice + optPrice) +" "; if (optType == "addopt" || optType == "opt" || _IsPlusOne=="T"){ ///20180208 joonyus _IsPlusOne 1+1 tHtml += " \""+"; } tHtml += " "; /*############# org 선택옵션 레이어 정보 ####//(E)*/ /*############# 우측 동적 선택옵션 레이어 정보 ####//(S)*/ var tHtml_dy = ""; tHtml_dy +="
"; tHtml_dy +="
"; tHtml_dy +="
"; if ( optType == "none" ){ tHtml_dy += "

"+ fnLANG("/jscript/fnOption.js",21) +""+ goodsTitle +"

"; } if (optType == "addopt" || optType == "opt" || _IsPlusOne=="T"){ ///20180208 joonyus _IsPlusOne 1+1 tHtml_dy +=" "; tHtml_dy +=" clear"; tHtml_dy +=" "; } if (optType == "addopt"){ tHtml_dy += "

"+ fnLANG("/jscript/fnOption.js",22) +""+ goodsTitle +":/"+ fnLANG("/jscript/fnOption.js",23) +""+ optName +"

"; } //추가옵션인경우 노출 안한다. if ( optType != 'addopt'){ //기본 옵션 보여주기 tHtml_dy += optHtml_dy; //텍스트옵션 tTextOptCount = $("textarea[name='textOpt_Value']", $("#optSel")).size(); if ( tTextOptCount != 0){ tHtml_dy += "
"; for (i=0;i"; tHtml_dy += " "+optReqTitle + optTitle +""; tHtml_dy += " "+ optPrice +""; tHtml_dy += " "; tHtml_dy += " "; tHtml_dy += "
"; tHtml_dy += " "; } tHtml_dy += "
"; //텍스트옵션 } } //end optType tHtml_dy +="
"; tHtml_dy +="
"; tHtml_dy +=" "; tHtml_dy +="
"; tHtml_dy +="
"; tHtml_dy +="
"; tHtml_dy +="
"; tHtml_dy +="
"; tHtml_dy +="
"+ formatComma(goodPrice + optPrice) +"
"; tHtml_dy +="
"; tHtml_dy +="
"; tHtml_dy +="
"; tHtml_dy +=" "; $("input:text[name='tEa']", "#optList").each(function(index) { ea=parseInt($("input:text[name='tEa']", "#optList").eq(index).val()); total_ea+=ea; }); if (_IsMaxBuy=="T"){///''20180712 joonyus 최대구매설정추가 var total_ea=0; $("input:text[name='tEa']", "#optList").each(function(index) { ea=parseInt($("input:text[name='tEa']", "#optList").eq(index).val()); total_ea+=ea; }); total_ea+=bEa; if (total_ea > _MaxEa){ alert(''+ fnLANG("/jscript/fnOption.js",26) +''+_MaxEa+''+ fnLANG("/jscript/fnOption.js",27) +''); return false; } } /*############# 우측 동적 선택옵션 레이어 정보 ####//(E)*/ $("#optList").append(tHtml); $("#optList_dy").append(tHtml_dy); // $('#optListQuick').append(tHtml); } //레이어 삭제 function fnDelLayer(e){ /* # 클릭obj의 INDEX구하기, jings3, 2018-04-06 //(s)#*/ var $parent1 = $(e).closest(".optList"); var $parent2 = $(e).closest(".selected_area"); var myIndex = $($parent2, $parent2).index(); /* # 클릭obj의 INDEX구하기, jings3, 2018-04-06 //(e)#*/ $("div.selected_area", $("#optList")).eq(myIndex).remove(); $("div.selected_area", $("#optList_dy")).eq(myIndex).remove(); /* 우측 옵션 처리,jings3 */ //총 주문 상품 갯수 줄이기 var tCount = parseInt($("input[name='OptLayerCount']").val()); $("input[name='OptLayerCount']").val( tCount - 1 ); fnSetTotalGoodsPrice(); //총 상품금액 구하기 } //수량 변경 function controlNumNoOPT(e, oper){ /* # 클릭obj의 INDEX구하기, jings3, 2018-04-06 //(s)#*/ var $parent1 = $(e).closest(".optList"); var $parent2 = $(e).closest(".selected_area"); var myIndex = $($parent2, $parent1).index(); /* # 클릭obj의 INDEX구하기, jings3, 2018-04-06 //(e)#*/ var parent_IdName = $parent1.attr("id"); //양쪽에서 다 쓰기 위해 , 동적으로 ID값을 알아냄,jings3, 2018-12-17 var tEa = $("div.selected_area", $("#" + parent_IdName)).eq(myIndex).find("input[name='tEa']").val(); var tStock = $("div.selected_area", $("#optList")).eq(myIndex).find("input[name='tStock']").val(); num = (tEa.stripspace() == "") ? 0 : parseInt(tEa); num = (isNaN(num)) ? 0 : parseInt(num); if (oper == '+') { if ( num >= tStock ){ alert(""+ fnLANG("/jscript/fnOption.js",28) +""); return false; } if (_IsMaxBuy=="T"){///''20180712 joonyus 최대구매설정추가 var total_ea=0; $("input:text[name='tEa']", "#optList").each(function(index) { ea=parseInt($("input:text[name='tEa']", "#optList").eq(index).val()); total_ea+=ea; }); if (_IsUnit=="T"){///''20200117 joonyus 단위구매추가 plusnum=_buyUnit; }else{ plusnum=1; } total_ea = total_ea + plusnum; if (total_ea > _MaxEa){ alert(''+ fnLANG("/jscript/fnOption.js",29) +''+_MaxEa+''+ fnLANG("/jscript/fnOption.js",30) +''); --num; return false; } } if (_IsUnit=="T"){///''20171226 joonyus 단위구매추가 num = (Number(num) + _buyUnit); }else{ ++num; } }else if( oper === '-' ){ if (_IsUnit=="T"){///''20171226 joonyus 단위구매추가 num=(Number(num) - _buyUnit); }else{ --num; } if (num == 0 || num < _minEa){ var optType = $parent2.find('[name=tOptType]').val(); if ( optType=='addopt' ){ num = 1; } else { num = _minEa; alert(''+ fnLANG("/jscript/fnOption.js",31) +''+_minEa+''+ fnLANG("/jscript/fnOption.js",32) +''); } //return false; } }else{//+,-버튼을 누르지 않고 그냥 입력했을경우, jings3, 2018-12-17 ////////////////////////////////////////////////////////////////////////////////////////////////////////(B) if ( num >= tStock ){ alert(""+ fnLANG("/jscript/fnOption.js",33) +""); $(e).closest(".count_control").find("input[name='tEa']").val(tStock); $(e).trigger("focus"); //위 세팅갯수로 다시 계산되게 처리, jings3, 2018-12-17 return; } if (num == 0 || num < 0){ alert(''+ fnLANG("/jscript/fnOption.js",34) +''); num = 1; $(e).closest(".count_control").find("input[name='tEa']").val(1); $(e).trigger("focus"); //위 세팅갯수로 다시 계산되게 처리, jings3, 2018-12-17 return; } if (_IsMaxBuy == "T"){///''20180712 joonyus 최대구매설정추가 var total_ea=0; $("input:text[name='tEa']", "#optList").each(function(index) { ea = parseInt($("input:text[name='tEa']", "#optList").eq(index).val()); total_ea += ea; }); total_ea = total_ea + 1; if (total_ea > _MaxEa){ alert(''+ fnLANG("/jscript/fnOption.js",35) +''+_MaxEa+''+ fnLANG("/jscript/fnOption.js",36) +''); num = _MaxEa; $(e).closest(".count_control").find("input[name='tEa']").val(_MaxEa); $(e).trigger("focus"); //위 세팅갯수로 다시 계산되게 처리, jings3, 2018-12-17 return; } } if (_IsUnit=="T"){///''20171226 joonyus 단위구매추가 //계산식 변경, jings3, 2018-12-17 num = ( ( Math.round(num / _buyUnit) * _buyUnit ) <= 0 ) ? _buyUnit : Math.round(num / _buyUnit) * _buyUnit; } ////////////////////////////////////////////////////////////////////////////////////////////////////////(E) } $("div.selected_area", $("#optList")).eq(myIndex).find("input[name='tEa']").val(num); $("div.selected_area", $("#optList_dy")).eq(myIndex).find("input[name='tEa']").val(num); /*우측 옵션 처리 추가, jings3*/ fnSetTotalGoodsPrice(); //총 상품금액 구하기 } //총 상품금액 구하기 function fnSetTotalGoodsPrice(){ var totGoodsPrice = 0; var total_ea=0; $("input:text[name='tEa']", "#optList").each(function(index) { ea=parseInt($("input:text[name='tEa']", "#optList").eq(index).val()); total_ea+=ea; }); $("#optList div.selected_option").each(function(){ var OptType = $(this).find("input[name='tOptType']").val(); //옵션타입 var price = parseInt($(this).find("input[name='tGoodPrice']").val()); var sectionPrice = parseInt($(this).find("input[name='tGoodSectionPrice']").val()); // 구간별 할인 var optPrice = parseInt($(this).find("input[name='tGoodOptPrice']").val()); var ea = parseInt($(this).find("input[name='tEa']").val()); var chkea; //복수구매 할인(S), 복수구매가 구간별할인으로 변경 으로 주석, jings3 2017-10-19 //if ( OptType !="addopt" && _nChkMultiOpt_useFlag == "T" && ea >= parseInt(_nChkMultiOpt_EA) ) { //price = price + parseInt(_nChkMultiOpt_Price); //} //복수구매 할인(E) //텍스트옵션 가격(S) var subTextOptPrice = 0; var p = $(this).find("div.textOpt").find("input[name='optTextPrice']"); $(p).each(function(){ var textPrice = parseInt($(this).val()); subTextOptPrice += textPrice; }); //텍스트옵션 가격(E) chkea=ea if ( _EaType=="A" ){ chkea=total_ea; } var $nayana = $(this); //current 객체를 미리 참조 // '171128 edit bhc : 추가 상품 제외 조건 추가 if ( OptType != "addopt" ){ //복수구매( 구간별 할인) 체크(S) if ( OptType != "addopt" ){ var sectionGuid = $('#guid').val(); // 상품번호 var sectionEa = ea; // 수량 var thisLocation = $(this); $.ajax({ url : "/common/ajax/exec_getSectionPrice.asp", data : "guid=" + sectionGuid + "&ea=" + chkea+"&I_Reward_UserID="+_I_Reward_UserID, async : false, //동기처리 success : function(sectionPrice){ if (sectionPrice != 0){ thisLocation.find("input[name='tGoodSectionPrice']").val(sectionPrice); price = parseInt(sectionPrice); //구간별 할인가로 계산되게 처리, jings3, 2017-08-28 }else{ thisLocation.find("input[name='tGoodSectionPrice']").val(thisLocation.find("input[name='tGoodPrice']").val()); } } }); } //복수구매( 구간별 할인) 체크(E) //200109|wjy 상세페이지에서 쿠폰 적용 시 쿠폰할인 금액이 보이게.. var couponUid = $("#couponUid").val(); if (couponUid == "" || couponUid ==0) { }else{ //price = $("#coupon_use_id_"+couponUid).data("price"); // 2020-02-27 joonyus 할인금액 노출 변경. 쿠폰이 바로 적용되게 하는 기능 폐쇄. 주문페이지에서 쿠폰변경이 불가하기때문. } totGoodsPrice += (price + optPrice + subTextOptPrice) * ea; $nayana.find("#subTotalPrice").text( setCurrency((price + optPrice + subTextOptPrice) * ea) ); ///20190503 joonyus setCurrency 함수 재호출에러 (옵션있는상품 선택->선택취소->다시 옵션선택시 setCurrency 함수호출안됨. 임시로처리함 //$nayana.find("#subTotalPrice").text( formatComma((price + optPrice + subTextOptPrice) * ea)+" 원" ); ///20190617 joonyus 원복 var i_dex = $($nayana, $("div.selected_option")).index(); $("#subTotalPrice_dy", $(".selected_area")).eq(i_dex).text( $nayana.find("#subTotalPrice").text() ); /* 우측 동적 옵션 */ }); /* 우측 동적옵션 총주문갯수를 표시 //(S)*/ $(".optSelaAllEa").text( total_ea ); /* 우측 동적옵션 총주문갯수를 표시 //(E)*/ if (totGoodsPrice>0) { $("#TotalGoodsPrice, #TotalGoodsPrice_dy").text(setCurrency(totGoodsPrice)); ///20190503 joonyus setCurrency 함수 재호출에러 (옵션있는상품 선택->선택취소->다시 옵션선택시 setCurrency 함수호출안됨. 임시로처리함 //$("#TotalGoodsPrice, #TotalGoodsPrice_dy").text(formatComma(totGoodsPrice)+" 원" ); ///20190617 joonyus 원복 } else { $("#TotalGoodsPrice, #TotalGoodsPrice_dy").text("₱ "+ 0); } } /*goodsType추가, jings3, 2017-06-21*/ function checkGoods(method, goodsType){ var f = document.Frm; var rt = true; if(_IsPlusOne=="T" ){ if(_IsPlusOne_Select_check==false){ alert(""+ fnLANG("/jscript/fnOption.js",37) +""); rt=false; return false; } }else{ //기본 옵션 선택 여부 파악(S) if ( _nChkOpt_useFlag == "T" && _IsPlusOne!="T"){ var _optReqTCount = 0; //옵션 영역 갯수(필수) var __optReqTCount = 0; //주문 영역 갯수(필수) $("#optSel").find("select[name='itemUid']").each(function(){ _optReqTCount += 1; $("#optList div.selected_option").find("input[name='tOptType']").each(function(){ var __optType = $(this).val(); //val == addopt if ( __optType == "opt" ) { __optReqTCount += 1; } }); }); if ( _optReqTCount > __optReqTCount){ alert(""+ fnLANG("/jscript/fnOption.js",38) +""); rt = false; } } //기본 옵션 선택 여부 파악(E) } //텍스트 옵션 입력 여부 파악(S) if ( _nChkTextOpt_useFlag == "T" ){ var _textOptReqTCount = 0; //옵션 영역 갯수(필수) var arrTextOptReq = new Array(); //옵션 필수 배열 $("#optSel").find("textarea[name='textOpt_Value']").each(function(index){ var _optReq = $(this).attr("data-req"); arrTextOptReq[index] = _optReq; if (_optReq == "T") { _textOptReqTCount += 1; } }); $("#optList div.selected_option").find("div.textOpt").each(function(){ var _this = this; var __textOptReqTCount = 0; //주문 영역 갯수(필수) $(_this).find("textarea[name='optTextValue']").each(function(index){ var __this = this; var _optValue = $(__this).val(); if ( arrTextOptReq[index] == "T" && _optValue != "") { __textOptReqTCount += 1; } }); if ( _textOptReqTCount > __textOptReqTCount ){ alert(""+ fnLANG("/jscript/fnOption.js",39) +""); rt = false; } }); } //텍스트 옵션 입력 여부 파악(E) //추가상품 옵션 선택 여부 파악(S) if ( _nChkAddGoods_useFlag == "T" ){ var _addOptReqTCount = 0; //옵션 영역 갯수(필수) var __addOptReqTCount = 0; //주문 영역 갯수(필수) var _orioptUid = ""; //옵션 uid 비교 변수 $("#optSel").find("select[name='addGoodsUid']").each(function(){ var _addOptType = $(this).attr("data-opttype"); var _addOptReq = $(this).attr("data-optreq"); var _addOptUid = $(this).attr("data-optuid"); _orioptUid = _addOptUid; //비교 opt uid if ( _addOptType == "addopt" && _addOptReq == "T" ) { _addOptReqTCount += 1; $("#optList div.selected_option").find("input[name='tOptType']").each(function(){ var __addOptType = $(this).val(); //val == addopt var __addOptUid = $(this).parent().find("input[name='tAddOptUid']").val(); if ( __addOptType == "addopt" && _addOptUid == __addOptUid && _orioptUid == __addOptUid && __addOptUid != "0") { __addOptReqTCount += 1; } }); } }); if ( _addOptReqTCount > __addOptReqTCount ){ alert(""+ fnLANG("/jscript/fnOption.js",40) +""); rt = false; } } //추가상품 옵션 선택 여부 파악(E) if (rt) { if (method=="CART"){ $("input[name='mode']").val(method); //mode 설정 var params = $("#Frm").find(":input").serializeArray(); $.ajax({ type : "POST", async : false , data : params, url : "/product/ajax/ajaxCartOk.asp", success : function(data) { if(data != "OK"){ //FAIL+|+경고문구 var statusCode = data.split("|")[0] var statusTxt = data.split("|")[1] if (statusCode =="FAIL") { alert(statusTxt); return false; } } else { $("#pop_div").show(); } } }); } if (method=="DIRECT") { $("input[name='mode']").val(method); //mode 설정 var params = $("#Frm").find(":input").serializeArray(); $.ajax({ type : "POST", async : false , data : params, url : "/product/ajax/ajaxCartOk.asp", success : function(data) { if(data != "OK"){ //FAIL+|+경고문구 var statusCode = data.split("|")[0] var statusTxt = data.split("|")[1] if (statusCode =="FAIL") { alert(statusTxt); return false; } } else { location.href="/product/order.asp?chkType="+method + "&transGoodsType=" + goodsType; } } }); } //수정함. 추가상품도 선택가능하게. if (method=="NPAYDIRECT") { var rt2 = false; $("input[name='mode']").val(method); //mode 설정 var params = $("#Frm").find(":input").serializeArray(); $.ajax({ type : "POST", async : false , data : params, url : "/product/ajax/ajaxCartOk.asp", success : function(data) { if(data != "OK"){ //FAIL+|+경고문구 var statusCode = data.split("|")[0] var statusTxt = data.split("|")[1] if (statusCode =="FAIL") { alert(statusTxt); rt2 = false; } } else { rt2 = true ; } } }); return rt2; } } else { return ; } // showValues(); } function showValues() { var fields = $("#optList").find(":input").serializeArray(); $("#results").empty(); $.each(fields, function(i, field){ $("#results").append(field.name + "=" + field.value + ", "); }); } function cart_pop_close(){ document.getElementById("pop_div").style.display="none"; } function go_cart(){ location.href = "/product/cart.asp"; }