PluginProbe
Welcart e-Commerce / 1.4.0
Welcart e-Commerce v1.4.0
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.4.0, at functions/template_func.php

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