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

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