PluginProbe
Welcart e-Commerce / 1.3.2
Welcart e-Commerce v1.3.2
2.12.4 2.12.3 2.11.35 2.12.2 2.12.1 2.11.34 2.11.33 2.11.32 2.11.31 2.11.30 1.3.16 1.3.17 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 All 292 releases
usc-e-shop / functions / template_func.php

template_func.php in Welcart e-Commerce 1.3.2, at functions/template_func.php

3,140 lines 106.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 function usces_guid_tax( $out = '' ){
3 global $usces;
4
5 if( $out == 'return' ){
6 return $usces->getGuidTax();
7 }else{
8 echo $usces->getGuidTax();
9 }
10 }
11
12 function usces_currency_symbol( $out = '' ) {
13 global $usces;
14
15 if( $out == 'return' ){
16 return $usces->getCurrencySymbol();
17 }else{
18 echo esc_html($usces->getCurrencySymbol());
19 }
20 }
21
22 function usces_is_error_message() {
23 global $usces;
24 if ( $usces->error_message != '' )
25 return true;
26 else
27 return false;
28 }
29
30 function usces_is_item( $post_id = NULL ) {
31 if( NULL == $post_id ){
32 global $post;
33 }else{
34 $post = get_post($post_id);
35 }
36 if ( isset($post->post_mime_type) && $post->post_mime_type == 'item' )
37 return true;
38 else
39 return false;
40 }
41
42 function usces_the_itemCode( $out = '' ) {
43 global $post;
44 $post_id = $post->ID;
45
46 $str = get_post_meta($post_id, '_itemCode', true);
47
48 if( $out == 'return' ){
49 return $str;
50 }else{
51 echo esc_html($str);
52 }
53 }
54
55 function usces_the_itemName( $out = '', $post = NULL ) {
56 if($post == NULL)
57 global $post;
58
59 $post_id = $post->ID;
60
61 $str = get_post_meta($post_id, '_itemName', true);
62
63 if( $out == 'return' ){
64 return $str;
65 }else{
66 echo esc_html($str);
67 }
68 }
69
70 function usces_the_point_rate( $out = '' ){
71 global $post;
72 $post_id = $post->ID;
73
74 $str = get_post_meta($post_id, '_itemPointrate', true);
75 $rate = (int)$str;
76
77 if( $out == 'return' ){
78 return $rate;
79 }else{
80 echo esc_html($rate);
81 }
82 }
83
84 function usces_the_shipment_aim( $out = '' ){
85 global $post;
86 $post_id = $post->ID;
87
88 $str = get_post_meta($post_id, '_itemShipping', true);
89 $no = (int)$str;
90 if( 0 === $no ) return;
91
92 $rules = get_option('usces_shipping_rule');
93
94 if( $out == 'return' ){
95 return $rules[$no];
96 }else{
97 echo esc_html($rules[$no]);
98 }
99 }
100
101 function usces_the_item(){
102 global $usces, $post;
103
104 $usces->itemskus = $usces->get_skus($post->ID, 'sort');
105 $usces->itemopts = usces_get_opts($post->ID, 'sort');
106
107 return;
108 }
109
110 function usces_get_itemMeta($metakey, $post_id, $out = ''){
111 $str = get_post_meta($post_id, $metakey, true);
112 $value = $str;
113
114 if( $out == 'return' ){
115 return $value;
116 }else{
117 echo esc_html($value);
118 }
119 }
120
121 function usces_sku_num() {
122 global $usces;
123
124 return count($usces->itemskus);
125 }
126
127 function usces_is_skus() {
128 global $usces;
129
130 if( 0 < count($usces->itemskus) ){
131 reset($usces->itemskus);
132 $usces->itemsku = array();
133 return true;
134 }else{
135 return false;
136 }
137 }
138
139 function usces_have_skus() {
140 global $usces;
141
142 $res_each = each($usces->itemskus);
143 $usces->itemsku = $res_each['value'];
144 if($usces->itemsku) {
145 return true;
146 } else {
147 return false;
148 }
149 }
150
151 function usces_the_itemSku($out = '') {
152 global $usces;
153
154 if($out == 'return'){
155 return $usces->itemsku['code'];
156 }else{
157 echo esc_attr($usces->itemsku['code']);
158 }
159 }
160
161 function usces_the_itemPrice($out = '') {
162 global $usces;
163 if($out == 'return'){
164 return $usces->itemsku['price'];
165 }else{
166 echo number_format($usces->itemsku['price']);
167 }
168 }
169
170 function usces_the_itemCprice($out = '') {
171 global $usces;
172 if($out == 'return'){
173 return $usces->itemsku['cprice'];
174 }else{
175 echo number_format($usces->itemsku['cprice']);
176 }
177 }
178
179 function usces_the_itemPriceCr($out = '') {
180 global $usces;
181 $res = esc_html($usces->get_currency($usces->itemsku['price'], true, false ));
182
183 if($out == 'return'){
184 return $res;
185 }else{
186 echo $res;
187 }
188 }
189
190 function usces_the_itemCpriceCr($out = '') {
191 global $usces;
192 $res = esc_html($usces->get_currency($usces->itemsku['cprice'], true, false ));
193
194 if($out == 'return'){
195 return $res;
196 }else{
197 echo $res;
198 }
199 }
200
201 function usces_crcode( $out = '' ) {
202 global $usces;
203 $res = esc_html($usces->get_currency_code());
204
205 if($out == 'return'){
206 return $res;
207 }else{
208 echo __($res, 'usces');
209 }
210 }
211
212 function usces_crsymbol( $out = '', $js = NULL ) {
213 global $usces;
214 $res = $usces->getCurrencySymbol();
215 if( 'js' === $js && '&yen;' == $res ){
216 $res = mb_convert_encoding($res, 'UTF-8', 'HTML-ENTITIES');
217 }
218
219 if($out == 'return'){
220 return $res;
221 }else{
222 echo esc_html($res);
223 }
224 }
225
226 function usces_the_itemZaiko( $out = '' ) {
227 global $usces;
228 $num = (int)$usces->itemsku['stock'];
229
230 if( 1 < $num || ( 0 === (int)$usces->itemsku['stocknum'] && !WCUtils::is_blank($usces->itemsku['stocknum']) ) ){
231 $res = $usces->zaiko_status[$num];
232 }elseif( 1 >= $num && ( 0 === (int)$usces->itemsku['stocknum'] && !WCUtils::is_blank($usces->itemsku['stocknum']) ) ){
233 $res = $usces->zaiko_status[2];
234 }else{
235 $res = $usces->zaiko_status[$num];
236 }
237
238 if( $out == 'return' ){
239 return $res;
240 }else{
241 echo esc_html($res);
242 }
243 }
244
245 function usces_the_itemZaikoStatus( $out = '' ) {
246 global $usces;
247
248 if( $out == 'return' ){
249 return usces_get_itemZaiko( 'name' );
250 }else{
251 echo esc_html(usces_get_itemZaiko( 'name' ));
252 }
253 }
254
255 function usces_get_itemZaiko( $field = 'name', $post_id=NULL, $sku=NULL ) {
256 global $usces;
257 if( empty($sku) ){
258 $num = (int)$usces->itemsku['stock'];
259 }else{
260 $skus = $usces->get_skus( $post_id, 'code' );
261 $num = (int)$skus[$sku]['stock'];
262 }
263
264 if( 'id' == $field ){
265 $res = $num;
266 }else{
267 $res = $usces->zaiko_status[$num];
268 }
269 return $res;
270 }
271
272 function usces_the_itemZaikoNum( $out = '' ) {
273 global $usces;
274 $num = $usces->itemsku['stocknum'];
275
276 if( $out == 'return' ){
277 return $num;
278 }else{
279 echo number_format($num);
280 }
281 }
282
283 function usces_the_itemSkuDisp( $out = '' ) {
284 global $usces;
285
286 if( $out == 'return' ){
287 return $usces->itemsku['name'];
288 }else{
289 echo esc_html($usces->itemsku['name']);
290 }
291 }
292
293 function usces_the_itemSkuUnit( $out = '' ) {
294 global $usces;
295
296 if( $out == 'return' ){
297 return $usces->itemsku['unit'];
298 }else{
299 echo esc_html($usces->itemsku['unit']);
300 }
301 }
302
303 function usces_the_firstSku( $out = '' ) {
304 global $post, $usces;
305 $post_id = $post->ID;
306
307
308 $skus = $usces->get_skus( $post_id );
309
310
311 if($out == 'return'){
312 return $skus[0]['code'];
313 }else{
314 echo esc_html($skus[0]['code']);
315 }
316 }
317
318 function usces_the_firstPrice( $out = '', $post = NULL ) {
319 global $usces;
320 if($post == NULL)
321 global $post;
322 $post_id = $post->ID;
323
324 $skus = $usces->get_skus( $post_id );
325
326 if($out == 'return'){
327 return $skus[0]['price'];
328 }else{
329 echo number_format($skus[0]['price']);
330 }
331 }
332
333 function usces_the_firstCprice( $out = '', $post = NULL ) {
334 global $usces;
335 if($post == NULL)
336 global $post;
337 $post_id = $post->ID;
338
339 $skus = $usces->get_skus( $post_id );
340
341 if($out == 'return'){
342 return $skus[0]['cprice'];
343 }else{
344 echo number_format($skus[0]['cprice']);
345 }
346 }
347
348 function usces_the_firstPriceCr( $out = '', $post = NULL ) {
349 global $usces;
350 if($post == NULL)
351 global $post;
352 $post_id = $post->ID;
353
354 $skus = $usces->get_skus( $post_id );
355 $res = esc_html($usces->get_currency($skus[0]['price'], true, false ));
356
357 if($out == 'return'){
358 return $res;
359 }else{
360 echo $res;
361 }
362 }
363
364 function usces_the_firstCpriceCr( $out = '', $post = NULL ) {
365 global $usces;
366 if($post == NULL)
367 global $post;
368 $post_id = $post->ID;
369
370 $skus = $usces->get_skus( $post_id );
371 $res = esc_html($usces->get_currency($skus[0]['cprice'], true, false ));
372
373 if($out == 'return'){
374 return $res;
375 }else{
376 echo $res;
377 }
378 }
379
380 function usces_the_firstZaiko( $out = '' ) {
381 global $post, $usces;
382 $post_id = $post->ID;
383
384
385 $skus = $usces->get_skus( $post_id );
386
387 if($out == 'return'){
388 return $skus[0]['stock'];
389 }else{
390 echo esc_html($skus[0]['stock']);
391 }
392 }
393
394 function usces_the_lastSku( $out = '' ) {
395 global $post, $usces;
396 $post_id = $post->ID;
397
398
399 $skus = $usces->get_skus( $post_id );
400 $sku = end($skus);
401
402 if($out == 'return'){
403 return $sku['code'];
404 }else{
405 echo esc_html($sku['code']);
406 }
407 }
408
409 function usces_the_lastPrice( $out = '' ) {
410 global $post, $usces;
411 $post_id = $post->ID;
412
413
414 $skus = $usces->get_skus( $post_id );
415 $sku = end($skus);
416
417 if($out == 'return'){
418 return $sku['price'];
419 }else{
420 echo number_format($sku['price']);
421 }
422 }
423
424 function usces_the_lastZaiko( $out = '' ) {
425 global $post, $usces;
426 $post_id = $post->ID;
427
428
429 $skus = $usces->get_skus( $post_id );
430 $sku = end($skus);
431
432 if($out == 'return'){
433 return $sku['stock'];
434 }else{
435 echo esc_html($sku['stock']);
436 }
437 }
438
439 function usces_have_zaiko(){
440 global $post, $usces;
441 return $usces->is_item_zaiko( $post->ID, $usces->itemsku['code'] );
442 }
443
444 function usces_have_zaiko_anyone( $post_id = NULL ){
445 global $post, $usces;
446 if( NULL == $post_id ) $post_id = $post->ID;
447
448 $skus = $usces->get_skus($post_id);
449 $status = false;
450 foreach($skus as $sku){
451 if( (WCUtils::is_blank($sku['stocknum']) || 0 < (int)$sku['stocknum']) && 2 > (int)$sku['stock']) {
452 $status = true;
453 break;
454 }
455 }
456 return $status;
457 }
458
459 function usces_is_gptekiyo( $post_id, $sku, $quant ){
460 global $usces;
461 return $usces->is_gptekiyo( $post_id, $sku, $quant );
462 }
463 function usces_the_itemGpExp( $out = '' ) {
464 global $post, $usces;
465 $post_id = $post->ID;
466 $sku = $usces->itemsku['code'];
467 $GpN1 = $usces->getItemGpNum1($post_id);
468 $GpN2 = $usces->getItemGpNum2($post_id);
469 $GpN3 = $usces->getItemGpNum3($post_id);
470 $GpD1 = $usces->getItemGpDis1($post_id);
471 $GpD2 = $usces->getItemGpDis2($post_id);
472 $GpD3 = $usces->getItemGpDis3($post_id);
473 $unit = $usces->getItemSkuUnit($post_id, $sku);
474 $price = $usces->getItemPrice($post_id, $sku);
475
476 if( ($usces->itemsku['gp'] == 0) || empty($GpN1) || empty($GpD1) ){
477 return;
478 }
479 $html = "<dl class='itemGpExp'>\n<dt>" . apply_filters( 'usces_filter_itemGpExp_title', __('Business package discount','usces')) . "</dt>\n<dd>\n<ul>\n";
480 if(!empty($GpN1) && !empty($GpD1)) {
481 if(empty($GpN2) || empty($GpD2)) {
482 $html .= "<li>";
483 $html .= sprintf( __('<span class=%6$s>%5$s%1$s</span>%2$s par 1%3$s for more than %4$s%3$s', 'usces'),
484 number_format(round($price * (100 - $GpD1) / 100)),
485 $usces->getGuidTax(),
486 esc_html($unit),
487 $GpN1,
488 __('$', 'usces'),
489 "'price'"
490 );
491 $html .= "</li>\n";
492 } else {
493
494 $html .= "<li>";
495 $html .= sprintf( __('<span class=%7$s>%6$s%1$s</span>%2$s par 1%3$s for %4$s-%5$s%3$s', 'usces'),
496 number_format(round($price * (100 - $GpD1) / 100)),
497 $usces->getGuidTax(),
498 esc_html($unit),
499 $GpN1,
500 $GpN2-1,
501 __('$', 'usces'),
502 "'price'"
503 );
504 $html .= "</li>\n";
505 if(empty($GpN3) || empty($GpD3)) {
506 //$html .= "<li>" . $GpN2 . $unit . __('for more than ','usces') . "1" . $unit . __('par','usces') . "<span class='price'>" . __('$', 'usces') . number_format(round($price * (100 - $GpD2) / 100)) . $usces->getGuidTax() . "</span></li>\n";
507 $html .= "<li>";
508 $html .= sprintf( __('<span class=%6$s>%5$s%1$s</span>%2$s par 1%3$s for more than %4$s%3$s', 'usces'),
509 number_format(round($price * (100 - $GpD2) / 100)),
510 $usces->getGuidTax(),
511 esc_html($unit),
512 $GpN2,
513 __('$', 'usces'),
514 "'price'"
515 );
516 $html .= "</li>\n";
517 } else {
518 $html .= "<li>";
519 $html .= sprintf( __('<span class=%7$s>%6$s%1$s</span>%2$s par 1%3$s for %4$s-%5$s%3$s', 'usces'),
520 number_format(round($price * (100 - $GpD2) / 100)),
521 $usces->getGuidTax(),
522 esc_html($unit),
523 $GpN2,
524 $GpN3-1,
525 __('$', 'usces'),
526 "'price'"
527 );
528 $html .= "</li>\n";
529 $html .= "<li>";
530 $html .= sprintf( __('<span class=%6$s>%5$s%1$s</span>%2$s par 1%3$s for more than %4$s%3$s', 'usces'),
531 number_format(round($price * (100 - $GpD3) / 100)),
532 $usces->getGuidTax(),
533 esc_html($unit),
534 $GpN3,
535 __('$', 'usces'),
536 "'price'"
537 );
538 $html .= "</li>\n";
539 }
540 }
541 }
542 $html .= "</ul></dd></dl>";
543
544 $html = apply_filters('usces_filter_itemGpExp', $html);
545
546 if( $out == 'return' ){
547 return $html;
548 }else{
549 echo $html;
550 }
551 }
552
553 function usces_the_itemQuant( $out = '' ) {
554 global $usces, $post;
555 $post_id = $post->ID;
556 $sku = esc_attr(urlencode($usces->itemsku['code']));
557 $value = isset( $_SESSION['usces_singleitem']['quant'][$post_id][$sku] ) ? $_SESSION['usces_singleitem']['quant'][$post_id][$sku] : 1;
558 $quant = "<input name=\"quant[{$post_id}][" . $sku . "]\" type=\"text\" id=\"quant[{$post_id}][" . $sku . "]\" class=\"skuquantity\" value=\"" . $value . "\" onKeyDown=\"if (event.keyCode == 13) {return false;}\" />";
559 $html = apply_filters('usces_filter_the_itemQuant', $quant, $post);
560
561 if( $out == 'return' ){
562 return $html;
563 }else{
564 echo $html;
565 }
566 }
567
568 function usces_the_itemSkuButton($value, $type=0, $out = '') {
569 global $usces, $post;
570 $post_id = $post->ID;
571 $zaikonum = $usces->itemsku['stocknum'];
572 $zaiko_status = $usces->itemsku['stock'];
573 $gptekiyo = $usces->itemsku['gp'];
574 $skuPrice = $usces->getItemPrice($post_id, $usces->itemsku['code']);
575 $value = esc_attr(apply_filters( 'usces_filter_incart_button_label', $value));
576 $sku = esc_attr(urlencode($usces->itemsku['code']));
577
578 if($type == 1)
579 $type = 'button';
580 else
581 $type = 'submit';
582
583 $html = "<input name=\"zaikonum[{$post_id}][{$sku}]\" type=\"hidden\" id=\"zaikonum[{$post_id}][{$sku}]\" value=\"{$zaikonum}\" />\n";
584 $html .= "<input name=\"zaiko[{$post_id}][{$sku}]\" type=\"hidden\" id=\"zaiko[{$post_id}][{$sku}]\" value=\"{$zaiko_status}\" />\n";
585 $html .= "<input name=\"gptekiyo[{$post_id}][{$sku}]\" type=\"hidden\" id=\"gptekiyo[{$post_id}][{$sku}]\" value=\"{$gptekiyo}\" />\n";
586 $html .= "<input name=\"skuPrice[{$post_id}][{$sku}]\" type=\"hidden\" id=\"skuPrice[{$post_id}][{$sku}]\" value=\"{$skuPrice}\" />\n";
587 if( $usces->use_js ){
588 $html .= "<input name=\"inCart[{$post_id}][{$sku}]\" type=\"{$type}\" id=\"inCart[{$post_id}][{$sku}]\" class=\"skubutton\" value=\"{$value}\" onclick=\"return uscesCart.intoCart('{$post_id}','{$sku}')\" />";
589 }else{
590 $html .= "<a name=\"cart_button\"></a><input name=\"inCart[{$post_id}][{$sku}]\" type=\"{$type}\" id=\"inCart[{$post_id}][{$sku}]\" class=\"skubutton\" value=\"{$value}\" />";
591 }
592 $html .= "<input name=\"usces_referer\" type=\"hidden\" value=\"" . $_SERVER['REQUEST_URI'] . "\" />\n";
593
594 if( $out == 'return' ){
595 return $html;
596 }else{
597 echo $html;
598 }
599 }
600
601 function usces_direct_intoCart($post_id, $sku, $force=false, $value=NULL, $options=NULL, $out = '') {
602 global $usces;
603 if( empty($value) )
604 $value = __('Add To Cart', 'usces');
605 $skus = $usces->get_skus( $post_id, 'code' );
606 $zaikonum = $skus[$sku]['stocknum'];
607 $zaiko = $skus[$sku]['stock'];
608 $gptekiyo = $skus[$sku]['gp'];
609 $skuPrice = $skus[$sku]['price'];
610 $enc_sku = urlencode($sku);
611
612 $html = "<form action=\"" . USCES_CART_URL . "\" method=\"post\" name=\"" . $post_id."-". $enc_sku . "\">\n";
613 $html .= "<input name=\"zaikonum[{$post_id}][{$enc_sku}]\" type=\"hidden\" id=\"zaikonum[{$post_id}][{$enc_sku}]\" value=\"{$zaikonum}\" />\n";
614 $html .= "<input name=\"zaiko[{$post_id}][{$enc_sku}]\" type=\"hidden\" id=\"zaiko[{$post_id}][{$enc_sku}]\" value=\"{$zaiko}\" />\n";
615 $html .= "<input name=\"gptekiyo[{$post_id}][{$enc_sku}]\" type=\"hidden\" id=\"gptekiyo[{$post_id}][{$enc_sku}]\" value=\"{$gptekiyo}\" />\n";
616 $html .= "<input name=\"skuPrice[{$post_id}][{$enc_sku}]\" type=\"hidden\" id=\"skuPrice[{$post_id}][{$enc_sku}]\" value=\"{$skuPrice}\" />\n";
617 $html .= "<a name=\"cart_button\"></a><input name=\"inCart[{$post_id}][{$enc_sku}]\" type=\"submit\" id=\"inCart[{$post_id}][{$enc_sku}]\" class=\"skubutton\" value=\"{$value}\" " . apply_filters('usces_filter_direct_intocart_button', NULL, $post_id, $sku, $force, $options) . " />";
618 $html .= "<input name=\"usces_referer\" type=\"hidden\" value=\"" . $_SERVER['REQUEST_URI'] . "\" />\n";
619 if( $force )
620 $html .= "<input name=\"usces_force\" type=\"hidden\" value=\"incart\" />\n";
621 $html = apply_filters('usces_filter_single_item_inform', $html);
622 $html .= "</form>";
623 $html .= '<div class="direct_error_message">' . usces_singleitem_error_message($post_id, $sku, 'return') . '</div>'."\n";
624
625 if( $out == 'return' ){
626 return $html;
627 }else{
628 echo $html;
629 }
630 }
631
632
633 function usces_the_itemImage($number = 0, $width = 60, $height = 60, $post = '', $out = '', $media = 'item' ) {
634 global $usces;
635 $ptitle = $number;
636 if($post == '') global $post;
637
638 $post_id = $post->ID;
639
640 if( $ptitle && 0 == (int)$number ){
641
642 $picposts = query_posts(array('post_type'=>'attachment','name'=>$ptitle));
643 $pictid = empty($picposts) ? 0 : $picposts[0]->ID;
644 $html = wp_get_attachment_image( $pictid, array($width, $height), false );
645 if( 'item' == $media ){
646 $alt = 'alt="'.esc_attr($code[0]).'"';
647 $alt = apply_filters('usces_filter_img_alt', $alt, $post_id, $pictid);
648 $html = preg_replace('/alt=\"[^\"]*\"/', $alt, $html);
649 $title = 'title="'.esc_attr($name[0]).'"';
650 $title = apply_filters('usces_filter_img_title', $title, $post_id, $pictid);
651 $html = preg_replace('/title=\"[^\"]+\"/', $title, $html);
652 $html = apply_filters( 'usces_filter_main_img', $html, $post_id, $pictid);
653 }
654
655 }else{
656
657
658 $code = get_post_meta($post_id, '_itemCode', true);
659 if(!$code) return false;
660
661 $name = get_post_meta($post_id, '_itemName', true);
662
663 if( 0 == $number ){
664 $pictid = (int)$usces->get_mainpictid($code);
665 $html = wp_get_attachment_image( $pictid, array($width, $height), true );//'<img src="#" height="60" width="60" alt="" />';
666 if( 'item' == $media ){
667 $alt = 'alt="'.esc_attr($code).'"';
668 $alt = apply_filters('usces_filter_img_alt', $alt, $post_id, $pictid);
669 $html = preg_replace('/alt=\"[^\"]*\"/', $alt, $html);
670 $title = 'title="'.esc_attr($name).'"';
671 $title = apply_filters('usces_filter_img_title', $title, $post_id, $pictid);
672 $html = preg_replace('/title=\"[^\"]+\"/', $title, $html);
673 $html = apply_filters( 'usces_filter_main_img', $html, $post_id, $pictid);
674 }
675 }else{
676 $pictids = $usces->get_pictids($code);
677 $ind = $number - 1;
678 $pictid = ( isset($pictids[$ind]) && (int)$pictids[$ind] ) ? $pictids[$ind] : 0;
679 $html = wp_get_attachment_image( $pictid, array($width, $height), false );//'<img src="#" height="60" width="60" alt="" />';
680 if( 'item' == $media ){
681 $alt = 'alt="'.esc_attr($code).'"';
682 $alt = apply_filters('usces_filter_img_alt', $alt, $post_id, $pictid);
683 $html = preg_replace('/alt=\"[^\"]*\"/', $alt, $html);
684 $title = 'title="'.esc_attr($name).'"';
685 $title = apply_filters('usces_filter_img_title', $title, $post_id, $pictid);
686 $html = preg_replace('/title=\"[^\"]+\"/', $title, $html);
687 $html = apply_filters( 'usces_filter_sub_img', $html, $post_id, $pictid);
688 }
689 }
690 }
691
692 if($out == 'return'){
693 return $html;
694 }else{
695 echo $html;
696 }
697 }
698
699 function usces_the_itemImageURL($number = 0, $out = '', $post = '' ) {
700 global $usces;
701 $ptitle = $number;
702
703 if( $ptitle && is_string($number) ){
704 $picposts = query_posts(array('post_type'=>'attachment','name'=>$ptitle));
705 $pictid = empty($picposts) ? 0 : $picposts[0]->ID;
706 $pictid = $picposts[0]->ID;
707 $html = wp_get_attachment_url( $pictid );
708 }else{
709
710 if($post == '') global $post;
711 $post_id = $post->ID;
712
713 $code = get_post_meta($post_id, '_itemCode', true);
714 if(!$code) return false;
715 $name = get_post_meta($post_id, '_itemName', true);
716 if( 0 == $number ){
717 $pictid = (int)$usces->get_mainpictid($code);
718 $html = wp_get_attachment_url( $pictid );
719 }else{
720 $pictids = $usces->get_pictids($code);
721 $ind = $number - 1;
722 $pictid = ( isset($pictids[$ind]) && (int)$pictids[$ind] ) ? $pictids[$ind] : 0;
723 $html = wp_get_attachment_url( $pictid );
724 }
725 }
726
727 if($out == 'return'){
728 return $html;
729 }else{
730 echo $html;
731 }
732 }
733
734 function usces_the_itemImageCaption($number = 0, $post = '', $out = '' ) {
735 global $usces;
736 $ptitle = $number;
737
738 if( $ptitle && 0 == (int)$number ){
739
740 $picposts = query_posts(array('post_type'=>'attachment','name'=>$ptitle));
741 $excerpt = empty($picposts) ? '' : $picposts[0]->post_excerpt;
742
743 }else{
744
745 if($post == '') global $post;
746
747 $post_id = $post->ID;
748
749 $code = get_post_meta($post_id, '_itemCode', true);
750 if(!$code) return false;
751
752 $name = get_post_meta($post_id, '_itemName', true);
753
754 if( 0 == $number ){
755 $pictid = $usces->get_mainpictid($code);
756 $attach_ob = get_post($pictid);
757 }else{
758 $pictids = $usces->get_pictids($code);
759 $ind = $number - 1;
760 $attach_ob = get_post($pictids[$ind]);
761 }
762 $excerpt = $attach_ob->post_excerpt;
763 }
764
765 if($out == 'return'){
766 return $excerpt;
767 }else{
768 echo esc_html($excerpt);
769 }
770 }
771
772 function usces_the_itemImageDescription($number = 0, $post = '', $out = '' ) {
773 global $usces;
774 $ptitle = $number;
775
776 if( $ptitle && 0 == (int)$number ){
777
778 $picposts = query_posts(array('post_type'=>'attachment','name'=>$ptitle));
779 $excerpt = empty($picposts) ? '' : $picposts[0]->post_content;
780
781 }else{
782
783 if($post == '') global $post;
784
785 $post_id = $post->ID;
786
787 $code = get_post_meta($post_id, '_itemCode', true);
788 if(!$code) return false;
789
790 $name = get_post_meta($post_id, '_itemName', true);
791
792 if( 0 == $number ){
793 $pictid = $usces->get_mainpictid($code);
794 $attach_ob = get_post($pictid);
795 }else{
796 $pictids = $usces->get_pictids($code);
797 $ind = $number - 1;
798 $attach_ob = get_post($pictids[$ind]);
799 }
800 $excerpt = $attach_ob->post_content;
801 }
802
803 if($out == 'return'){
804 return $excerpt;
805 }else{
806 echo esc_html($excerpt);
807 }
808 }
809
810 function usces_get_itemSubImageNums() {
811 global $post, $usces;
812 $post_id = $post->ID;
813 $res = array();
814
815 $code = get_post_meta($post_id, '_itemCode', true);
816 if(!$code) return false;
817 $name = get_post_meta($post_id, '_itemName', true);
818 $pictids = $usces->get_pictids($code);
819 for($i=1; $i<=count($pictids); $i++){
820 $res[] = $i;
821 }
822 return $res;
823 }
824
825 function usces_is_options() {
826 global $usces;
827
828 if( 0 < count($usces->itemopts) ){
829 reset($usces->itemopts);
830 $usces->itemopt = array();
831 return true;
832 }else{
833 return false;
834 }
835 }
836
837 function usces_have_options() {
838 global $usces;
839
840 $res_each = each($usces->itemopts);
841 $usces->itemopt = $res_each['value'];
842 if($usces->itemopt) {
843 return true;
844 } else {
845 return false;
846 }
847 }
848
849 function usces_getItemOptName() {
850 global $usces;
851 return $usces->itemopt['name'];
852 }
853
854 function usces_the_itemOptName($out = '') {
855 global $usces;
856
857 if($out == 'return'){
858 return $usces->itemopt['name'];
859 }else{
860 echo esc_html($usces->itemopt['name']);
861 }
862 }
863
864 function usces_the_itemOption( $name, $label = '#default#', $out = '' ) {
865 global $post, $usces;
866 $post_id = $post->ID;
867
868 if($label == '#default#')
869 $label = $name;
870
871 $opts = usces_get_opts($post_id, 'name');
872 if(!$opts)
873 return false;
874
875 $opt = $opts[$name];
876 $means = (int)$opt['means'];
877 $essential = (int)$opt['essential'];
878
879 $html = '';
880 $sku = esc_attr(urlencode($usces->itemsku['code']));
881 $optcode = esc_attr(urlencode($name));
882 $name = esc_attr($name);
883 $label = esc_attr($label);
884 $session_value = isset( $_SESSION['usces_singleitem']['itemOption'][$post_id][$sku][$optcode] ) ? $_SESSION['usces_singleitem']['itemOption'][$post_id][$sku][$optcode] : NULL;
885 //20110715ysk start 0000208
886 $html .= "\n<label for='itemOption[{$post_id}][{$sku}][{$optcode}]' class='iopt_label'>{$label}</label>\n";
887 //20110715ysk end
888 //20100914ysk start
889 //if($means < 2){
890 switch($means) {
891 case 0://Single-select
892 case 1://Multi-select
893 //20100914ysk end
894 $selects = explode("\n", $opt['value']);
895 $multiple = ($means === 0) ? '' : ' multiple';
896 $multiple_array = ($means == 0) ? '' : '[]';//20110629ysk 0000190
897 //$html .= "\n<label for='itemOption[{$post_id}][{$sku}][{$name}]' class='iopt_label'>{$label}</label>\n";
898 //20110629ysk start 0000190
899 //$html .= "\n<select name='itemOption[{$post_id}][{$sku}][{$name}]' id='itemOption[{$post_id}][{$sku}][{$name}]' class='iopt_select'{$multiple} onKeyDown=\"if (event.keyCode == 13) {return false;}\">\n";
900 $html .= "\n<select name='itemOption[{$post_id}][{$sku}][{$optcode}]{$multiple_array}' id='itemOption[{$post_id}][{$sku}][{$optcode}]' class='iopt_select'{$multiple} onKeyDown=\"if (event.keyCode == 13) {return false;}\">\n";
901 //20110629ysk end
902 if($essential == 1){
903 if( '#NONE#' == $session_value || NULL == $session_value )
904 $selected = ' selected="selected"';
905 else
906 $selected = '';
907 $html .= "\t<option value='#NONE#'{$selected}>" . __('Choose','usces') . "</option>\n";
908 }
909 $i=0;
910 foreach($selects as $v) {
911 $v = trim($v);
912 if( ($i == 0 && $essential == 0 && NULL == $session_value) || esc_attr($v) == $session_value )
913 $selected = ' selected="selected"';
914 else
915 $selected = '';
916 $html .= "\t<option value='" . esc_attr($v) . "'{$selected}>" . esc_attr($v) . "</option>\n";
917 $i++;
918 }
919 $html .= "</select>\n";
920 //20100914ysk start
921 //}else{
922 break;
923 case 2://Text
924 //20100914ysk end
925 $html .= "\n<input name='itemOption[{$post_id}][{$sku}][{$optcode}]' type='text' id='itemOption[{$post_id}][{$sku}][{$optcode}]' class='iopt_text' onKeyDown=\"if (event.keyCode == 13) {return false;}\" value=\"" . esc_attr($session_value) . "\" />\n";
926 //20100914ysk start
927 break;
928 case 5://Text-area
929 $html .= "\n<textarea name='itemOption[{$post_id}][{$sku}][{$optcode}]' id='itemOption[{$post_id}][{$sku}][{$optcode}]' class='iopt_textarea'>" . esc_attr($session_value) . "</textarea>\n";
930 break;
931 //20100914ysk end
932 }
933
934 $html = apply_filters('usces_filter_the_itemOption', $html, $opts, $name, $label, $post_id, $usces->itemsku['code']);
935
936 if( $out == 'return' ){
937 return $html;
938 }else{
939 echo $html;
940 }
941 }
942
943 function usces_the_cart() {
944 global $usces;
945
946 $usces->display_cart();
947
948 }
949
950 function usces_is_cart() {
951 global $usces;
952
953 if($usces->cart->num_row() > 0)
954 if( apply_filters('usces_is_cart_check', true) ) {
955 return true;
956 }else{
957 return false;
958 }
959 else
960 return false;
961
962 }
963
964 function usces_is_category( $str ) {
965 global $post;
966
967 //if( $post->post_type != 'post' ) return false;
968
969 $cat = get_the_category();
970 $slugs = array();
971 foreach($cat as $value){
972 $slugs[] = $value->slug;
973 }
974
975 $str = utf8_uri_encode($str);
976
977 if( in_array( $str, $slugs) )
978 return true;
979 else
980 return false;
981 }
982
983 function usces_the_pref( $flag, $out = '' ){
984 global $usces;
985
986 $usces_members = $usces->get_member();
987 $usces_entries = $usces->cart->get_entry();
988 $name = esc_attr($flag) . '[pref]';
989 $pref = $usces_entries[$flag]['pref'];
990 if( 'member' == $flag)
991 $pref = $usces_members['pref'];
992
993 $html = "<select name='" . esc_attr($name) . "' id='pref' class='pref'>\n";
994 // $prefs = get_option('usces_pref');
995 //20110331ysk start
996 //$prefs = $usces->options['province'];
997 $prefs = get_usces_states(usces_get_local_addressform());
998 //20110331ysk end
999 foreach($prefs as $value) {
1000 $selected = ($pref == $value) ? ' selected="selected"' : '';
1001 $html .= "\t<option value='" . esc_attr($value) . "'{$selected}>" . esc_html($value) . "</option>\n";
1002 }
1003 $html .= "</select>\n";
1004
1005 if( $out == 'return' ){
1006 return $html;
1007 }else{
1008 echo $html;
1009 }
1010 }
1011
1012 function usces_the_company_name(){
1013 global $usces;
1014 echo esc_html($usces->options['company_name']);
1015 }
1016
1017 function usces_the_zip_code(){
1018 global $usces;
1019 echo esc_html($usces->options['zip_code']);
1020 }
1021
1022 function usces_the_address1(){
1023 global $usces;
1024 echo esc_html($usces->options['address1']);
1025 }
1026
1027 function usces_the_address2(){
1028 global $usces;
1029 echo esc_html($usces->options['address2']);
1030 }
1031
1032 function usces_the_tel_number(){
1033 global $usces;
1034 echo esc_html($usces->options['tel_number']);
1035 }
1036
1037 function usces_the_fax_number(){
1038 global $usces;
1039 echo esc_html($usces->options['fax_number']);
1040 }
1041
1042 function usces_the_inquiry_mail(){
1043 global $usces;
1044 echo esc_html($usces->options['inquiry_mail']);
1045 }
1046
1047 function usces_the_postage_privilege(){
1048 global $usces;
1049 echo esc_html($usces->options['postage_privilege']);
1050 }
1051
1052 function usces_the_start_point(){
1053 global $usces;
1054 echo esc_html($usces->options['start_point']);
1055 }
1056
1057 function usces_point_rate( $post_id = NULL, $out = '' ){
1058 global $usces;
1059 if( $post_id == NULL ){
1060 $rate = $usces->options['point_rate'];
1061 }else{
1062 $str = get_post_meta($post_id, '_itemPointrate', true);
1063 $rate = (int)$str;
1064 }
1065 if( $out == 'return' ){
1066 return $rate;
1067 }else{
1068 echo $rate;
1069 }
1070 }
1071
1072 function usces_get_point( $post_id, $sku_code ){
1073 global $usces;
1074 if( $post_id == NULL ){
1075 $rate = $usces->options['point_rate'];
1076 }else{
1077 $str = get_post_meta($post_id, '_itemPointrate', true);
1078 $rate = (int)$str;
1079 }
1080
1081 $skus = $usces->get_skus($post_id, 'code');
1082 $point = ceil($skus[$sku_code]['price'] * $rate / 100);
1083
1084 return $point;
1085 }
1086
1087 function usces_the_payment_method( $value = '', $out = '' ){
1088 global $usces;
1089 $payments = usces_get_system_option( 'usces_payment_method', 'sort' );
1090 $payments = apply_filters('usces_fiter_the_payment_method', $payments, $value);
1091 //if( empty($payments) ) return; 20120328ysk 0000454
1092
1093 $cart = $usces->cart->get_cart();
1094 //$charging_type = $usces->getItemChargingType($cart[0]['post_id']);
1095 $charging_type = $usces->getItemChargingType($cart[0]['post_id'], $cart);
1096 $html = "<dl>\n";
1097 $list = '';
1098 $payment_ct = count($payments);
1099 //20120328ysk start 0000454
1100 //foreach ($payments as $id => $payment) {
1101 foreach ((array)$payments as $id => $payment) {
1102 //20120328ysk end
1103 if( 'continue' == $charging_type ){
1104 //if( 'acting' != substr($payments['settlement'], 0, 6) )
1105 //20110412ysk start
1106 if( 'acting_remise_card' != $payment['settlement'] && 'acting_paypal_ec' != $payment['settlement']) {
1107 $payment_ct--;
1108 continue;
1109 }
1110 //if( 'on' !== $usces->options['acting_settings']['remise']['continuation'] && 'acting_remise_card' == $payment['settlement'])
1111 // continue;
1112 if( 'on' !== $usces->options['acting_settings']['remise']['continuation'] && 'acting_remise_card' == $payment['settlement']) {
1113 $payment_ct--;
1114 continue;
1115 } elseif( 'on' !== $usces->options['acting_settings']['paypal']['continuation'] && 'acting_paypal_ec' == $payment['settlement']) {
1116 $payment_ct--;
1117 continue;
1118 }
1119 //20110412ysk end
1120 }
1121 if( $payment['name'] != '' ) {
1122 $module = trim($payment['module']);
1123 if( !WCUtils::is_blank($value) ){
1124 $checked = ($payment['name'] == $value) ? ' checked' : '';
1125 }else if( 1 == $payment_ct ){//0000428
1126 $checked = ' checked';
1127 }else{
1128 $checked = '';
1129 }
1130 if( (empty($module) || !file_exists($usces->options['settlement_path'] . $module)) && $payment['settlement'] == 'acting' ) {
1131 $checked = '';
1132 $list .= "\t".'<dt><label for="payment_name_' . $id . '"><input name="offer[payment_name]" id="payment_name_' . $id . '" type="radio" value="'.esc_attr($payment['name']).'"' . $checked . ' disabled onKeyDown="if (event.keyCode == 13) {return false;}" />'.esc_attr($payment['name'])."</label> <b> (" . __('cannot use this payment method now.','usces') . ") </b></dt>\n";
1133 }else{
1134 $list .= "\t".'<dt><label for="payment_name_' . $id . '"><input name="offer[payment_name]" id="payment_name_' . $id . '" type="radio" value="'.esc_attr($payment['name']).'"' . $checked . ' onKeyDown="if (event.keyCode == 13) {return false;}" />'.esc_attr($payment['name'])."</label></dt>\n";
1135 }
1136 $list .= "\t<dd>{$payment['explanation']}</dd>\n";
1137 }
1138 }
1139
1140 $html .= $list . "</dl>\n";
1141
1142 if( empty($list) )
1143 $html = __('Not yet ready for the payment method. Please refer to a manager.', 'usces')."\n";
1144
1145 if( $out == 'return' ){
1146 return $html;
1147 }else{
1148 echo $html;
1149 }
1150 }
1151
1152 function usces_get_payments_by_name( $name ){
1153 global $usces;
1154 $payments = usces_get_system_option( 'usces_payment_method', 'name' );
1155 if( empty($payments) ) return false;
1156
1157 if( isset($payments[$name]) ) {
1158 return $payments[$name];
1159 }
1160
1161 return false;
1162 }
1163
1164 function usces_the_delivery_method( $value = '', $out = '' ){
1165 global $usces;
1166 $deli_id = apply_filters('usces_filter_get_available_delivery_method', $usces->get_available_delivery_method());
1167 if( empty($deli_id) ){
1168 $html = '<p>' . __('No valid shipping methods.', 'usces') . '</p>';
1169 }else{
1170 $cdeliid = count($deli_id);
1171 $html = '<select name="offer[delivery_method]" id="delivery_method_select" class="delivery_time" onKeyDown="if (event.keyCode == 13) {return false;}">'."\n";
1172 foreach ($deli_id as $id) {
1173 $index = $usces->get_delivery_method_index($id);
1174 $selected = ($id == $value || 1 === $cdeliid) ? ' selected="selected"' : '';
1175 $html .= "\t<option value='{$id}'{$selected}>" . esc_html($usces->options['delivery_method'][$index]['name']) . "</option>\n";
1176 }
1177
1178 $html .= "</select>\n";
1179 }
1180
1181 if( $out == 'return' ){
1182 return $html;
1183 }else{
1184 echo $html;
1185 }
1186 }
1187 //20101208ysk start
1188 function usces_the_delivery_date( $value = '', $out = '' ){
1189 global $usces;
1190
1191 $html = "<select name='offer[delivery_date]' id='delivery_date_select' class='delivery_date'>\n";
1192 $html .= "</select>\n";
1193
1194 if( $out == 'return' ){
1195 return $html;
1196 }else{
1197 echo $html;
1198 }
1199 }
1200 //20101208ysk end
1201 function usces_the_delivery_time( $value = '', $out = '' ){
1202 global $usces;
1203
1204 //20101208ysk start
1205 //$html = "<select name='offer[delivery_time]' id='delivery_time_select' class='delivery_time'>\n";
1206 $html = "<div id='delivery_time_limit_message'></div>\n";
1207 $html .= "<select name='offer[delivery_time]' id='delivery_time_select' class='delivery_time'>\n";
1208 //20101208ysk end
1209
1210 $html .= "</select>\n";
1211
1212 if( $out == 'return' ){
1213 return $html;
1214 }else{
1215 echo $html;
1216 }
1217 }
1218
1219 function usces_the_campaign_schedule($flag, $kind){
1220 global $usces;
1221 $startdate = $usces->options['campaign_schedule']['start']['year'] . __('year','usces') . $usces->options['campaign_schedule']['start']['month'] . __('month','usces') . $usces->options['campaign_schedule']['start']['day'] . __('day','usces');
1222 $starttime = $usces->options['campaign_schedule']['start']['hour'] . __('hour','usces') . $usces->options['campaign_schedule']['start']['min'] . __('min','usces');
1223 $enddate = $usces->options['campaign_schedule']['end']['year'] . __('year','usces') . $usces->options['campaign_schedule']['end']['month'] . __('month','usces') . $usces->options['campaign_schedule']['end']['day'] . __('day','usces');
1224 $endtime = $usces->options['campaign_schedule']['end']['hour'] . __('hour','usces') . $usces->options['campaign_schedule']['end']['min'] . __('min','usces');
1225 if( 'start' == $flag ) {
1226 if( 'date' == $kind ) {
1227 echo esc_html($startdate);
1228 }elseif( 'datetime' == $kind ) {
1229 echo esc_html($startdate . ' ' . $starttime);
1230 }
1231 } elseif ( 'end' == $flag ) {
1232 if( 'date' == $kind ) {
1233 echo esc_html($enddate);
1234 }elseif( 'datetime' == $kind ) {
1235 echo esc_html($enddate . ' ' . $endtime);
1236 }
1237 }
1238 }
1239
1240
1241 function usces_the_confirm() {
1242 global $usces;
1243
1244 $usces->display_cart_confirm();
1245 }
1246
1247 function usces_inquiry_condition() {
1248 global $error_message, $reserve, $inq_name, $inq_mailaddress, $inq_contents;
1249 require(USCES_PLUGIN_DIR.'/includes/inquiry_condition.php');
1250 }
1251
1252 function usces_the_inquiry_form() {
1253 global $usces;
1254 $error_message = '';
1255 if( isset($_POST['inq_name']) && !WCUtils::is_blank($_POST['inq_name']) ) {
1256 $inq_name = trim($_POST['inq_name']);
1257 }else{
1258 $inq_name = '';
1259 if($usces->page == 'deficiency')
1260 $error_message .= __('Please input your name.', 'usces') . "<br />";
1261 }
1262 if( isset($_POST['inq_mailaddress']) && is_email(trim($_POST['inq_mailaddress'])) ) {
1263 $inq_mailaddress = trim($_POST['inq_mailaddress']);
1264 }elseif( isset($_POST['inq_mailaddress']) && !is_email(trim($_POST['inq_mailaddress'])) ) {
1265 $inq_mailaddress = trim($_POST['inq_mailaddress']);
1266 if($usces->page == 'deficiency')
1267 $error_message .= __('E-mail address is not correct', 'usces') . "<br />";
1268 }else{
1269 $inq_mailaddress = '';
1270 if($usces->page == 'deficiency')
1271 $error_message .= __('Please input your e-mail address.', 'usces') . "<br />";
1272 }
1273 if( isset($_POST['inq_contents']) && !WCUtils::is_blank($_POST['inq_contents']) ) {
1274 $inq_contents = trim($_POST['inq_contents']);
1275 }else{
1276 $inq_contents = '';
1277 if($usces->page == 'deficiency')
1278 $error_message .= __('Please input contents.', 'usces');
1279 }
1280
1281
1282 if($usces->page == 'inquiry_comp') :
1283 ?>
1284 <div class="inquiry_comp"><?php _e('sending completed','usces') ?></div>
1285 <div class="compbox"><?php _e('I send a reply email to a visitor. I ask in a few minutes to be able to have you refer in there being the fear that e-mail address is different again when the email from this shop does not arrive.','usces') ?></div>
1286 <?php
1287 elseif($usces->page == 'inquiry_error') :
1288 ?>
1289 <div class="inquiry_comp"><?php _e('Failure in sending','usces') ?></div>
1290 <?php
1291 else :
1292 ?>
1293 <?php if( !empty($error_message) ): ?>
1294 <div class="error_message"><?php echo $error_message; ?></div>
1295 <?php endif; ?>
1296 <form name="inquiry_form" action="<?php //echo USCES_CART_URL; ?>" method="post">
1297 <table border="0" cellpadding="0" cellspacing="0" class="inquiry_table">
1298 <tr>
1299 <th scope="row"><?php _e('Full name','usces') ?></th>
1300 <td><input name="inq_name" type="text" class="inquiry_name" value="<?php echo esc_attr($inq_name); ?>" /></td>
1301 </tr>
1302 <tr>
1303 <th scope="row"><?php _e('e-mail adress','usces') ?></th>
1304 <td><input name="inq_mailaddress" type="text" class="inquiry_mailaddress" value="<?php echo esc_attr($inq_mailaddress); ?>" /></td>
1305 </tr>
1306 <tr>
1307 <th scope="row"><?php _e('contents','usces') ?></th>
1308 <td><textarea name="inq_contents" class="inquiry_contents"><?php echo esc_attr($inq_contents); ?></textarea></td>
1309 </tr>
1310 </table>
1311 <div class="send"><input name="inquiry_button" type="submit" value="<?php _e('Admit to send it with this information.','usces') ?>" /></div>
1312 </form>
1313 <?php
1314 endif;
1315 }
1316
1317 function usces_get_cat_id( $slug ) {
1318 $cat = get_category_by_slug( $slug );
1319 return $cat->term_id;
1320 }
1321
1322 function usces_the_calendar() {
1323 global $usces;
1324 include (USCES_PLUGIN_DIR . '/includes/widget_calendar.php');
1325 }
1326
1327 function usces_loginout( $out = '') {
1328 global $usces;
1329 if ( !$usces->is_member_logged_in() )
1330 $res = '<a href="' . apply_filters('usces_filter_login_uri', USCES_LOGIN_URL) . '" class="usces_login_a">' . apply_filters('usces_filter_loginlink_label', __('Log-in','usces')) . '</a>';
1331 else
1332 $res = '<a href="' . apply_filters('usces_filter_logout_uri', USCES_LOGOUT_URL) . '" class="usces_logout_a">' . apply_filters('usces_filter_logoutlink_label', __('Log out','usces')) . '</a>';
1333
1334 if( $out == 'return' ){
1335 return $res;
1336 }else{
1337 echo $res;
1338 }
1339 }
1340
1341 function usces_is_login() {
1342 global $usces;
1343
1344 if( false === $usces->is_member_logged_in() )
1345 $res = false;
1346 else
1347 $res = true;
1348
1349 return $res;
1350 }
1351
1352 function usces_the_member_name( $out = '') {
1353 global $usces;
1354 $usces->get_current_member();
1355 $res = esc_html($usces->current_member['name']);
1356 if( $out == 'return' ){
1357 return $res;
1358 }else{
1359 echo $res;
1360 }
1361
1362 }
1363
1364 function usces_the_member_point( $out = '' ) {
1365 global $usces;
1366
1367 if( !$usces->is_member_logged_in() ) return;
1368
1369 $member = $usces->get_member();
1370 if( $out == 'return' ){
1371 return $member['point'];
1372 }else{
1373 echo number_format($member['point']);
1374 }
1375 }
1376
1377 function usces_the_member_status( $out = '' ) {
1378 global $usces;
1379 if( !$usces->is_member_logged_in() ) return;
1380
1381 $usces->get_current_member();
1382 $member = $usces->get_member_info($usces->current_member['id']);
1383 $status_name = $usces->member_status[$member['mem_status']];
1384
1385 if( $out == 'return' ){
1386 return $status_name;
1387 }else{
1388 echo esc_html($status_name);
1389 }
1390 }
1391
1392 function usces_get_assistance_id_list($post_id) {
1393 global $usces;
1394 $names = $usces->get_tag_names($post_id);
1395 $list = '';
1396 foreach ( $names as $itemname )
1397 $list .= $usces->get_ID_byItemName($itemname, 'publish') . ',';
1398
1399 $list = trim($list, ',');
1400
1401 return $list;
1402 }
1403 function usces_get_assistance_ids($post_id) {
1404 global $usces;
1405 $names = $usces->get_tag_names($post_id);
1406 $ids = array();
1407 foreach ( $names as $itemname )
1408 $ids[] = $usces->get_ID_byItemName($itemname, 'publish');
1409
1410 return $ids;
1411 }
1412 function usces_remembername( $out = '' ){
1413 global $usces;
1414 $value = $usces->get_cookie();
1415
1416 if( $out == 'return' ){
1417 if(isset($value['name']))
1418 return $value['name'];
1419 else
1420 return '';
1421 }else{
1422 if(isset($value['name']))
1423 echo esc_html($value['name']);
1424 else
1425 echo '';
1426 }
1427 }
1428 function usces_rememberpass( $out = '' ){
1429 global $usces;
1430 $value = $usces->get_cookie();
1431
1432 if( $out == 'return' ){
1433 if(isset($value['pass']))
1434 return $value['pass'];
1435 else
1436 return '';
1437 }else{
1438 if(isset($value['pass']))
1439 echo esc_html($value['pass']);
1440 else
1441 echo '';
1442 }
1443 }
1444 function usces_remembercheck( $out = '' ){
1445 global $usces;
1446 $value = $usces->get_cookie();
1447
1448 if( $out == 'return' ){
1449 if(isset($value['name']) && $value['name'] != '')
1450 return ' checked="checked"';
1451 else
1452 return '';
1453 }else{
1454 if(isset($value['name']) && $value['name'] != '')
1455 echo ' checked="checked"';
1456 else
1457 echo '';
1458 }
1459 }
1460 function usces_shippingchargeTR( $index='' ) {
1461 global $usces;
1462 if($index == ""){
1463 $index = 0;
1464 }
1465 $list = '';
1466 if( !isset($usces->options['shipping_charge'][$index]) ) return;
1467 $shipping_charge = $usces->options['shipping_charge'][$index];
1468 //20120710ysk start 0000472
1469 $entry = $usces->cart->get_entry();
1470 $country = (isset($entry['delivery']['country']) && !empty($entry['delivery']['country'])) ? $entry['delivery']['country'] : $entry['customer']['country'];//20120710ysk 0000472
1471 //foreach ($shipping_charge['value'] as $pref => $value) {
1472 foreach ($shipping_charge[$country] as $pref => $value) {
1473 //20120710ysk end
1474 $list .= "<tr><th>" . esc_html($pref) . "</th>\n";
1475 $list .= "<td class='rightnum'>" . number_format($value) . "</td>\n";
1476 $list .= "</tr>\n";
1477 }
1478 echo $list;
1479 }
1480 function usces_sc_shipping_charge() {
1481 global $usces;
1482 echo esc_html($usces->sc_shipping_charge());
1483 }
1484 function usces_sc_postage_privilege() {
1485 global $usces;
1486 echo esc_html($usces->sc_postage_privilege());
1487 }
1488 function usces_sc_payment_title() {
1489 global $usces;
1490 echo $usces->sc_payment_title();
1491 }
1492
1493
1494
1495 function usces_posts_random_offset( $posts ){
1496 $ids = array();
1497 foreach( (array)$posts as $post ){
1498 $ids[] = $post->ID;
1499 }
1500 $ct = count($ids);
1501 $index = rand(0, ($ct-1));
1502 return $index;
1503 }
1504
1505 function usces_get_category_link_by_slug( $slug ){
1506 $category = get_category_by_slug($slug);
1507 echo get_category_link( $category->term_id );
1508 }
1509
1510 function usces_get_page_ID_by_pname( $post_name, $return = 'echo' ){
1511 $page = get_page_by_path( $post_name );
1512 if($return == 'return')
1513 return $page->ID;
1514 else
1515 echo $page->ID;
1516 }
1517
1518 function usces_list_bestseller($num, $days = ''){
1519 global $usces;
1520 $ids = $usces->get_bestseller_ids( $days );
1521 $htm = "";
1522 for($i=0; $i<$num; $i++){
1523 if(isset($ids[$i])){
1524 $post = get_post($ids[$i]);
1525 $disp_text = apply_filters('usces_widget_bestseller_auto_text', esc_html($post->post_title), $ids[$i]);
1526 $list = "<li><a href='" . get_permalink($ids[$i]) . "'>" . $disp_text . "</a></li>\n";
1527 $htm .= apply_filters('usces_filter_bestseller', $list, $ids[$i], $i);
1528 }
1529 }
1530 wp_reset_postdata();
1531 echo $htm;
1532 }
1533
1534 function usces_list_post( $slug, $rownum, $widget_id=NULL ){
1535 global $usces, $post;
1536 usces_remove_filter();
1537
1538 $li = '';
1539 $infolist = new wp_query( array('category_name'=>$slug, 'post_status'=>'publish', 'posts_per_page'=>$rownum, 'order'=>'DESC', 'orderby'=>'date') );
1540 if( NULL != $widget_id && $infolist->have_posts() ){
1541 remove_filter( 'excerpt_length', 'welcart_excerpt_length' );
1542 remove_filter( 'excerpt_mblength', 'welcart_excerpt_mblength' );
1543 remove_filter( 'excerpt_more', 'welcart_auto_excerpt_more' );
1544 if( function_exists('welcart_widget_post_excerpt_length_'.$widget_id) )
1545 add_filter( 'excerpt_length', 'welcart_widget_post_excerpt_length_'.$widget_id );
1546 if( function_exists('welcart_widget_post_excerpt_mblength_'.$widget_id) )
1547 add_filter( 'excerpt_mblength', 'welcart_widget_post_excerpt_mblength_'.$widget_id );
1548 }
1549 $list_index = 0;
1550 while ($infolist->have_posts()) {
1551 $infolist->the_post();
1552 $list = '<li class="post_list'. apply_filters('usces_filter_post_list_class', NULL, $list_index, count($infolist)) . '">'."\n";
1553 $list .= "<div class='title'><a href='" . get_permalink($post->ID) . "'>" . get_the_title() . "</a></div>\n";
1554 $list .= "<p>" . get_the_excerpt() . "</p>\n";
1555 $list .= "</li>\n";
1556 $li .= apply_filters( 'usces_filter_widget_post', $list, $post, $slug, $list_index);
1557 $list_index++;
1558 }
1559 wp_reset_query();
1560 usces_reset_filter();
1561 if( NULL != $widget_id && $infolist->have_posts() ){
1562 add_filter( 'excerpt_length', 'welcart_excerpt_length' );
1563 add_filter( 'excerpt_mblength', 'welcart_excerpt_mblength' );
1564 add_filter( 'excerpt_more', 'welcart_auto_excerpt_more' );
1565 }
1566 echo $li;
1567 }
1568
1569 function usces_categories_checkbox($output=''){
1570 global $usces;
1571 $retcats = apply_filters('usces_search_retcats', usces_search_categories());
1572 $parent_id = apply_filters('usces_search_categories_checkbox_parent', USCES_ITEM_CAT_PARENT_ID);
1573 $htm = usces_get_categories_checkbox($parent_id);
1574 $htm = apply_filters('usces_filter_categories_checkbox', $htm, $parent_id);
1575
1576 if($output == '' || $output == 'echo')
1577 echo $htm;
1578 else
1579 return $htm;
1580 }
1581
1582 function usces_get_categories_checkbox($parent_id){
1583 global $usces;
1584 $htm = '';
1585 $retcats = usces_search_categories();
1586 $parent_cat = get_category($parent_id);
1587 $categories = get_categories('parent='.$parent_id . "&hide_empty=0&orderby=" . $usces->options['fukugo_category_orderby'] . "&order=" . $usces->options['fukugo_category_order']);
1588 $htm .= "<fieldset class='catfield-" . $parent_cat->term_id . "'><legend>" . $parent_cat->cat_name . "</legend><ul>\n";
1589 foreach ($categories as $cat) {
1590 $children = get_categories('parent='.$cat->term_id . "&hide_empty=0");
1591 if( 0 === count($children) ){
1592 $checked = in_array($cat->term_id, $retcats) ? " checked='checked'" : "";
1593 $htm .= "<li><input name='category[".$cat->term_id."]' type='checkbox' id='category[".$cat->term_id."]' value='".$cat->term_id."'".$checked." /><label for='category[".$cat->term_id."]' class='catlabel-" . $cat->term_id . "'>".esc_html($cat->cat_name)."</label></li>\n";
1594 }
1595 }
1596 $htm .= "</ul>\n";
1597 foreach ($categories as $cat) {
1598 $children = get_categories('parent='.$cat->term_id . "&hide_empty=0");
1599 if( 0 < count($children) ){
1600 $htm .= usces_get_categories_checkbox($cat->term_id);
1601 }
1602 }
1603 $htm .= "</fieldset>\n";
1604
1605 return $htm;
1606 }
1607
1608 function usces_search_categories(){
1609 $cats = array();
1610 //if(isset($_POST['category']))
1611 // $cats = $_POST['category'];
1612 if(isset($_REQUEST['category']))
1613 $cats = $_REQUEST['category'];
1614 else
1615 $cats[] = USCES_ITEM_CAT_PARENT_ID;
1616 sort($cats);
1617 return $cats;
1618 }
1619
1620 function usces_delivery_method_name( $id, $out = '' ){
1621 global $usces;
1622
1623 if($id > -1){
1624 $id =$usces->get_delivery_method_index($id);
1625 $name = $usces->options['delivery_method'][$id]['name'];
1626 }else{
1627 $name = __('No preference','usces');
1628 }
1629
1630 if($out == 'return'){
1631 return $name;
1632 }else{
1633 echo esc_html($name);
1634 }
1635 }
1636
1637 function usces_is_membersystem_state(){
1638 global $usces;
1639
1640 if($usces->options['membersystem_state'] == 'activate') {
1641 return true;
1642 }else{
1643 return false;
1644 }
1645 }
1646
1647 function usces_is_membersystem_point(){
1648 global $usces;
1649
1650 if($usces->options['membersystem_point'] == 'activate') {
1651 return true;
1652 }else{
1653 return false;
1654 }
1655 }
1656
1657 function usces_copyright(){
1658 global $usces;
1659
1660 echo esc_html($usces->options['copyright']);
1661 }
1662
1663 function usces_totalprice_in_cart(){
1664 global $usces;
1665
1666 echo number_format($usces->get_total_price());
1667 }
1668
1669 function usces_totalquantity_in_cart(){
1670 global $usces;
1671
1672 echo number_format($usces->get_total_quantity());
1673 }
1674
1675 function usces_get_page_mode(){
1676 global $usces;
1677
1678 return $usces->page;
1679 }
1680
1681 function usces_is_cat_of_item( $cat_id ){
1682 global $usces;
1683 $ids = $usces->get_item_cat_ids();
1684 $ids[] = USCES_ITEM_CAT_PARENT_ID;
1685 if(in_array($cat_id, $ids)){
1686 return true;
1687 }else{
1688 return false;
1689 }
1690 }
1691
1692 function usces_get_item_custom( $post_id, $type = 'list', $out = '' ){
1693 global $usces;
1694 $cfields = $usces->get_post_custom($post_id);
1695 switch( $type ){
1696 case 'list':
1697 $list = '';
1698 $html = '<ul class="item_custom_field">'."\n";
1699 foreach( $cfields as $key => $value ){
1700 if( 'wccs_' == substr($key, 0, 5) ){
1701 $list .= '<li>' . esc_html(substr($key, 5)) . ' : ' . nl2br(esc_html($value[0])) . '</li>'."\n";
1702 }
1703 }
1704 if(empty($list)){
1705 $html = '';
1706 }else{
1707 $html .= $list . '</ul>'."\n";
1708 }
1709 break;
1710
1711 case 'table':
1712 $list = '';
1713 $html = '<table class="item_custom_field">'."\n";
1714 foreach($cfields as $key => $value){
1715 if( 'wccs_' == substr($key, 0, 5) ){
1716 $list .= '<tr><th>' . esc_html(substr($key, 5)) . '</th><td>' . nl2br(esc_html($value[0])) . '</td></tr>'."\n";
1717 }
1718 }
1719 if(empty($list)){
1720 $html = '';
1721 }else{
1722 $html .= $list . '</table>'."\n";
1723 }
1724 break;
1725
1726 case 'notag':
1727 $list = '';
1728 foreach($cfields as $key => $value){
1729 if( 'wccs_' == substr($key, 0, 5) ){
1730 $list .= esc_html(substr($key, 5)) . ' : ' . nl2br(esc_html($value[0])) . "\r\n";
1731 }
1732 }
1733 if(empty($list)){
1734 $html = '';
1735 }else{
1736 $html = $list;
1737 }
1738 break;
1739 }
1740 $html = apply_filters( 'usces_filter_item_custom', $html, $post_id);
1741
1742 if( 'return' == $out){
1743 return $html;
1744 }else{
1745 echo $html;
1746 }
1747 }
1748
1749 function usces_settle_info_field( $order_id, $type='nl', $out='echo' ){
1750 global $usces;
1751 $str = '';
1752 $fields = $usces->get_settle_info_field( $order_id );
1753 //20101018ysk start
1754 $acting = isset($fields['acting']) ? $fields['acting'] : '';
1755 foreach($fields as $key => $value){
1756 //20101018ysk end
1757 $keys = array(
1758 'acting','order_no','tracking_no','status','error_message','money',
1759 'pay_cvs', 'pay_no1', 'pay_no2', 'pay_limit', 'error_code',
1760 'settlement_id','RECDATE','JOB_ID','S_TORIHIKI_NO','TOTAL','CENDATE',
1761 'gid', 'rst', 'ap', 'ec', 'god', 'ta', 'cv', 'no', 'cu', 'mf', 'nk', 'nkd', 'bank', 'exp',
1762 'order_number',
1763 'res_tracking_id', 'res_payment_date', 'res_payinfo_key',
1764 'SID', 'DATE', 'TIME', 'CVS', 'SHNO', 'FURL', 'settltment_status', 'settltment_errmsg',
1765 'stran', 'mbtran', 'bktrans', 'tranid'
1766 );
1767 $keys = apply_filters( 'usces_filter_settle_info_field_keys', $keys );
1768 if( !in_array($key, $keys) ) {
1769 continue;
1770 }
1771
1772 switch($acting){
1773 case 'zeus_bank':
1774 if( 'status' == $key){
1775 if( '01' === $value ){
1776 $value = '受付中';
1777 }elseif( '02' === $value ){
1778 $value = '未�
1779 �金';
1780 }elseif( '03' === $value ){
1781 $value = '�
1782 �金済';
1783 }elseif( '04' === $value ){
1784 $value = 'エラー';
1785 }elseif( '05' === $value ){
1786 $value = '�
1787 �金失敗';
1788 }
1789 }elseif( 'error_message' == $key){
1790 if( '0002' === $value ){
1791 $value = '�
1792 �金不足';
1793 }elseif( '0003' === $value ){
1794 $value = '過剰�
1795 �金';
1796 }
1797 }
1798 break;
1799 case 'zeus_conv':
1800 if( 'pay_cvs' == $key){
1801 if( 'D001' === $value ){
1802 $value = 'セブンイレブン';
1803 }elseif( 'D002' === $value ){
1804 $value = 'ローソン';
1805 }elseif( 'D030' === $value ){
1806 $value = 'ファミリーマート';
1807 }elseif( 'D040' === $value ){
1808 $value = 'サークルKサンクス';
1809 }elseif( 'D015' === $value ){
1810 $value = 'セイコーマート';
1811 }
1812 }elseif( 'status' == $key){
1813 if( '01' === $value ){
1814 $value = '未�
1815 �金';
1816 }elseif( '02' === $value ){
1817 $value = '申込エラー';
1818 }elseif( '03' === $value ){
1819 $value = '期日切';
1820 }elseif( '04' === $value ){
1821 $value = '�
1822 �金済';
1823 }elseif( '05' === $value ){
1824 $value = '売上確定';
1825 }elseif( '06' === $value ){
1826 $value = '�
1827 �金取消';
1828 }elseif( '11' === $value ){
1829 $value = 'キャンセル後�
1830 �金';
1831 }elseif( '12' === $value ){
1832 $value = 'キャンセル後売上';
1833 }elseif( '13' === $value ){
1834 $value = 'キャンセル後取消';
1835 }
1836 }elseif( 'pay_limit' == $key){
1837 $value = substr($value, 0, 4).'' . substr($value, 4, 2).'' . substr($value, 6, 2).'';
1838 }
1839 break;
1840 //20101018ysk start
1841 case 'jpayment_conv':
1842 switch($key) {
1843 case 'rst':
1844 switch($value) {
1845 case '1':
1846 $value = 'OK'; break;
1847 case '2':
1848 $value = 'NG'; break;
1849 }
1850 break;
1851 case 'ap':
1852 switch($value) {
1853 case 'CPL_PRE':
1854 $value = 'コンビニペーパーレス決済識別コード'; break;
1855 case 'CPL':
1856 $value = '�
1857 �金確定'; break;
1858 case 'CVS_CAN':
1859 $value = '�
1860 �金取消'; break;
1861 }
1862 break;
1863 case 'cv':
1864 $value = esc_html(usces_get_conv_name($value));
1865 break;
1866 case 'mf':
1867 case 'nk':
1868 case 'nkd':
1869 case 'bank':
1870 case 'exp':
1871 continue;
1872 break;
1873 }
1874 break;
1875
1876 case 'jpayment_bank':
1877 switch($key) {
1878 case 'rst':
1879 switch($value) {
1880 case '1':
1881 $value = 'OK'; break;
1882 case '2':
1883 $value = 'NG'; break;
1884 }
1885 break;
1886 case 'ap':
1887 switch($value) {
1888 case 'BANK':
1889 $value = '受付完了'; break;
1890 case 'BAN_SAL':
1891 $value = '�
1892 �金完了'; break;
1893 }
1894 break;
1895 case 'mf':
1896 switch($value) {
1897 case '1':
1898 $value = 'マッチ'; break;
1899 case '2':
1900 $value = '過少'; break;
1901 case '3':
1902 $value = '過剰'; break;
1903 }
1904 break;
1905 case 'nkd':
1906 $value = substr($value, 0, 4).''.substr($value, 4, 2).''.substr($value, 6, 2).'';
1907 break;
1908 case 'exp':
1909 $value = substr($value, 0, 4).''.substr($value, 4, 2).''.substr($value, 6, 2).'';
1910 break;
1911 case 'cv':
1912 case 'no':
1913 case 'cu':
1914 continue;
1915 break;
1916 }
1917 break;
1918 //20101018ysk end
1919 }
1920 $value = apply_filters( 'usces_filter_settle_info_field_value', $value, $key, $acting );
1921 switch($type){
1922 case 'nl':
1923 $str .= $key . ' : ' . $value . "<br />\n";
1924 break;
1925
1926 case 'tr':
1927 $str .= '<tr><td class="label">' . $key . '</td><td>' . $value . "</td></tr>\n";
1928 break;
1929
1930 case 'li':
1931 $str .= '<li>' . $key . ' : ' . $value . "</li>\n";
1932 break;
1933 }
1934 }
1935 if( 'return' == $out){
1936 return $str;
1937 }else{
1938 echo $str;
1939 }
1940 }
1941
1942 //20100818ysk start
1943 function usces_custom_field_input( $data, $custom_field, $position, $out = '' ) {
1944
1945 $html = '';
1946 switch($custom_field) {
1947 case 'order':
1948 $label = 'custom_order';
1949 $field = 'usces_custom_order_field';
1950 break;
1951 case 'customer':
1952 $label = 'custom_customer';
1953 $field = 'usces_custom_customer_field';
1954 break;
1955 case 'delivery':
1956 $label = 'custom_delivery';
1957 $field = 'usces_custom_delivery_field';
1958 break;
1959 case 'member':
1960 $label = 'custom_member';
1961 $field = 'usces_custom_member_field';
1962 break;
1963 default:
1964 return;
1965 }
1966
1967 $meta = usces_has_custom_field_meta($custom_field);
1968
1969 if(!empty($meta) and is_array($meta)) {
1970 foreach($meta as $key => $entry) {
1971 if($custom_field == 'order' or $entry['position'] == $position) {
1972 $name = $entry['name'];
1973 $means = $entry['means'];
1974 $essential = $entry['essential'];
1975 $value = '';
1976 if(is_array($entry['value'])) {
1977 foreach($entry['value'] as $k => $v) {
1978 $value .= $v."\n";
1979 }
1980 }
1981 $value = trim($value);
1982
1983 $e = ($essential == 1) ? '<em>' . __('*', 'usces') . '</em>' : '';
1984 $html .= '
1985 <tr class="customkey_' . $key . '">
1986 <th scope="row">'.$e.esc_html($name).apply_filters('usces_filter_custom_field_input_label', NULL, $key, $entry).'</th>';
1987 $html .= apply_filters( 'usces_filter_custom_field_input_td', '<td colspan="2">', $key, $entry);
1988 switch($means) {
1989 case 0://シングルセレクト
1990 case 1://マルチセレクト
1991 $selects = explode("\n", $value);
1992 $multiple = ($means == 0) ? '' : ' multiple';
1993 $multiple_array = ($means == 0) ? '' : '[]';
1994 $html .= '<select name="'.$label.'['.esc_attr($key).']'.$multiple_array.'" class="iopt_select"'.$multiple.'>';
1995 if($essential == 1)
1996 $html .= '
1997 <option value="#NONE#">'.__('Choose','usces').'</option>';
1998 foreach($selects as $v) {
1999 $selected = (isset($data[$label][$key]) && $data[$label][$key] == $v) ? ' selected' : '';
2000 $html .= '
2001 <option value="'.esc_attr($v).'"'.$selected.'>'.esc_html($v).'</option>';
2002 }
2003 $html .= '
2004 </select>';
2005 break;
2006 case 2://テキスト
2007 $text = isset($data[$label][$key]) ? $data[$label][$key] : '';
2008 $html .= '<input type="text" name="'.$label.'['.esc_attr($key).']" value="'.esc_attr($text).'" />';
2009 break;
2010 case 3://ラジオボタン
2011 $selects = explode("\n", $value);
2012 foreach($selects as $v) {
2013 $checked = ( isset($data[$label][$key]) && $data[$label][$key] == $v) ? ' checked' : '';
2014 $html .= '
2015 <label for="'.$label.'['.esc_attr($key).']['.esc_attr($v).']" class="iopt_label"><input type="radio" name="'.$label.'['.esc_attr($key).']" id="'.$label.'['.esc_attr($key).']['.esc_attr($v).']" value="'.esc_attr($v).'"'.$checked.'>'.esc_html($v).'</label>';
2016 }
2017 break;
2018 case 4://チェックボックス
2019 $selects = explode("\n", $value);
2020 foreach($selects as $v) {
2021 if( isset($data[$label][$key]) && is_array($data[$label][$key]) ) {
2022 $checked = (isset($data[$label][$key]) && array_key_exists($v, $data[$label][$key])) ? ' checked' : '';
2023 } else {
2024 $checked = (isset($data[$label][$key]) && $data[$label][$key] == $v) ? ' checked' : '';
2025 }
2026 $html .= '
2027 <label for="'.$label.'['.esc_attr($key).']['.esc_attr($v).']" class="iopt_label"><input type="checkbox" name="'.$label.'['.esc_attr($key).']['.esc_attr($v).']" id="'.$label.'['.esc_attr($key).']['.esc_attr($v).']" value="'.esc_attr($v).'"'.$checked.'>'.esc_html($v).'</label>';
2028 }
2029 break;
2030 }
2031 $html .= apply_filters('usces_filter_custom_field_input_value', NULL, $key, $entry).'</td>';
2032 $html .= '
2033 </tr>';
2034 }
2035 }
2036 }
2037
2038 $html = apply_filters('usces_filter_custom_field_input', $html, $data, $custom_field, $position);
2039
2040 if($out == 'return') {
2041 return stripslashes($html);
2042 } else {
2043 echo stripslashes($html);
2044 }
2045 }
2046
2047 function usces_custom_field_info( $data, $custom_field, $position, $out = '' ) {
2048
2049 $html = '';
2050 switch($custom_field) {
2051 case 'order':
2052 $label = 'custom_order';
2053 $field = 'usces_custom_order_field';
2054 break;
2055 case 'customer':
2056 $label = 'custom_customer';
2057 $field = 'usces_custom_customer_field';
2058 break;
2059 case 'delivery':
2060 $label = 'custom_delivery';
2061 $field = 'usces_custom_delivery_field';
2062 break;
2063 case 'member':
2064 $label = 'custom_member';
2065 $field = 'usces_custom_member_field';
2066 break;
2067 default:
2068 return;
2069 }
2070
2071 $meta = usces_has_custom_field_meta($custom_field);
2072
2073 if(!empty($meta) and is_array($meta)) {
2074 foreach($meta as $key => $entry) {
2075 if($custom_field == 'order' or $entry['position'] == $position) {
2076 $name = $entry['name'];
2077 $means = $entry['means'];
2078
2079 $html .= '<tr>
2080 <th>'.esc_html($name).'</th>
2081 <td>';
2082 if(!empty($data[$label][$key])) {
2083 switch($means) {
2084 case 0://シングルセレクト
2085 case 2://テキスト
2086 case 3://ラジオボタン
2087 $html .= esc_html($data[$label][$key]);
2088 break;
2089 case 1://マルチセレクト
2090 case 4://チェックボックス
2091 if(is_array($data[$label][$key])) {
2092 $c = '';
2093 foreach($data[$label][$key] as $v) {
2094 $html .= $c.esc_html($v);
2095 $c = ', ';
2096 }
2097 } else {
2098 if(!empty($data[$label][$key])) $html .= esc_html($data[$label][$key]);
2099 }
2100 break;
2101 }
2102 }
2103 $html .= '
2104 </td>
2105 </tr>';
2106 }
2107 }
2108 }
2109
2110 $html = apply_filters('usces_filter_custom_field_info', $html, $data, $custom_field, $position);
2111
2112 if($out == 'return') {
2113 return stripslashes($html);
2114 } else {
2115 echo stripslashes($html);
2116 }
2117 }
2118
2119 function usces_admin_custom_field_input( $meta, $custom_field, $position, $out = '' ) {
2120
2121 $html = '';
2122 switch($custom_field) {
2123 case 'order':
2124 $label = 'custom_order';
2125 $class = '';
2126 break;
2127 case 'customer':
2128 $label = 'custom_customer';
2129 $class = ' class="col2"';
2130 break;
2131 case 'delivery':
2132 $label = 'custom_delivery';
2133 $class = ' class="col3"';
2134 break;
2135 case 'member':
2136 $label = 'custom_member';
2137 $class = '';
2138 break;
2139 default:
2140 return;
2141 }
2142
2143
2144 if(!empty($meta) and is_array($meta)) {
2145 foreach($meta as $key => $entry) {
2146 if($custom_field == 'order' or $entry['position'] == $position) {
2147 $name = $entry['name'];
2148 $means = $entry['means'];
2149 $essential = $entry['essential'];
2150 $value = '';
2151 if(is_array($entry['value'])) {
2152 foreach($entry['value'] as $k => $v) {
2153 $value .= $v."\n";
2154 }
2155 }
2156 $value = trim($value);
2157 $data = $entry['data'];
2158
2159 $html .= '
2160 <tr>
2161 <td class="label">'.esc_html($name).'</td>';
2162 switch($means) {
2163 case 0://シングルセレクト
2164 case 1://マルチセレクト
2165 $selects = explode("\n", $value);
2166 $multiple = ($means == 0) ? '' : ' multiple';
2167 $multiple_array = ($means == 0) ? '' : '[]';
2168 $html .= '
2169 <td'.$class.'>
2170 <select name="'.$label.'['.esc_attr($key).']'.$multiple_array.'" class="iopt_select"'.$multiple.'>';
2171 if($essential == 1)
2172 $html .= '
2173 <option value="#NONE#">'.__('Choose','usces').'</option>';
2174 foreach($selects as $v) {
2175 $selected = ($data == $v) ? ' selected' : '';
2176 $html .= '
2177 <option value="'.esc_attr($v).'"'.$selected.'>'.esc_html($v).'</option>';
2178 }
2179 $html .= '
2180 </select></td>';
2181 break;
2182 case 2://テキスト
2183 $html .= '
2184 <td'.$class.'><input type="text" name="'.$label.'['.esc_attr($key).']" size="30" value="'.esc_attr($data).'" /></td>';
2185 break;
2186 case 3://ラジオボタン
2187 $selects = explode("\n", $value);
2188 $html .= '
2189 <td'.$class.'>';
2190 foreach($selects as $v) {
2191 $checked = ($data == $v) ? ' checked' : '';
2192 $html .= '
2193 <input type="radio" name="'.$label.'['.esc_attr($key).']" value="'.esc_attr($v).'"'.$checked.'><label for="'.$label.'['.esc_attr($key).']['.esc_attr($v).']" class="iopt_label">'.esc_html($v).'</label>';
2194 }
2195 $html .= '
2196 </td>';
2197 break;
2198 case 4://チェックボックス
2199 $selects = explode("\n", $value);
2200 $html .= '
2201 <td'.$class.'>';
2202 foreach($selects as $v) {
2203 if(is_array($data)) {
2204 $checked = (array_key_exists($v, $data)) ? ' checked' : '';
2205 } else {
2206 $checked = ($data == $v) ? ' checked' : '';
2207 }
2208 $html .= '
2209 <input type="checkbox" name="'.$label.'['.esc_attr($key).']['.esc_attr($v).']" value="'.esc_attr($v).'"'.$checked.'><label for="'.$label.'['.esc_attr($key).']['.esc_attr($v).']" class="iopt_label">'.esc_html($v).'</label>';
2210 }
2211 $html .= '
2212 </td>';
2213 break;
2214 }
2215 $html .= '
2216 </tr>';
2217 }
2218 }
2219 }
2220
2221 if($out == 'return') {
2222 return stripslashes($html);
2223 } else {
2224 echo stripslashes($html);
2225 }
2226 }
2227
2228 function has_custom_customer_field_essential() {
2229
2230 $mes = '';
2231 $essential = array();
2232
2233 $csmb_meta = usces_has_custom_field_meta('member');
2234 if(!empty($csmb_meta) and is_array($csmb_meta)) {
2235 foreach($csmb_meta as $key => $entry) {
2236 if($entry['essential'] == 1) {
2237 $essential[$key] = $key;
2238 }
2239 }
2240 }
2241 if(!empty($essential)) {
2242 $cscs_meta = usces_has_custom_field_meta('customer');
2243 if(!empty($cscs_meta) and is_array($cscs_meta)) {
2244 foreach($cscs_meta as $key => $entry) {
2245 if($entry['essential'] == 1) {
2246 if(!array_key_exists($key, $essential)) {
2247 if($entry['means'] == 2) {//Text
2248 $mes .= __(esc_html($entry['name']).'を�
2249 �力してください。', 'usces')."<br />";
2250 } else {
2251 $mes .= __(esc_html($entry['name']).'を選択してください。', 'usces')."<br />";
2252 }
2253 }
2254 }
2255 }
2256 }
2257 }
2258 return $mes;
2259 }
2260 //20100818ysk end
2261
2262 function usces_order_discount( $out = '' ){
2263 global $usces;
2264 $res = abs($usces->get_order_discount());
2265
2266 if($out == 'return') {
2267 return $res;
2268 } else {
2269 echo number_format($res);
2270 }
2271 }
2272
2273 function usces_item_discount( $out = '', $post_id = '', $sku = '' ){
2274 global $usces, $post;
2275
2276 if( '' == $post_id )
2277 $post_id = $post->ID;
2278 if( '' == $sku )
2279 $sku = $usces->itemsku['code'];
2280
2281 $res = $usces->getItemDiscount($post_id, $sku);
2282
2283 if($out == 'return') {
2284 return $res;
2285 } else {
2286 echo number_format($res);
2287 }
2288 }
2289
2290 function usces_singleitem_error_message($post_id, $skukey, $out = ''){
2291 if( !isset($_SESSION['usces_singleitem']['error_message'][$post_id][$skukey]) )
2292 $ret = '';
2293 else
2294 $ret = $_SESSION['usces_singleitem']['error_message'][$post_id][$skukey];
2295
2296 if($out == 'return') {
2297 return $ret;
2298 } else {
2299 echo $ret;
2300 }
2301 }
2302
2303 function usces_crform( $float, $symbol_pre = true, $symbol_post = true, $out = '', $seperator_flag = true ) {
2304 global $usces;
2305 $price = esc_html($usces->get_currency($float, $symbol_pre, $symbol_post, $seperator_flag ));
2306 $res = apply_filters('usces_filter_crform', $price, $float);
2307
2308 if($out == 'return'){
2309 return $res;
2310 }else{
2311 echo $res;
2312 }
2313 }
2314
2315 function usces_memberinfo( $key, $out = '' ){
2316 global $usces, $wpdb;
2317 $info = $usces->get_member();
2318
2319 if( empty($key) ) return $info;
2320
2321 switch ($key){
2322 case 'registered':
2323 $res = mysql2date(__('Mj, Y', 'usces'), $info['registered']);
2324 break;
2325 //20120919ysk start 0000573
2326 case 'point':
2327 $member_table = $wpdb->prefix."usces_member";
2328 $query = $wpdb->prepare("SELECT mem_point FROM $member_table WHERE ID = %d", $info['ID']);
2329 $res = $wpdb->get_var( $query );
2330 break;
2331 //20120919ysk end
2332 default:
2333 $res = isset($info[$key]) ? $info[$key] : '';
2334 }
2335
2336 if($out == 'return'){
2337 return $res;
2338 }else{
2339 echo esc_html($res);
2340 }
2341 }
2342
2343 function usces_localized_name( $Familly_name, $Given_name, $out = '' ){
2344 global $usces_settings, $usces;
2345
2346 $options = get_option('usces');
2347 $form = $options['system']['addressform'];
2348 if( $usces_settings['nameform'][$form] ){
2349 $res = $Given_name . ' ' . $Familly_name;
2350 }else{
2351 $res = $Familly_name . ' ' . $Given_name;
2352 }
2353
2354 if($out == 'return'){
2355 return $res;
2356 }else{
2357 echo esc_html($res);
2358 }
2359 }
2360
2361 function usces_member_history( $out = '' ){
2362 global $usces;
2363
2364 $usces_members = $usces->get_member();
2365 $usces_member_history = $usces->get_member_history($usces_members['ID']);
2366 $colspan = usces_is_membersystem_point() ? 9 : 7;
2367
2368 $html = '<table>';
2369 if ( !count($usces_member_history) ) {
2370 $html .= '<tr>
2371 <td>' . __('There is no purchase history for this moment.', 'usces') . '</td>
2372 </tr>';
2373 }
2374 foreach ( $usces_member_history as $umhs ) {
2375 $cart = $umhs['cart'];
2376 $html .= '<tr>
2377 <th class="historyrow">' . __('Order number', 'usces') . '</th>
2378 <th class="historyrow">' . __('Purchase date', 'usces') . '</th>
2379 <th class="historyrow">' . __('Purchase price', 'usces') . '</th>';
2380 if( usces_is_membersystem_point() ){
2381 $html .= '<th class="historyrow">' . __('Used points', 'usces') . '</th>';
2382 }
2383 $html .= '<th class="historyrow">' . apply_filters( 'usces_member_discount_label', __('Special Price', 'usces'), $umhs['ID'] ) . '</th>
2384 <th class="historyrow">' . __('Shipping', 'usces') . '</th>
2385 <th class="historyrow">' . __('C.O.D', 'usces') . '</th>
2386 <th class="historyrow">' . __('consumption tax', 'usces') . '</th>';
2387 if( usces_is_membersystem_point() ){
2388 $html .= '<th class="historyrow">' . __('Acquired points', 'usces') . '</th>';
2389 }
2390 $html .= '</tr>
2391 <tr>
2392 <td class="rightnum">' . usces_get_deco_order_id($umhs['ID']) . '</td>
2393 <td class="date">' . $umhs['date'] . '</td>
2394 <td class="rightnum">' . usces_crform(($usces->get_total_price($cart)-$umhs['usedpoint']+$umhs['discount']+$umhs['shipping_charge']+$umhs['cod_fee']+$umhs['tax']), true, false, 'return') . '</td>';
2395 if( usces_is_membersystem_point() ){
2396 $html .= '<td class="rightnum">' . number_format($umhs['usedpoint']) . '</td>';
2397 }
2398 $html .= '<td class="rightnum">' . usces_crform($umhs['discount'], true, false, 'return') . '</td>
2399 <td class="rightnum">' . usces_crform($umhs['shipping_charge'], true, false, 'return') . '</td>
2400 <td class="rightnum">' . usces_crform($umhs['cod_fee'], true, false, 'return') . '</td>
2401 <td class="rightnum">' . usces_crform($umhs['tax'], true, false, 'return') . '</td>';
2402 if( usces_is_membersystem_point() ){
2403 $html .= '<td class="rightnum">' . number_format($umhs['getpoint']) . '</td>';
2404 }
2405 $html .= '</tr>';
2406 $html .= apply_filters('usces_filter_member_history_header', NULL, $umhs);
2407 $html .= '<tr>
2408 <td class="retail" colspan="' . $colspan . '">
2409 <table id="retail_table_' . $umhs['ID'] . '" class="retail">';
2410 $history_cart_head = '<tr>
2411 <th scope="row" class="num">No.</th>
2412 <th class="thumbnail">&nbsp;</th>
2413 <th>' . __('Items', 'usces') . '</th>
2414 <th class="price ">' . __('Unit price', 'usces') . '</th>
2415 <th class="quantity">' . __('Quantity', 'usces') . '</th>
2416 <th class="subtotal">' . __('Amount', 'usces') . '</th>
2417 </tr>';
2418 $html .= apply_filters('usces_filter_history_cart_head', $history_cart_head, $umhs);
2419
2420 for($i=0; $i<count($cart); $i++) {
2421 $cart_row = $cart[$i];
2422 $post_id = $cart_row['post_id'];
2423 $sku = urldecode($cart_row['sku']);
2424 $quantity = $cart_row['quantity'];
2425 $options = $cart_row['options'];
2426 $itemCode = $usces->getItemCode($post_id);
2427 $itemName = $usces->getItemName($post_id);
2428 $cartItemName = $usces->getCartItemName($post_id, $sku);
2429 //$skuPrice = $usces->getItemPrice($post_id, $sku);
2430 $skuPrice = $cart_row['price'];
2431 $pictid = (int)$usces->get_mainpictid($itemCode);
2432 $optstr = '';
2433 if( is_array($options) && count($options) > 0 ){
2434 $optstr = '';
2435 foreach($options as $key => $value){
2436 //20110629ysk start 0000190
2437 //f( !empty($key) )
2438 // $optstr .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
2439 if( !empty($key) ) {
2440 $key = urldecode($key);
2441 if(is_array($value)) {
2442 $c = '';
2443 $optstr .= esc_html($key) . ' : ';
2444 foreach($value as $v) {
2445 $optstr .= $c.nl2br(esc_html(urldecode($v)));
2446 $c = ', ';
2447 }
2448 $optstr .= "<br />\n";
2449 } else {
2450 $optstr .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
2451 }
2452 }
2453 //20110629ysk end
2454 }
2455 $optstr = apply_filters( 'usces_filter_option_history', $optstr, $options);
2456 }
2457 $optstr = apply_filters( 'usces_filter_option_info_history', $optstr, $umhs, $cart_row, $i );
2458
2459 $history_cart_row = '<tr>
2460 <td>' . ($i + 1) . '</td>
2461 <td>';
2462 $cart_thumbnail = '<a href="' . get_permalink($post_id) . '">' . wp_get_attachment_image( $pictid, array(60, 60), true ) . '</a>';
2463 $history_cart_row .= apply_filters('usces_filter_cart_thumbnail', $cart_thumbnail, $post_id, $pictid, $i, $cart_row);
2464 $history_cart_row .= '</td>
2465 <td class="aleft"><a href="' . get_permalink($post_id) . '">' . esc_html($cartItemName) . '<br />' . $optstr . '</a>' . apply_filters('usces_filter_history_item_name', NULL, $umhs, $cart_row, $i) . '</td>
2466 <td class="rightnum">' . usces_crform($skuPrice, true, false, 'return') . '</td>
2467 <td class="rightnum">' . number_format($cart_row['quantity']) . '</td>
2468 <td class="rightnum">' . usces_crform($skuPrice * $cart_row['quantity'], true, false, 'return') . '</td>
2469 </tr>';
2470 $html .= apply_filters('usces_filter_history_cart_row', $history_cart_row, $umhs, $cart_row, $i);
2471 }
2472 $html .= '</table>
2473 </td>
2474 </tr>';
2475 }
2476
2477 $html .= '</table>';
2478
2479 if($out == 'return'){
2480 return $html;
2481 }else{
2482 echo $html;
2483 }
2484 }
2485
2486 function usces_newmember_button($member_regmode){
2487 $html = '<input name="member_regmode" type="hidden" value="' . $member_regmode . '" />';
2488 $newmemberbutton = '<input name="regmember" type="submit" value="' . __('transmit a message', 'usces') . '" />';
2489 $html .= apply_filters('usces_filter_newmember_button', $newmemberbutton);
2490 echo $html;
2491 }
2492
2493 function usces_login_button(){
2494 $loginbutton = '<input type="submit" name="member_login" id="member_login" class="member_login_button" value="' . __('Log-in', 'usces') . '" />';
2495 $html = apply_filters('usces_filter_login_button', $loginbutton);
2496 echo $html;
2497 }
2498
2499 function usces_assistance_item($post_id, $title ){
2500 if (usces_get_assistance_id_list($post_id)) :
2501 global $post;
2502 $r = new WP_Query( array('post__in'=>usces_get_assistance_ids($post_id), 'ignore_sticky_posts'=>1) );
2503 if($r->have_posts()) :
2504 add_filter( 'excerpt_length', 'welcart_assistance_excerpt_length' );
2505 add_filter( 'excerpt_mblength', 'welcart_assistance_excerpt_mblength' );
2506 ?>
2507 <div class="assistance_item">
2508 <h3><?php echo $title; ?></h3>
2509 <ul class="clearfix">
2510 <?php
2511 while ($r->have_posts()) :
2512 $r->the_post();
2513 usces_remove_filter();
2514 usces_the_item();
2515 ob_start();
2516 ?>
2517 <li>
2518 <div class="listbox clearfix">
2519 <div class="slit">
2520 <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php echo wp_filter_nohtml_kses(get_the_title()); ?>"><?php usces_the_itemImage(0, 100, 100, $post); ?></a>
2521 </div>
2522 <div class="detail">
2523 <div class="assist_excerpt">
2524 <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php echo wp_filter_nohtml_kses(get_the_title()); ?>"><h4><?php usces_the_itemName(); ?></h4></a>
2525 <?php the_excerpt(); ?>
2526 </div>
2527 <div class="assist_price">
2528 <?php if (usces_is_skus()) : ?>
2529 <?php _e('$', 'usces'); ?><?php usces_the_firstPrice(); ?>
2530 <?php endif; ?>
2531 </div>
2532 </div>
2533 </div>
2534 </li>
2535 <?php
2536 $list = ob_get_contents();
2537 ob_end_clean();
2538 echo apply_filters('usces_filter_assistance_item_list', $list, $post);
2539 endwhile; ?>
2540
2541 </ul>
2542 </div><!-- end of assistance_item -->
2543 <?php
2544 wp_reset_postdata();
2545 usces_reset_filter();
2546 remove_filter( 'excerpt_length', 'welcart_assistance_excerpt_length' );
2547 remove_filter( 'excerpt_mblength', 'welcart_assistance_excerpt_mblength' );
2548 endif;
2549 endif;
2550 }
2551
2552 function usces_get_cart_rows( $out = '' ) {
2553 global $usces, $usces_gp;
2554 $cart = $usces->cart->get_cart();
2555 $usces_gp = 0;
2556 $res = '';
2557
2558 for($i=0; $i<count($cart); $i++) {
2559 $cart_row = $cart[$i];
2560 $post_id = $cart_row['post_id'];
2561 $sku = $cart_row['sku'];
2562 $sku_code = esc_attr(urldecode($cart_row['sku']));
2563 $quantity = $cart_row['quantity'];
2564 $options = $cart_row['options'];
2565 $advance = $usces->cart->wc_serialize($cart_row['advance']);
2566 $itemCode = $usces->getItemCode($post_id);
2567 $itemName = $usces->getItemName($post_id);
2568 $cartItemName = $usces->getCartItemName($post_id, $sku_code);
2569 $itemRestriction = $usces->getItemRestriction($post_id);
2570 $skuPrice = $cart_row['price'];
2571 $skuZaikonum = $usces->getItemZaikonum($post_id, $sku_code);
2572 $stockid = $usces->getItemZaikoStatusId($post_id, $sku_code);
2573 $stock = $usces->getItemZaiko($post_id, $sku_code);
2574 $red = (in_array($stock, array(__('sellout','usces'), __('Out Of Stock','usces'), __('Out of print','usces')))) ? 'class="signal_red"' : '';
2575 $pictid = (int)$usces->get_mainpictid($itemCode);
2576 $args = compact('cart', 'i', 'cart_row', 'post_id', 'sku' );
2577 $row = '';
2578 if ( empty($options) ) {
2579 $optstr = '';
2580 $options = array();
2581 }
2582 $row .= '<tr>
2583 <td>' . ($i + 1) . '</td>
2584 <td>';
2585 $cart_thumbnail = '<a href="' . get_permalink($post_id) . '">' . wp_get_attachment_image( $pictid, array(60, 60), true ) . '</a>';
2586 $row .= apply_filters('usces_filter_cart_thumbnail', $cart_thumbnail, $post_id, $pictid, $i,$cart_row);
2587 $row .= '</td><td class="aleft">' . esc_html($cartItemName) . '<br />';
2588 if( is_array($options) && count($options) > 0 ){
2589 $optstr = '';
2590 foreach($options as $key => $value){
2591 //20110629ysk start 0000190
2592 //if( !empty($key) )
2593 // $row .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
2594 if( !empty($key) ) {
2595 $key = urldecode($key);
2596 if(is_array($value)) {
2597 $c = '';
2598 $optstr .= esc_html($key) . ' : ';
2599 foreach($value as $v) {
2600 $optstr .= $c.nl2br(esc_html(urldecode($v)));
2601 $c = ', ';
2602 }
2603 $optstr .= "<br />\n";
2604 } else {
2605 $optstr .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
2606 }
2607 }
2608 //20110629ysk end
2609 }
2610 $row .= apply_filters( 'usces_filter_option_cart', $optstr, $options);
2611 }
2612 $row .= apply_filters( 'usces_filter_option_info_cart', '', $cart_row );
2613 $row .= '</td>
2614 <td class="aright">';
2615 if( usces_is_gptekiyo($post_id, $sku_code, $quantity) ) {
2616 $usces_gp = 1;
2617 $Business_pack_mark = '<img src="' . get_template_directory_uri() . '/images/gp.gif" alt="' . __('Business package discount','usces') . '" /><br />';
2618 $row .= apply_filters('usces_filter_itemGpExp_cart_mark', $Business_pack_mark);
2619 }
2620 $row .= usces_crform($skuPrice, true, false, 'return') . '
2621 </td>
2622 <td>';
2623 $row_quant = '<input name="quant[' . $i . '][' . $post_id . '][' . $sku . ']" class="quantity" type="text" value="' . esc_attr($cart_row['quantity']) . '" />';
2624 $row .= apply_filters( 'usces_filter_cart_rows_quant', $row_quant, $args );
2625 $row .= '</td>
2626 <td class="aright">' . usces_crform(($skuPrice * $cart_row['quantity']), true, false, 'return') . '</td>
2627 <td ' . $red . '>' . $stock . '</td>
2628 <td>';
2629 foreach($options as $key => $value){
2630 //20110629ysk start 0000190
2631 //$row .= '<input name="itemOption[' . $i . '][' . $post_id . '][' . $sku . '][' . $key . ']" type="hidden" value="' . $value . '" />';
2632 if(is_array($value)) {
2633 foreach($value as $v) {
2634 $row .= '<input name="itemOption[' . $i . '][' . $post_id . '][' . $sku . '][' . $key . '][' . $v . ']" type="hidden" value="' . $v . '" />';
2635 }
2636 } else {
2637 $row .= '<input name="itemOption[' . $i . '][' . $post_id . '][' . $sku . '][' . $key . ']" type="hidden" value="' . $value . '" />';
2638 }
2639 //20110629ysk end
2640 }
2641 $row .= '<input name="itemRestriction[' . $i . ']" type="hidden" value="' . $itemRestriction . '" />
2642 <input name="stockid[' . $i . ']" type="hidden" value="' . $stockid . '" />
2643 <input name="itempostid[' . $i . ']" type="hidden" value="' . $post_id . '" />
2644 <input name="itemsku[' . $i . ']" type="hidden" value="' . $sku . '" />
2645 <input name="zaikonum[' . $i . '][' . $post_id . '][' . $sku . ']" type="hidden" value="' . esc_attr($skuZaikonum) . '" />
2646 <input name="skuPrice[' . $i . '][' . $post_id . '][' . $sku . ']" type="hidden" value="' . esc_attr($skuPrice) . '" />
2647 <input name="advance[' . $i . '][' . $post_id . '][' . $sku . ']" type="hidden" value="' . esc_attr($advance) . '" />
2648 <input name="delButton[' . $i . '][' . $post_id . '][' . $sku . ']" class="delButton" type="submit" value="' . __('Delete','usces') . '" />
2649 </td>
2650 </tr>';
2651 $materials = compact('i', 'cart_row', 'post_id', 'sku', 'sku_code', 'quantity', 'options', 'advance',
2652 'itemCode', 'itemName', 'cartItemName', 'itemRestriction', 'skuPrice', 'skuZaikonum',
2653 'stockid', 'stock', 'red', 'pictid');
2654 $res .= apply_filters( 'usces_filter_cart_row', $row, $cart, $materials);
2655 }
2656
2657 $res = apply_filters( 'usces_filter_cart_rows', $res, $cart);
2658
2659 if($out == 'return'){
2660 return $res;
2661 }else{
2662 echo $res;
2663 }
2664 }
2665 function usces_get_confirm_rows( $out = '' ) {
2666 global $usces, $usces_members, $usces_entries;
2667 // $usces_members = $usces->get_member();
2668 $memid = ( empty($usces_members['ID']) ) ? 999999999 : $usces_members['ID'];
2669 // $usces_entries = $usces->cart->get_entry();
2670 $usces->set_cart_fees( $usces_members, $usces_entries );
2671 $usces_entries = $usces->cart->get_entry();
2672
2673 $cart = $usces->cart->get_cart();
2674 $res = '';
2675 for($i=0; $i<count($cart); $i++) {
2676 $cart_row = $cart[$i];
2677 $post_id = $cart_row['post_id'];
2678 $sku = esc_attr($cart_row['sku']);
2679 $sku_code = esc_attr(urldecode($cart_row['sku']));
2680 $quantity = $cart_row['quantity'];
2681 $options = $cart_row['options'];
2682 $advance = $usces->cart->wc_serialize($cart_row['advance']);
2683 $itemCode = $usces->getItemCode($post_id);
2684 $itemName = $usces->getItemName($post_id);
2685 $cartItemName = $usces->getCartItemName($post_id, $sku_code);
2686 $skuPrice = $cart_row['price'];
2687 $pictid = $usces->get_mainpictid($itemCode);
2688 $row = '';
2689 if (empty($options)) {
2690 $optstr = '';
2691 $options = array();
2692 }
2693
2694 $row .= '<tr>
2695 <td>' . ($i + 1) . '</td>
2696 <td>';
2697 $cart_thumbnail = wp_get_attachment_image( $pictid, array(60, 60), true );
2698 $row .= apply_filters('usces_filter_cart_thumbnail', $cart_thumbnail, $post_id, $pictid, $i, $cart_row);
2699 $row .= '</td><td class="aleft">' . $cartItemName . '<br />';
2700 if( is_array($options) && count($options) > 0 ){
2701 $optstr = '';
2702 foreach($options as $key => $value){
2703 //20110629ysk start 0000190
2704 //if( !empty($key) )
2705 // $row .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
2706 if( !empty($key) ) {
2707 $key = urldecode($key);
2708 if(is_array($value)) {
2709 $c = '';
2710 $optstr .= esc_html($key) . ' : ';
2711 foreach($value as $v) {
2712 $optstr .= $c.nl2br(esc_html(urldecode($v)));
2713 $c = ', ';
2714 }
2715 $optstr .= "<br />\n";
2716 } else {
2717 $optstr .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
2718 }
2719 }
2720 //20110629ysk end
2721 }
2722 $row .= apply_filters( 'usces_filter_option_confirm', $optstr, $options);
2723 }
2724 $row .= apply_filters( 'usces_filter_option_info_confirm', '', $cart_row );
2725 $row .= '</td>
2726 <td class="aright">' . usces_crform($skuPrice, true, false, 'return') . '</td>
2727 <td>' . $cart_row['quantity'] . '</td>
2728 <td class="aright">' . usces_crform(($skuPrice * $cart_row['quantity']), true, false, 'return') . '</td>
2729 <td>';
2730 $res = apply_filters('usces_additional_confirm', $res, array($i, $post_id, $sku_code));
2731 $row .= '</td>
2732 </tr>';
2733
2734 $materials = compact('i', 'cart_row', 'post_id', 'sku', 'sku_code', 'quantity', 'options', 'advance',
2735 'itemCode', 'itemName', 'cartItemName', 'skuPrice', 'pictid');
2736 $res .= apply_filters( 'usces_filter_confirm_row', $row, $cart, $materials);
2737 }
2738
2739 $res = apply_filters( 'usces_filter_confirm_rows', $res, $cart);
2740
2741 if($out == 'return'){
2742 return $res;
2743 }else{
2744 echo $res;
2745 }
2746 }
2747
2748 function uesces_addressform( $type, $data, $out = 'return' ){
2749 global $usces, $usces_settings;
2750 $options = get_option('usces');
2751 $form = $options['system']['addressform'];
2752 $nameform = $usces_settings['nameform'][$form];
2753 $applyform = usces_get_apply_addressform($form);
2754 $formtag = '';
2755 switch( $type ){
2756 case 'confirm':
2757 case 'member':
2758 $values = $data;
2759 break;
2760 case 'customer':
2761 case 'delivery':
2762 $values = $data[$type];
2763 break;
2764 }
2765 $data['type'] = $type;
2766 $values['country'] = !empty($values['country']) ? $values['country'] : usces_get_local_addressform();
2767 $values = $usces->stripslashes_deep_post($values);
2768 if( 'confirm' == $type ){
2769
2770 switch ($applyform){
2771
2772 case 'JP':
2773 $formtag .= usces_custom_field_info($data, 'customer', 'name_pre', 'return');
2774 $formtag .= '<tr><th>'.__('Full name', 'usces').'</th><td>' . esc_html($values['customer']['name1']) . ' ' . esc_html($values['customer']['name2']) . '</td></tr>';
2775 $furigana_customer = '<tr><th>'.__('furigana', 'usces').'</th><td>' . esc_html($values['customer']['name3']) . ' ' . esc_html($values['customer']['name4']) . '</td></tr>';
2776 $formtag .= apply_filters( 'usces_filter_furigana_confirm_customer', $furigana_customer, $type, $values );
2777 $formtag .= usces_custom_field_info($data, 'customer', 'name_after', 'return');
2778 $customer_country = (!empty($usces_settings['country'][$values['customer']['country']])) ? $usces_settings['country'][$values['customer']['country']] : '';
2779 $formtag .= '
2780 <tr><th>'.__('Zip/Postal Code', 'usces').'</th><td>' . esc_html($values['customer']['zipcode']) . '</td></tr>
2781 <tr><th>'.__('Country', 'usces').'</th><td>' . esc_html($customer_country) . '</td></tr>
2782 <tr><th>'.__('Province', 'usces').'</th><td>' . esc_html($values['customer']['pref']) . '</td></tr>
2783 <tr><th>'.__('city', 'usces').'</th><td>' . esc_html($values['customer']['address1']) . '</td></tr>
2784 <tr><th>'.__('numbers', 'usces').'</th><td>' . esc_html($values['customer']['address2']) . '</td></tr>
2785 <tr><th>'.__('building name', 'usces').'</th><td>' . esc_html($values['customer']['address3']) . '</td></tr>
2786 <tr><th>'.__('Phone number', 'usces').'</th><td>' . esc_html($values['customer']['tel']) . '</td></tr>
2787 <tr><th>'.__('FAX number', 'usces').'</th><td>' . esc_html($values['customer']['fax']) . '</td></tr>';
2788 $formtag .= usces_custom_field_info($data, 'customer', 'fax_after', 'return');
2789
2790 $shipping_address_info = '<tr class="ttl"><td colspan="2"><h3>'.__('Shipping address information', 'usces').'</h3></td></tr>';
2791 $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'name_pre', 'return');
2792 $shipping_address_info .= '<tr><th>'.__('Full name', 'usces').'</th><td>' . esc_html($values['delivery']['name1']) . ' ' . esc_html($values['delivery']['name2']) . '</td></tr>';
2793 $furigana_delivery = '<tr><th>'.__('furigana', 'usces').'</th><td>' . esc_html($values['delivery']['name3']) . ' ' . esc_html($values['delivery']['name4']) . '</td></tr>';
2794 $shipping_address_info .= apply_filters( 'usces_filter_furigana_confirm_delivery', $furigana_delivery, $type, $values );
2795 $shipping_address_info .= usces_custom_field_info($values, 'delivery', 'name_after', 'return');
2796 $shipping_country = (!empty($usces_settings['country'][$values['delivery']['country']])) ? $usces_settings['country'][$values['delivery']['country']] : '';
2797 $shipping_address_info .= '
2798 <tr><th>'.__('Zip/Postal Code', 'usces').'</th><td>' . esc_html($values['delivery']['zipcode']) . '</td></tr>
2799 <tr><th>'.__('Country', 'usces').'</th><td>' . esc_html($shipping_country) . '</td></tr>
2800 <tr><th>'.__('Province', 'usces').'</th><td>' . esc_html($values['delivery']['pref']) . '</td></tr>
2801 <tr><th>'.__('city', 'usces').'</th><td>' . esc_html($values['delivery']['address1']) . '</td></tr>
2802 <tr><th>'.__('numbers', 'usces').'</th><td>' . esc_html($values['delivery']['address2']) . '</td></tr>
2803 <tr><th>'.__('building name', 'usces').'</th><td>' . esc_html($values['delivery']['address3']) . '</td></tr>
2804 <tr><th>'.__('Phone number', 'usces').'</th><td>' . esc_html($values['delivery']['tel']) . '</td></tr>
2805 <tr><th>'.__('FAX number', 'usces').'</th><td>' . esc_html($values['delivery']['fax']) . '</td></tr>';
2806 $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'fax_after', 'return');
2807 $formtag .= apply_filters('usces_filter_shipping_address_info', $shipping_address_info);
2808 break;
2809
2810 case 'CN':
2811 $formtag .= usces_custom_field_info($data, 'customer', 'name_pre', 'return');
2812 $formtag .= '<tr><th>'.__('Full name', 'usces').'</th><td>' . esc_html(usces_localized_name( $values['customer']['name1'], $values['customer']['name2'], 'return' )) . '</td></tr>';
2813 $formtag .= usces_custom_field_info($data, 'customer', 'name_after', 'return');
2814 $formtag .= '
2815 <tr><th>'.__('Country', 'usces').'</th><td>' . esc_html($usces_settings['country'][$values['customer']['country']]) . '</td></tr>
2816 <tr><th>'.__('State', 'usces').'</th><td>' . esc_html($values['customer']['pref']) . '</td></tr>
2817 <tr><th>'.__('city', 'usces').'</th><td>' . esc_html($values['customer']['address1']) . '</td></tr>
2818 <tr><th>'.__('Address Line1', 'usces').'</th><td>' . esc_html($values['customer']['address2']) . '</td></tr>
2819 <tr><th>'.__('Address Line2', 'usces').'</th><td>' . esc_html($values['customer']['address3']) . '</td></tr>
2820 <tr><th>'.__('Zip', 'usces').'</th><td>' . esc_html($values['customer']['zipcode']) . '</td></tr>
2821 <tr><th>'.__('Phone number', 'usces').'</th><td>' . esc_html($values['customer']['tel']) . '</td></tr>
2822 <tr><th>'.__('FAX number', 'usces').'</th><td>' . esc_html($values['customer']['fax']) . '</td></tr>';
2823 $formtag .= usces_custom_field_info($data, 'customer', 'fax_after', 'return');
2824
2825 $shipping_address_info = '<tr class="ttl"><td colspan="2"><h3>'.__('Shipping address information', 'usces').'</h3></td></tr>';
2826 $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'name_pre', 'return');
2827 $shipping_address_info .= '<tr><th>'.__('Full name', 'usces').'</th><td>' . esc_html(usces_localized_name( $values['delivery']['name1'], $values['delivery']['name2'], 'return' )) . '</td></tr>';
2828 $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'name_after', 'return');
2829 $shipping_address_info .= '
2830 <tr><th>'.__('Country', 'usces').'</th><td>' . esc_html($usces_settings['country'][$values['delivery']['country']]) . '</td></tr>
2831 <tr><th>'.__('State', 'usces').'</th><td>' . esc_html($values['delivery']['pref']) . '</td></tr>
2832 <tr><th>'.__('city', 'usces').'</th><td>' . esc_html($values['delivery']['address1']) . '</td></tr>
2833 <tr><th>'.__('Address Line1', 'usces').'</th><td>' . esc_html($values['delivery']['address2']) . '</td></tr>
2834 <tr><th>'.__('Address Line2', 'usces').'</th><td>' . esc_html($values['delivery']['address3']) . '</td></tr>
2835 <tr><th>'.__('Zip', 'usces').'</th><td>' . esc_html($values['delivery']['zipcode']) . '</td></tr>
2836 <tr><th>'.__('Phone number', 'usces').'</th><td>' . esc_html($values['delivery']['tel']) . '</td></tr>
2837 <tr><th>'.__('FAX number', 'usces').'</th><td>' . esc_html($values['delivery']['fax']) . '</td></tr>';
2838 $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'fax_after', 'return');
2839 $formtag .= apply_filters('usces_filter_shipping_address_info', $shipping_address_info);
2840 break;
2841
2842 case 'US':
2843 default :
2844 $formtag .= usces_custom_field_info($data, 'customer', 'name_pre', 'return');
2845 $formtag .= '<tr><th>'.__('Full name', 'usces').'</th><td>' . esc_html($values['customer']['name2']) . ' ' . esc_html($values['customer']['name1']) . '</td></tr>';
2846 $formtag .= usces_custom_field_info($data, 'customer', 'name_after', 'return');
2847 $customer_country = (!empty($usces_settings['country'][$values['customer']['country']])) ? $usces_settings['country'][$values['customer']['country']] : '';
2848 $formtag .= '
2849 <tr><th>'.__('Address Line1', 'usces').'</th><td>' . esc_html($values['customer']['address2']) . '</td></tr>
2850 <tr><th>'.__('Address Line2', 'usces').'</th><td>' . esc_html($values['customer']['address3']) . '</td></tr>
2851 <tr><th>'.__('city', 'usces').'</th><td>' . esc_html($values['customer']['address1']) . '</td></tr>
2852 <tr><th>'.__('State', 'usces').'</th><td>' . esc_html($values['customer']['pref']) . '</td></tr>
2853 <tr><th>'.__('Country', 'usces').'</th><td>' . esc_html($customer_country) . '</td></tr>
2854 <tr><th>'.__('Zip', 'usces').'</th><td>' . esc_html($values['customer']['zipcode']) . '</td></tr>
2855 <tr><th>'.__('Phone number', 'usces').'</th><td>' . esc_html($values['customer']['tel']) . '</td></tr>
2856 <tr><th>'.__('FAX number', 'usces').'</th><td>' . esc_html($values['customer']['fax']) . '</td></tr>';
2857 $formtag .= usces_custom_field_info($data, 'customer', 'fax_after', 'return');
2858
2859 $shipping_address_info = '<tr class="ttl"><td colspan="2"><h3>'.__('Shipping address information', 'usces').'</h3></td></tr>';
2860 $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'name_pre', 'return');
2861 $shipping_address_info .= '<tr><th>'.__('Full name', 'usces').'</th><td>' . esc_html($values['delivery']['name2']) . ' ' . esc_html($values['delivery']['name1']) . '</td></tr>';
2862 $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'name_after', 'return');
2863 $shipping_country = (!empty($usces_settings['country'][$values['delivery']['country']])) ? $usces_settings['country'][$values['delivery']['country']] : '';
2864 $shipping_address_info .= '
2865 <tr><th>'.__('Address Line1', 'usces').'</th><td>' . esc_html($values['delivery']['address2']) . '</td></tr>
2866 <tr><th>'.__('Address Line2', 'usces').'</th><td>' . esc_html($values['delivery']['address3']) . '</td></tr>
2867 <tr><th>'.__('city', 'usces').'</th><td>' . esc_html($values['delivery']['address1']) . '</td></tr>
2868 <tr><th>'.__('State', 'usces').'</th><td>' . esc_html($values['delivery']['pref']) . '</td></tr>
2869 <tr><th>'.__('Country', 'usces').'</th><td>' . esc_html($shipping_country) . '</td></tr>
2870 <tr><th>'.__('Zip', 'usces').'</th><td>' . esc_html($values['delivery']['zipcode']) . '</td></tr>
2871 <tr><th>'.__('Phone number', 'usces').'</th><td>' . esc_html($values['delivery']['tel']) . '</td></tr>
2872 <tr><th>'.__('FAX number', 'usces').'</th><td>' . esc_html($values['delivery']['fax']) . '</td></tr>';
2873 $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'fax_after', 'return');
2874 $formtag .= apply_filters('usces_filter_shipping_address_info', $shipping_address_info);
2875 break;
2876
2877 }
2878 $res = apply_filters('usces_filter_apply_addressform_confirm', $formtag, $type, $data);
2879
2880 }else{
2881
2882 switch ($applyform){
2883
2884 case 'JP':
2885 $formtag .= usces_custom_field_input($data, $type, 'name_pre', 'return');
2886 $formtag .= '<tr class="inp1">
2887 <th width="127" scope="row">' . usces_get_essential_mark('name1', $data) . __('Full name', 'usces').'</th>';
2888 if( $nameform ){
2889 $formtag .= '<td class="name_td">'.__('Given name', 'usces').'<input name="' . $type . '[name2]" id="name2" type="text" value="' . esc_attr($values['name2']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" style="ime-mode: active" /></td>';
2890 $formtag .= '<td class="name_td">'.__('Familly name', 'usces').'<input name="' . $type . '[name1]" id="name1" type="text" value="' . esc_attr($values['name1']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" style="ime-mode: active" /></td>';
2891 }else{
2892 $formtag .= '<td class="name_td">'.__('Familly name', 'usces').'<input name="' . $type . '[name1]" id="name1" type="text" value="' . esc_attr($values['name1']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" style="ime-mode: active" /></td>';
2893 $formtag .= '<td class="name_td">'.__('Given name', 'usces').'<input name="' . $type . '[name2]" id="name2" type="text" value="' . esc_attr($values['name2']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" style="ime-mode: active" /></td>';
2894 }
2895 $formtag .= '</tr>';
2896 $furigana = '<tr class="inp1">
2897 <th scope="row">' . usces_get_essential_mark('name3', $data).__('furigana', 'usces').'</th>';
2898 if( $nameform ){
2899 $furigana .= '<td>'.__('Given name', 'usces').'<input name="' . $type . '[name4]" id="name4" type="text" value="' . esc_attr($values['name4']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" style="ime-mode: active" /></td>';
2900 $furigana .= '<td>'.__('Familly name', 'usces').'<input name="' . $type . '[name3]" id="name3" type="text" value="' . esc_attr($values['name3']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" style="ime-mode: active" /></td>';
2901 }else{
2902 $furigana .= '<td>'.__('Familly name', 'usces').'<input name="' . $type . '[name3]" id="name3" type="text" value="' . esc_attr($values['name3']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" style="ime-mode: active" /></td>';
2903 $furigana .= '<td>'.__('Given name', 'usces').'<input name="' . $type . '[name4]" id="name4" type="text" value="' . esc_attr($values['name4']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" style="ime-mode: active" /></td>';
2904 }
2905 $furigana .= '</tr>';
2906 $formtag .= apply_filters( 'usces_filter_furigana_form', $furigana, $type, $values );
2907 $formtag .= usces_custom_field_input($data, $type, 'name_after', 'return');
2908 $formtag .= '<tr>
2909 <th scope="row">' . usces_get_essential_mark('zipcode', $data).__('Zip/Postal Code', 'usces').'</th>
2910 <td colspan="2"><input name="' . $type . '[zipcode]" id="zipcode" type="text" value="' . esc_attr($values['zipcode']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" style="ime-mode: inactive" />'.apply_filters('usces_filter_addressform_zipcode', NULL, $type) . apply_filters( 'usces_filter_after_zipcode', '100-1000', $applyform ) . '</td>
2911 </tr>
2912 <tr>
2913 <th scope="row">' . usces_get_essential_mark('country', $data) . __('Country', 'usces') . '</th>
2914 <td colspan="2">' . uesces_get_target_market_form( $type, $values['country'] ) . apply_filters( 'usces_filter_after_country', NULL, $applyform ) . '</td>
2915 </tr>
2916 <tr>
2917 <th scope="row">' . usces_get_essential_mark('states', $data).__('Province', 'usces').'</th>
2918 <td colspan="2">' . usces_pref_select( $type, $values ) . apply_filters( 'usces_filter_after_states', NULL, $applyform ) . '</td>
2919 </tr>
2920 <tr class="inp2">
2921 <th scope="row">' . usces_get_essential_mark('address1', $data).__('city', 'usces').'</th>
2922 <td colspan="2"><input name="' . $type . '[address1]" id="address1" type="text" value="' . esc_attr($values['address1']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" style="ime-mode: active" />' . apply_filters( 'usces_filter_after_address1', __('Kitakami Yokohama', 'usces'), $applyform ) . '</td>
2923 </tr>
2924 <tr>
2925 <th scope="row">' . usces_get_essential_mark('address2', $data).__('numbers', 'usces').'</th>
2926 <td colspan="2"><input name="' . $type . '[address2]" id="address2" type="text" value="' . esc_attr($values['address2']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" style="ime-mode: active" />' . apply_filters( 'usces_filter_after_address2', '3-24-555', $applyform ) . '</td>
2927 </tr>
2928 <tr>
2929 <th scope="row">' . usces_get_essential_mark('address3', $data).__('building name', 'usces').'</th>
2930 <td colspan="2"><input name="' . $type . '[address3]" id="address3" type="text" value="' . esc_attr($values['address3']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" style="ime-mode: active" />' . apply_filters( 'usces_filter_after_address3', __('tuhanbuild 4F', 'usces'), $applyform ) . '</td>
2931 </tr>
2932 <tr>
2933 <th scope="row">' . usces_get_essential_mark('tel', $data).__('Phone number', 'usces').'</th>
2934 <td colspan="2"><input name="' . $type . '[tel]" id="tel" type="text" value="' . esc_attr($values['tel']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" style="ime-mode: inactive" />' . apply_filters( 'usces_filter_after_tel', '1000-10-1000', $applyform ) . '</td>
2935 </tr>
2936 <tr>
2937 <th scope="row">' . usces_get_essential_mark('fax', $data).__('FAX number', 'usces').'</th>
2938 <td colspan="2"><input name="' . $type . '[fax]" id="fax" type="text" value="' . esc_attr($values['fax']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" style="ime-mode: inactive" />' . apply_filters( 'usces_filter_after_fax', '1000-10-1000', $applyform ) . '</td>
2939 </tr>';
2940 $formtag .= usces_custom_field_input($data, $type, 'fax_after', 'return');
2941 break;
2942
2943 case 'CN':
2944 $formtag .= usces_custom_field_input($data, $type, 'name_pre', 'return');
2945 $formtag .= '<tr class="inp1">
2946 <th scope="row">' . usces_get_essential_mark('name1', $data) . __('Full name', 'usces') . '</th>';
2947 if( $nameform ){
2948 $formtag .= '<td>' . __('Given name', 'usces') . '<input name="' . $type . '[name2]" id="name2" type="text" value="' . esc_attr($values['name2']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" /></td>';
2949 $formtag .= '<td>' . __('Familly name', 'usces') . '<input name="' . $type . '[name1]" id="name1" type="text" value="' . esc_attr($values['name1']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" /></td>';
2950 }else{
2951 $formtag .= '<td>' . __('Familly name', 'usces') . '<input name="' . $type . '[name1]" id="name1" type="text" value="' . esc_attr($values['name1']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" /></td>';
2952 $formtag .= '<td>' . __('Given name', 'usces') . '<input name="' . $type . '[name2]" id="name2" type="text" value="' . esc_attr($values['name2']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" /></td>';
2953 }
2954 $formtag .= '</tr>';
2955 $formtag .= usces_custom_field_input($data, $type, 'name_after', 'return');
2956 $formtag .= '
2957 <tr>
2958 <th scope="row">' . usces_get_essential_mark('country', $data) . __('Country', 'usces') . '</th>
2959 <td colspan="2">' . uesces_get_target_market_form( $type, $values['country'] ) . apply_filters( 'usces_filter_after_country', NULL, $applyform ) . '</td>
2960 </tr>
2961 <tr>
2962 <th scope="row">' . usces_get_essential_mark('states', $data) . __('State', 'usces') . '</th>
2963 <td colspan="2">' . usces_pref_select( $type, $values ) . apply_filters( 'usces_filter_after_states', NULL, $applyform ) . '</td>
2964 </tr>
2965 <tr class="inp2">
2966 <th scope="row">' . usces_get_essential_mark('address1', $data) . __('city', 'usces') . '</th>
2967 <td colspan="2"><input name="' . $type . '[address1]" id="address1" type="text" value="' . esc_attr($values['address1']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" />' . apply_filters( 'usces_filter_after_address1', NULL, $applyform ) . '</td>
2968 </tr>
2969 <tr>
2970 <th scope="row">' . usces_get_essential_mark('address2', $data) . __('Address Line1', 'usces') . '</th>
2971 <td colspan="2">' . __('Street address', 'usces') . '<br /><input name="' . $type . '[address2]" id="address2" type="text" value="' . esc_attr($values['address2']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" />' . apply_filters( 'usces_filter_after_address2', NULL, $applyform ) . '</td>
2972 </tr>
2973 <tr>
2974 <th scope="row">' . usces_get_essential_mark('address3', $data) . __('Address Line2', 'usces') . '</th>
2975 <td colspan="2">' . __('Apartment, building, etc.', 'usces') . '<br /><input name="' . $type . '[address3]" id="address3" type="text" value="' . esc_attr($values['address3']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" />' . apply_filters( 'usces_filter_after_address3', NULL, $applyform ) . '</td>
2976 </tr>
2977 <tr>
2978 <th scope="row">' . usces_get_essential_mark('zipcode', $data) . __('Zip', 'usces') . '</th>
2979 <td colspan="2"><input name="' . $type . '[zipcode]" id="zipcode" type="text" value="' . esc_attr($values['zipcode']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" />' . apply_filters( 'usces_filter_after_zipcode', NULL, $applyform ) . '</td>
2980 </tr>
2981 <tr>
2982 <th scope="row">' . usces_get_essential_mark('tel', $data) . __('Phone number', 'usces') . '</th>
2983 <td colspan="2"><input name="' . $type . '[tel]" id="tel" type="text" value="' . esc_attr($values['tel']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" />' . apply_filters( 'usces_filter_after_tel', NULL, $applyform ) . '</td>
2984 </tr>
2985 <tr>
2986 <th scope="row">' . usces_get_essential_mark('fax', $data) . __('FAX number', 'usces') . '</th>
2987 <td colspan="2"><input name="' . $type . '[fax]" id="fax" type="text" value="' . esc_attr($values['fax']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" />' . apply_filters( 'usces_filter_after_fax', NULL, $applyform ) . '</td>
2988 </tr>';
2989 $formtag .= usces_custom_field_input($data, $type, 'fax_after', 'return');
2990 break;
2991
2992 case 'US':
2993 default :
2994 $formtag .= usces_custom_field_input($data, $type, 'name_pre', 'return');
2995 $formtag .= '<tr class="inp1">
2996 <th scope="row">' . usces_get_essential_mark('name1', $data) . __('Full name', 'usces') . '</th>';
2997 if( $nameform ){
2998 $formtag .= '<td>' . __('Given name', 'usces') . '<input name="' . $type . '[name2]" id="name2" type="text" value="' . esc_attr($values['name2']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" /></td>';
2999 $formtag .= '<td>' . __('Familly name', 'usces') . '<input name="' . $type . '[name1]" id="name1" type="text" value="' . esc_attr($values['name1']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" /></td>';
3000 }else{
3001 $formtag .= '<td>' . __('Familly name', 'usces') . '<input name="' . $type . '[name1]" id="name1" type="text" value="' . esc_attr($values['name1']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" /></td>';
3002 $formtag .= '<td>' . __('Given name', 'usces') . '<input name="' . $type . '[name2]" id="name2" type="text" value="' . esc_attr($values['name2']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" /></td>';
3003 }
3004 $formtag .= '</tr>';
3005 $formtag .= usces_custom_field_input($data, $type, 'name_after', 'return');
3006 $formtag .= '
3007 <tr>
3008 <th scope="row">' . usces_get_essential_mark('address2', $data) . __('Address Line1', 'usces') . '</th>
3009 <td colspan="2">' . __('Street address', 'usces') . '<br /><input name="' . $type . '[address2]" id="address2" type="text" value="' . esc_attr($values['address2']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" />' . apply_filters( 'usces_filter_after_address2', NULL, $applyform ) . '</td>
3010 </tr>
3011 <tr>
3012 <th scope="row">' . usces_get_essential_mark('address3', $data) . __('Address Line2', 'usces') . '</th>
3013 <td colspan="2">' . __('Apartment, building, etc.', 'usces') . '<br /><input name="' . $type . '[address3]" id="address3" type="text" value="' . esc_attr($values['address3']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" />' . apply_filters( 'usces_filter_after_address3', NULL, $applyform ) . '</td>
3014 </tr>
3015 <tr class="inp2">
3016 <th scope="row">' . usces_get_essential_mark('address1', $data) . __('city', 'usces') . '</th>
3017 <td colspan="2"><input name="' . $type . '[address1]" id="address1" type="text" value="' . esc_attr($values['address1']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" />' . apply_filters( 'usces_filter_after_address1', NULL, $applyform ) . '</td>
3018 </tr>
3019 <tr>
3020 <th scope="row">' . usces_get_essential_mark('states', $data) . __('State', 'usces') . '</th>
3021 <td colspan="2">' . usces_pref_select( $type, $values ) . apply_filters( 'usces_filter_after_states', NULL, $applyform ) . '</td>
3022 </tr>
3023 <tr>
3024 <th scope="row">' . usces_get_essential_mark('country', $data) . __('Country', 'usces') . '</th>
3025 <td colspan="2">' . uesces_get_target_market_form( $type, $values['country'] ) . apply_filters( 'usces_filter_after_country', NULL, $applyform ) . '</td>
3026 </tr>
3027 <tr>
3028 <th scope="row">' . usces_get_essential_mark('zipcode', $data) . __('Zip', 'usces') . '</th>
3029 <td colspan="2"><input name="' . $type . '[zipcode]" id="zipcode" type="text" value="' . esc_attr($values['zipcode']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" />' . apply_filters( 'usces_filter_after_zipcode', NULL, $applyform ) . '</td>
3030 </tr>
3031 <tr>
3032 <th scope="row">' . usces_get_essential_mark('tel', $data) . __('Phone number', 'usces') . '</th>
3033 <td colspan="2"><input name="' . $type . '[tel]" id="tel" type="text" value="' . esc_attr($values['tel']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" />' . apply_filters( 'usces_filter_after_tel', NULL, $applyform ) . '</td>
3034 </tr>
3035 <tr>
3036 <th scope="row">' . usces_get_essential_mark('fax', $data) . __('FAX number', 'usces') . '</th>
3037 <td colspan="2"><input name="' . $type . '[fax]" id="fax" type="text" value="' . esc_attr($values['fax']) . '" onKeyDown="if (event.keyCode == 13) {return false;}" />' . apply_filters( 'usces_filter_after_fax', NULL, $applyform ) . '</td>
3038 </tr>';
3039 $formtag .= usces_custom_field_input($data, $type, 'fax_after', 'return');
3040 break;
3041 }
3042 $res = apply_filters('usces_filter_apply_addressform', $formtag, $type, $data);
3043
3044 }
3045
3046 if($out == 'return') {
3047 return $res;
3048 } else {
3049 echo $res;
3050 }
3051 }
3052
3053 function usces_item_option_fileds( $post_id, $sku, $label=1, $out='echo' ){
3054 $options = usces_get_opts($post_id, 'sort');
3055 if( 0 == count($options) )
3056 return false;
3057
3058 $sku_enc = urlencode($sku);
3059 $html ='';
3060 foreach( $options as $opt ){
3061 $name = $opt['name'];
3062 $opt_code = urlencode($name);
3063 $html .= "\n" . '<div class="opt_field" id="opt_' . $post_id . '_' . $sku_enc . '_' . $opt_code . '">';
3064 if( $label ){
3065 $html .= '<label for="itemOption[' . $post_id . '][' . $sku_enc . '][' . $opt_code . ']">' . esc_html($name) . '</label>';
3066 }
3067 $html .= usces_get_itemopt_filed($post_id, $sku, $opt);
3068 $html .= '</div>';
3069 }
3070 if( $out == 'return' ){
3071 return $html;
3072 }else{
3073 echo $html;
3074 }
3075 }
3076
3077 function usces_facebook_like(){
3078 global $post, $usces;
3079 $like = array(
3080 'url' => urlencode(get_permalink($post->ID)),
3081 'send' => 'false',
3082 'layout' => 'button_count', //standard, button_count, box_count
3083 'width' => '450',
3084 'height' => '35',
3085 'show_faces' => 'false',
3086 'action' => 'like', //like, recommend
3087 );
3088 $like = apply_filters( 'usces_filter_facebook_like', $like, $post->ID );
3089 ?>
3090 <iframe src="//www.facebook.com/plugins/like.php?href=<?php echo $like['url']; ?>&amp;send=<?php echo $like['send']; ?>&amp;layout=<?php echo $like['layout']; ?>&amp;width=<?php echo $like['width']; ?>&amp;show_faces=<?php echo $like['show_faces']; ?>&amp;action=<?php echo $like['action']; ?>&amp;colorscheme=light&amp;font=arial&amp;height=<?php echo $like['height']; ?>" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:<?php echo $like['width']; ?>px; height:<?php echo $like['height']; ?>px;" allowTransparency="true"></iframe>
3091 <?php
3092 }
3093
3094 function usces_action_confirm_page_point_inform_zeus() {
3095 $html = usces_point_inform_zeus();
3096 echo $html;
3097 }
3098
3099 function usces_filter_confirm_point_inform_zeus( $html ) {
3100 $html .= usces_point_inform_zeus();
3101 return $html;
3102 }
3103
3104 function usces_point_inform_zeus() {
3105 global $usces, $usces_entries;
3106 $html = '';
3107
3108 $payments = usces_get_payments_by_name( $usces_entries['order']['payment_name'] );
3109 $acting_flag = ( 'acting' == $payments['settlement'] ) ? $payments['module'] : $payments['settlement'];
3110
3111 switch( $acting_flag ) {
3112 case 'acting_zeus_card':
3113 $html .= '<input type="hidden" name="cnum1" value="'.$_POST['cnum1'].'">';
3114 if( isset($_POST['securecode']) ) {
3115 $html .= '<input type="hidden" name="securecode" value="'.$_POST['securecode'].'">';
3116 }
3117 $html .= '<input type="hidden" name="expyy" value="'.$_POST['expyy'].'">';
3118 $html .= '<input type="hidden" name="expmm" value="'.$_POST['expmm'].'">';
3119 $html .= '<input type="hidden" name="username" value="'.$_POST['username'].'">';
3120 if( isset($_POST['howpay']) ) {
3121 $html .= '<input type="hidden" name="howpay" value="'.$_POST['howpay'].'">';
3122 }
3123 if( isset($_POST['cbrand']) ) {
3124 $html .= '<input type="hidden" name="cbrand" value="'.$_POST['cbrand'].'">';
3125 $html .= '<input type="hidden" name="div_1" value="'.$_POST['div_1'].'">';
3126 $html .= '<input type="hidden" name="div_2" value="'.$_POST['div_2'].'">';
3127 $html .= '<input type="hidden" name="div_3" value="'.$_POST['div_3'].'">';
3128 }
3129 break;
3130
3131 case 'acting_zeus_conv':
3132 if( isset($_POST['pay_cvs']) ) {
3133 $html = '<input type="hidden" name="pay_cvs" value="'.$_POST['pay_cvs'].'">';
3134 }
3135 break;
3136 }
3137 return $html;
3138 }
3139
3140 ?>