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

3,205 lines 108.9 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_point_rate_discount( $post_id = NULL, $out = '' ) {
1073 global $post, $usces;
1074 if( $post_id == NULL )
1075 $post_id = $post->ID;
1076
1077 $str = get_post_meta( $post_id, '_itemPointrate', true );
1078 $rate = (int)$str;
1079 if( $usces->options['campaign_privilege'] == 'point' ) {
1080 if( in_category((int)$usces->options['campaign_category'], $post_id) ) {
1081 $rate *= $usces->options['privilege_point'];
1082 }
1083 }
1084 if( $out == 'return' ) {
1085 return $rate;
1086 } else {
1087 echo $rate;
1088 }
1089 }
1090
1091 function usces_get_point( $post_id, $sku_code ){
1092 global $usces;
1093 if( $post_id == NULL ){
1094 $rate = $usces->options['point_rate'];
1095 }else{
1096 $str = get_post_meta($post_id, '_itemPointrate', true);
1097 $rate = (int)$str;
1098 }
1099
1100 $skus = $usces->get_skus($post_id, 'code');
1101 $point = ceil($skus[$sku_code]['price'] * $rate / 100);
1102
1103 return $point;
1104 }
1105
1106 function usces_the_payment_method( $value = '', $out = '' ){
1107 global $usces;
1108 $payments = usces_get_system_option( 'usces_payment_method', 'sort' );
1109 $payments = apply_filters('usces_fiter_the_payment_method', $payments, $value);
1110 //if( empty($payments) ) return; 20120328ysk 0000454
1111
1112 $cart = $usces->cart->get_cart();
1113 //$charging_type = $usces->getItemChargingType($cart[0]['post_id']);
1114 $charging_type = $usces->getItemChargingType($cart[0]['post_id'], $cart);
1115 $html = "<dl>\n";
1116 $list = '';
1117 $payment_ct = count($payments);
1118 //20120328ysk start 0000454
1119 //foreach ($payments as $id => $payment) {
1120 foreach ((array)$payments as $id => $payment) {
1121 //20120328ysk end
1122 if( 'continue' == $charging_type ){
1123 //if( 'acting' != substr($payments['settlement'], 0, 6) )
1124 //20110412ysk start
1125 //if( 'acting_remise_card' != $payment['settlement'] && 'acting_paypal_ec' != $payment['settlement']) {
1126 $continue_payment_method = apply_filters( 'usces_filter_the_continue_payment_method', array( 'acting_remise_card', 'acting_paypal_ec' ) );
1127 if( !in_array( $payment['settlement'], $continue_payment_method ) ) {
1128 $payment_ct--;
1129 continue;
1130 }
1131 //if( 'on' !== $usces->options['acting_settings']['remise']['continuation'] && 'acting_remise_card' == $payment['settlement'])
1132 // continue;
1133 if( 'on' !== $usces->options['acting_settings']['remise']['continuation'] && 'acting_remise_card' == $payment['settlement']) {
1134 $payment_ct--;
1135 continue;
1136 } elseif( 'on' !== $usces->options['acting_settings']['paypal']['continuation'] && 'acting_paypal_ec' == $payment['settlement']) {
1137 $payment_ct--;
1138 continue;
1139 }
1140 //20110412ysk end
1141 }
1142 if( $payment['name'] != '' ) {
1143 $module = trim($payment['module']);
1144 if( !WCUtils::is_blank($value) ){
1145 $checked = ($payment['name'] == $value) ? ' checked' : '';
1146 }else if( 1 == $payment_ct ){//0000428
1147 $checked = ' checked';
1148 }else{
1149 $checked = '';
1150 }
1151 if( (empty($module) || !file_exists($usces->options['settlement_path'] . $module)) && $payment['settlement'] == 'acting' ) {
1152 $checked = '';
1153 $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";
1154 }else{
1155 $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";
1156 }
1157 $list .= "\t<dd>{$payment['explanation']}</dd>\n";
1158 }
1159 }
1160
1161 $html .= $list . "</dl>\n";
1162
1163 if( empty($list) )
1164 $html = __('Not yet ready for the payment method. Please refer to a manager.', 'usces')."\n";
1165
1166 if( $out == 'return' ){
1167 return $html;
1168 }else{
1169 echo $html;
1170 }
1171 }
1172
1173 function usces_get_payments_by_name( $name ){
1174 global $usces;
1175 $payments = usces_get_system_option( 'usces_payment_method', 'name' );
1176 if( empty($payments) ) return false;
1177
1178 if( isset($payments[$name]) ) {
1179 return $payments[$name];
1180 }
1181
1182 return false;
1183 }
1184
1185 function usces_the_delivery_method( $value = '', $out = '' ){
1186 global $usces;
1187 $deli_id = apply_filters('usces_filter_get_available_delivery_method', $usces->get_available_delivery_method());
1188 if( empty($deli_id) ){
1189 $html = '<p>' . __('No valid shipping methods.', 'usces') . '</p>';
1190 }else{
1191 $cdeliid = count($deli_id);
1192 $html = '<select name="offer[delivery_method]" id="delivery_method_select" class="delivery_time" onKeyDown="if (event.keyCode == 13) {return false;}">'."\n";
1193 foreach ($deli_id as $id) {
1194 $index = $usces->get_delivery_method_index($id);
1195 $selected = ($id == $value || 1 === $cdeliid) ? ' selected="selected"' : '';
1196 $html .= "\t<option value='{$id}'{$selected}>" . esc_html($usces->options['delivery_method'][$index]['name']) . "</option>\n";
1197 }
1198
1199 $html .= "</select>\n";
1200 }
1201
1202 if( $out == 'return' ){
1203 return $html;
1204 }else{
1205 echo $html;
1206 }
1207 }
1208 //20101208ysk start
1209 function usces_the_delivery_date( $value = '', $out = '' ){
1210 global $usces;
1211
1212 $html = "<select name='offer[delivery_date]' id='delivery_date_select' class='delivery_date'>\n";
1213 $html .= "</select>\n";
1214
1215 if( $out == 'return' ){
1216 return $html;
1217 }else{
1218 echo $html;
1219 }
1220 }
1221 //20101208ysk end
1222 function usces_the_delivery_time( $value = '', $out = '' ){
1223 global $usces;
1224
1225 //20101208ysk start
1226 //$html = "<select name='offer[delivery_time]' id='delivery_time_select' class='delivery_time'>\n";
1227 $html = "<div id='delivery_time_limit_message'></div>\n";
1228 $html .= "<select name='offer[delivery_time]' id='delivery_time_select' class='delivery_time'>\n";
1229 //20101208ysk end
1230
1231 $html .= "</select>\n";
1232
1233 if( $out == 'return' ){
1234 return $html;
1235 }else{
1236 echo $html;
1237 }
1238 }
1239
1240 function usces_the_campaign_schedule($flag, $kind){
1241 global $usces;
1242 $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');
1243 $starttime = $usces->options['campaign_schedule']['start']['hour'] . __('hour','usces') . $usces->options['campaign_schedule']['start']['min'] . __('min','usces');
1244 $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');
1245 $endtime = $usces->options['campaign_schedule']['end']['hour'] . __('hour','usces') . $usces->options['campaign_schedule']['end']['min'] . __('min','usces');
1246 if( 'start' == $flag ) {
1247 if( 'date' == $kind ) {
1248 echo esc_html($startdate);
1249 }elseif( 'datetime' == $kind ) {
1250 echo esc_html($startdate . ' ' . $starttime);
1251 }
1252 } elseif ( 'end' == $flag ) {
1253 if( 'date' == $kind ) {
1254 echo esc_html($enddate);
1255 }elseif( 'datetime' == $kind ) {
1256 echo esc_html($enddate . ' ' . $endtime);
1257 }
1258 }
1259 }
1260
1261
1262 function usces_the_confirm() {
1263 global $usces;
1264
1265 $usces->display_cart_confirm();
1266 }
1267
1268 function usces_inquiry_condition() {
1269 global $error_message, $reserve, $inq_name, $inq_mailaddress, $inq_contents;
1270 require(USCES_PLUGIN_DIR.'/includes/inquiry_condition.php');
1271 }
1272
1273 function usces_the_inquiry_form() {
1274 global $usces;
1275 $error_message = '';
1276 if( isset($_POST['inq_name']) && !WCUtils::is_blank($_POST['inq_name']) ) {
1277 $inq_name = trim($_POST['inq_name']);
1278 }else{
1279 $inq_name = '';
1280 if($usces->page == 'deficiency')
1281 $error_message .= __('Please input your name.', 'usces') . "<br />";
1282 }
1283 if( isset($_POST['inq_mailaddress']) && is_email(trim($_POST['inq_mailaddress'])) ) {
1284 $inq_mailaddress = trim($_POST['inq_mailaddress']);
1285 }elseif( isset($_POST['inq_mailaddress']) && !is_email(trim($_POST['inq_mailaddress'])) ) {
1286 $inq_mailaddress = trim($_POST['inq_mailaddress']);
1287 if($usces->page == 'deficiency')
1288 $error_message .= __('E-mail address is not correct', 'usces') . "<br />";
1289 }else{
1290 $inq_mailaddress = '';
1291 if($usces->page == 'deficiency')
1292 $error_message .= __('Please input your e-mail address.', 'usces') . "<br />";
1293 }
1294 if( isset($_POST['inq_contents']) && !WCUtils::is_blank($_POST['inq_contents']) ) {
1295 $inq_contents = trim($_POST['inq_contents']);
1296 }else{
1297 $inq_contents = '';
1298 if($usces->page == 'deficiency')
1299 $error_message .= __('Please input contents.', 'usces');
1300 }
1301
1302
1303 if($usces->page == 'inquiry_comp') :
1304 ?>
1305 <div class="inquiry_comp"><?php _e('sending completed','usces') ?></div>
1306 <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>
1307 <?php
1308 elseif($usces->page == 'inquiry_error') :
1309 ?>
1310 <div class="inquiry_comp"><?php _e('Failure in sending','usces') ?></div>
1311 <?php
1312 else :
1313 ?>
1314 <?php if( !empty($error_message) ): ?>
1315 <div class="error_message"><?php echo $error_message; ?></div>
1316 <?php endif; ?>
1317 <form name="inquiry_form" action="<?php //echo USCES_CART_URL; ?>" method="post">
1318 <table border="0" cellpadding="0" cellspacing="0" class="inquiry_table">
1319 <tr>
1320 <th scope="row"><?php _e('Full name','usces') ?></th>
1321 <td><input name="inq_name" type="text" class="inquiry_name" value="<?php echo esc_attr($inq_name); ?>" /></td>
1322 </tr>
1323 <tr>
1324 <th scope="row"><?php _e('e-mail adress','usces') ?></th>
1325 <td><input name="inq_mailaddress" type="text" class="inquiry_mailaddress" value="<?php echo esc_attr($inq_mailaddress); ?>" /></td>
1326 </tr>
1327 <tr>
1328 <th scope="row"><?php _e('contents','usces') ?></th>
1329 <td><textarea name="inq_contents" class="inquiry_contents"><?php echo esc_attr($inq_contents); ?></textarea></td>
1330 </tr>
1331 </table>
1332 <div class="send"><input name="inquiry_button" type="submit" value="<?php _e('Admit to send it with this information.','usces') ?>" /></div>
1333 </form>
1334 <?php
1335 endif;
1336 }
1337
1338 function usces_get_cat_id( $slug ) {
1339 $cat = get_category_by_slug( $slug );
1340 return $cat->term_id;
1341 }
1342
1343 function usces_the_calendar() {
1344 global $usces;
1345 include (USCES_PLUGIN_DIR . '/includes/widget_calendar.php');
1346 }
1347
1348 function usces_loginout( $out = '') {
1349 global $usces;
1350 if ( !$usces->is_member_logged_in() )
1351 $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>';
1352 else
1353 $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>';
1354
1355 if( $out == 'return' ){
1356 return $res;
1357 }else{
1358 echo $res;
1359 }
1360 }
1361
1362 function usces_is_login() {
1363 global $usces;
1364
1365 if( false === $usces->is_member_logged_in() )
1366 $res = false;
1367 else
1368 $res = true;
1369
1370 return $res;
1371 }
1372
1373 function usces_the_member_name( $out = '') {
1374 global $usces;
1375 $usces->get_current_member();
1376 $res = esc_html($usces->current_member['name']);
1377 if( $out == 'return' ){
1378 return $res;
1379 }else{
1380 echo $res;
1381 }
1382
1383 }
1384
1385 function usces_the_member_point( $out = '' ) {
1386 global $usces;
1387
1388 if( !$usces->is_member_logged_in() ) return;
1389
1390 $member = $usces->get_member();
1391 if( $out == 'return' ){
1392 return $member['point'];
1393 }else{
1394 echo number_format($member['point']);
1395 }
1396 }
1397
1398 function usces_the_member_status( $out = '' ) {
1399 global $usces;
1400 if( !$usces->is_member_logged_in() ) return;
1401
1402 $usces->get_current_member();
1403 $member = $usces->get_member_info($usces->current_member['id']);
1404 $status_name = $usces->member_status[$member['mem_status']];
1405
1406 if( $out == 'return' ){
1407 return $status_name;
1408 }else{
1409 echo esc_html($status_name);
1410 }
1411 }
1412
1413 function usces_get_assistance_id_list($post_id) {
1414 global $usces;
1415 $names = $usces->get_tag_names($post_id);
1416 $list = '';
1417 foreach ( $names as $itemname )
1418 $list .= $usces->get_ID_byItemName($itemname, 'publish') . ',';
1419
1420 $list = trim($list, ',');
1421
1422 return $list;
1423 }
1424 function usces_get_assistance_ids($post_id) {
1425 global $usces;
1426 $names = $usces->get_tag_names($post_id);
1427 $ids = array();
1428 foreach ( $names as $itemname )
1429 $ids[] = $usces->get_ID_byItemName($itemname, 'publish');
1430
1431 return $ids;
1432 }
1433 function usces_remembername( $out = '' ){
1434 global $usces;
1435 $value = $usces->get_cookie();
1436
1437 if( $out == 'return' ){
1438 if(isset($value['name']))
1439 return $value['name'];
1440 else
1441 return '';
1442 }else{
1443 if(isset($value['name']))
1444 echo esc_html($value['name']);
1445 else
1446 echo '';
1447 }
1448 }
1449 function usces_rememberpass( $out = '' ){
1450 global $usces;
1451 $value = $usces->get_cookie();
1452
1453 if( $out == 'return' ){
1454 if(isset($value['pass']))
1455 return $value['pass'];
1456 else
1457 return '';
1458 }else{
1459 if(isset($value['pass']))
1460 echo esc_html($value['pass']);
1461 else
1462 echo '';
1463 }
1464 }
1465 function usces_remembercheck( $out = '' ){
1466 global $usces;
1467 $value = $usces->get_cookie();
1468
1469 if( $out == 'return' ){
1470 if(isset($value['name']) && $value['name'] != '')
1471 return ' checked="checked"';
1472 else
1473 return '';
1474 }else{
1475 if(isset($value['name']) && $value['name'] != '')
1476 echo ' checked="checked"';
1477 else
1478 echo '';
1479 }
1480 }
1481 function usces_shippingchargeTR( $index='' ) {
1482 global $usces;
1483 if($index == ""){
1484 $index = 0;
1485 }
1486 $list = '';
1487 if( !isset($usces->options['shipping_charge'][$index]) ) return;
1488 $shipping_charge = $usces->options['shipping_charge'][$index];
1489 //20120710ysk start 0000472
1490 $entry = $usces->cart->get_entry();
1491 $country = (isset($entry['delivery']['country']) && !empty($entry['delivery']['country'])) ? $entry['delivery']['country'] : $entry['customer']['country'];//20120710ysk 0000472
1492 //foreach ($shipping_charge['value'] as $pref => $value) {
1493 foreach ($shipping_charge[$country] as $pref => $value) {
1494 //20120710ysk end
1495 $list .= "<tr><th>" . esc_html($pref) . "</th>\n";
1496 $list .= "<td class='rightnum'>" . number_format($value) . "</td>\n";
1497 $list .= "</tr>\n";
1498 }
1499 echo $list;
1500 }
1501 function usces_sc_shipping_charge() {
1502 global $usces;
1503 echo esc_html($usces->sc_shipping_charge());
1504 }
1505 function usces_sc_postage_privilege() {
1506 global $usces;
1507 echo esc_html($usces->sc_postage_privilege());
1508 }
1509 function usces_sc_payment_title() {
1510 global $usces;
1511 echo $usces->sc_payment_title();
1512 }
1513
1514
1515
1516 function usces_posts_random_offset( $posts ){
1517 $ids = array();
1518 foreach( (array)$posts as $post ){
1519 $ids[] = $post->ID;
1520 }
1521 $ct = count($ids);
1522 $index = rand(0, ($ct-1));
1523 return $index;
1524 }
1525
1526 function usces_get_category_link_by_slug( $slug ){
1527 $category = get_category_by_slug($slug);
1528 echo get_category_link( $category->term_id );
1529 }
1530
1531 function usces_get_page_ID_by_pname( $post_name, $return = 'echo' ){
1532 $page = get_page_by_path( $post_name );
1533 if($return == 'return')
1534 return $page->ID;
1535 else
1536 echo $page->ID;
1537 }
1538
1539 function usces_list_bestseller($num, $days = ''){
1540 global $usces;
1541 $ids = $usces->get_bestseller_ids( $days );
1542 $htm = "";
1543 for($i=0; $i<$num; $i++){
1544 if(isset($ids[$i])){
1545 $post = get_post($ids[$i]);
1546 if( !is_object($post) )
1547 continue;
1548
1549 $disp_text = apply_filters('usces_widget_bestseller_auto_text', esc_html($post->post_title), $ids[$i]);
1550 $list = "<li><a href='" . get_permalink($ids[$i]) . "'>" . $disp_text . "</a></li>\n";
1551 $htm .= apply_filters('usces_filter_bestseller', $list, $ids[$i], $i);
1552 }
1553 }
1554 wp_reset_postdata();
1555 echo $htm;
1556 }
1557
1558 function usces_list_post( $slug, $rownum, $widget_id=NULL ){
1559 global $usces, $post;
1560 usces_remove_filter();
1561
1562 $li = '';
1563 $infolist = new wp_query( array('category_name'=>$slug, 'post_status'=>'publish', 'posts_per_page'=>$rownum, 'order'=>'DESC', 'orderby'=>'date') );
1564 if( NULL != $widget_id && $infolist->have_posts() ){
1565 remove_filter( 'excerpt_length', 'welcart_excerpt_length' );
1566 remove_filter( 'excerpt_mblength', 'welcart_excerpt_mblength' );
1567 remove_filter( 'excerpt_more', 'welcart_auto_excerpt_more' );
1568 if( function_exists('welcart_widget_post_excerpt_length_'.$widget_id) )
1569 add_filter( 'excerpt_length', 'welcart_widget_post_excerpt_length_'.$widget_id );
1570 if( function_exists('welcart_widget_post_excerpt_mblength_'.$widget_id) )
1571 add_filter( 'excerpt_mblength', 'welcart_widget_post_excerpt_mblength_'.$widget_id );
1572 }
1573 $list_index = 0;
1574 while ($infolist->have_posts()) {
1575 $infolist->the_post();
1576 $list = '<li class="post_list'. apply_filters('usces_filter_post_list_class', NULL, $list_index, count($infolist)) . '">'."\n";
1577 $list .= "<div class='title'><a href='" . get_permalink($post->ID) . "'>" . get_the_title() . "</a></div>\n";
1578 $list .= "<p>" . get_the_excerpt() . "</p>\n";
1579 $list .= "</li>\n";
1580 $li .= apply_filters( 'usces_filter_widget_post', $list, $post, $slug, $list_index);
1581 $list_index++;
1582 }
1583 wp_reset_query();
1584 usces_reset_filter();
1585 if( NULL != $widget_id && $infolist->have_posts() ){
1586 add_filter( 'excerpt_length', 'welcart_excerpt_length' );
1587 add_filter( 'excerpt_mblength', 'welcart_excerpt_mblength' );
1588 add_filter( 'excerpt_more', 'welcart_auto_excerpt_more' );
1589 }
1590 echo $li;
1591 }
1592
1593 function usces_categories_checkbox($output=''){
1594 global $usces;
1595 $retcats = apply_filters('usces_search_retcats', usces_search_categories());
1596 $parent_id = apply_filters('usces_search_categories_checkbox_parent', USCES_ITEM_CAT_PARENT_ID);
1597 $htm = usces_get_categories_checkbox($parent_id);
1598 $htm = apply_filters('usces_filter_categories_checkbox', $htm, $parent_id);
1599
1600 if($output == '' || $output == 'echo')
1601 echo $htm;
1602 else
1603 return $htm;
1604 }
1605
1606 function usces_get_categories_checkbox($parent_id){
1607 global $usces;
1608 $htm = '';
1609 $retcats = usces_search_categories();
1610 $parent_cat = get_category($parent_id);
1611 $categories = get_categories('parent='.$parent_id . "&hide_empty=0&orderby=" . $usces->options['fukugo_category_orderby'] . "&order=" . $usces->options['fukugo_category_order']);
1612 $htm .= "<fieldset class='catfield-" . $parent_cat->term_id . "'><legend>" . $parent_cat->cat_name . "</legend><ul>\n";
1613 foreach ($categories as $cat) {
1614 $children = get_categories('parent='.$cat->term_id . "&hide_empty=0");
1615 if( 0 === count($children) ){
1616 $checked = in_array($cat->term_id, $retcats) ? " checked='checked'" : "";
1617 $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";
1618 }
1619 }
1620 $htm .= "</ul>\n";
1621 foreach ($categories as $cat) {
1622 $children = get_categories('parent='.$cat->term_id . "&hide_empty=0");
1623 if( 0 < count($children) ){
1624 $htm .= usces_get_categories_checkbox($cat->term_id);
1625 }
1626 }
1627 $htm .= "</fieldset>\n";
1628
1629 return $htm;
1630 }
1631
1632 function usces_search_categories(){
1633 $cats = array();
1634 //if(isset($_POST['category']))
1635 // $cats = $_POST['category'];
1636 if(isset($_REQUEST['category']))
1637 $cats = $_REQUEST['category'];
1638 else
1639 $cats[] = USCES_ITEM_CAT_PARENT_ID;
1640 sort($cats);
1641 return $cats;
1642 }
1643
1644 function usces_delivery_method_name( $id, $out = '' ){
1645 global $usces;
1646
1647 if($id > -1){
1648 $id =$usces->get_delivery_method_index($id);
1649 $name = $usces->options['delivery_method'][$id]['name'];
1650 }else{
1651 $name = __('No preference','usces');
1652 }
1653
1654 if($out == 'return'){
1655 return $name;
1656 }else{
1657 echo esc_html($name);
1658 }
1659 }
1660
1661 function usces_is_membersystem_state(){
1662 global $usces;
1663
1664 if($usces->options['membersystem_state'] == 'activate') {
1665 return true;
1666 }else{
1667 return false;
1668 }
1669 }
1670
1671 function usces_is_membersystem_point(){
1672 global $usces;
1673
1674 if($usces->options['membersystem_point'] == 'activate') {
1675 return true;
1676 }else{
1677 return false;
1678 }
1679 }
1680
1681 function usces_copyright(){
1682 global $usces;
1683
1684 echo esc_html($usces->options['copyright']);
1685 }
1686
1687 function usces_totalprice_in_cart(){
1688 global $usces;
1689
1690 echo number_format($usces->get_total_price());
1691 }
1692
1693 function usces_totalquantity_in_cart(){
1694 global $usces;
1695
1696 echo number_format($usces->get_total_quantity());
1697 }
1698
1699 function usces_get_page_mode(){
1700 global $usces;
1701
1702 return $usces->page;
1703 }
1704
1705 function usces_is_cat_of_item( $cat_id ){
1706 global $usces;
1707 $ids = $usces->get_item_cat_ids();
1708 $ids[] = USCES_ITEM_CAT_PARENT_ID;
1709 if(in_array($cat_id, $ids)){
1710 return true;
1711 }else{
1712 return false;
1713 }
1714 }
1715
1716 function usces_get_item_custom( $post_id, $type = 'list', $out = '' ){
1717 global $usces;
1718 $cfields = $usces->get_post_custom($post_id);
1719 switch( $type ){
1720 case 'list':
1721 $list = '';
1722 $html = '<ul class="item_custom_field">'."\n";
1723 foreach( $cfields as $key => $value ){
1724 if( 'wccs_' == substr($key, 0, 5) ){
1725 $list .= '<li>' . esc_html(substr($key, 5)) . ' : ' . nl2br(esc_html($value[0])) . '</li>'."\n";
1726 }
1727 }
1728 if(empty($list)){
1729 $html = '';
1730 }else{
1731 $html .= $list . '</ul>'."\n";
1732 }
1733 break;
1734
1735 case 'table':
1736 $list = '';
1737 $html = '<table class="item_custom_field">'."\n";
1738 foreach($cfields as $key => $value){
1739 if( 'wccs_' == substr($key, 0, 5) ){
1740 $list .= '<tr><th>' . esc_html(substr($key, 5)) . '</th><td>' . nl2br(esc_html($value[0])) . '</td></tr>'."\n";
1741 }
1742 }
1743 if(empty($list)){
1744 $html = '';
1745 }else{
1746 $html .= $list . '</table>'."\n";
1747 }
1748 break;
1749
1750 case 'notag':
1751 $list = '';
1752 foreach($cfields as $key => $value){
1753 if( 'wccs_' == substr($key, 0, 5) ){
1754 $list .= esc_html(substr($key, 5)) . ' : ' . nl2br(esc_html($value[0])) . "\r\n";
1755 }
1756 }
1757 if(empty($list)){
1758 $html = '';
1759 }else{
1760 $html = $list;
1761 }
1762 break;
1763 }
1764 $html = apply_filters( 'usces_filter_item_custom', $html, $post_id);
1765
1766 if( 'return' == $out){
1767 return $html;
1768 }else{
1769 echo $html;
1770 }
1771 }
1772
1773 function usces_settle_info_field( $order_id, $type='nl', $out='echo' ){
1774 global $usces;
1775 $str = '';
1776 $fields = $usces->get_settle_info_field( $order_id );
1777 //20101018ysk start
1778 $acting = isset($fields['acting']) ? $fields['acting'] : '';
1779 foreach($fields as $key => $value){
1780 //20101018ysk end
1781 $keys = array(
1782 'acting','order_no','tracking_no','status','error_message','money',
1783 'pay_cvs', 'pay_no1', 'pay_no2', 'pay_limit', 'error_code',
1784 'settlement_id','RECDATE','JOB_ID','S_TORIHIKI_NO','TOTAL','CENDATE',
1785 'gid', 'rst', 'ap', 'ec', 'god', 'ta', 'cv', 'no', 'cu', 'mf', 'nk', 'nkd', 'bank', 'exp',
1786 'order_number',
1787 'res_tracking_id', 'res_payment_date', 'res_payinfo_key',
1788 'SID', 'DATE', 'TIME', 'CVS', 'SHNO', 'FURL', 'settltment_status', 'settltment_errmsg',
1789 'stran', 'mbtran', 'bktrans', 'tranid'
1790 );
1791 $keys = apply_filters( 'usces_filter_settle_info_field_keys', $keys );
1792 if( !in_array($key, $keys) ) {
1793 continue;
1794 }
1795
1796 switch($acting){
1797 case 'zeus_bank':
1798 if( 'status' == $key){
1799 if( '01' === $value ){
1800 $value = '受付中';
1801 }elseif( '02' === $value ){
1802 $value = '未�
1803 �金';
1804 }elseif( '03' === $value ){
1805 $value = '�
1806 �金済';
1807 }elseif( '04' === $value ){
1808 $value = 'エラー';
1809 }elseif( '05' === $value ){
1810 $value = '�
1811 �金失敗';
1812 }
1813 }elseif( 'error_message' == $key){
1814 if( '0002' === $value ){
1815 $value = '�
1816 �金不足';
1817 }elseif( '0003' === $value ){
1818 $value = '過剰�
1819 �金';
1820 }
1821 }
1822 break;
1823 case 'zeus_conv':
1824 if( 'pay_cvs' == $key){
1825 if( 'D001' === $value ){
1826 $value = 'セブンイレブン';
1827 }elseif( 'D002' === $value ){
1828 $value = 'ローソン';
1829 }elseif( 'D030' === $value ){
1830 $value = 'ファミリーマート';
1831 }elseif( 'D040' === $value ){
1832 $value = 'サークルKサンクス';
1833 }elseif( 'D015' === $value ){
1834 $value = 'セイコーマート';
1835 }
1836 }elseif( 'status' == $key){
1837 if( '01' === $value ){
1838 $value = '未�
1839 �金';
1840 }elseif( '02' === $value ){
1841 $value = '申込エラー';
1842 }elseif( '03' === $value ){
1843 $value = '期日切';
1844 }elseif( '04' === $value ){
1845 $value = '�
1846 �金済';
1847 }elseif( '05' === $value ){
1848 $value = '売上確定';
1849 }elseif( '06' === $value ){
1850 $value = '�
1851 �金取消';
1852 }elseif( '11' === $value ){
1853 $value = 'キャンセル後�
1854 �金';
1855 }elseif( '12' === $value ){
1856 $value = 'キャンセル後売上';
1857 }elseif( '13' === $value ){
1858 $value = 'キャンセル後取消';
1859 }
1860 }elseif( 'pay_limit' == $key){
1861 $value = substr($value, 0, 4).'' . substr($value, 4, 2).'' . substr($value, 6, 2).'';
1862 }
1863 break;
1864 //20101018ysk start
1865 case 'jpayment_conv':
1866 switch($key) {
1867 case 'rst':
1868 switch($value) {
1869 case '1':
1870 $value = 'OK'; break;
1871 case '2':
1872 $value = 'NG'; break;
1873 }
1874 break;
1875 case 'ap':
1876 switch($value) {
1877 case 'CPL_PRE':
1878 $value = 'コンビニペーパーレス決済識別コード'; break;
1879 case 'CPL':
1880 $value = '�
1881 �金確定'; break;
1882 case 'CVS_CAN':
1883 $value = '�
1884 �金取消'; break;
1885 }
1886 break;
1887 case 'cv':
1888 $value = esc_html(usces_get_conv_name($value));
1889 break;
1890 case 'mf':
1891 case 'nk':
1892 case 'nkd':
1893 case 'bank':
1894 case 'exp':
1895 continue;
1896 break;
1897 }
1898 break;
1899
1900 case 'jpayment_bank':
1901 switch($key) {
1902 case 'rst':
1903 switch($value) {
1904 case '1':
1905 $value = 'OK'; break;
1906 case '2':
1907 $value = 'NG'; break;
1908 }
1909 break;
1910 case 'ap':
1911 switch($value) {
1912 case 'BANK':
1913 $value = '受付完了'; break;
1914 case 'BAN_SAL':
1915 $value = '�
1916 �金完了'; break;
1917 }
1918 break;
1919 case 'mf':
1920 switch($value) {
1921 case '1':
1922 $value = 'マッチ'; break;
1923 case '2':
1924 $value = '過少'; break;
1925 case '3':
1926 $value = '過剰'; break;
1927 }
1928 break;
1929 case 'nkd':
1930 $value = substr($value, 0, 4).''.substr($value, 4, 2).''.substr($value, 6, 2).'';
1931 break;
1932 case 'exp':
1933 $value = substr($value, 0, 4).''.substr($value, 4, 2).''.substr($value, 6, 2).'';
1934 break;
1935 case 'cv':
1936 case 'no':
1937 case 'cu':
1938 continue;
1939 break;
1940 }
1941 break;
1942 //20101018ysk end
1943 }
1944 $value = apply_filters( 'usces_filter_settle_info_field_value', $value, $key, $acting );
1945 switch($type){
1946 case 'nl':
1947 $str .= $key . ' : ' . $value . "<br />\n";
1948 break;
1949
1950 case 'tr':
1951 $str .= '<tr><td class="label">' . $key . '</td><td>' . $value . "</td></tr>\n";
1952 break;
1953
1954 case 'li':
1955 $str .= '<li>' . $key . ' : ' . $value . "</li>\n";
1956 break;
1957 }
1958 }
1959 if( 'return' == $out){
1960 return $str;
1961 }else{
1962 echo $str;
1963 }
1964 }
1965
1966 //20100818ysk start
1967 function usces_custom_field_input( $data, $custom_field, $position, $out = '' ) {
1968
1969 $html = '';
1970 switch($custom_field) {
1971 case 'order':
1972 $label = 'custom_order';
1973 $field = 'usces_custom_order_field';
1974 break;
1975 case 'customer':
1976 $label = 'custom_customer';
1977 $field = 'usces_custom_customer_field';
1978 break;
1979 case 'delivery':
1980 $label = 'custom_delivery';
1981 $field = 'usces_custom_delivery_field';
1982 break;
1983 case 'member':
1984 $label = 'custom_member';
1985 $field = 'usces_custom_member_field';
1986 break;
1987 default:
1988 return;
1989 }
1990
1991 $meta = usces_has_custom_field_meta($custom_field);
1992
1993 if(!empty($meta) and is_array($meta)) {
1994 foreach($meta as $key => $entry) {
1995 if($custom_field == 'order' or $entry['position'] == $position) {
1996 $name = $entry['name'];
1997 $means = $entry['means'];
1998 $essential = $entry['essential'];
1999 $value = '';
2000 if(is_array($entry['value'])) {
2001 foreach($entry['value'] as $k => $v) {
2002 $value .= $v."\n";
2003 }
2004 }
2005 $value = trim($value);
2006
2007 $e = ($essential == 1) ? '<em>' . __('*', 'usces') . '</em>' : '';
2008 $html .= '
2009 <tr class="customkey_' . $key . '">
2010 <th scope="row">'.$e.esc_html($name).apply_filters('usces_filter_custom_field_input_label', NULL, $key, $entry).'</th>';
2011 $html .= apply_filters( 'usces_filter_custom_field_input_td', '<td colspan="2">', $key, $entry);
2012 switch($means) {
2013 case 0://シングルセレクト
2014 case 1://マルチセレクト
2015 $selects = explode("\n", $value);
2016 $multiple = ($means == 0) ? '' : ' multiple';
2017 $multiple_array = ($means == 0) ? '' : '[]';
2018 $html .= '<select name="'.$label.'['.esc_attr($key).']'.$multiple_array.'" class="iopt_select"'.$multiple.'>';
2019 if($essential == 1)
2020 $html .= '
2021 <option value="#NONE#">'.__('Choose','usces').'</option>';
2022 foreach($selects as $v) {
2023 $selected = (isset($data[$label][$key]) && $data[$label][$key] == $v) ? ' selected' : '';
2024 $html .= '
2025 <option value="'.esc_attr($v).'"'.$selected.'>'.esc_html($v).'</option>';
2026 }
2027 $html .= '
2028 </select>';
2029 break;
2030 case 2://テキスト
2031 $text = isset($data[$label][$key]) ? $data[$label][$key] : '';
2032 $html .= '<input type="text" name="'.$label.'['.esc_attr($key).']" value="'.esc_attr($text).'" />';
2033 break;
2034 case 3://ラジオボタン
2035 $selects = explode("\n", $value);
2036 foreach($selects as $v) {
2037 $checked = ( isset($data[$label][$key]) && $data[$label][$key] == $v) ? ' checked' : '';
2038 $html .= '
2039 <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>';
2040 }
2041 break;
2042 case 4://チェックボックス
2043 $selects = explode("\n", $value);
2044 foreach($selects as $v) {
2045 if( isset($data[$label][$key]) && is_array($data[$label][$key]) ) {
2046 $checked = (isset($data[$label][$key]) && array_key_exists($v, $data[$label][$key])) ? ' checked' : '';
2047 } else {
2048 $checked = (isset($data[$label][$key]) && $data[$label][$key] == $v) ? ' checked' : '';
2049 }
2050 $html .= '
2051 <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>';
2052 }
2053 break;
2054 }
2055 $html .= apply_filters('usces_filter_custom_field_input_value', NULL, $key, $entry).'</td>';
2056 $html .= '
2057 </tr>';
2058 }
2059 }
2060 }
2061
2062 $html = apply_filters('usces_filter_custom_field_input', $html, $data, $custom_field, $position);
2063
2064 if($out == 'return') {
2065 return stripslashes($html);
2066 } else {
2067 echo stripslashes($html);
2068 }
2069 }
2070
2071 function usces_custom_field_info( $data, $custom_field, $position, $out = '' ) {
2072
2073 $html = '';
2074 switch($custom_field) {
2075 case 'order':
2076 $label = 'custom_order';
2077 $field = 'usces_custom_order_field';
2078 break;
2079 case 'customer':
2080 $label = 'custom_customer';
2081 $field = 'usces_custom_customer_field';
2082 break;
2083 case 'delivery':
2084 $label = 'custom_delivery';
2085 $field = 'usces_custom_delivery_field';
2086 break;
2087 case 'member':
2088 $label = 'custom_member';
2089 $field = 'usces_custom_member_field';
2090 break;
2091 default:
2092 return;
2093 }
2094
2095 $meta = usces_has_custom_field_meta($custom_field);
2096
2097 if(!empty($meta) and is_array($meta)) {
2098 foreach($meta as $key => $entry) {
2099 if($custom_field == 'order' or $entry['position'] == $position) {
2100 $name = $entry['name'];
2101 $means = $entry['means'];
2102
2103 $html .= '<tr>
2104 <th>'.esc_html($name).'</th>
2105 <td>';
2106 if(!empty($data[$label][$key])) {
2107 switch($means) {
2108 case 0://シングルセレクト
2109 case 2://テキスト
2110 case 3://ラジオボタン
2111 $html .= esc_html($data[$label][$key]);
2112 break;
2113 case 1://マルチセレクト
2114 case 4://チェックボックス
2115 if(is_array($data[$label][$key])) {
2116 $c = '';
2117 foreach($data[$label][$key] as $v) {
2118 $html .= $c.esc_html($v);
2119 $c = ', ';
2120 }
2121 } else {
2122 if(!empty($data[$label][$key])) $html .= esc_html($data[$label][$key]);
2123 }
2124 break;
2125 }
2126 }
2127 $html .= '
2128 </td>
2129 </tr>';
2130 }
2131 }
2132 }
2133
2134 $html = apply_filters('usces_filter_custom_field_info', $html, $data, $custom_field, $position);
2135
2136 if($out == 'return') {
2137 return stripslashes($html);
2138 } else {
2139 echo stripslashes($html);
2140 }
2141 }
2142
2143 function usces_admin_custom_field_input( $meta, $custom_field, $position, $out = '' ) {
2144
2145 $html = '';
2146 switch($custom_field) {
2147 case 'order':
2148 $label = 'custom_order';
2149 $class = '';
2150 break;
2151 case 'customer':
2152 $label = 'custom_customer';
2153 $class = ' class="col2"';
2154 break;
2155 case 'delivery':
2156 $label = 'custom_delivery';
2157 $class = ' class="col3"';
2158 break;
2159 case 'member':
2160 $label = 'custom_member';
2161 $class = '';
2162 break;
2163 default:
2164 return;
2165 }
2166
2167
2168 if(!empty($meta) and is_array($meta)) {
2169 foreach($meta as $key => $entry) {
2170 if($custom_field == 'order' or $entry['position'] == $position) {
2171 $name = $entry['name'];
2172 $means = $entry['means'];
2173 $essential = $entry['essential'];
2174 $value = '';
2175 if(is_array($entry['value'])) {
2176 foreach($entry['value'] as $k => $v) {
2177 $value .= $v."\n";
2178 }
2179 }
2180 $value = trim($value);
2181 $data = $entry['data'];
2182
2183 $html .= '
2184 <tr>
2185 <td class="label">'.esc_html($name).'</td>';
2186 switch($means) {
2187 case 0://シングルセレクト
2188 case 1://マルチセレクト
2189 $selects = explode("\n", $value);
2190 $multiple = ($means == 0) ? '' : ' multiple';
2191 $multiple_array = ($means == 0) ? '' : '[]';
2192 $html .= '
2193 <td'.$class.'>
2194 <select name="'.$label.'['.esc_attr($key).']'.$multiple_array.'" id="'.$label.'['.esc_attr($key).']" class="iopt_select"'.$multiple.'>';
2195 if($essential == 1)
2196 $html .= '
2197 <option value="#NONE#">'.__('Choose','usces').'</option>';
2198 foreach($selects as $v) {
2199 $selected = ($data == $v) ? ' selected' : '';
2200 $html .= '
2201 <option value="'.esc_attr($v).'"'.$selected.'>'.esc_html($v).'</option>';
2202 }
2203 $html .= '
2204 </select></td>';
2205 break;
2206 case 2://テキスト
2207 $html .= '
2208 <td'.$class.'><input type="text" name="'.$label.'['.esc_attr($key).']" id="'.$label.'['.esc_attr($key).']" size="30" value="'.esc_attr($data).'" /></td>';
2209 break;
2210 case 3://ラジオボタン
2211 $selects = explode("\n", $value);
2212 $html .= '
2213 <td'.$class.'>';
2214 foreach($selects as $v) {
2215 $checked = ($data == $v) ? ' checked' : '';
2216 $html .= '
2217 <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>';
2218 }
2219 $html .= '
2220 </td>';
2221 break;
2222 case 4://チェックボックス
2223 $selects = explode("\n", $value);
2224 $html .= '
2225 <td'.$class.'>';
2226 foreach($selects as $v) {
2227 if(is_array($data)) {
2228 $checked = (array_key_exists($v, $data)) ? ' checked' : '';
2229 } else {
2230 $checked = ($data == $v) ? ' checked' : '';
2231 }
2232 $html .= '
2233 <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>';
2234 }
2235 $html .= '
2236 </td>';
2237 break;
2238 }
2239 $html .= '
2240 </tr>';
2241 }
2242
2243 }
2244 }
2245 $html = apply_filters( 'usces_filter_admin_custom_field_input', $html, $meta, $custom_field, $position, $out );
2246
2247 if($out == 'return') {
2248 return stripslashes($html);
2249 } else {
2250 echo stripslashes($html);
2251 }
2252 }
2253
2254 function has_custom_customer_field_essential() {
2255
2256 $mes = '';
2257 $essential = array();
2258
2259 $csmb_meta = usces_has_custom_field_meta('member');
2260 if(!empty($csmb_meta) and is_array($csmb_meta)) {
2261 foreach($csmb_meta as $key => $entry) {
2262 if($entry['essential'] == 1) {
2263 $essential[$key] = $key;
2264 }
2265 }
2266 }
2267 if(!empty($essential)) {
2268 $cscs_meta = usces_has_custom_field_meta('customer');
2269 if(!empty($cscs_meta) and is_array($cscs_meta)) {
2270 foreach($cscs_meta as $key => $entry) {
2271 if($entry['essential'] == 1) {
2272 if(!array_key_exists($key, $essential)) {
2273 if($entry['means'] == 2) {//Text
2274 $mes .= sprintf(__("Input the %s", 'usces'), esc_html($entry['name']))."<br />";
2275 } else {
2276 $mes .= sprintf(__("Chose the %s", 'usces'), esc_html($entry['name']))."<br />";
2277 }
2278 }
2279 }
2280 }
2281 }
2282 }
2283 return $mes;
2284 }
2285 //20100818ysk end
2286
2287 function usces_order_discount( $out = '' ){
2288 global $usces;
2289 $res = abs($usces->get_order_discount());
2290
2291 if($out == 'return') {
2292 return $res;
2293 } else {
2294 echo number_format($res);
2295 }
2296 }
2297
2298 function usces_item_discount( $out = '', $post_id = '', $sku = '' ){
2299 global $usces, $post;
2300
2301 if( '' == $post_id )
2302 $post_id = $post->ID;
2303 if( '' == $sku )
2304 $sku = $usces->itemsku['code'];
2305
2306 $res = $usces->getItemDiscount($post_id, $sku);
2307
2308 if($out == 'return') {
2309 return $res;
2310 } else {
2311 echo number_format($res);
2312 }
2313 }
2314
2315 function usces_singleitem_error_message($post_id, $skukey, $out = ''){
2316 if( !isset($_SESSION['usces_singleitem']['error_message'][$post_id][$skukey]) )
2317 $ret = '';
2318 else
2319 $ret = $_SESSION['usces_singleitem']['error_message'][$post_id][$skukey];
2320
2321 if($out == 'return') {
2322 return $ret;
2323 } else {
2324 echo $ret;
2325 }
2326 }
2327
2328 function usces_crform( $float, $symbol_pre = true, $symbol_post = true, $out = '', $seperator_flag = true ) {
2329 global $usces;
2330 $price = esc_html($usces->get_currency($float, $symbol_pre, $symbol_post, $seperator_flag ));
2331 $res = apply_filters('usces_filter_crform', $price, $float);
2332
2333 if($out == 'return'){
2334 return $res;
2335 }else{
2336 echo $res;
2337 }
2338 }
2339
2340 function usces_memberinfo( $key, $out = '' ){
2341 global $usces, $wpdb;
2342 $info = $usces->get_member();
2343
2344 if( empty($key) ) return $info;
2345
2346 switch ($key){
2347 case 'registered':
2348 $res = mysql2date(__('Mj, Y', 'usces'), $info['registered']);
2349 break;
2350 //20120919ysk start 0000573
2351 case 'point':
2352 $member_table = $wpdb->prefix."usces_member";
2353 $query = $wpdb->prepare("SELECT mem_point FROM $member_table WHERE ID = %d", $info['ID']);
2354 $res = $wpdb->get_var( $query );
2355 break;
2356 //20120919ysk end
2357 default:
2358 $res = isset($info[$key]) ? $info[$key] : '';
2359 }
2360
2361 if($out == 'return'){
2362 return $res;
2363 }else{
2364 echo esc_html($res);
2365 }
2366 }
2367
2368 function usces_localized_name( $Familly_name, $Given_name, $out = '' ){
2369 global $usces_settings, $usces;
2370
2371 $options = get_option('usces');
2372 $form = $options['system']['addressform'];
2373 if( $usces_settings['nameform'][$form] ){
2374 $res = $Given_name . ' ' . $Familly_name;
2375 }else{
2376 $res = $Familly_name . ' ' . $Given_name;
2377 }
2378
2379 if($out == 'return'){
2380 return $res;
2381 }else{
2382 echo esc_html($res);
2383 }
2384 }
2385
2386 function usces_member_history( $out = '' ){
2387 global $usces;
2388
2389 $usces_members = $usces->get_member();
2390 $usces_member_history = $usces->get_member_history($usces_members['ID']);
2391 $colspan = usces_is_membersystem_point() ? 9 : 7;
2392
2393 $html = '<table>';
2394 if ( !count($usces_member_history) ) {
2395 $html .= '<tr>
2396 <td>' . __('There is no purchase history for this moment.', 'usces') . '</td>
2397 </tr>';
2398 }
2399 foreach ( $usces_member_history as $umhs ) {
2400 $cart = $umhs['cart'];
2401 $history_member_head = '<tr>
2402 <th class="historyrow">' . __('Order number', 'usces') . '</th>
2403 <th class="historyrow">' . __('Purchase date', 'usces') . '</th>
2404 <th class="historyrow">' . __('Purchase price', 'usces') . '</th>';
2405 if( usces_is_membersystem_point() ){
2406 $history_member_head .= '<th class="historyrow">' . __('Used points', 'usces') . '</th>';
2407 }
2408 $history_member_head .= '<th class="historyrow">' . apply_filters( 'usces_member_discount_label', __('Special Price', 'usces'), $umhs['ID'] ) . '</th>
2409 <th class="historyrow">' . __('Shipping', 'usces') . '</th>
2410 <th class="historyrow">' . __('C.O.D', 'usces') . '</th>
2411 <th class="historyrow">' . __('consumption tax', 'usces') . '</th>';
2412 if( usces_is_membersystem_point() ){
2413 $history_member_head .= '<th class="historyrow">' . __('Acquired points', 'usces') . '</th>';
2414 }
2415 $history_member_head .= '</tr>
2416 <tr>
2417 <td class="rightnum">' . usces_get_deco_order_id($umhs['ID']) . '</td>
2418 <td class="date">' . $umhs['date'] . '</td>
2419 <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>';
2420 if( usces_is_membersystem_point() ){
2421 $history_member_head .= '<td class="rightnum">' . number_format($umhs['usedpoint']) . '</td>';
2422 }
2423 $history_member_head .= '<td class="rightnum">' . usces_crform($umhs['discount'], true, false, 'return') . '</td>
2424 <td class="rightnum">' . usces_crform($umhs['shipping_charge'], true, false, 'return') . '</td>
2425 <td class="rightnum">' . usces_crform($umhs['cod_fee'], true, false, 'return') . '</td>
2426 <td class="rightnum">' . usces_crform($umhs['tax'], true, false, 'return') . '</td>';
2427 if( usces_is_membersystem_point() ){
2428 $history_member_head .= '<td class="rightnum">' . number_format($umhs['getpoint']) . '</td>';
2429 }
2430 $history_member_head .= '</tr>';
2431 $html .= apply_filters( 'usces_filter_history_member_head', $history_member_head, $umhs );
2432 $html .= apply_filters('usces_filter_member_history_header', NULL, $umhs);
2433 $html .= '<tr>
2434 <td class="retail" colspan="' . $colspan . '">
2435 <table id="retail_table_' . $umhs['ID'] . '" class="retail">';
2436 $history_cart_head = '<tr>
2437 <th scope="row" class="num">No.</th>
2438 <th class="thumbnail">&nbsp;</th>
2439 <th>' . __('Items', 'usces') . '</th>
2440 <th class="price ">' . __('Unit price', 'usces') . '</th>
2441 <th class="quantity">' . __('Quantity', 'usces') . '</th>
2442 <th class="subtotal">' . __('Amount', 'usces') . '</th>
2443 </tr>';
2444 $html .= apply_filters('usces_filter_history_cart_head', $history_cart_head, $umhs);
2445
2446 for($i=0; $i<count($cart); $i++) {
2447 $cart_row = $cart[$i];
2448 $post_id = $cart_row['post_id'];
2449 $sku = urldecode($cart_row['sku']);
2450 $quantity = $cart_row['quantity'];
2451 $options = $cart_row['options'];
2452 $itemCode = $usces->getItemCode($post_id);
2453 $itemName = $usces->getItemName($post_id);
2454 $cartItemName = $usces->getCartItemName($post_id, $sku);
2455 //$skuPrice = $usces->getItemPrice($post_id, $sku);
2456 $skuPrice = $cart_row['price'];
2457 $pictid = (int)$usces->get_mainpictid($itemCode);
2458 $optstr = '';
2459 if( is_array($options) && count($options) > 0 ){
2460 $optstr = '';
2461 foreach($options as $key => $value){
2462 //20110629ysk start 0000190
2463 //f( !empty($key) )
2464 // $optstr .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
2465 if( !empty($key) ) {
2466 $key = urldecode($key);
2467 if(is_array($value)) {
2468 $c = '';
2469 $optstr .= esc_html($key) . ' : ';
2470 foreach($value as $v) {
2471 $optstr .= $c.nl2br(esc_html(urldecode($v)));
2472 $c = ', ';
2473 }
2474 $optstr .= "<br />\n";
2475 } else {
2476 $optstr .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
2477 }
2478 }
2479 //20110629ysk end
2480 }
2481 $optstr = apply_filters( 'usces_filter_option_history', $optstr, $options);
2482 }
2483 $optstr = apply_filters( 'usces_filter_option_info_history', $optstr, $umhs, $cart_row, $i );
2484
2485 $history_cart_row = '<tr>
2486 <td>' . ($i + 1) . '</td>
2487 <td>';
2488 $cart_thumbnail = '<a href="' . get_permalink($post_id) . '">' . wp_get_attachment_image( $pictid, array(60, 60), true ) . '</a>';
2489 $history_cart_row .= apply_filters('usces_filter_cart_thumbnail', $cart_thumbnail, $post_id, $pictid, $i, $cart_row);
2490 $history_cart_row .= '</td>
2491 <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>
2492 <td class="rightnum">' . usces_crform($skuPrice, true, false, 'return') . '</td>
2493 <td class="rightnum">' . number_format($cart_row['quantity']) . '</td>
2494 <td class="rightnum">' . usces_crform($skuPrice * $cart_row['quantity'], true, false, 'return') . '</td>
2495 </tr>';
2496 $materials = compact( 'cart_thumbnail', 'post_id', 'pictid', 'cartItemName', 'optstr' );
2497 $html .= apply_filters( 'usces_filter_history_cart_row', $history_cart_row, $umhs, $cart_row, $i, $materials );
2498 }
2499 $html .= '</table>
2500 </td>
2501 </tr>';
2502 }
2503
2504 $html .= '</table>';
2505
2506 if($out == 'return'){
2507 return $html;
2508 }else{
2509 echo $html;
2510 }
2511 }
2512
2513 function usces_newmember_button($member_regmode){
2514 $html = '<input name="member_regmode" type="hidden" value="' . $member_regmode . '" />';
2515 $newmemberbutton = '<input name="regmember" type="submit" value="' . __('transmit a message', 'usces') . '" />';
2516 $html .= apply_filters('usces_filter_newmember_button', $newmemberbutton);
2517 echo $html;
2518 }
2519
2520 function usces_login_button(){
2521 $loginbutton = '<input type="submit" name="member_login" id="member_login" class="member_login_button" value="' . __('Log-in', 'usces') . '" />';
2522 $html = apply_filters('usces_filter_login_button', $loginbutton);
2523 echo $html;
2524 }
2525
2526 function usces_assistance_item($post_id, $title ){
2527 if (usces_get_assistance_id_list($post_id)) :
2528 global $post;
2529 $r = new WP_Query( array('post__in'=>usces_get_assistance_ids($post_id), 'ignore_sticky_posts'=>1) );
2530 if($r->have_posts()) :
2531 add_filter( 'excerpt_length', 'welcart_assistance_excerpt_length' );
2532 add_filter( 'excerpt_mblength', 'welcart_assistance_excerpt_mblength' );
2533 $width = apply_filters( 'usces_filter_assistance_item_width', 100 );
2534 $height = apply_filters( 'usces_filter_assistance_item_height', 100 );
2535 ?>
2536 <div class="assistance_item">
2537 <h3><?php echo $title; ?></h3>
2538 <ul class="clearfix">
2539 <?php
2540 while ($r->have_posts()) :
2541 $r->the_post();
2542 usces_remove_filter();
2543 usces_the_item();
2544 ob_start();
2545 ?>
2546 <li>
2547 <div class="listbox clearfix">
2548 <div class="slit">
2549 <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>
2550 </div>
2551 <div class="detail">
2552 <div class="assist_excerpt">
2553 <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php echo wp_filter_nohtml_kses(get_the_title()); ?>"><h4><?php usces_the_itemName(); ?></h4></a>
2554 <?php the_excerpt(); ?>
2555 </div>
2556 <div class="assist_price">
2557 <?php if (usces_is_skus()) : ?>
2558 <?php _e('$', 'usces'); ?><?php usces_the_firstPrice(); ?>
2559 <?php endif; ?>
2560 </div>
2561 </div>
2562 </div>
2563 </li>
2564 <?php
2565 $list = ob_get_contents();
2566 ob_end_clean();
2567 echo apply_filters('usces_filter_assistance_item_list', $list, $post);
2568 endwhile; ?>
2569
2570 </ul>
2571 </div><!-- end of assistance_item -->
2572 <?php
2573 wp_reset_postdata();
2574 usces_reset_filter();
2575 remove_filter( 'excerpt_length', 'welcart_assistance_excerpt_length' );
2576 remove_filter( 'excerpt_mblength', 'welcart_assistance_excerpt_mblength' );
2577 endif;
2578 endif;
2579 }
2580
2581 function usces_get_cart_rows( $out = '' ) {
2582 global $usces, $usces_gp;
2583 $cart = $usces->cart->get_cart();
2584 $usces_gp = 0;
2585 $res = '';
2586
2587 for($i=0; $i<count($cart); $i++) {
2588 $cart_row = $cart[$i];
2589 $post_id = $cart_row['post_id'];
2590 $sku = $cart_row['sku'];
2591 $sku_code = esc_attr(urldecode($cart_row['sku']));
2592 $quantity = $cart_row['quantity'];
2593 $options = $cart_row['options'];
2594 $advance = $usces->cart->wc_serialize($cart_row['advance']);
2595 $itemCode = $usces->getItemCode($post_id);
2596 $itemName = $usces->getItemName($post_id);
2597 $cartItemName = $usces->getCartItemName($post_id, $sku_code);
2598 $itemRestriction = $usces->getItemRestriction($post_id);
2599 $skuPrice = $cart_row['price'];
2600 $skuZaikonum = $usces->getItemZaikonum($post_id, $sku_code);
2601 $stockid = $usces->getItemZaikoStatusId($post_id, $sku_code);
2602 $stock = $usces->getItemZaiko($post_id, $sku_code);
2603 $red = (in_array($stock, array(__('sellout','usces'), __('Out Of Stock','usces'), __('Out of print','usces')))) ? 'class="signal_red"' : '';
2604 $pictid = (int)$usces->get_mainpictid($itemCode);
2605 $args = compact('cart', 'i', 'cart_row', 'post_id', 'sku' );
2606 $row = '';
2607 if ( empty($options) ) {
2608 $optstr = '';
2609 $options = array();
2610 }
2611 $row .= '<tr>
2612 <td>' . ($i + 1) . '</td>
2613 <td>';
2614 $cart_thumbnail = '<a href="' . get_permalink($post_id) . '">' . wp_get_attachment_image( $pictid, array(60, 60), true ) . '</a>';
2615 $row .= apply_filters('usces_filter_cart_thumbnail', $cart_thumbnail, $post_id, $pictid, $i,$cart_row);
2616 $row .= '</td><td class="aleft">' . esc_html($cartItemName) . '<br />';
2617 if( is_array($options) && count($options) > 0 ){
2618 $optstr = '';
2619 foreach($options as $key => $value){
2620 //20110629ysk start 0000190
2621 //if( !empty($key) )
2622 // $row .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
2623 if( !empty($key) ) {
2624 $key = urldecode($key);
2625 if(is_array($value)) {
2626 $c = '';
2627 $optstr .= esc_html($key) . ' : ';
2628 foreach($value as $v) {
2629 $optstr .= $c.nl2br(esc_html(urldecode($v)));
2630 $c = ', ';
2631 }
2632 $optstr .= "<br />\n";
2633 } else {
2634 $optstr .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
2635 }
2636 }
2637 //20110629ysk end
2638 }
2639 $row .= apply_filters( 'usces_filter_option_cart', $optstr, $options);
2640 }
2641 $row .= apply_filters( 'usces_filter_option_info_cart', '', $cart_row, $args );
2642 $row .= '</td>
2643 <td class="aright">';
2644 if( usces_is_gptekiyo($post_id, $sku_code, $quantity) ) {
2645 $usces_gp = 1;
2646 $Business_pack_mark = '<img src="' . get_template_directory_uri() . '/images/gp.gif" alt="' . __('Business package discount','usces') . '" /><br />';
2647 $row .= apply_filters('usces_filter_itemGpExp_cart_mark', $Business_pack_mark);
2648 }
2649 $row .= usces_crform($skuPrice, true, false, 'return') . '
2650 </td>
2651 <td>';
2652 $row_quant = '<input name="quant[' . $i . '][' . $post_id . '][' . $sku . ']" class="quantity" type="text" value="' . esc_attr($cart_row['quantity']) . '" />';
2653 $row .= apply_filters( 'usces_filter_cart_rows_quant', $row_quant, $args );
2654 $row .= '</td>
2655 <td class="aright">' . usces_crform(($skuPrice * $cart_row['quantity']), true, false, 'return') . '</td>
2656 <td ' . $red . '>' . $stock . '</td>
2657 <td>';
2658 foreach($options as $key => $value){
2659 //20110629ysk start 0000190
2660 //$row .= '<input name="itemOption[' . $i . '][' . $post_id . '][' . $sku . '][' . $key . ']" type="hidden" value="' . $value . '" />';
2661 if(is_array($value)) {
2662 foreach($value as $v) {
2663 $row .= '<input name="itemOption[' . $i . '][' . $post_id . '][' . $sku . '][' . $key . '][' . $v . ']" type="hidden" value="' . $v . '" />';
2664 }
2665 } else {
2666 $row .= '<input name="itemOption[' . $i . '][' . $post_id . '][' . $sku . '][' . $key . ']" type="hidden" value="' . $value . '" />';
2667 }
2668 //20110629ysk end
2669 }
2670 $row .= '<input name="itemRestriction[' . $i . ']" type="hidden" value="' . $itemRestriction . '" />
2671 <input name="stockid[' . $i . ']" type="hidden" value="' . $stockid . '" />
2672 <input name="itempostid[' . $i . ']" type="hidden" value="' . $post_id . '" />
2673 <input name="itemsku[' . $i . ']" type="hidden" value="' . $sku . '" />
2674 <input name="zaikonum[' . $i . '][' . $post_id . '][' . $sku . ']" type="hidden" value="' . esc_attr($skuZaikonum) . '" />
2675 <input name="skuPrice[' . $i . '][' . $post_id . '][' . $sku . ']" type="hidden" value="' . esc_attr($skuPrice) . '" />
2676 <input name="advance[' . $i . '][' . $post_id . '][' . $sku . ']" type="hidden" value="' . esc_attr($advance) . '" />
2677 <input name="delButton[' . $i . '][' . $post_id . '][' . $sku . ']" class="delButton" type="submit" value="' . __('Delete','usces') . '" />
2678 </td>
2679 </tr>';
2680 $materials = compact('i', 'cart_row', 'post_id', 'sku', 'sku_code', 'quantity', 'options', 'advance',
2681 'itemCode', 'itemName', 'cartItemName', 'itemRestriction', 'skuPrice', 'skuZaikonum',
2682 'stockid', 'stock', 'red', 'pictid');
2683 $res .= apply_filters( 'usces_filter_cart_row', $row, $cart, $materials);
2684 }
2685
2686 $res = apply_filters( 'usces_filter_cart_rows', $res, $cart);
2687
2688 if($out == 'return'){
2689 return $res;
2690 }else{
2691 echo $res;
2692 }
2693 }
2694 function usces_get_confirm_rows( $out = '' ) {
2695 global $usces, $usces_members, $usces_entries;
2696 // $usces_members = $usces->get_member();
2697 $memid = ( empty($usces_members['ID']) ) ? 999999999 : $usces_members['ID'];
2698 // $usces_entries = $usces->cart->get_entry();
2699 $usces->set_cart_fees( $usces_members, $usces_entries );
2700 $usces_entries = $usces->cart->get_entry();
2701
2702 $cart = $usces->cart->get_cart();
2703 $res = '';
2704 for($i=0; $i<count($cart); $i++) {
2705 $cart_row = $cart[$i];
2706 $post_id = $cart_row['post_id'];
2707 $sku = esc_attr($cart_row['sku']);
2708 $sku_code = esc_attr(urldecode($cart_row['sku']));
2709 $quantity = $cart_row['quantity'];
2710 $options = $cart_row['options'];
2711 $advance = $usces->cart->wc_serialize($cart_row['advance']);
2712 $itemCode = $usces->getItemCode($post_id);
2713 $itemName = $usces->getItemName($post_id);
2714 $cartItemName = $usces->getCartItemName($post_id, $sku_code);
2715 $skuPrice = $cart_row['price'];
2716 $pictid = $usces->get_mainpictid($itemCode);
2717 $args = compact('cart', 'i', 'cart_row', 'post_id', 'sku' );
2718 $row = '';
2719 if (empty($options)) {
2720 $optstr = '';
2721 $options = array();
2722 }
2723
2724 $row .= '<tr>
2725 <td>' . ($i + 1) . '</td>
2726 <td>';
2727 $cart_thumbnail = wp_get_attachment_image( $pictid, array(60, 60), true );
2728 $row .= apply_filters('usces_filter_cart_thumbnail', $cart_thumbnail, $post_id, $pictid, $i, $cart_row);
2729 $row .= '</td><td class="aleft">' . $cartItemName . '<br />';
2730 if( is_array($options) && count($options) > 0 ){
2731 $optstr = '';
2732 foreach($options as $key => $value){
2733 //20110629ysk start 0000190
2734 //if( !empty($key) )
2735 // $row .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
2736 if( !empty($key) ) {
2737 $key = urldecode($key);
2738 if(is_array($value)) {
2739 $c = '';
2740 $optstr .= esc_html($key) . ' : ';
2741 foreach($value as $v) {
2742 $optstr .= $c.nl2br(esc_html(urldecode($v)));
2743 $c = ', ';
2744 }
2745 $optstr .= "<br />\n";
2746 } else {
2747 $optstr .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
2748 }
2749 }
2750 //20110629ysk end
2751 }
2752 $row .= apply_filters( 'usces_filter_option_confirm', $optstr, $options);
2753 }
2754 $row .= apply_filters( 'usces_filter_option_info_confirm', '', $cart_row, $args );
2755 $row .= '</td>
2756 <td class="aright">' . usces_crform($skuPrice, true, false, 'return') . '</td>
2757 <td>' . $cart_row['quantity'] . '</td>
2758 <td class="aright">' . usces_crform(($skuPrice * $cart_row['quantity']), true, false, 'return') . '</td>
2759 <td>';
2760 $res = apply_filters('usces_additional_confirm', $res, array($i, $post_id, $sku_code));
2761 $row .= '</td>
2762 </tr>';
2763
2764 $materials = compact('i', 'cart_row', 'post_id', 'sku', 'sku_code', 'quantity', 'options', 'advance',
2765 'itemCode', 'itemName', 'cartItemName', 'skuPrice', 'pictid');
2766 $res .= apply_filters( 'usces_filter_confirm_row', $row, $cart, $materials);
2767 }
2768
2769 $res = apply_filters( 'usces_filter_confirm_rows', $res, $cart);
2770
2771 if($out == 'return'){
2772 return $res;
2773 }else{
2774 echo $res;
2775 }
2776 }
2777
2778 function uesces_addressform( $type, $data, $out = 'return' ){
2779 global $usces, $usces_settings;
2780 $options = get_option('usces');
2781 $form = $options['system']['addressform'];
2782 $nameform = $usces_settings['nameform'][$form];
2783 $applyform = usces_get_apply_addressform($form);
2784 $formtag = '';
2785 switch( $type ){
2786 case 'confirm':
2787 case 'member':
2788 $values = $data;
2789 break;
2790 case 'customer':
2791 case 'delivery':
2792 $values = $data[$type];
2793 break;
2794 }
2795 $data['type'] = $type;
2796 $values['country'] = !empty($values['country']) ? $values['country'] : usces_get_local_addressform();
2797 $values = $usces->stripslashes_deep_post($values);
2798 if( 'confirm' == $type ){
2799
2800 switch ($applyform){
2801
2802 case 'JP':
2803 $formtag .= usces_custom_field_info($data, 'customer', 'name_pre', 'return');
2804 $formtag .= '<tr><th>'.__('Full name', 'usces').'</th><td>' . esc_html($values['customer']['name1']) . ' ' . esc_html($values['customer']['name2']) . '</td></tr>';
2805 $furigana_customer = '<tr><th>'.__('furigana', 'usces').'</th><td>' . esc_html($values['customer']['name3']) . ' ' . esc_html($values['customer']['name4']) . '</td></tr>';
2806 $formtag .= apply_filters( 'usces_filter_furigana_confirm_customer', $furigana_customer, $type, $values );
2807 $formtag .= usces_custom_field_info($data, 'customer', 'name_after', 'return');
2808 $customer_country = (!empty($usces_settings['country'][$values['customer']['country']])) ? $usces_settings['country'][$values['customer']['country']] : '';
2809 $formtag .= '
2810 <tr><th>'.__('Zip/Postal Code', 'usces').'</th><td>' . esc_html($values['customer']['zipcode']) . '</td></tr>
2811 <tr><th>'.__('Country', 'usces').'</th><td>' . esc_html($customer_country) . '</td></tr>
2812 <tr><th>'.__('Province', 'usces').'</th><td>' . esc_html($values['customer']['pref']) . '</td></tr>
2813 <tr><th>'.__('city', 'usces').'</th><td>' . esc_html($values['customer']['address1']) . '</td></tr>
2814 <tr><th>'.__('numbers', 'usces').'</th><td>' . esc_html($values['customer']['address2']) . '</td></tr>
2815 <tr><th>'.__('building name', 'usces').'</th><td>' . esc_html($values['customer']['address3']) . '</td></tr>
2816 <tr><th>'.__('Phone number', 'usces').'</th><td>' . esc_html($values['customer']['tel']) . '</td></tr>
2817 <tr><th>'.__('FAX number', 'usces').'</th><td>' . esc_html($values['customer']['fax']) . '</td></tr>';
2818 $formtag .= usces_custom_field_info($data, 'customer', 'fax_after', 'return');
2819
2820 $shipping_address_info = '<tr class="ttl"><td colspan="2"><h3>'.__('Shipping address information', 'usces').'</h3></td></tr>';
2821 $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'name_pre', 'return');
2822 $shipping_address_info .= '<tr><th>'.__('Full name', 'usces').'</th><td>' . esc_html($values['delivery']['name1']) . ' ' . esc_html($values['delivery']['name2']) . '</td></tr>';
2823 $furigana_delivery = '<tr><th>'.__('furigana', 'usces').'</th><td>' . esc_html($values['delivery']['name3']) . ' ' . esc_html($values['delivery']['name4']) . '</td></tr>';
2824 $shipping_address_info .= apply_filters( 'usces_filter_furigana_confirm_delivery', $furigana_delivery, $type, $values );
2825 $shipping_address_info .= usces_custom_field_info($values, 'delivery', 'name_after', 'return');
2826 $shipping_country = (!empty($usces_settings['country'][$values['delivery']['country']])) ? $usces_settings['country'][$values['delivery']['country']] : '';
2827 $shipping_address_info .= '
2828 <tr><th>'.__('Zip/Postal Code', 'usces').'</th><td>' . esc_html($values['delivery']['zipcode']) . '</td></tr>
2829 <tr><th>'.__('Country', 'usces').'</th><td>' . esc_html($shipping_country) . '</td></tr>
2830 <tr><th>'.__('Province', 'usces').'</th><td>' . esc_html($values['delivery']['pref']) . '</td></tr>
2831 <tr><th>'.__('city', 'usces').'</th><td>' . esc_html($values['delivery']['address1']) . '</td></tr>
2832 <tr><th>'.__('numbers', 'usces').'</th><td>' . esc_html($values['delivery']['address2']) . '</td></tr>
2833 <tr><th>'.__('building name', 'usces').'</th><td>' . esc_html($values['delivery']['address3']) . '</td></tr>
2834 <tr><th>'.__('Phone number', 'usces').'</th><td>' . esc_html($values['delivery']['tel']) . '</td></tr>
2835 <tr><th>'.__('FAX number', 'usces').'</th><td>' . esc_html($values['delivery']['fax']) . '</td></tr>';
2836 $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'fax_after', 'return');
2837 $formtag .= apply_filters('usces_filter_shipping_address_info', $shipping_address_info);
2838 break;
2839
2840 case 'CN':
2841 $formtag .= usces_custom_field_info($data, 'customer', 'name_pre', 'return');
2842 $formtag .= '<tr><th>'.__('Full name', 'usces').'</th><td>' . esc_html(usces_localized_name( $values['customer']['name1'], $values['customer']['name2'], 'return' )) . '</td></tr>';
2843 $formtag .= usces_custom_field_info($data, 'customer', 'name_after', 'return');
2844 $formtag .= '
2845 <tr><th>'.__('Country', 'usces').'</th><td>' . esc_html($usces_settings['country'][$values['customer']['country']]) . '</td></tr>
2846 <tr><th>'.__('State', 'usces').'</th><td>' . esc_html($values['customer']['pref']) . '</td></tr>
2847 <tr><th>'.__('city', 'usces').'</th><td>' . esc_html($values['customer']['address1']) . '</td></tr>
2848 <tr><th>'.__('Address Line1', 'usces').'</th><td>' . esc_html($values['customer']['address2']) . '</td></tr>
2849 <tr><th>'.__('Address Line2', 'usces').'</th><td>' . esc_html($values['customer']['address3']) . '</td></tr>
2850 <tr><th>'.__('Zip', 'usces').'</th><td>' . esc_html($values['customer']['zipcode']) . '</td></tr>
2851 <tr><th>'.__('Phone number', 'usces').'</th><td>' . esc_html($values['customer']['tel']) . '</td></tr>
2852 <tr><th>'.__('FAX number', 'usces').'</th><td>' . esc_html($values['customer']['fax']) . '</td></tr>';
2853 $formtag .= usces_custom_field_info($data, 'customer', 'fax_after', 'return');
2854
2855 $shipping_address_info = '<tr class="ttl"><td colspan="2"><h3>'.__('Shipping address information', 'usces').'</h3></td></tr>';
2856 $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'name_pre', 'return');
2857 $shipping_address_info .= '<tr><th>'.__('Full name', 'usces').'</th><td>' . esc_html(usces_localized_name( $values['delivery']['name1'], $values['delivery']['name2'], 'return' )) . '</td></tr>';
2858 $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'name_after', 'return');
2859 $shipping_address_info .= '
2860 <tr><th>'.__('Country', 'usces').'</th><td>' . esc_html($usces_settings['country'][$values['delivery']['country']]) . '</td></tr>
2861 <tr><th>'.__('State', 'usces').'</th><td>' . esc_html($values['delivery']['pref']) . '</td></tr>
2862 <tr><th>'.__('city', 'usces').'</th><td>' . esc_html($values['delivery']['address1']) . '</td></tr>
2863 <tr><th>'.__('Address Line1', 'usces').'</th><td>' . esc_html($values['delivery']['address2']) . '</td></tr>
2864 <tr><th>'.__('Address Line2', 'usces').'</th><td>' . esc_html($values['delivery']['address3']) . '</td></tr>
2865 <tr><th>'.__('Zip', 'usces').'</th><td>' . esc_html($values['delivery']['zipcode']) . '</td></tr>
2866 <tr><th>'.__('Phone number', 'usces').'</th><td>' . esc_html($values['delivery']['tel']) . '</td></tr>
2867 <tr><th>'.__('FAX number', 'usces').'</th><td>' . esc_html($values['delivery']['fax']) . '</td></tr>';
2868 $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'fax_after', 'return');
2869 $formtag .= apply_filters('usces_filter_shipping_address_info', $shipping_address_info);
2870 break;
2871
2872 case 'US':
2873 default :
2874 $formtag .= usces_custom_field_info($data, 'customer', 'name_pre', 'return');
2875 $formtag .= '<tr><th>'.__('Full name', 'usces').'</th><td>' . esc_html($values['customer']['name2']) . ' ' . esc_html($values['customer']['name1']) . '</td></tr>';
2876 $formtag .= usces_custom_field_info($data, 'customer', 'name_after', 'return');
2877 $customer_country = (!empty($usces_settings['country'][$values['customer']['country']])) ? $usces_settings['country'][$values['customer']['country']] : '';
2878 $formtag .= '
2879 <tr><th>'.__('Address Line1', 'usces').'</th><td>' . esc_html($values['customer']['address2']) . '</td></tr>
2880 <tr><th>'.__('Address Line2', 'usces').'</th><td>' . esc_html($values['customer']['address3']) . '</td></tr>
2881 <tr><th>'.__('city', 'usces').'</th><td>' . esc_html($values['customer']['address1']) . '</td></tr>
2882 <tr><th>'.__('State', 'usces').'</th><td>' . esc_html($values['customer']['pref']) . '</td></tr>
2883 <tr><th>'.__('Country', 'usces').'</th><td>' . esc_html($customer_country) . '</td></tr>
2884 <tr><th>'.__('Zip', 'usces').'</th><td>' . esc_html($values['customer']['zipcode']) . '</td></tr>
2885 <tr><th>'.__('Phone number', 'usces').'</th><td>' . esc_html($values['customer']['tel']) . '</td></tr>
2886 <tr><th>'.__('FAX number', 'usces').'</th><td>' . esc_html($values['customer']['fax']) . '</td></tr>';
2887 $formtag .= usces_custom_field_info($data, 'customer', 'fax_after', 'return');
2888
2889 $shipping_address_info = '<tr class="ttl"><td colspan="2"><h3>'.__('Shipping address information', 'usces').'</h3></td></tr>';
2890 $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'name_pre', 'return');
2891 $shipping_address_info .= '<tr><th>'.__('Full name', 'usces').'</th><td>' . esc_html($values['delivery']['name2']) . ' ' . esc_html($values['delivery']['name1']) . '</td></tr>';
2892 $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'name_after', 'return');
2893 $shipping_country = (!empty($usces_settings['country'][$values['delivery']['country']])) ? $usces_settings['country'][$values['delivery']['country']] : '';
2894 $shipping_address_info .= '
2895 <tr><th>'.__('Address Line1', 'usces').'</th><td>' . esc_html($values['delivery']['address2']) . '</td></tr>
2896 <tr><th>'.__('Address Line2', 'usces').'</th><td>' . esc_html($values['delivery']['address3']) . '</td></tr>
2897 <tr><th>'.__('city', 'usces').'</th><td>' . esc_html($values['delivery']['address1']) . '</td></tr>
2898 <tr><th>'.__('State', 'usces').'</th><td>' . esc_html($values['delivery']['pref']) . '</td></tr>
2899 <tr><th>'.__('Country', 'usces').'</th><td>' . esc_html($shipping_country) . '</td></tr>
2900 <tr><th>'.__('Zip', 'usces').'</th><td>' . esc_html($values['delivery']['zipcode']) . '</td></tr>
2901 <tr><th>'.__('Phone number', 'usces').'</th><td>' . esc_html($values['delivery']['tel']) . '</td></tr>
2902 <tr><th>'.__('FAX number', 'usces').'</th><td>' . esc_html($values['delivery']['fax']) . '</td></tr>';
2903 $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'fax_after', 'return');
2904 $formtag .= apply_filters('usces_filter_shipping_address_info', $shipping_address_info);
2905 break;
2906
2907 }
2908 $res = apply_filters('usces_filter_apply_addressform_confirm', $formtag, $type, $data);
2909
2910 }else{
2911
2912 switch ($applyform){
2913
2914 case 'JP':
2915 $formtag .= usces_custom_field_input($data, $type, 'name_pre', 'return');
2916 $formtag .= '<tr class="inp1">
2917 <th width="127" scope="row">' . usces_get_essential_mark('name1', $data) . __('Full name', 'usces').'</th>';
2918 if( $nameform ){
2919 $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>';
2920 $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>';
2921 }else{
2922 $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>';
2923 $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>';
2924 }
2925 $formtag .= '</tr>';
2926 $furigana = '<tr class="inp1">
2927 <th scope="row">' . usces_get_essential_mark('name3', $data).__('furigana', 'usces').'</th>';
2928 if( $nameform ){
2929 $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>';
2930 $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>';
2931 }else{
2932 $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>';
2933 $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>';
2934 }
2935 $furigana .= '</tr>';
2936 $formtag .= apply_filters( 'usces_filter_furigana_form', $furigana, $type, $values );
2937 $formtag .= usces_custom_field_input($data, $type, 'name_after', 'return');
2938 $formtag .= '<tr>
2939 <th scope="row">' . usces_get_essential_mark('zipcode', $data).__('Zip/Postal Code', 'usces').'</th>
2940 <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>
2941 </tr>
2942 <tr>
2943 <th scope="row">' . usces_get_essential_mark('country', $data) . __('Country', 'usces') . '</th>
2944 <td colspan="2">' . uesces_get_target_market_form( $type, $values['country'] ) . apply_filters( 'usces_filter_after_country', NULL, $applyform ) . '</td>
2945 </tr>
2946 <tr>
2947 <th scope="row">' . usces_get_essential_mark('states', $data).__('Province', 'usces').'</th>
2948 <td colspan="2">' . usces_pref_select( $type, $values ) . apply_filters( 'usces_filter_after_states', NULL, $applyform ) . '</td>
2949 </tr>
2950 <tr class="inp2">
2951 <th scope="row">' . usces_get_essential_mark('address1', $data).__('city', 'usces').'</th>
2952 <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>
2953 </tr>
2954 <tr>
2955 <th scope="row">' . usces_get_essential_mark('address2', $data).__('numbers', 'usces').'</th>
2956 <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>
2957 </tr>
2958 <tr>
2959 <th scope="row">' . usces_get_essential_mark('address3', $data).__('building name', 'usces').'</th>
2960 <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>
2961 </tr>
2962 <tr>
2963 <th scope="row">' . usces_get_essential_mark('tel', $data).__('Phone number', 'usces').'</th>
2964 <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>
2965 </tr>
2966 <tr>
2967 <th scope="row">' . usces_get_essential_mark('fax', $data).__('FAX number', 'usces').'</th>
2968 <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>
2969 </tr>';
2970 $formtag .= usces_custom_field_input($data, $type, 'fax_after', 'return');
2971 break;
2972
2973 case 'CN':
2974 $formtag .= usces_custom_field_input($data, $type, 'name_pre', 'return');
2975 $formtag .= '<tr class="inp1">
2976 <th scope="row">' . usces_get_essential_mark('name1', $data) . __('Full name', 'usces') . '</th>';
2977 if( $nameform ){
2978 $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>';
2979 $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>';
2980 }else{
2981 $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>';
2982 $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>';
2983 }
2984 $formtag .= '</tr>';
2985 $formtag .= usces_custom_field_input($data, $type, 'name_after', 'return');
2986 $formtag .= '
2987 <tr>
2988 <th scope="row">' . usces_get_essential_mark('country', $data) . __('Country', 'usces') . '</th>
2989 <td colspan="2">' . uesces_get_target_market_form( $type, $values['country'] ) . apply_filters( 'usces_filter_after_country', NULL, $applyform ) . '</td>
2990 </tr>
2991 <tr>
2992 <th scope="row">' . usces_get_essential_mark('states', $data) . __('State', 'usces') . '</th>
2993 <td colspan="2">' . usces_pref_select( $type, $values ) . apply_filters( 'usces_filter_after_states', NULL, $applyform ) . '</td>
2994 </tr>
2995 <tr class="inp2">
2996 <th scope="row">' . usces_get_essential_mark('address1', $data) . __('city', 'usces') . '</th>
2997 <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>
2998 </tr>
2999 <tr>
3000 <th scope="row">' . usces_get_essential_mark('address2', $data) . __('Address Line1', 'usces') . '</th>
3001 <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>
3002 </tr>
3003 <tr>
3004 <th scope="row">' . usces_get_essential_mark('address3', $data) . __('Address Line2', 'usces') . '</th>
3005 <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>
3006 </tr>
3007 <tr>
3008 <th scope="row">' . usces_get_essential_mark('zipcode', $data) . __('Zip', 'usces') . '</th>
3009 <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>
3010 </tr>
3011 <tr>
3012 <th scope="row">' . usces_get_essential_mark('tel', $data) . __('Phone number', 'usces') . '</th>
3013 <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>
3014 </tr>
3015 <tr>
3016 <th scope="row">' . usces_get_essential_mark('fax', $data) . __('FAX number', 'usces') . '</th>
3017 <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>
3018 </tr>';
3019 $formtag .= usces_custom_field_input($data, $type, 'fax_after', 'return');
3020 break;
3021
3022 case 'US':
3023 default :
3024 $formtag .= usces_custom_field_input($data, $type, 'name_pre', 'return');
3025 $formtag .= '<tr class="inp1">
3026 <th scope="row">' . usces_get_essential_mark('name1', $data) . __('Full name', 'usces') . '</th>';
3027 if( $nameform ){
3028 $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>';
3029 $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>';
3030 }else{
3031 $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>';
3032 $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>';
3033 }
3034 $formtag .= '</tr>';
3035 $formtag .= usces_custom_field_input($data, $type, 'name_after', 'return');
3036 $formtag .= '
3037 <tr>
3038 <th scope="row">' . usces_get_essential_mark('address2', $data) . __('Address Line1', 'usces') . '</th>
3039 <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>
3040 </tr>
3041 <tr>
3042 <th scope="row">' . usces_get_essential_mark('address3', $data) . __('Address Line2', 'usces') . '</th>
3043 <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>
3044 </tr>
3045 <tr class="inp2">
3046 <th scope="row">' . usces_get_essential_mark('address1', $data) . __('city', 'usces') . '</th>
3047 <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>
3048 </tr>
3049 <tr>
3050 <th scope="row">' . usces_get_essential_mark('states', $data) . __('State', 'usces') . '</th>
3051 <td colspan="2">' . usces_pref_select( $type, $values ) . apply_filters( 'usces_filter_after_states', NULL, $applyform ) . '</td>
3052 </tr>
3053 <tr>
3054 <th scope="row">' . usces_get_essential_mark('country', $data) . __('Country', 'usces') . '</th>
3055 <td colspan="2">' . uesces_get_target_market_form( $type, $values['country'] ) . apply_filters( 'usces_filter_after_country', NULL, $applyform ) . '</td>
3056 </tr>
3057 <tr>
3058 <th scope="row">' . usces_get_essential_mark('zipcode', $data) . __('Zip', 'usces') . '</th>
3059 <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>
3060 </tr>
3061 <tr>
3062 <th scope="row">' . usces_get_essential_mark('tel', $data) . __('Phone number', 'usces') . '</th>
3063 <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>
3064 </tr>
3065 <tr>
3066 <th scope="row">' . usces_get_essential_mark('fax', $data) . __('FAX number', 'usces') . '</th>
3067 <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>
3068 </tr>';
3069 $formtag .= usces_custom_field_input($data, $type, 'fax_after', 'return');
3070 break;
3071 }
3072 $res = apply_filters('usces_filter_apply_addressform', $formtag, $type, $data);
3073
3074 }
3075
3076 if($out == 'return') {
3077 return $res;
3078 } else {
3079 echo $res;
3080 }
3081 }
3082
3083 function usces_item_option_fileds( $post_id, $sku, $label=1, $out='echo' ){
3084 $options = usces_get_opts($post_id, 'sort');
3085 if( 0 == count($options) )
3086 return false;
3087
3088 $sku_enc = urlencode($sku);
3089 $html ='';
3090 foreach( $options as $opt ){
3091 $name = $opt['name'];
3092 $opt_code = urlencode($name);
3093 $html .= "\n" . '<div class="opt_field" id="opt_' . $post_id . '_' . $sku_enc . '_' . $opt_code . '">';
3094 if( $label ){
3095 $html .= '<label for="itemOption[' . $post_id . '][' . $sku_enc . '][' . $opt_code . ']">' . esc_html($name) . '</label>';
3096 }
3097 $html .= usces_get_itemopt_filed($post_id, $sku, $opt);
3098 $html .= '</div>';
3099 }
3100 if( $out == 'return' ){
3101 return $html;
3102 }else{
3103 echo $html;
3104 }
3105 }
3106
3107 function usces_facebook_like(){
3108 global $post, $usces;
3109 $like = array(
3110 'url' => urlencode(get_permalink($post->ID)),
3111 'send' => 'false',
3112 'layout' => 'button_count', //standard, button_count, box_count
3113 'width' => '450',
3114 'height' => '35',
3115 'show_faces' => 'false',
3116 'action' => 'like', //like, recommend
3117 );
3118 $like = apply_filters( 'usces_filter_facebook_like', $like, $post->ID );
3119 ?>
3120 <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>
3121 <?php
3122 }
3123
3124 function usces_action_confirm_page_point_inform_zeus() {
3125 $html = usces_point_inform_zeus();
3126 echo $html;
3127 }
3128
3129 function usces_filter_confirm_point_inform_zeus( $html ) {
3130 $html .= usces_point_inform_zeus();
3131 return $html;
3132 }
3133
3134 function usces_point_inform_zeus() {
3135 global $usces, $usces_entries;
3136 $html = '';
3137
3138 $payments = usces_get_payments_by_name( $usces_entries['order']['payment_name'] );
3139 $acting_flag = ( 'acting' == $payments['settlement'] ) ? $payments['module'] : $payments['settlement'];
3140
3141 switch( $acting_flag ) {
3142 case 'acting_zeus_card':
3143 $html .= '<input type="hidden" name="cnum1" value="'.$_POST['cnum1'].'">';
3144 if( isset($_POST['securecode']) ) {
3145 $html .= '<input type="hidden" name="securecode" value="'.$_POST['securecode'].'">';
3146 }
3147 $html .= '<input type="hidden" name="expyy" value="'.$_POST['expyy'].'">';
3148 $html .= '<input type="hidden" name="expmm" value="'.$_POST['expmm'].'">';
3149 $html .= '<input type="hidden" name="username" value="'.$_POST['username'].'">';
3150 if( isset($_POST['howpay']) ) {
3151 $html .= '<input type="hidden" name="howpay" value="'.$_POST['howpay'].'">';
3152 }
3153 if( isset($_POST['cbrand']) ) {
3154 $html .= '<input type="hidden" name="cbrand" value="'.$_POST['cbrand'].'">';
3155 $html .= '<input type="hidden" name="div_1" value="'.$_POST['div_1'].'">';
3156 $html .= '<input type="hidden" name="div_2" value="'.$_POST['div_2'].'">';
3157 $html .= '<input type="hidden" name="div_3" value="'.$_POST['div_3'].'">';
3158 }
3159 break;
3160
3161 case 'acting_zeus_conv':
3162 if( isset($_POST['pay_cvs']) ) {
3163 $html = '<input type="hidden" name="pay_cvs" value="'.$_POST['pay_cvs'].'">';
3164 }
3165 break;
3166 }
3167 return $html;
3168 }
3169
3170 function usces_checked( $chk, $key, $out = '' ) {
3171 $checked = ( isset($chk[$key]) and $chk[$key] == 1 ) ? ' checked' : '';
3172 if( $out == 'return' ) {
3173 return $checked;
3174 } else {
3175 echo $checked;
3176 }
3177 }
3178
3179 function usces_get_custom_field_value( $field, $key, $id, $out = '' ) {
3180 global $usces;
3181
3182 $value = '';
3183 switch( $field ) {
3184 case 'order':
3185 $value = $usces->get_order_meta_value( 'csod_'.$key, $id );
3186 break;
3187 case 'customer':
3188 $value = $usces->get_order_meta_value( 'cscs_'.$key, $id );
3189 break;
3190 case 'delivery':
3191 $value = $usces->get_order_meta_value( 'csde_'.$key, $id );
3192 break;
3193 case 'member':
3194 $value = $usces->get_member_meta_value( 'csmb_'.$key, $id );
3195 break;
3196 }
3197
3198 if( $out == 'return' ) {
3199 return $value;
3200 } else {
3201 echo $value;
3202 }
3203 }
3204
3205 ?>