1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
|
<?php include_once("./_common.php");
$prodinfo = product_info_get($code); // 제품정보 가져옴 $cateinfo = cate_info_get($prodinfo['code2']); // 분류정보 가져옴 $hasWishcnt = prod_wish_heart($prodinfo['code']);
if($prodinfo['p_use']=='0'){ alert("판매중인 상품이 아닙니다."); }
$is_soldout = false; if($prodinfo['opt_yn']==1){ // 옵션 상품 일 경우 $opt_array = prod_opt_get($prodinfo['code'], "" ,""); // 상품옵션 가져옴 } else { if($prodinfo['jego']<='0' || $prodinfo['p_soldout']=='1'){ // 품절 체크 $is_soldout = true; } } $addopt_array = prod_addopt_get($prodinfo['code'], "" ,""); // 추가상품옵션 가져옴
if(table_field_ck("shop_cart", "ev_code")){ // 이벤트 전용단가별로 장바구니 가져옴 $add_where = " and ev_code = '{$ev_code}' "; } $sql = "select * from shop_cart where od_id = '{$od_ids}' and pcode = '{$code}' {$add_where}"; $res = mysql_query($sql,$connect_j3); while($info=mysql_fetch_array($res)){ $ct_array[] = $info; }
?> <dl class="p10_0 relative width_full height80 gray_line_b"> <dt class="float_l width_30 align_c"> <a href='<?php echo $it_href;?>'><img src="<?php echo $thumb_file = get_it_thumbnail($prodinfo['pcode'],$prodinfo['pic1'],80,80);?>" alt="상품이미지"></a> </dt> <dd class="float_r width_70"> <div class="width_full ellipsis txt14 bold"><?php echo $prodinfo['name'];?></div> <div class="absolute ab_bot5_right txt17 bold align_r"><?php echo number_format($prodinfo['saleprice']);?><span class="txt12 normal">원</span></div> </dd> </dl>
<table class="width_full"> <colgroup> <col class="" style='width:25%;'><col class=""> </colgroup> <?php if($prodinfo['opt_yn']==1){ // 옵션상품일경우 ?> <tr><td colspan="2" class="dotline"></td></tr> <tr> <th class="align_l txt13 height30 l_height30">상품선택</th> <td class="l_height30">
<select id="opt" title="옵션선택" class="width_full height26 l_height26 p0_10 opacity0 pointer"> <option value=''> 선택 </option> <?php $jego_cnt = 0; foreach($opt_array as $key=>$opt){ if($opt['p_soldout']!='1'){ if($opt['jego']>0){ $jego_cnt += $opt['jego']; } } ?> <option value='<?php echo $opt['code']?>'> <?php echo $opt['name']." ".$opt['opt_price'];?> <?php if($opt['jego']<"0" || $opt['p_soldout']==1){ echo "[품절]"; } else { if($configshop['qty_hidden']!='1'){ echo "[재고:".number_format($opt['jego'])."]"; } } ?> </option> <?php } if($jego_cnt=='0'){ $is_soldout = true; } ?> </select>
</td> </tr> <?php }?> <?php if(count($addopt_array)>0){ ?> <tr><td colspan="2" class="dotline"></td></tr> <tr> <th class="align_l txt13 height30">추가구성상품</th> <td class="l_height30"> <select id="opt_add" title="옵션선택" class="width_full height26 l_height26 p0_10 opacity0 pointer"> <option value=''> 선택 </option> <?php foreach($addopt_array as $key=>$opt){ ?> <option value='<?php echo $opt['code']?>'> <?php echo $opt['name']." +".$opt['saleprice'];?>원 <?php if($opt['jego']<"0" || $opt['p_soldout']==1){ echo "[품절]"; } else { if($configshop['qty_hidden']!='1'){ echo "[재고:".number_format($opt['jego'])."]"; } } ?> </option> <?php } ?> </select> </td> </tr> <?php } ?> </table> <form name='item_cart_form' id='item_cart_form' method='post'> <!-- 옵션 선택 항목이 이곳에 표시됨 --> <input type='hidden' name='od_ids' value='<?php echo $od_ids;?>'> <input type='hidden' name='code' value='<?php echo $prodinfo['code'];?>'> <input type='hidden' name='ct_name' value='<?php echo $prodinfo['name'];?>'> <input type='hidden' name='ct_price' value='<?php echo $prodinfo['saleprice'];?>'> <div class='opt_sel_class'> </div> <!-- .opt_sel_class end--> </form>
<div id="sit_tot_price" class="mt15 p5 txt13 l_height35 bg_gray"> <em class="bold">총 상품금액 : </em> <div class="float_r"><span class="gray">총 수량 <span class='all_qty_class bold'>0</span>개 │</span><span class="ml10 txt15 bold all_price_class">0</span>원</div> </div>
<script> $(function(){ <?php foreach($ct_array as $key=>$val){?> add_opt_info_get('<?php echo $val['opt_pcode']?>','<?php echo $val['opt_mode']?>','<?php echo $val['ct_qty']?>'); <?php }?>
var select = $("#opt, #opt_add"); // 옵션 셀렉트 처리 select.change(function(){ var select_name = $(this).children("option:selected").text(); $(this).siblings("label").text(select_name);
code = $(this).val(); if($(this).attr("id")=='opt'){ mode = 'opt'; } else { mode = 'addopt'; } add_opt_info_get(code,mode,''); });
// *********************************** // 옵션 수량변경(+,-)과 옵션상품 삭제는 common.js로 옮겼음 // ***********************************
/*$(document).on("click",".opt_del_class",function(){ // 옵션 삭제 $parent_obj = $(this).closest("#sit_sel_option"); if($parent_obj.find("input[name='opt_mode[]']").val()!=''){ $parent_obj.remove(); sum_opt_price(); } });
$(document).on("click",".minus_qty_class",function(){ // - 버튼시 동작 $parent_obj = $(this).closest("#sit_sel_option"); $min_qty = parseInt($parent_obj.find("input[name='p_min_buy[]']").val()); $cur_qty = parseInt($parent_obj.find("input[name='qty[]']").val()); if($cur_qty==$min_qty){ alert('해당 상품의 최소구매수량은 '+$min_qty+'개 입니다.'); } else if($min_qty==0 && $cur_qty==1){
} else { $parent_obj.find("input[name='qty[]']").val($cur_qty-1); sum_opt_price(); } });
$(document).on("click",".add_qty_class",function(){ // + 버튼시 동작 $parent_obj = $(this).closest("#sit_sel_option"); $max_qty = parseInt($parent_obj.find("input[name='p_max_buy[]']").val()); $cur_qty = parseInt($parent_obj.find("input[name='qty[]']").val()); $jego = parseInt($parent_obj.find("input[name='jego[]']").val()); if(Number($max_qty)>0 && $cur_qty==$max_qty){ alert('해당 상품의 최대구매수량은 '+$max_qty+'개 입니다.'); } else if(Number($jego)<=Number($cur_qty)){ alert('해당 상품의 재고는 '+$jego+'개 입니다.'); } else { $parent_obj.find("input[name='qty[]']").val($cur_qty+1); sum_opt_price(); } });
$(document).on("change","input[name='qty[]']",function(){ // 수량 직접 수정시 동작 preg_replace2("number",$(this).val(),$(this));
$parent_obj = $(this).closest("#sit_sel_option"); $min_qty = parseInt($parent_obj.find("input[name='p_min_buy[]']").val()); $max_qty = parseInt($parent_obj.find("input[name='p_max_buy[]']").val()); $cur_qty = parseInt($parent_obj.find("input[name='qty[]']").val()); $jego = parseInt($parent_obj.find("input[name='jego[]']").val()); if(Number($min_qty)>0 && Number($min_qty)>Number($cur_qty)){ alert('해당 상품의 최소구매수량은 '+$min_qty+'개 입니다.'); $parent_obj.find("input[name='qty[]']").val($parent_obj.find("input[name='qty_default[]']").val()); } else if(Number($max_qty)<Number($cur_qty) && Number($max_qty)>0){ alert('해당 상품의 최대구매수량은 '+$max_qty+'개 입니다.'); $parent_obj.find("input[name='qty[]']").val($parent_obj.find("input[name='qty_default[]']").val()); } else if(Number($jego)<=Number($cur_qty)){ alert('해당 상품의 재고는 '+$jego+'개 입니다.'); $parent_obj.find("input[name='qty[]']").val($jego); } sum_opt_price(); });*/
}); function add_opt_info_get(code,mode,ct_qty){ // 옵션 상품 정보 가져옴 if(code==''){ return; } $.get("ajax.opt_sel_get.php?code="+code+"&mode="+mode+"&ct_qty="+ct_qty+"&ev_code=<?php echo $ev_code;?>",function(rtn){ $v = rtn.split("§§§"); $pcode = $v[0]; $rtn = $v[1]; if($pcode==0){ if($rtn!=''){ alert($rtn); } return; } // 품절 상품일 경우 처리 $dflag = 0; $(".opt_sel_class").find("input[name='opt_code[]']").each(function(){ // 기존 옵션 중복 체크 if($pcode==$(this).val()){ $dflag = 1; } }); if($dflag==0){ $(".opt_sel_class").append($rtn); sum_opt_price(); } }); }
function sum_opt_price(){ // 합산처리 $sum_price = 0; $cnt = 0; $(".sit_sel_option_class").each(function(){ $price = $(this).find("input[name='opt_price[]']").val(); $qty = $(this).find("input[name='qty[]']").val(); $sum_price = $sum_price + (parseInt($price)*parseInt($qty)); $cnt++; }); //alert($sum_price); $(".all_qty_class").html($cnt); $(".all_price_class").html(formatCurrency($sum_price)); } </script>
|