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

3,155 lines 107.6 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.'" 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).']" 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 if($out == 'return') {
2224 return stripslashes($html);
2225 } else {
2226 echo stripslashes($html);
2227 }
2228 }
2229
2230 function has_custom_customer_field_essential() {
2231
2232 $mes = '';
2233 $essential = array();
2234
2235 $csmb_meta = usces_has_custom_field_meta('member');
2236 if(!empty($csmb_meta) and is_array($csmb_meta)) {
2237 foreach($csmb_meta as $key => $entry) {
2238 if($entry['essential'] == 1) {
2239 $essential[$key] = $key;
2240 }
2241 }
2242 }
2243 if(!empty($essential)) {
2244 $cscs_meta = usces_has_custom_field_meta('customer');
2245 if(!empty($cscs_meta) and is_array($cscs_meta)) {
2246 foreach($cscs_meta as $key => $entry) {
2247 if($entry['essential'] == 1) {
2248 if(!array_key_exists($key, $essential)) {
2249 if($entry['means'] == 2) {//Text
2250 $mes .= __(esc_html($entry['name']).'を�
2251 �力してください。', 'usces')."<br />";
2252 } else {
2253 $mes .= __(esc_html($entry['name']).'を選択してください。', 'usces')."<br />";
2254 }
2255 }
2256 }
2257 }
2258 }
2259 }
2260 return $mes;
2261 }
2262 //20100818ysk end
2263
2264 function usces_order_discount( $out = '' ){
2265 global $usces;
2266 $res = abs($usces->get_order_discount());
2267
2268 if($out == 'return') {
2269 return $res;
2270 } else {
2271 echo number_format($res);
2272 }
2273 }
2274
2275 function usces_item_discount( $out = '', $post_id = '', $sku = '' ){
2276 global $usces, $post;
2277
2278 if( '' == $post_id )
2279 $post_id = $post->ID;
2280 if( '' == $sku )
2281 $sku = $usces->itemsku['code'];
2282
2283 $res = $usces->getItemDiscount($post_id, $sku);
2284
2285 if($out == 'return') {
2286 return $res;
2287 } else {
2288 echo number_format($res);
2289 }
2290 }
2291
2292 function usces_singleitem_error_message($post_id, $skukey, $out = ''){
2293 if( !isset($_SESSION['usces_singleitem']['error_message'][$post_id][$skukey]) )
2294 $ret = '';
2295 else
2296 $ret = $_SESSION['usces_singleitem']['error_message'][$post_id][$skukey];
2297
2298 if($out == 'return') {
2299 return $ret;
2300 } else {
2301 echo $ret;
2302 }
2303 }
2304
2305 function usces_crform( $float, $symbol_pre = true, $symbol_post = true, $out = '', $seperator_flag = true ) {
2306 global $usces;
2307 $price = esc_html($usces->get_currency($float, $symbol_pre, $symbol_post, $seperator_flag ));
2308 $res = apply_filters('usces_filter_crform', $price, $float);
2309
2310 if($out == 'return'){
2311 return $res;
2312 }else{
2313 echo $res;
2314 }
2315 }
2316
2317 function usces_memberinfo( $key, $out = '' ){
2318 global $usces, $wpdb;
2319 $info = $usces->get_member();
2320
2321 if( empty($key) ) return $info;
2322
2323 switch ($key){
2324 case 'registered':
2325 $res = mysql2date(__('Mj, Y', 'usces'), $info['registered']);
2326 break;
2327 //20120919ysk start 0000573
2328 case 'point':
2329 $member_table = $wpdb->prefix."usces_member";
2330 $query = $wpdb->prepare("SELECT mem_point FROM $member_table WHERE ID = %d", $info['ID']);
2331 $res = $wpdb->get_var( $query );
2332 break;
2333 //20120919ysk end
2334 default:
2335 $res = isset($info[$key]) ? $info[$key] : '';
2336 }
2337
2338 if($out == 'return'){
2339 return $res;
2340 }else{
2341 echo esc_html($res);
2342 }
2343 }
2344
2345 function usces_localized_name( $Familly_name, $Given_name, $out = '' ){
2346 global $usces_settings, $usces;
2347
2348 $options = get_option('usces');
2349 $form = $options['system']['addressform'];
2350 if( $usces_settings['nameform'][$form] ){
2351 $res = $Given_name . ' ' . $Familly_name;
2352 }else{
2353 $res = $Familly_name . ' ' . $Given_name;
2354 }
2355
2356 if($out == 'return'){
2357 return $res;
2358 }else{
2359 echo esc_html($res);
2360 }
2361 }
2362
2363 function usces_member_history( $out = '' ){
2364 global $usces;
2365
2366 $usces_members = $usces->get_member();
2367 $usces_member_history = $usces->get_member_history($usces_members['ID']);
2368 $colspan = usces_is_membersystem_point() ? 9 : 7;
2369
2370 $html = '<table>';
2371 if ( !count($usces_member_history) ) {
2372 $html .= '<tr>
2373 <td>' . __('There is no purchase history for this moment.', 'usces') . '</td>
2374 </tr>';
2375 }
2376 foreach ( $usces_member_history as $umhs ) {
2377 $cart = $umhs['cart'];
2378 $history_member_head = '<tr>
2379 <th class="historyrow">' . __('Order number', 'usces') . '</th>
2380 <th class="historyrow">' . __('Purchase date', 'usces') . '</th>
2381 <th class="historyrow">' . __('Purchase price', 'usces') . '</th>';
2382 if( usces_is_membersystem_point() ){
2383 $history_member_head .= '<th class="historyrow">' . __('Used points', 'usces') . '</th>';
2384 }
2385 $history_member_head .= '<th class="historyrow">' . apply_filters( 'usces_member_discount_label', __('Special Price', 'usces'), $umhs['ID'] ) . '</th>
2386 <th class="historyrow">' . __('Shipping', 'usces') . '</th>
2387 <th class="historyrow">' . __('C.O.D', 'usces') . '</th>
2388 <th class="historyrow">' . __('consumption tax', 'usces') . '</th>';
2389 if( usces_is_membersystem_point() ){
2390 $history_member_head .= '<th class="historyrow">' . __('Acquired points', 'usces') . '</th>';
2391 }
2392 $history_member_head .= '</tr>
2393 <tr>
2394 <td class="rightnum">' . usces_get_deco_order_id($umhs['ID']) . '</td>
2395 <td class="date">' . $umhs['date'] . '</td>
2396 <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>';
2397 if( usces_is_membersystem_point() ){
2398 $history_member_head .= '<td class="rightnum">' . number_format($umhs['usedpoint']) . '</td>';
2399 }
2400 $history_member_head .= '<td class="rightnum">' . usces_crform($umhs['discount'], true, false, 'return') . '</td>
2401 <td class="rightnum">' . usces_crform($umhs['shipping_charge'], true, false, 'return') . '</td>
2402 <td class="rightnum">' . usces_crform($umhs['cod_fee'], true, false, 'return') . '</td>
2403 <td class="rightnum">' . usces_crform($umhs['tax'], true, false, 'return') . '</td>';
2404 if( usces_is_membersystem_point() ){
2405 $history_member_head .= '<td class="rightnum">' . number_format($umhs['getpoint']) . '</td>';
2406 }
2407 $history_member_head .= '</tr>';
2408 $html .= apply_filters( 'usces_filter_history_member_head', $history_member_head, $umhs );
2409 $html .= apply_filters('usces_filter_member_history_header', NULL, $umhs);
2410 $html .= '<tr>
2411 <td class="retail" colspan="' . $colspan . '">
2412 <table id="retail_table_' . $umhs['ID'] . '" class="retail">';
2413 $history_cart_head = '<tr>
2414 <th scope="row" class="num">No.</th>
2415 <th class="thumbnail">&nbsp;</th>
2416 <th>' . __('Items', 'usces') . '</th>
2417 <th class="price ">' . __('Unit price', 'usces') . '</th>
2418 <th class="quantity">' . __('Quantity', 'usces') . '</th>
2419 <th class="subtotal">' . __('Amount', 'usces') . '</th>
2420 </tr>';
2421 $html .= apply_filters('usces_filter_history_cart_head', $history_cart_head, $umhs);
2422
2423 for($i=0; $i<count($cart); $i++) {
2424 $cart_row = $cart[$i];
2425 $post_id = $cart_row['post_id'];
2426 $sku = urldecode($cart_row['sku']);
2427 $quantity = $cart_row['quantity'];
2428 $options = $cart_row['options'];
2429 $itemCode = $usces->getItemCode($post_id);
2430 $itemName = $usces->getItemName($post_id);
2431 $cartItemName = $usces->getCartItemName($post_id, $sku);
2432 //$skuPrice = $usces->getItemPrice($post_id, $sku);
2433 $skuPrice = $cart_row['price'];
2434 $pictid = (int)$usces->get_mainpictid($itemCode);
2435 $optstr = '';
2436 if( is_array($options) && count($options) > 0 ){
2437 $optstr = '';
2438 foreach($options as $key => $value){
2439 //20110629ysk start 0000190
2440 //f( !empty($key) )
2441 // $optstr .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
2442 if( !empty($key) ) {
2443 $key = urldecode($key);
2444 if(is_array($value)) {
2445 $c = '';
2446 $optstr .= esc_html($key) . ' : ';
2447 foreach($value as $v) {
2448 $optstr .= $c.nl2br(esc_html(urldecode($v)));
2449 $c = ', ';
2450 }
2451 $optstr .= "<br />\n";
2452 } else {
2453 $optstr .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
2454 }
2455 }
2456 //20110629ysk end
2457 }
2458 $optstr = apply_filters( 'usces_filter_option_history', $optstr, $options);
2459 }
2460 $optstr = apply_filters( 'usces_filter_option_info_history', $optstr, $umhs, $cart_row, $i );
2461
2462 $history_cart_row = '<tr>
2463 <td>' . ($i + 1) . '</td>
2464 <td>';
2465 $cart_thumbnail = '<a href="' . get_permalink($post_id) . '">' . wp_get_attachment_image( $pictid, array(60, 60), true ) . '</a>';
2466 $history_cart_row .= apply_filters('usces_filter_cart_thumbnail', $cart_thumbnail, $post_id, $pictid, $i, $cart_row);
2467 $history_cart_row .= '</td>
2468 <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>
2469 <td class="rightnum">' . usces_crform($skuPrice, true, false, 'return') . '</td>
2470 <td class="rightnum">' . number_format($cart_row['quantity']) . '</td>
2471 <td class="rightnum">' . usces_crform($skuPrice * $cart_row['quantity'], true, false, 'return') . '</td>
2472 </tr>';
2473 $materials = compact( 'cart_thumbnail', 'post_id', 'pictid', 'cartItemName', 'optstr' );
2474 $html .= apply_filters( 'usces_filter_history_cart_row', $history_cart_row, $umhs, $cart_row, $i, $materials );
2475 }
2476 $html .= '</table>
2477 </td>
2478 </tr>';
2479 }
2480
2481 $html .= '</table>';
2482
2483 if($out == 'return'){
2484 return $html;
2485 }else{
2486 echo $html;
2487 }
2488 }
2489
2490 function usces_newmember_button($member_regmode){
2491 $html = '<input name="member_regmode" type="hidden" value="' . $member_regmode . '" />';
2492 $newmemberbutton = '<input name="regmember" type="submit" value="' . __('transmit a message', 'usces') . '" />';
2493 $html .= apply_filters('usces_filter_newmember_button', $newmemberbutton);
2494 echo $html;
2495 }
2496
2497 function usces_login_button(){
2498 $loginbutton = '<input type="submit" name="member_login" id="member_login" class="member_login_button" value="' . __('Log-in', 'usces') . '" />';
2499 $html = apply_filters('usces_filter_login_button', $loginbutton);
2500 echo $html;
2501 }
2502
2503 function usces_assistance_item($post_id, $title ){
2504 if (usces_get_assistance_id_list($post_id)) :
2505 global $post;
2506 $r = new WP_Query( array('post__in'=>usces_get_assistance_ids($post_id), 'ignore_sticky_posts'=>1) );
2507 if($r->have_posts()) :
2508 add_filter( 'excerpt_length', 'welcart_assistance_excerpt_length' );
2509 add_filter( 'excerpt_mblength', 'welcart_assistance_excerpt_mblength' );
2510 $width = apply_filters( 'usces_filter_assistance_item_width', 100 );
2511 $height = apply_filters( 'usces_filter_assistance_item_height', 100 );
2512 ?>
2513 <div class="assistance_item">
2514 <h3><?php echo $title; ?></h3>
2515 <ul class="clearfix">
2516 <?php
2517 while ($r->have_posts()) :
2518 $r->the_post();
2519 usces_remove_filter();
2520 usces_the_item();
2521 ob_start();
2522 ?>
2523 <li>
2524 <div class="listbox clearfix">
2525 <div class="slit">
2526 <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>
2527 </div>
2528 <div class="detail">
2529 <div class="assist_excerpt">
2530 <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php echo wp_filter_nohtml_kses(get_the_title()); ?>"><h4><?php usces_the_itemName(); ?></h4></a>
2531 <?php the_excerpt(); ?>
2532 </div>
2533 <div class="assist_price">
2534 <?php if (usces_is_skus()) : ?>
2535 <?php _e('$', 'usces'); ?><?php usces_the_firstPrice(); ?>
2536 <?php endif; ?>
2537 </div>
2538 </div>
2539 </div>
2540 </li>
2541 <?php
2542 $list = ob_get_contents();
2543 ob_end_clean();
2544 echo apply_filters('usces_filter_assistance_item_list', $list, $post);
2545 endwhile; ?>
2546
2547 </ul>
2548 </div><!-- end of assistance_item -->
2549 <?php
2550 wp_reset_postdata();
2551 usces_reset_filter();
2552 remove_filter( 'excerpt_length', 'welcart_assistance_excerpt_length' );
2553 remove_filter( 'excerpt_mblength', 'welcart_assistance_excerpt_mblength' );
2554 endif;
2555 endif;
2556 }
2557
2558 function usces_get_cart_rows( $out = '' ) {
2559 global $usces, $usces_gp;
2560 $cart = $usces->cart->get_cart();
2561 $usces_gp = 0;
2562 $res = '';
2563
2564 for($i=0; $i<count($cart); $i++) {
2565 $cart_row = $cart[$i];
2566 $post_id = $cart_row['post_id'];
2567 $sku = $cart_row['sku'];
2568 $sku_code = esc_attr(urldecode($cart_row['sku']));
2569 $quantity = $cart_row['quantity'];
2570 $options = $cart_row['options'];
2571 $advance = $usces->cart->wc_serialize($cart_row['advance']);
2572 $itemCode = $usces->getItemCode($post_id);
2573 $itemName = $usces->getItemName($post_id);
2574 $cartItemName = $usces->getCartItemName($post_id, $sku_code);
2575 $itemRestriction = $usces->getItemRestriction($post_id);
2576 $skuPrice = $cart_row['price'];
2577 $skuZaikonum = $usces->getItemZaikonum($post_id, $sku_code);
2578 $stockid = $usces->getItemZaikoStatusId($post_id, $sku_code);
2579 $stock = $usces->getItemZaiko($post_id, $sku_code);
2580 $red = (in_array($stock, array(__('sellout','usces'), __('Out Of Stock','usces'), __('Out of print','usces')))) ? 'class="signal_red"' : '';
2581 $pictid = (int)$usces->get_mainpictid($itemCode);
2582 $args = compact('cart', 'i', 'cart_row', 'post_id', 'sku' );
2583 $row = '';
2584 if ( empty($options) ) {
2585 $optstr = '';
2586 $options = array();
2587 }
2588 $row .= '<tr>
2589 <td>' . ($i + 1) . '</td>
2590 <td>';
2591 $cart_thumbnail = '<a href="' . get_permalink($post_id) . '">' . wp_get_attachment_image( $pictid, array(60, 60), true ) . '</a>';
2592 $row .= apply_filters('usces_filter_cart_thumbnail', $cart_thumbnail, $post_id, $pictid, $i,$cart_row);
2593 $row .= '</td><td class="aleft">' . esc_html($cartItemName) . '<br />';
2594 if( is_array($options) && count($options) > 0 ){
2595 $optstr = '';
2596 foreach($options as $key => $value){
2597 //20110629ysk start 0000190
2598 //if( !empty($key) )
2599 // $row .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
2600 if( !empty($key) ) {
2601 $key = urldecode($key);
2602 if(is_array($value)) {
2603 $c = '';
2604 $optstr .= esc_html($key) . ' : ';
2605 foreach($value as $v) {
2606 $optstr .= $c.nl2br(esc_html(urldecode($v)));
2607 $c = ', ';
2608 }
2609 $optstr .= "<br />\n";
2610 } else {
2611 $optstr .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
2612 }
2613 }
2614 //20110629ysk end
2615 }
2616 $row .= apply_filters( 'usces_filter_option_cart', $optstr, $options);
2617 }
2618 $row .= apply_filters( 'usces_filter_option_info_cart', '', $cart_row );
2619 $row .= '</td>
2620 <td class="aright">';
2621 if( usces_is_gptekiyo($post_id, $sku_code, $quantity) ) {
2622 $usces_gp = 1;
2623 $Business_pack_mark = '<img src="' . get_template_directory_uri() . '/images/gp.gif" alt="' . __('Business package discount','usces') . '" /><br />';
2624 $row .= apply_filters('usces_filter_itemGpExp_cart_mark', $Business_pack_mark);
2625 }
2626 $row .= usces_crform($skuPrice, true, false, 'return') . '
2627 </td>
2628 <td>';
2629 $row_quant = '<input name="quant[' . $i . '][' . $post_id . '][' . $sku . ']" class="quantity" type="text" value="' . esc_attr($cart_row['quantity']) . '" />';
2630 $row .= apply_filters( 'usces_filter_cart_rows_quant', $row_quant, $args );
2631 $row .= '</td>
2632 <td class="aright">' . usces_crform(($skuPrice * $cart_row['quantity']), true, false, 'return') . '</td>
2633 <td ' . $red . '>' . $stock . '</td>
2634 <td>';
2635 foreach($options as $key => $value){
2636 //20110629ysk start 0000190
2637 //$row .= '<input name="itemOption[' . $i . '][' . $post_id . '][' . $sku . '][' . $key . ']" type="hidden" value="' . $value . '" />';
2638 if(is_array($value)) {
2639 foreach($value as $v) {
2640 $row .= '<input name="itemOption[' . $i . '][' . $post_id . '][' . $sku . '][' . $key . '][' . $v . ']" type="hidden" value="' . $v . '" />';
2641 }
2642 } else {
2643 $row .= '<input name="itemOption[' . $i . '][' . $post_id . '][' . $sku . '][' . $key . ']" type="hidden" value="' . $value . '" />';
2644 }
2645 //20110629ysk end
2646 }
2647 $row .= '<input name="itemRestriction[' . $i . ']" type="hidden" value="' . $itemRestriction . '" />
2648 <input name="stockid[' . $i . ']" type="hidden" value="' . $stockid . '" />
2649 <input name="itempostid[' . $i . ']" type="hidden" value="' . $post_id . '" />
2650 <input name="itemsku[' . $i . ']" type="hidden" value="' . $sku . '" />
2651 <input name="zaikonum[' . $i . '][' . $post_id . '][' . $sku . ']" type="hidden" value="' . esc_attr($skuZaikonum) . '" />
2652 <input name="skuPrice[' . $i . '][' . $post_id . '][' . $sku . ']" type="hidden" value="' . esc_attr($skuPrice) . '" />
2653 <input name="advance[' . $i . '][' . $post_id . '][' . $sku . ']" type="hidden" value="' . esc_attr($advance) . '" />
2654 <input name="delButton[' . $i . '][' . $post_id . '][' . $sku . ']" class="delButton" type="submit" value="' . __('Delete','usces') . '" />
2655 </td>
2656 </tr>';
2657 $materials = compact('i', 'cart_row', 'post_id', 'sku', 'sku_code', 'quantity', 'options', 'advance',
2658 'itemCode', 'itemName', 'cartItemName', 'itemRestriction', 'skuPrice', 'skuZaikonum',
2659 'stockid', 'stock', 'red', 'pictid');
2660 $res .= apply_filters( 'usces_filter_cart_row', $row, $cart, $materials);
2661 }
2662
2663 $res = apply_filters( 'usces_filter_cart_rows', $res, $cart);
2664
2665 if($out == 'return'){
2666 return $res;
2667 }else{
2668 echo $res;
2669 }
2670 }
2671 function usces_get_confirm_rows( $out = '' ) {
2672 global $usces, $usces_members, $usces_entries;
2673 // $usces_members = $usces->get_member();
2674 $memid = ( empty($usces_members['ID']) ) ? 999999999 : $usces_members['ID'];
2675 // $usces_entries = $usces->cart->get_entry();
2676 $usces->set_cart_fees( $usces_members, $usces_entries );
2677 $usces_entries = $usces->cart->get_entry();
2678
2679 $cart = $usces->cart->get_cart();
2680 $res = '';
2681 for($i=0; $i<count($cart); $i++) {
2682 $cart_row = $cart[$i];
2683 $post_id = $cart_row['post_id'];
2684 $sku = esc_attr($cart_row['sku']);
2685 $sku_code = esc_attr(urldecode($cart_row['sku']));
2686 $quantity = $cart_row['quantity'];
2687 $options = $cart_row['options'];
2688 $advance = $usces->cart->wc_serialize($cart_row['advance']);
2689 $itemCode = $usces->getItemCode($post_id);
2690 $itemName = $usces->getItemName($post_id);
2691 $cartItemName = $usces->getCartItemName($post_id, $sku_code);
2692 $skuPrice = $cart_row['price'];
2693 $pictid = $usces->get_mainpictid($itemCode);
2694 $row = '';
2695 if (empty($options)) {
2696 $optstr = '';
2697 $options = array();
2698 }
2699
2700 $row .= '<tr>
2701 <td>' . ($i + 1) . '</td>
2702 <td>';
2703 $cart_thumbnail = wp_get_attachment_image( $pictid, array(60, 60), true );
2704 $row .= apply_filters('usces_filter_cart_thumbnail', $cart_thumbnail, $post_id, $pictid, $i, $cart_row);
2705 $row .= '</td><td class="aleft">' . $cartItemName . '<br />';
2706 if( is_array($options) && count($options) > 0 ){
2707 $optstr = '';
2708 foreach($options as $key => $value){
2709 //20110629ysk start 0000190
2710 //if( !empty($key) )
2711 // $row .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
2712 if( !empty($key) ) {
2713 $key = urldecode($key);
2714 if(is_array($value)) {
2715 $c = '';
2716 $optstr .= esc_html($key) . ' : ';
2717 foreach($value as $v) {
2718 $optstr .= $c.nl2br(esc_html(urldecode($v)));
2719 $c = ', ';
2720 }
2721 $optstr .= "<br />\n";
2722 } else {
2723 $optstr .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
2724 }
2725 }
2726 //20110629ysk end
2727 }
2728 $row .= apply_filters( 'usces_filter_option_confirm', $optstr, $options);
2729 }
2730 $row .= apply_filters( 'usces_filter_option_info_confirm', '', $cart_row );
2731 $row .= '</td>
2732 <td class="aright">' . usces_crform($skuPrice, true, false, 'return') . '</td>
2733 <td>' . $cart_row['quantity'] . '</td>
2734 <td class="aright">' . usces_crform(($skuPrice * $cart_row['quantity']), true, false, 'return') . '</td>
2735 <td>';
2736 $res = apply_filters('usces_additional_confirm', $res, array($i, $post_id, $sku_code));
2737 $row .= '</td>
2738 </tr>';
2739
2740 $materials = compact('i', 'cart_row', 'post_id', 'sku', 'sku_code', 'quantity', 'options', 'advance',
2741 'itemCode', 'itemName', 'cartItemName', 'skuPrice', 'pictid');
2742 $res .= apply_filters( 'usces_filter_confirm_row', $row, $cart, $materials);
2743 }
2744
2745 $res = apply_filters( 'usces_filter_confirm_rows', $res, $cart);
2746
2747 if($out == 'return'){
2748 return $res;
2749 }else{
2750 echo $res;
2751 }
2752 }
2753
2754 function uesces_addressform( $type, $data, $out = 'return' ){
2755 global $usces, $usces_settings;
2756 $options = get_option('usces');
2757 $form = $options['system']['addressform'];
2758 $nameform = $usces_settings['nameform'][$form];
2759 $applyform = usces_get_apply_addressform($form);
2760 $formtag = '';
2761 switch( $type ){
2762 case 'confirm':
2763 case 'member':
2764 $values = $data;
2765 break;
2766 case 'customer':
2767 case 'delivery':
2768 $values = $data[$type];
2769 break;
2770 }
2771 $data['type'] = $type;
2772 $values['country'] = !empty($values['country']) ? $values['country'] : usces_get_local_addressform();
2773 $values = $usces->stripslashes_deep_post($values);
2774 if( 'confirm' == $type ){
2775
2776 switch ($applyform){
2777
2778 case 'JP':
2779 $formtag .= usces_custom_field_info($data, 'customer', 'name_pre', 'return');
2780 $formtag .= '<tr><th>'.__('Full name', 'usces').'</th><td>' . esc_html($values['customer']['name1']) . ' ' . esc_html($values['customer']['name2']) . '</td></tr>';
2781 $furigana_customer = '<tr><th>'.__('furigana', 'usces').'</th><td>' . esc_html($values['customer']['name3']) . ' ' . esc_html($values['customer']['name4']) . '</td></tr>';
2782 $formtag .= apply_filters( 'usces_filter_furigana_confirm_customer', $furigana_customer, $type, $values );
2783 $formtag .= usces_custom_field_info($data, 'customer', 'name_after', 'return');
2784 $customer_country = (!empty($usces_settings['country'][$values['customer']['country']])) ? $usces_settings['country'][$values['customer']['country']] : '';
2785 $formtag .= '
2786 <tr><th>'.__('Zip/Postal Code', 'usces').'</th><td>' . esc_html($values['customer']['zipcode']) . '</td></tr>
2787 <tr><th>'.__('Country', 'usces').'</th><td>' . esc_html($customer_country) . '</td></tr>
2788 <tr><th>'.__('Province', 'usces').'</th><td>' . esc_html($values['customer']['pref']) . '</td></tr>
2789 <tr><th>'.__('city', 'usces').'</th><td>' . esc_html($values['customer']['address1']) . '</td></tr>
2790 <tr><th>'.__('numbers', 'usces').'</th><td>' . esc_html($values['customer']['address2']) . '</td></tr>
2791 <tr><th>'.__('building name', 'usces').'</th><td>' . esc_html($values['customer']['address3']) . '</td></tr>
2792 <tr><th>'.__('Phone number', 'usces').'</th><td>' . esc_html($values['customer']['tel']) . '</td></tr>
2793 <tr><th>'.__('FAX number', 'usces').'</th><td>' . esc_html($values['customer']['fax']) . '</td></tr>';
2794 $formtag .= usces_custom_field_info($data, 'customer', 'fax_after', 'return');
2795
2796 $shipping_address_info = '<tr class="ttl"><td colspan="2"><h3>'.__('Shipping address information', 'usces').'</h3></td></tr>';
2797 $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'name_pre', 'return');
2798 $shipping_address_info .= '<tr><th>'.__('Full name', 'usces').'</th><td>' . esc_html($values['delivery']['name1']) . ' ' . esc_html($values['delivery']['name2']) . '</td></tr>';
2799 $furigana_delivery = '<tr><th>'.__('furigana', 'usces').'</th><td>' . esc_html($values['delivery']['name3']) . ' ' . esc_html($values['delivery']['name4']) . '</td></tr>';
2800 $shipping_address_info .= apply_filters( 'usces_filter_furigana_confirm_delivery', $furigana_delivery, $type, $values );
2801 $shipping_address_info .= usces_custom_field_info($values, 'delivery', 'name_after', 'return');
2802 $shipping_country = (!empty($usces_settings['country'][$values['delivery']['country']])) ? $usces_settings['country'][$values['delivery']['country']] : '';
2803 $shipping_address_info .= '
2804 <tr><th>'.__('Zip/Postal Code', 'usces').'</th><td>' . esc_html($values['delivery']['zipcode']) . '</td></tr>
2805 <tr><th>'.__('Country', 'usces').'</th><td>' . esc_html($shipping_country) . '</td></tr>
2806 <tr><th>'.__('Province', 'usces').'</th><td>' . esc_html($values['delivery']['pref']) . '</td></tr>
2807 <tr><th>'.__('city', 'usces').'</th><td>' . esc_html($values['delivery']['address1']) . '</td></tr>
2808 <tr><th>'.__('numbers', 'usces').'</th><td>' . esc_html($values['delivery']['address2']) . '</td></tr>
2809 <tr><th>'.__('building name', 'usces').'</th><td>' . esc_html($values['delivery']['address3']) . '</td></tr>
2810 <tr><th>'.__('Phone number', 'usces').'</th><td>' . esc_html($values['delivery']['tel']) . '</td></tr>
2811 <tr><th>'.__('FAX number', 'usces').'</th><td>' . esc_html($values['delivery']['fax']) . '</td></tr>';
2812 $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'fax_after', 'return');
2813 $formtag .= apply_filters('usces_filter_shipping_address_info', $shipping_address_info);
2814 break;
2815
2816 case 'CN':
2817 $formtag .= usces_custom_field_info($data, 'customer', 'name_pre', 'return');
2818 $formtag .= '<tr><th>'.__('Full name', 'usces').'</th><td>' . esc_html(usces_localized_name( $values['customer']['name1'], $values['customer']['name2'], 'return' )) . '</td></tr>';
2819 $formtag .= usces_custom_field_info($data, 'customer', 'name_after', 'return');
2820 $formtag .= '
2821 <tr><th>'.__('Country', 'usces').'</th><td>' . esc_html($usces_settings['country'][$values['customer']['country']]) . '</td></tr>
2822 <tr><th>'.__('State', 'usces').'</th><td>' . esc_html($values['customer']['pref']) . '</td></tr>
2823 <tr><th>'.__('city', 'usces').'</th><td>' . esc_html($values['customer']['address1']) . '</td></tr>
2824 <tr><th>'.__('Address Line1', 'usces').'</th><td>' . esc_html($values['customer']['address2']) . '</td></tr>
2825 <tr><th>'.__('Address Line2', 'usces').'</th><td>' . esc_html($values['customer']['address3']) . '</td></tr>
2826 <tr><th>'.__('Zip', 'usces').'</th><td>' . esc_html($values['customer']['zipcode']) . '</td></tr>
2827 <tr><th>'.__('Phone number', 'usces').'</th><td>' . esc_html($values['customer']['tel']) . '</td></tr>
2828 <tr><th>'.__('FAX number', 'usces').'</th><td>' . esc_html($values['customer']['fax']) . '</td></tr>';
2829 $formtag .= usces_custom_field_info($data, 'customer', 'fax_after', 'return');
2830
2831 $shipping_address_info = '<tr class="ttl"><td colspan="2"><h3>'.__('Shipping address information', 'usces').'</h3></td></tr>';
2832 $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'name_pre', 'return');
2833 $shipping_address_info .= '<tr><th>'.__('Full name', 'usces').'</th><td>' . esc_html(usces_localized_name( $values['delivery']['name1'], $values['delivery']['name2'], 'return' )) . '</td></tr>';
2834 $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'name_after', 'return');
2835 $shipping_address_info .= '
2836 <tr><th>'.__('Country', 'usces').'</th><td>' . esc_html($usces_settings['country'][$values['delivery']['country']]) . '</td></tr>
2837 <tr><th>'.__('State', 'usces').'</th><td>' . esc_html($values['delivery']['pref']) . '</td></tr>
2838 <tr><th>'.__('city', 'usces').'</th><td>' . esc_html($values['delivery']['address1']) . '</td></tr>
2839 <tr><th>'.__('Address Line1', 'usces').'</th><td>' . esc_html($values['delivery']['address2']) . '</td></tr>
2840 <tr><th>'.__('Address Line2', 'usces').'</th><td>' . esc_html($values['delivery']['address3']) . '</td></tr>
2841 <tr><th>'.__('Zip', 'usces').'</th><td>' . esc_html($values['delivery']['zipcode']) . '</td></tr>
2842 <tr><th>'.__('Phone number', 'usces').'</th><td>' . esc_html($values['delivery']['tel']) . '</td></tr>
2843 <tr><th>'.__('FAX number', 'usces').'</th><td>' . esc_html($values['delivery']['fax']) . '</td></tr>';
2844 $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'fax_after', 'return');
2845 $formtag .= apply_filters('usces_filter_shipping_address_info', $shipping_address_info);
2846 break;
2847
2848 case 'US':
2849 default :
2850 $formtag .= usces_custom_field_info($data, 'customer', 'name_pre', 'return');
2851 $formtag .= '<tr><th>'.__('Full name', 'usces').'</th><td>' . esc_html($values['customer']['name2']) . ' ' . esc_html($values['customer']['name1']) . '</td></tr>';
2852 $formtag .= usces_custom_field_info($data, 'customer', 'name_after', 'return');
2853 $customer_country = (!empty($usces_settings['country'][$values['customer']['country']])) ? $usces_settings['country'][$values['customer']['country']] : '';
2854 $formtag .= '
2855 <tr><th>'.__('Address Line1', 'usces').'</th><td>' . esc_html($values['customer']['address2']) . '</td></tr>
2856 <tr><th>'.__('Address Line2', 'usces').'</th><td>' . esc_html($values['customer']['address3']) . '</td></tr>
2857 <tr><th>'.__('city', 'usces').'</th><td>' . esc_html($values['customer']['address1']) . '</td></tr>
2858 <tr><th>'.__('State', 'usces').'</th><td>' . esc_html($values['customer']['pref']) . '</td></tr>
2859 <tr><th>'.__('Country', 'usces').'</th><td>' . esc_html($customer_country) . '</td></tr>
2860 <tr><th>'.__('Zip', 'usces').'</th><td>' . esc_html($values['customer']['zipcode']) . '</td></tr>
2861 <tr><th>'.__('Phone number', 'usces').'</th><td>' . esc_html($values['customer']['tel']) . '</td></tr>
2862 <tr><th>'.__('FAX number', 'usces').'</th><td>' . esc_html($values['customer']['fax']) . '</td></tr>';
2863 $formtag .= usces_custom_field_info($data, 'customer', 'fax_after', 'return');
2864
2865 $shipping_address_info = '<tr class="ttl"><td colspan="2"><h3>'.__('Shipping address information', 'usces').'</h3></td></tr>';
2866 $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'name_pre', 'return');
2867 $shipping_address_info .= '<tr><th>'.__('Full name', 'usces').'</th><td>' . esc_html($values['delivery']['name2']) . ' ' . esc_html($values['delivery']['name1']) . '</td></tr>';
2868 $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'name_after', 'return');
2869 $shipping_country = (!empty($usces_settings['country'][$values['delivery']['country']])) ? $usces_settings['country'][$values['delivery']['country']] : '';
2870 $shipping_address_info .= '
2871 <tr><th>'.__('Address Line1', 'usces').'</th><td>' . esc_html($values['delivery']['address2']) . '</td></tr>
2872 <tr><th>'.__('Address Line2', 'usces').'</th><td>' . esc_html($values['delivery']['address3']) . '</td></tr>
2873 <tr><th>'.__('city', 'usces').'</th><td>' . esc_html($values['delivery']['address1']) . '</td></tr>
2874 <tr><th>'.__('State', 'usces').'</th><td>' . esc_html($values['delivery']['pref']) . '</td></tr>
2875 <tr><th>'.__('Country', 'usces').'</th><td>' . esc_html($shipping_country) . '</td></tr>
2876 <tr><th>'.__('Zip', 'usces').'</th><td>' . esc_html($values['delivery']['zipcode']) . '</td></tr>
2877 <tr><th>'.__('Phone number', 'usces').'</th><td>' . esc_html($values['delivery']['tel']) . '</td></tr>
2878 <tr><th>'.__('FAX number', 'usces').'</th><td>' . esc_html($values['delivery']['fax']) . '</td></tr>';
2879 $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'fax_after', 'return');
2880 $formtag .= apply_filters('usces_filter_shipping_address_info', $shipping_address_info);
2881 break;
2882
2883 }
2884 $res = apply_filters('usces_filter_apply_addressform_confirm', $formtag, $type, $data);
2885
2886 }else{
2887
2888 switch ($applyform){
2889
2890 case 'JP':
2891 $formtag .= usces_custom_field_input($data, $type, 'name_pre', 'return');
2892 $formtag .= '<tr class="inp1">
2893 <th width="127" scope="row">' . usces_get_essential_mark('name1', $data) . __('Full name', 'usces').'</th>';
2894 if( $nameform ){
2895 $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>';
2896 $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>';
2897 }else{
2898 $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>';
2899 $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>';
2900 }
2901 $formtag .= '</tr>';
2902 $furigana = '<tr class="inp1">
2903 <th scope="row">' . usces_get_essential_mark('name3', $data).__('furigana', 'usces').'</th>';
2904 if( $nameform ){
2905 $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>';
2906 $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>';
2907 }else{
2908 $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>';
2909 $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>';
2910 }
2911 $furigana .= '</tr>';
2912 $formtag .= apply_filters( 'usces_filter_furigana_form', $furigana, $type, $values );
2913 $formtag .= usces_custom_field_input($data, $type, 'name_after', 'return');
2914 $formtag .= '<tr>
2915 <th scope="row">' . usces_get_essential_mark('zipcode', $data).__('Zip/Postal Code', 'usces').'</th>
2916 <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>
2917 </tr>
2918 <tr>
2919 <th scope="row">' . usces_get_essential_mark('country', $data) . __('Country', 'usces') . '</th>
2920 <td colspan="2">' . uesces_get_target_market_form( $type, $values['country'] ) . apply_filters( 'usces_filter_after_country', NULL, $applyform ) . '</td>
2921 </tr>
2922 <tr>
2923 <th scope="row">' . usces_get_essential_mark('states', $data).__('Province', 'usces').'</th>
2924 <td colspan="2">' . usces_pref_select( $type, $values ) . apply_filters( 'usces_filter_after_states', NULL, $applyform ) . '</td>
2925 </tr>
2926 <tr class="inp2">
2927 <th scope="row">' . usces_get_essential_mark('address1', $data).__('city', 'usces').'</th>
2928 <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>
2929 </tr>
2930 <tr>
2931 <th scope="row">' . usces_get_essential_mark('address2', $data).__('numbers', 'usces').'</th>
2932 <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>
2933 </tr>
2934 <tr>
2935 <th scope="row">' . usces_get_essential_mark('address3', $data).__('building name', 'usces').'</th>
2936 <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>
2937 </tr>
2938 <tr>
2939 <th scope="row">' . usces_get_essential_mark('tel', $data).__('Phone number', 'usces').'</th>
2940 <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>
2941 </tr>
2942 <tr>
2943 <th scope="row">' . usces_get_essential_mark('fax', $data).__('FAX number', 'usces').'</th>
2944 <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>
2945 </tr>';
2946 $formtag .= usces_custom_field_input($data, $type, 'fax_after', 'return');
2947 break;
2948
2949 case 'CN':
2950 $formtag .= usces_custom_field_input($data, $type, 'name_pre', 'return');
2951 $formtag .= '<tr class="inp1">
2952 <th scope="row">' . usces_get_essential_mark('name1', $data) . __('Full name', 'usces') . '</th>';
2953 if( $nameform ){
2954 $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>';
2955 $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>';
2956 }else{
2957 $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>';
2958 $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>';
2959 }
2960 $formtag .= '</tr>';
2961 $formtag .= usces_custom_field_input($data, $type, 'name_after', 'return');
2962 $formtag .= '
2963 <tr>
2964 <th scope="row">' . usces_get_essential_mark('country', $data) . __('Country', 'usces') . '</th>
2965 <td colspan="2">' . uesces_get_target_market_form( $type, $values['country'] ) . apply_filters( 'usces_filter_after_country', NULL, $applyform ) . '</td>
2966 </tr>
2967 <tr>
2968 <th scope="row">' . usces_get_essential_mark('states', $data) . __('State', 'usces') . '</th>
2969 <td colspan="2">' . usces_pref_select( $type, $values ) . apply_filters( 'usces_filter_after_states', NULL, $applyform ) . '</td>
2970 </tr>
2971 <tr class="inp2">
2972 <th scope="row">' . usces_get_essential_mark('address1', $data) . __('city', 'usces') . '</th>
2973 <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>
2974 </tr>
2975 <tr>
2976 <th scope="row">' . usces_get_essential_mark('address2', $data) . __('Address Line1', 'usces') . '</th>
2977 <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>
2978 </tr>
2979 <tr>
2980 <th scope="row">' . usces_get_essential_mark('address3', $data) . __('Address Line2', 'usces') . '</th>
2981 <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>
2982 </tr>
2983 <tr>
2984 <th scope="row">' . usces_get_essential_mark('zipcode', $data) . __('Zip', 'usces') . '</th>
2985 <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>
2986 </tr>
2987 <tr>
2988 <th scope="row">' . usces_get_essential_mark('tel', $data) . __('Phone number', 'usces') . '</th>
2989 <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>
2990 </tr>
2991 <tr>
2992 <th scope="row">' . usces_get_essential_mark('fax', $data) . __('FAX number', 'usces') . '</th>
2993 <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>
2994 </tr>';
2995 $formtag .= usces_custom_field_input($data, $type, 'fax_after', 'return');
2996 break;
2997
2998 case 'US':
2999 default :
3000 $formtag .= usces_custom_field_input($data, $type, 'name_pre', 'return');
3001 $formtag .= '<tr class="inp1">
3002 <th scope="row">' . usces_get_essential_mark('name1', $data) . __('Full name', 'usces') . '</th>';
3003 if( $nameform ){
3004 $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>';
3005 $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>';
3006 }else{
3007 $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>';
3008 $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>';
3009 }
3010 $formtag .= '</tr>';
3011 $formtag .= usces_custom_field_input($data, $type, 'name_after', 'return');
3012 $formtag .= '
3013 <tr>
3014 <th scope="row">' . usces_get_essential_mark('address2', $data) . __('Address Line1', 'usces') . '</th>
3015 <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>
3016 </tr>
3017 <tr>
3018 <th scope="row">' . usces_get_essential_mark('address3', $data) . __('Address Line2', 'usces') . '</th>
3019 <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>
3020 </tr>
3021 <tr class="inp2">
3022 <th scope="row">' . usces_get_essential_mark('address1', $data) . __('city', 'usces') . '</th>
3023 <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>
3024 </tr>
3025 <tr>
3026 <th scope="row">' . usces_get_essential_mark('states', $data) . __('State', 'usces') . '</th>
3027 <td colspan="2">' . usces_pref_select( $type, $values ) . apply_filters( 'usces_filter_after_states', NULL, $applyform ) . '</td>
3028 </tr>
3029 <tr>
3030 <th scope="row">' . usces_get_essential_mark('country', $data) . __('Country', 'usces') . '</th>
3031 <td colspan="2">' . uesces_get_target_market_form( $type, $values['country'] ) . apply_filters( 'usces_filter_after_country', NULL, $applyform ) . '</td>
3032 </tr>
3033 <tr>
3034 <th scope="row">' . usces_get_essential_mark('zipcode', $data) . __('Zip', 'usces') . '</th>
3035 <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>
3036 </tr>
3037 <tr>
3038 <th scope="row">' . usces_get_essential_mark('tel', $data) . __('Phone number', 'usces') . '</th>
3039 <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>
3040 </tr>
3041 <tr>
3042 <th scope="row">' . usces_get_essential_mark('fax', $data) . __('FAX number', 'usces') . '</th>
3043 <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>
3044 </tr>';
3045 $formtag .= usces_custom_field_input($data, $type, 'fax_after', 'return');
3046 break;
3047 }
3048 $res = apply_filters('usces_filter_apply_addressform', $formtag, $type, $data);
3049
3050 }
3051
3052 if($out == 'return') {
3053 return $res;
3054 } else {
3055 echo $res;
3056 }
3057 }
3058
3059 function usces_item_option_fileds( $post_id, $sku, $label=1, $out='echo' ){
3060 $options = usces_get_opts($post_id, 'sort');
3061 if( 0 == count($options) )
3062 return false;
3063
3064 $sku_enc = urlencode($sku);
3065 $html ='';
3066 foreach( $options as $opt ){
3067 $name = $opt['name'];
3068 $opt_code = urlencode($name);
3069 $html .= "\n" . '<div class="opt_field" id="opt_' . $post_id . '_' . $sku_enc . '_' . $opt_code . '">';
3070 if( $label ){
3071 $html .= '<label for="itemOption[' . $post_id . '][' . $sku_enc . '][' . $opt_code . ']">' . esc_html($name) . '</label>';
3072 }
3073 $html .= usces_get_itemopt_filed($post_id, $sku, $opt);
3074 $html .= '</div>';
3075 }
3076 if( $out == 'return' ){
3077 return $html;
3078 }else{
3079 echo $html;
3080 }
3081 }
3082
3083 function usces_facebook_like(){
3084 global $post, $usces;
3085 $like = array(
3086 'url' => urlencode(get_permalink($post->ID)),
3087 'send' => 'false',
3088 'layout' => 'button_count', //standard, button_count, box_count
3089 'width' => '450',
3090 'height' => '35',
3091 'show_faces' => 'false',
3092 'action' => 'like', //like, recommend
3093 );
3094 $like = apply_filters( 'usces_filter_facebook_like', $like, $post->ID );
3095 ?>
3096 <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>
3097 <?php
3098 }
3099
3100 function usces_action_confirm_page_point_inform_zeus() {
3101 $html = usces_point_inform_zeus();
3102 echo $html;
3103 }
3104
3105 function usces_filter_confirm_point_inform_zeus( $html ) {
3106 $html .= usces_point_inform_zeus();
3107 return $html;
3108 }
3109
3110 function usces_point_inform_zeus() {
3111 global $usces, $usces_entries;
3112 $html = '';
3113
3114 $payments = usces_get_payments_by_name( $usces_entries['order']['payment_name'] );
3115 $acting_flag = ( 'acting' == $payments['settlement'] ) ? $payments['module'] : $payments['settlement'];
3116
3117 switch( $acting_flag ) {
3118 case 'acting_zeus_card':
3119 $html .= '<input type="hidden" name="cnum1" value="'.$_POST['cnum1'].'">';
3120 if( isset($_POST['securecode']) ) {
3121 $html .= '<input type="hidden" name="securecode" value="'.$_POST['securecode'].'">';
3122 }
3123 $html .= '<input type="hidden" name="expyy" value="'.$_POST['expyy'].'">';
3124 $html .= '<input type="hidden" name="expmm" value="'.$_POST['expmm'].'">';
3125 $html .= '<input type="hidden" name="username" value="'.$_POST['username'].'">';
3126 if( isset($_POST['howpay']) ) {
3127 $html .= '<input type="hidden" name="howpay" value="'.$_POST['howpay'].'">';
3128 }
3129 if( isset($_POST['cbrand']) ) {
3130 $html .= '<input type="hidden" name="cbrand" value="'.$_POST['cbrand'].'">';
3131 $html .= '<input type="hidden" name="div_1" value="'.$_POST['div_1'].'">';
3132 $html .= '<input type="hidden" name="div_2" value="'.$_POST['div_2'].'">';
3133 $html .= '<input type="hidden" name="div_3" value="'.$_POST['div_3'].'">';
3134 }
3135 break;
3136
3137 case 'acting_zeus_conv':
3138 if( isset($_POST['pay_cvs']) ) {
3139 $html = '<input type="hidden" name="pay_cvs" value="'.$_POST['pay_cvs'].'">';
3140 }
3141 break;
3142 }
3143 return $html;
3144 }
3145
3146 function usces_checked( $chk, $out = '' ) {
3147 $checked = ( isset($chk) and $chk == 1 ) ? ' checked' : '';
3148 if( $out == 'return' ) {
3149 return $checked;
3150 } else {
3151 echo $checked;
3152 }
3153 }
3154
3155 ?>