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

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

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