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

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