PluginProbe
Welcart e-Commerce / 2.12.4
Welcart e-Commerce v2.12.4
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
← All changes | functions/template_func.php +5367 -3192 1.3.92.12.4 View file →
@@ -1,3193 +1,5368 @@
1 -<?php
2 -function usces_guid_tax( $out = '' ){
3 - global $usces;
4 -
5 - if( $out == 'return' ){
6 - return $usces->getGuidTax();
7 - }else{
8 - echo $usces->getGuidTax();
9 - }
10 -}
11 -
12 -function usces_currency_symbol( $out = '' ) {
13 - global $usces;
14 -
15 - if( $out == 'return' ){
16 - return $usces->getCurrencySymbol();
17 - }else{
18 - echo esc_html($usces->getCurrencySymbol());
19 - }
20 -}
21 -
22 -function usces_is_error_message() {
23 - global $usces;
24 - if ( $usces->error_message != '' )
25 - return true;
26 - else
27 - return false;
28 -}
29 -
30 -function usces_is_item( $post_id = NULL ) {
31 - if( NULL == $post_id ){
32 - global $post;
33 - }else{
34 - $post = get_post($post_id);
35 - }
36 - if ( isset($post->post_mime_type) && $post->post_mime_type == 'item' )
37 - return true;
38 - else
39 - return false;
40 -}
41 -
42 -function usces_the_itemCode( $out = '' ) {
43 - global $post;
44 - $post_id = $post->ID;
45 -
46 - $str = get_post_meta($post_id, '_itemCode', true);
47 -
48 - if( $out == 'return' ){
49 - return $str;
50 - }else{
51 - echo esc_html($str);
52 - }
53 -}
54 -
55 -function usces_the_itemName( $out = '', $post = NULL ) {
56 - if($post == NULL)
57 - global $post;
58 -
59 - $post_id = $post->ID;
60 -
61 - $str = get_post_meta($post_id, '_itemName', true);
62 -
63 - if( $out == 'return' ){
64 - return $str;
65 - }else{
66 - echo esc_html($str);
67 - }
68 -}
69 -
70 -function usces_the_point_rate( $out = '' ){
71 - global $post;
72 - $post_id = $post->ID;
73 -
74 - $str = get_post_meta($post_id, '_itemPointrate', true);
75 - $rate = (int)$str;
76 -
77 - if( $out == 'return' ){
78 - return $rate;
79 - }else{
80 - echo esc_html($rate);
81 - }
82 -}
83 -
84 -function usces_the_shipment_aim( $out = '' ){
85 - global $post;
86 - $post_id = $post->ID;
87 -
88 - $str = get_post_meta($post_id, '_itemShipping', true);
89 - $no = (int)$str;
90 - if( 0 === $no ) return;
91 -
92 - $rules = get_option('usces_shipping_rule');
93 -
94 - if( $out == 'return' ){
95 - return $rules[$no];
96 - }else{
97 - echo esc_html($rules[$no]);
98 - }
99 -}
100 -
101 -function usces_the_item(){
102 - global $usces, $post;
103 -
104 - $usces->itemskus = $usces->get_skus($post->ID, 'sort');
105 - $usces->itemopts = usces_get_opts($post->ID, 'sort');
106 -
107 - return;
108 -}
109 -
110 -function usces_get_itemMeta($metakey, $post_id, $out = ''){
111 - $str = get_post_meta($post_id, $metakey, true);
112 - $value = $str;
113 -
114 - if( $out == 'return' ){
115 - return $value;
116 - }else{
117 - echo esc_html($value);
118 - }
119 -}
120 -
121 -function usces_sku_num() {
122 - global $usces;
123 -
124 - return count($usces->itemskus);
125 -}
126 -
127 -function usces_is_skus() {
128 - global $usces;
129 -
130 - if( 0 < count($usces->itemskus) ){
131 - reset($usces->itemskus);
132 - $usces->itemsku = array();
133 - return true;
134 - }else{
135 - return false;
136 - }
137 -}
138 -
139 -function usces_have_skus() {
140 - global $usces;
141 -
142 - $res_each = each($usces->itemskus);
143 - $usces->itemsku = $res_each['value'];
144 - if($usces->itemsku) {
145 - return true;
146 - } else {
147 - return false;
148 - }
149 -}
150 -
151 -function usces_the_itemSku($out = '') {
152 - global $usces;
153 -
154 - if($out == 'return'){
155 - return $usces->itemsku['code'];
156 - }else{
157 - echo esc_attr($usces->itemsku['code']);
158 - }
159 -}
160 -
161 -function usces_the_itemPrice($out = '') {
162 - global $usces;
163 - if($out == 'return'){
164 - return $usces->itemsku['price'];
165 - }else{
166 - echo number_format($usces->itemsku['price']);
167 - }
168 -}
169 -
170 -function usces_the_itemCprice($out = '') {
171 - global $usces;
172 - if($out == 'return'){
173 - return $usces->itemsku['cprice'];
174 - }else{
175 - echo number_format($usces->itemsku['cprice']);
176 - }
177 -}
178 -
179 -function usces_the_itemPriceCr($out = '') {
180 - global $usces;
181 - $res = esc_html($usces->get_currency($usces->itemsku['price'], true, false ));
182 -
183 - if($out == 'return'){
184 - return $res;
185 - }else{
186 - echo $res;
187 - }
188 -}
189 -
190 -function usces_the_itemCpriceCr($out = '') {
191 - global $usces;
192 - $res = esc_html($usces->get_currency($usces->itemsku['cprice'], true, false ));
193 -
194 - if($out == 'return'){
195 - return $res;
196 - }else{
197 - echo $res;
198 - }
199 -}
200 -
201 -function usces_crcode( $out = '' ) {
202 - global $usces;
203 - $res = esc_html($usces->get_currency_code());
204 -
205 - if($out == 'return'){
206 - return $res;
207 - }else{
208 - echo __($res, 'usces');
209 - }
210 -}
211 -
212 -function usces_crsymbol( $out = '', $js = NULL ) {
213 - global $usces;
214 - $res = $usces->getCurrencySymbol();
215 - if( 'js' === $js && '&yen;' == $res ){
216 - $res = mb_convert_encoding($res, 'UTF-8', 'HTML-ENTITIES');
217 - }
218 -
219 - if($out == 'return'){
220 - return $res;
221 - }else{
222 - echo esc_html($res);
223 - }
224 -}
225 -
226 -function usces_the_itemZaiko( $out = '' ) {
227 - global $usces;
228 - $num = (int)$usces->itemsku['stock'];
229 -
230 - if( 1 < $num || ( 0 === (int)$usces->itemsku['stocknum'] && !WCUtils::is_blank($usces->itemsku['stocknum']) ) ){
231 - $res = $usces->zaiko_status[$num];
232 - }elseif( 1 >= $num && ( 0 === (int)$usces->itemsku['stocknum'] && !WCUtils::is_blank($usces->itemsku['stocknum']) ) ){
233 - $res = $usces->zaiko_status[2];
234 - }else{
235 - $res = $usces->zaiko_status[$num];
236 - }
237 -
238 - if( $out == 'return' ){
239 - return $res;
240 - }else{
241 - echo esc_html($res);
242 - }
243 -}
244 -
245 -function usces_the_itemZaikoStatus( $out = '' ) {
246 - global $usces;
247 -
248 - if( $out == 'return' ){
249 - return usces_get_itemZaiko( 'name' );
250 - }else{
251 - echo esc_html(usces_get_itemZaiko( 'name' ));
252 - }
253 -}
254 -
255 -function usces_get_itemZaiko( $field = 'name', $post_id=NULL, $sku=NULL ) {
256 - global $usces;
257 - if( empty($sku) ){
258 - $num = (int)$usces->itemsku['stock'];
259 - }else{
260 - $skus = $usces->get_skus( $post_id, 'code' );
261 - $num = (int)$skus[$sku]['stock'];
262 - }
263 -
264 - if( 'id' == $field ){
265 - $res = $num;
266 - }else{
267 - $res = $usces->zaiko_status[$num];
268 - }
269 - return $res;
270 -}
271 -
272 -function usces_the_itemZaikoNum( $out = '' ) {
273 - global $usces;
274 - $num = $usces->itemsku['stocknum'];
275 -
276 - if( $out == 'return' ){
277 - return $num;
278 - }else{
279 - echo number_format($num);
280 - }
281 -}
282 -
283 -function usces_the_itemSkuDisp( $out = '' ) {
284 - global $usces;
285 -
286 - if( $out == 'return' ){
287 - return $usces->itemsku['name'];
288 - }else{
289 - echo esc_html($usces->itemsku['name']);
290 - }
291 -}
292 -
293 -function usces_the_itemSkuUnit( $out = '' ) {
294 - global $usces;
295 -
296 - if( $out == 'return' ){
297 - return $usces->itemsku['unit'];
298 - }else{
299 - echo esc_html($usces->itemsku['unit']);
300 - }
301 -}
302 -
303 -function usces_the_firstSku( $out = '' ) {
304 - global $post, $usces;
305 - $post_id = $post->ID;
306 -
307 -
308 - $skus = $usces->get_skus( $post_id );
309 -
310 -
311 - if($out == 'return'){
312 - return $skus[0]['code'];
313 - }else{
314 - echo esc_html($skus[0]['code']);
315 - }
316 -}
317 -
318 -function usces_the_firstPrice( $out = '', $post = NULL ) {
319 - global $usces;
320 - if($post == NULL)
321 - global $post;
322 - $post_id = $post->ID;
323 -
324 - $skus = $usces->get_skus( $post_id );
325 -
326 - if($out == 'return'){
327 - return $skus[0]['price'];
328 - }else{
329 - echo number_format($skus[0]['price']);
330 - }
331 -}
332 -
333 -function usces_the_firstCprice( $out = '', $post = NULL ) {
334 - global $usces;
335 - if($post == NULL)
336 - global $post;
337 - $post_id = $post->ID;
338 -
339 - $skus = $usces->get_skus( $post_id );
340 -
341 - if($out == 'return'){
342 - return $skus[0]['cprice'];
343 - }else{
344 - echo number_format($skus[0]['cprice']);
345 - }
346 -}
347 -
348 -function usces_the_firstPriceCr( $out = '', $post = NULL ) {
349 - global $usces;
350 - if($post == NULL)
351 - global $post;
352 - $post_id = $post->ID;
353 -
354 - $skus = $usces->get_skus( $post_id );
355 - $res = esc_html($usces->get_currency($skus[0]['price'], true, false ));
356 -
357 - if($out == 'return'){
358 - return $res;
359 - }else{
360 - echo $res;
361 - }
362 -}
363 -
364 -function usces_the_firstCpriceCr( $out = '', $post = NULL ) {
365 - global $usces;
366 - if($post == NULL)
367 - global $post;
368 - $post_id = $post->ID;
369 -
370 - $skus = $usces->get_skus( $post_id );
371 - $res = esc_html($usces->get_currency($skus[0]['cprice'], true, false ));
372 -
373 - if($out == 'return'){
374 - return $res;
375 - }else{
376 - echo $res;
377 - }
378 -}
379 -
380 -function usces_the_firstZaiko( $out = '' ) {
381 - global $post, $usces;
382 - $post_id = $post->ID;
383 -
384 -
385 - $skus = $usces->get_skus( $post_id );
386 -
387 - if($out == 'return'){
388 - return $skus[0]['stock'];
389 - }else{
390 - echo esc_html($skus[0]['stock']);
391 - }
392 -}
393 -
394 -function usces_the_lastSku( $out = '' ) {
395 - global $post, $usces;
396 - $post_id = $post->ID;
397 -
398 -
399 - $skus = $usces->get_skus( $post_id );
400 - $sku = end($skus);
401 -
402 - if($out == 'return'){
403 - return $sku['code'];
404 - }else{
405 - echo esc_html($sku['code']);
406 - }
407 -}
408 -
409 -function usces_the_lastPrice( $out = '' ) {
410 - global $post, $usces;
411 - $post_id = $post->ID;
412 -
413 -
414 - $skus = $usces->get_skus( $post_id );
415 - $sku = end($skus);
416 -
417 - if($out == 'return'){
418 - return $sku['price'];
419 - }else{
420 - echo number_format($sku['price']);
421 - }
422 -}
423 -
424 -function usces_the_lastZaiko( $out = '' ) {
425 - global $post, $usces;
426 - $post_id = $post->ID;
427 -
428 -
429 - $skus = $usces->get_skus( $post_id );
430 - $sku = end($skus);
431 -
432 - if($out == 'return'){
433 - return $sku['stock'];
434 - }else{
435 - echo esc_html($sku['stock']);
436 - }
437 -}
438 -
439 -function usces_have_zaiko(){
440 - global $post, $usces;
441 - return $usces->is_item_zaiko( $post->ID, $usces->itemsku['code'] );
442 -}
443 -
444 -function usces_have_zaiko_anyone( $post_id = NULL ){
445 - global $post, $usces;
446 - if( NULL == $post_id ) $post_id = $post->ID;
447 -
448 - $skus = $usces->get_skus($post_id);
449 - $status = false;
450 - foreach($skus as $sku){
451 - if( (WCUtils::is_blank($sku['stocknum']) || 0 < (int)$sku['stocknum']) && 2 > (int)$sku['stock']) {
452 - $status = true;
453 - break;
454 - }
455 - }
456 - return $status;
457 -}
458 -
459 -function usces_is_gptekiyo( $post_id, $sku, $quant ){
460 - global $usces;
461 - return $usces->is_gptekiyo( $post_id, $sku, $quant );
462 -}
463 -function usces_the_itemGpExp( $out = '' ) {
464 - global $post, $usces;
465 - $post_id = $post->ID;
466 - $sku = $usces->itemsku['code'];
467 - $GpN1 = $usces->getItemGpNum1($post_id);
468 - $GpN2 = $usces->getItemGpNum2($post_id);
469 - $GpN3 = $usces->getItemGpNum3($post_id);
470 - $GpD1 = $usces->getItemGpDis1($post_id);
471 - $GpD2 = $usces->getItemGpDis2($post_id);
472 - $GpD3 = $usces->getItemGpDis3($post_id);
473 - $unit = $usces->getItemSkuUnit($post_id, $sku);
474 - $price = $usces->getItemPrice($post_id, $sku);
475 -
476 - if( ($usces->itemsku['gp'] == 0) || empty($GpN1) || empty($GpD1) ){
477 - return;
478 - }
479 - $html = "<dl class='itemGpExp'>\n<dt>" . apply_filters( 'usces_filter_itemGpExp_title', __('Business package discount','usces')) . "</dt>\n<dd>\n<ul>\n";
480 - if(!empty($GpN1) && !empty($GpD1)) {
481 - if(empty($GpN2) || empty($GpD2)) {
482 - $html .= "<li>";
483 - $html .= sprintf( __('<span class=%6$s>%5$s%1$s</span>%2$s par 1%3$s for more than %4$s%3$s', 'usces'),
484 - number_format(round($price * (100 - $GpD1) / 100)),
485 - $usces->getGuidTax(),
486 - esc_html($unit),
487 - $GpN1,
488 - __('$', 'usces'),
489 - "'price'"
490 - );
491 - $html .= "</li>\n";
492 - } else {
493 -
494 - $html .= "<li>";
495 - $html .= sprintf( __('<span class=%7$s>%6$s%1$s</span>%2$s par 1%3$s for %4$s-%5$s%3$s', 'usces'),
496 - number_format(round($price * (100 - $GpD1) / 100)),
497 - $usces->getGuidTax(),
498 - esc_html($unit),
499 - $GpN1,
500 - $GpN2-1,
501 - __('$', 'usces'),
502 - "'price'"
503 - );
504 - $html .= "</li>\n";
505 - if(empty($GpN3) || empty($GpD3)) {
506 - //$html .= "<li>" . $GpN2 . $unit . __('for more than ','usces') . "1" . $unit . __('par','usces') . "<span class='price'>" . __('$', 'usces') . number_format(round($price * (100 - $GpD2) / 100)) . $usces->getGuidTax() . "</span></li>\n";
507 - $html .= "<li>";
508 - $html .= sprintf( __('<span class=%6$s>%5$s%1$s</span>%2$s par 1%3$s for more than %4$s%3$s', 'usces'),
509 - number_format(round($price * (100 - $GpD2) / 100)),
510 - $usces->getGuidTax(),
511 - esc_html($unit),
512 - $GpN2,
513 - __('$', 'usces'),
514 - "'price'"
515 - );
516 - $html .= "</li>\n";
517 - } else {
518 - $html .= "<li>";
519 - $html .= sprintf( __('<span class=%7$s>%6$s%1$s</span>%2$s par 1%3$s for %4$s-%5$s%3$s', 'usces'),
520 - number_format(round($price * (100 - $GpD2) / 100)),
521 - $usces->getGuidTax(),
522 - esc_html($unit),
523 - $GpN2,
524 - $GpN3-1,
525 - __('$', 'usces'),
526 - "'price'"
527 - );
528 - $html .= "</li>\n";
529 - $html .= "<li>";
530 - $html .= sprintf( __('<span class=%6$s>%5$s%1$s</span>%2$s par 1%3$s for more than %4$s%3$s', 'usces'),
531 - number_format(round($price * (100 - $GpD3) / 100)),
532 - $usces->getGuidTax(),
533 - esc_html($unit),
534 - $GpN3,
535 - __('$', 'usces'),
536 - "'price'"
537 - );
538 - $html .= "</li>\n";
539 - }
540 - }
541 - }
542 - $html .= "</ul></dd></dl>";
543 -
544 - $html = apply_filters('usces_filter_itemGpExp', $html);
545 -
546 - if( $out == 'return' ){
547 - return $html;
548 - }else{
549 - echo $html;
550 - }
551 -}
552 -
553 -function usces_the_itemQuant( $out = '' ) {
554 - global $usces, $post;
555 - $post_id = $post->ID;
556 - $sku = esc_attr(urlencode($usces->itemsku['code']));
557 - $value = isset( $_SESSION['usces_singleitem']['quant'][$post_id][$sku] ) ? $_SESSION['usces_singleitem']['quant'][$post_id][$sku] : 1;
558 - $quant = "<input name=\"quant[{$post_id}][" . $sku . "]\" type=\"text\" id=\"quant[{$post_id}][" . $sku . "]\" class=\"skuquantity\" value=\"" . $value . "\" onKeyDown=\"if (event.keyCode == 13) {return false;}\" />";
559 - $html = apply_filters('usces_filter_the_itemQuant', $quant, $post);
560 -
561 - if( $out == 'return' ){
562 - return $html;
563 - }else{
564 - echo $html;
565 - }
566 -}
567 -
568 -function usces_the_itemSkuButton($value, $type=0, $out = '') {
569 - global $usces, $post;
570 - $post_id = $post->ID;
571 - $zaikonum = $usces->itemsku['stocknum'];
572 - $zaiko_status = $usces->itemsku['stock'];
573 - $gptekiyo = $usces->itemsku['gp'];
574 - $skuPrice = $usces->getItemPrice($post_id, $usces->itemsku['code']);
575 - $value = esc_attr(apply_filters( 'usces_filter_incart_button_label', $value));
576 - $sku = esc_attr(urlencode($usces->itemsku['code']));
577 -
578 - if($type == 1)
579 - $type = 'button';
580 - else
581 - $type = 'submit';
582 -
583 - $html = "<input name=\"zaikonum[{$post_id}][{$sku}]\" type=\"hidden\" id=\"zaikonum[{$post_id}][{$sku}]\" value=\"{$zaikonum}\" />\n";
584 - $html .= "<input name=\"zaiko[{$post_id}][{$sku}]\" type=\"hidden\" id=\"zaiko[{$post_id}][{$sku}]\" value=\"{$zaiko_status}\" />\n";
585 - $html .= "<input name=\"gptekiyo[{$post_id}][{$sku}]\" type=\"hidden\" id=\"gptekiyo[{$post_id}][{$sku}]\" value=\"{$gptekiyo}\" />\n";
586 - $html .= "<input name=\"skuPrice[{$post_id}][{$sku}]\" type=\"hidden\" id=\"skuPrice[{$post_id}][{$sku}]\" value=\"{$skuPrice}\" />\n";
587 - if( $usces->use_js ){
588 - $html .= "<input name=\"inCart[{$post_id}][{$sku}]\" type=\"{$type}\" id=\"inCart[{$post_id}][{$sku}]\" class=\"skubutton\" value=\"{$value}\" onclick=\"return uscesCart.intoCart('{$post_id}','{$sku}')\" />";
589 - }else{
590 - $html .= "<a name=\"cart_button\"></a><input name=\"inCart[{$post_id}][{$sku}]\" type=\"{$type}\" id=\"inCart[{$post_id}][{$sku}]\" class=\"skubutton\" value=\"{$value}\" />";
591 - }
592 - $html .= "<input name=\"usces_referer\" type=\"hidden\" value=\"" . $_SERVER['REQUEST_URI'] . "\" />\n";
593 -
594 - if( $out == 'return' ){
595 - return $html;
596 - }else{
597 - echo $html;
598 - }
599 -}
600 -
601 -function usces_direct_intoCart($post_id, $sku, $force=false, $value=NULL, $options=NULL, $out = '') {
602 - global $usces;
603 - if( empty($value) )
604 - $value = __('Add To Cart', 'usces');
605 - $skus = $usces->get_skus( $post_id, 'code' );
606 - $zaikonum = $skus[$sku]['stocknum'];
607 - $zaiko = $skus[$sku]['stock'];
608 - $gptekiyo = $skus[$sku]['gp'];
609 - $skuPrice = $skus[$sku]['price'];
610 - $enc_sku = urlencode($sku);
611 -
612 - $html = "<form action=\"" . USCES_CART_URL . "\" method=\"post\" name=\"" . $post_id."-". $enc_sku . "\">\n";
613 - $html .= "<input name=\"zaikonum[{$post_id}][{$enc_sku}]\" type=\"hidden\" id=\"zaikonum[{$post_id}][{$enc_sku}]\" value=\"{$zaikonum}\" />\n";
614 - $html .= "<input name=\"zaiko[{$post_id}][{$enc_sku}]\" type=\"hidden\" id=\"zaiko[{$post_id}][{$enc_sku}]\" value=\"{$zaiko}\" />\n";
615 - $html .= "<input name=\"gptekiyo[{$post_id}][{$enc_sku}]\" type=\"hidden\" id=\"gptekiyo[{$post_id}][{$enc_sku}]\" value=\"{$gptekiyo}\" />\n";
616 - $html .= "<input name=\"skuPrice[{$post_id}][{$enc_sku}]\" type=\"hidden\" id=\"skuPrice[{$post_id}][{$enc_sku}]\" value=\"{$skuPrice}\" />\n";
617 - $html .= "<a name=\"cart_button\"></a><input name=\"inCart[{$post_id}][{$enc_sku}]\" type=\"submit\" id=\"inCart[{$post_id}][{$enc_sku}]\" class=\"skubutton\" value=\"{$value}\" " . apply_filters('usces_filter_direct_intocart_button', NULL, $post_id, $sku, $force, $options) . " />";
618 - $html .= "<input name=\"usces_referer\" type=\"hidden\" value=\"" . $_SERVER['REQUEST_URI'] . "\" />\n";
619 - if( $force )
620 - $html .= "<input name=\"usces_force\" type=\"hidden\" value=\"incart\" />\n";
621 - $html = apply_filters('usces_filter_single_item_inform', $html);
622 - $html .= "</form>";
623 - $html .= '<div class="direct_error_message">' . usces_singleitem_error_message($post_id, $sku, 'return') . '</div>'."\n";
624 -
625 - if( $out == 'return' ){
626 - return $html;
627 - }else{
628 - echo $html;
629 - }
630 -}
631 -
632 -
633 -function usces_the_itemImage($number = 0, $width = 60, $height = 60, $post = '', $out = '', $media = 'item' ) {
634 - global $usces;
635 - $ptitle = $number;
636 - if($post == '') global $post;
637 -
638 - $post_id = $post->ID;
639 -
640 - if( $ptitle && 0 == (int)$number ){
641 -
642 - $picposts = query_posts(array('post_type'=>'attachment','name'=>$ptitle));
643 - $pictid = empty($picposts) ? 0 : $picposts[0]->ID;
644 - $html = wp_get_attachment_image( $pictid, array($width, $height), false );
645 - if( 'item' == $media ){
646 - $alt = 'alt="'.esc_attr($code[0]).'"';
647 - $alt = apply_filters('usces_filter_img_alt', $alt, $post_id, $pictid);
648 - $html = preg_replace('/alt=\"[^\"]*\"/', $alt, $html);
649 - $title = 'title="'.esc_attr($name[0]).'"';
650 - $title = apply_filters('usces_filter_img_title', $title, $post_id, $pictid);
651 - $html = preg_replace('/title=\"[^\"]+\"/', $title, $html);
652 - $html = apply_filters( 'usces_filter_main_img', $html, $post_id, $pictid);
653 - }
654 -
655 - }else{
656 -
657 -
658 - $code = get_post_meta($post_id, '_itemCode', true);
659 - if(!$code) return false;
660 -
661 - $name = get_post_meta($post_id, '_itemName', true);
662 -
663 - if( 0 == $number ){
664 - $pictid = (int)$usces->get_mainpictid($code);
665 - $html = wp_get_attachment_image( $pictid, array($width, $height), true );//'<img src="#" height="60" width="60" alt="" />';
666 - if( 'item' == $media ){
667 - $alt = 'alt="'.esc_attr($code).'"';
668 - $alt = apply_filters('usces_filter_img_alt', $alt, $post_id, $pictid);
669 - $html = preg_replace('/alt=\"[^\"]*\"/', $alt, $html);
670 - $title = 'title="'.esc_attr($name).'"';
671 - $title = apply_filters('usces_filter_img_title', $title, $post_id, $pictid);
672 - $html = preg_replace('/title=\"[^\"]+\"/', $title, $html);
673 - $html = apply_filters( 'usces_filter_main_img', $html, $post_id, $pictid);
674 - }
675 - }else{
676 - $pictids = $usces->get_pictids($code);
677 - $ind = $number - 1;
678 - $pictid = ( isset($pictids[$ind]) && (int)$pictids[$ind] ) ? $pictids[$ind] : 0;
679 - $html = wp_get_attachment_image( $pictid, array($width, $height), false );//'<img src="#" height="60" width="60" alt="" />';
680 - if( 'item' == $media ){
681 - $alt = 'alt="'.esc_attr($code).'"';
682 - $alt = apply_filters('usces_filter_img_alt', $alt, $post_id, $pictid);
683 - $html = preg_replace('/alt=\"[^\"]*\"/', $alt, $html);
684 - $title = 'title="'.esc_attr($name).'"';
685 - $title = apply_filters('usces_filter_img_title', $title, $post_id, $pictid);
686 - $html = preg_replace('/title=\"[^\"]+\"/', $title, $html);
687 - $html = apply_filters( 'usces_filter_sub_img', $html, $post_id, $pictid);
688 - }
689 - }
690 - }
691 -
692 - if($out == 'return'){
693 - return $html;
694 - }else{
695 - echo $html;
696 - }
697 -}
698 -
699 -function usces_the_itemImageURL($number = 0, $out = '', $post = '' ) {
700 - global $usces;
701 - $ptitle = $number;
702 -
703 - if( $ptitle && is_string($number) ){
704 - $picposts = query_posts(array('post_type'=>'attachment','name'=>$ptitle));
705 - $pictid = empty($picposts) ? 0 : $picposts[0]->ID;
706 - $pictid = $picposts[0]->ID;
707 - $html = wp_get_attachment_url( $pictid );
708 - }else{
709 -
710 - if($post == '') global $post;
711 - $post_id = $post->ID;
712 -
713 - $code = get_post_meta($post_id, '_itemCode', true);
714 - if(!$code) return false;
715 - $name = get_post_meta($post_id, '_itemName', true);
716 - if( 0 == $number ){
717 - $pictid = (int)$usces->get_mainpictid($code);
718 - $html = wp_get_attachment_url( $pictid );
719 - }else{
720 - $pictids = $usces->get_pictids($code);
721 - $ind = $number - 1;
722 - $pictid = ( isset($pictids[$ind]) && (int)$pictids[$ind] ) ? $pictids[$ind] : 0;
723 - $html = wp_get_attachment_url( $pictid );
724 - }
725 - }
726 -
727 - if($out == 'return'){
728 - return $html;
729 - }else{
730 - echo $html;
731 - }
732 -}
733 -
734 -function usces_the_itemImageCaption($number = 0, $post = '', $out = '' ) {
735 - global $usces;
736 - $ptitle = $number;
737 -
738 - if( $ptitle && 0 == (int)$number ){
739 -
740 - $picposts = query_posts(array('post_type'=>'attachment','name'=>$ptitle));
741 - $excerpt = empty($picposts) ? '' : $picposts[0]->post_excerpt;
742 -
743 - }else{
744 -
745 - if($post == '') global $post;
746 -
747 - $post_id = $post->ID;
748 -
749 - $code = get_post_meta($post_id, '_itemCode', true);
750 - if(!$code) return false;
751 -
752 - $name = get_post_meta($post_id, '_itemName', true);
753 -
754 - if( 0 == $number ){
755 - $pictid = $usces->get_mainpictid($code);
756 - $attach_ob = get_post($pictid);
757 - }else{
758 - $pictids = $usces->get_pictids($code);
759 - $ind = $number - 1;
760 - $attach_ob = get_post($pictids[$ind]);
761 - }
762 - $excerpt = $attach_ob->post_excerpt;
763 - }
764 -
765 - if($out == 'return'){
766 - return $excerpt;
767 - }else{
768 - echo esc_html($excerpt);
769 - }
770 -}
771 -
772 -function usces_the_itemImageDescription($number = 0, $post = '', $out = '' ) {
773 - global $usces;
774 - $ptitle = $number;
775 -
776 - if( $ptitle && 0 == (int)$number ){
777 -
778 - $picposts = query_posts(array('post_type'=>'attachment','name'=>$ptitle));
779 - $excerpt = empty($picposts) ? '' : $picposts[0]->post_content;
780 -
781 - }else{
782 -
783 - if($post == '') global $post;
784 -
785 - $post_id = $post->ID;
786 -
787 - $code = get_post_meta($post_id, '_itemCode', true);
788 - if(!$code) return false;
789 -
790 - $name = get_post_meta($post_id, '_itemName', true);
791 -
792 - if( 0 == $number ){
793 - $pictid = $usces->get_mainpictid($code);
794 - $attach_ob = get_post($pictid);
795 - }else{
796 - $pictids = $usces->get_pictids($code);
797 - $ind = $number - 1;
798 - $attach_ob = get_post($pictids[$ind]);
799 - }
800 - $excerpt = $attach_ob->post_content;
801 - }
802 -
803 - if($out == 'return'){
804 - return $excerpt;
805 - }else{
806 - echo esc_html($excerpt);
807 - }
808 -}
809 -
810 -function usces_get_itemSubImageNums() {
811 - global $post, $usces;
812 - $post_id = $post->ID;
813 - $res = array();
814 -
815 - $code = get_post_meta($post_id, '_itemCode', true);
816 - if(!$code) return false;
817 - $name = get_post_meta($post_id, '_itemName', true);
818 - $pictids = $usces->get_pictids($code);
819 - for($i=1; $i<=count($pictids); $i++){
820 - $res[] = $i;
821 - }
822 - return $res;
823 -}
824 -
825 -function usces_is_options() {
826 - global $usces;
827 -
828 - if( 0 < count($usces->itemopts) ){
829 - reset($usces->itemopts);
830 - $usces->itemopt = array();
831 - return true;
832 - }else{
833 - return false;
834 - }
835 -}
836 -
837 -function usces_have_options() {
838 - global $usces;
839 -
840 - $res_each = each($usces->itemopts);
841 - $usces->itemopt = $res_each['value'];
842 - if($usces->itemopt) {
843 - return true;
844 - } else {
845 - return false;
846 - }
847 -}
848 -
849 -function usces_getItemOptName() {
850 - global $usces;
851 - return $usces->itemopt['name'];
852 -}
853 -
854 -function usces_the_itemOptName($out = '') {
855 - global $usces;
856 -
857 - if($out == 'return'){
858 - return $usces->itemopt['name'];
859 - }else{
860 - echo esc_html($usces->itemopt['name']);
861 - }
862 -}
863 -
864 -function usces_the_itemOption( $name, $label = '#default#', $out = '' ) {
865 - global $post, $usces;
866 - $post_id = $post->ID;
867 -
868 - if($label == '#default#')
869 - $label = $name;
870 -
871 - $opts = usces_get_opts($post_id, 'name');
872 - if(!$opts)
873 - return false;
874 -
875 - $opt = $opts[$name];
876 - $means = (int)$opt['means'];
877 - $essential = (int)$opt['essential'];
878 -
879 - $html = '';
880 - $sku = esc_attr(urlencode($usces->itemsku['code']));
881 - $optcode = esc_attr(urlencode($name));
882 - $name = esc_attr($name);
883 - $label = esc_attr($label);
884 - $session_value = isset( $_SESSION['usces_singleitem']['itemOption'][$post_id][$sku][$optcode] ) ? $_SESSION['usces_singleitem']['itemOption'][$post_id][$sku][$optcode] : NULL;
885 -//20110715ysk start 0000208
886 - $html .= "\n<label for='itemOption[{$post_id}][{$sku}][{$optcode}]' class='iopt_label'>{$label}</label>\n";
887 -//20110715ysk end
888 -//20100914ysk start
889 - //if($means < 2){
890 - switch($means) {
891 - case 0://Single-select
892 - case 1://Multi-select
893 -//20100914ysk end
894 - $selects = explode("\n", $opt['value']);
895 - $multiple = ($means === 0) ? '' : ' multiple';
896 - $multiple_array = ($means == 0) ? '' : '[]';//20110629ysk 0000190
897 - //$html .= "\n<label for='itemOption[{$post_id}][{$sku}][{$name}]' class='iopt_label'>{$label}</label>\n";
898 -//20110629ysk start 0000190
899 - //$html .= "\n<select name='itemOption[{$post_id}][{$sku}][{$name}]' id='itemOption[{$post_id}][{$sku}][{$name}]' class='iopt_select'{$multiple} onKeyDown=\"if (event.keyCode == 13) {return false;}\">\n";
900 - $html .= "\n<select name='itemOption[{$post_id}][{$sku}][{$optcode}]{$multiple_array}' id='itemOption[{$post_id}][{$sku}][{$optcode}]' class='iopt_select'{$multiple} onKeyDown=\"if (event.keyCode == 13) {return false;}\">\n";
901 -//20110629ysk end
902 - if($essential == 1){
903 - if( '#NONE#' == $session_value || NULL == $session_value )
904 - $selected = ' selected="selected"';
905 - else
906 - $selected = '';
907 - $html .= "\t<option value='#NONE#'{$selected}>" . __('Choose','usces') . "</option>\n";
908 - }
909 - $i=0;
910 - foreach($selects as $v) {
911 - $v = trim($v);
912 - if( ($i == 0 && $essential == 0 && NULL == $session_value) || esc_attr($v) == $session_value )
913 - $selected = ' selected="selected"';
914 - else
915 - $selected = '';
916 - $html .= "\t<option value='" . esc_attr($v) . "'{$selected}>" . esc_attr($v) . "</option>\n";
917 - $i++;
918 - }
919 - $html .= "</select>\n";
920 -//20100914ysk start
921 - //}else{
922 - break;
923 - case 2://Text
924 -//20100914ysk end
925 - $html .= "\n<input name='itemOption[{$post_id}][{$sku}][{$optcode}]' type='text' id='itemOption[{$post_id}][{$sku}][{$optcode}]' class='iopt_text' onKeyDown=\"if (event.keyCode == 13) {return false;}\" value=\"" . esc_attr($session_value) . "\" />\n";
926 -//20100914ysk start
927 - break;
928 - case 5://Text-area
929 - $html .= "\n<textarea name='itemOption[{$post_id}][{$sku}][{$optcode}]' id='itemOption[{$post_id}][{$sku}][{$optcode}]' class='iopt_textarea'>" . esc_attr($session_value) . "</textarea>\n";
930 - break;
931 -//20100914ysk end
932 - }
933 -
934 - $html = apply_filters('usces_filter_the_itemOption', $html, $opts, $name, $label, $post_id, $usces->itemsku['code']);
935 -
936 - if( $out == 'return' ){
937 - return $html;
938 - }else{
939 - echo $html;
940 - }
941 -}
942 -
943 -function usces_the_cart() {
944 - global $usces;
945 -
946 - $usces->display_cart();
947 -
948 -}
949 -
950 -function usces_is_cart() {
951 - global $usces;
952 -
953 - if($usces->cart->num_row() > 0)
954 - if( apply_filters('usces_is_cart_check', true) ) {
955 - return true;
956 - }else{
957 - return false;
958 - }
959 - else
960 - return false;
961 -
962 -}
963 -
964 -function usces_is_category( $str ) {
965 - global $post;
966 -
967 - //if( $post->post_type != 'post' ) return false;
968 -
969 - $cat = get_the_category();
970 - $slugs = array();
971 - foreach($cat as $value){
972 - $slugs[] = $value->slug;
973 - }
974 -
975 - $str = utf8_uri_encode($str);
976 -
977 - if( in_array( $str, $slugs) )
978 - return true;
979 - else
980 - return false;
981 -}
982 -
983 -function usces_the_pref( $flag, $out = '' ){
984 - global $usces;
985 -
986 - $usces_members = $usces->get_member();
987 - $usces_entries = $usces->cart->get_entry();
988 - $name = esc_attr($flag) . '[pref]';
989 - $pref = $usces_entries[$flag]['pref'];
990 - if( 'member' == $flag)
991 - $pref = $usces_members['pref'];
992 -
993 - $html = "<select name='" . esc_attr($name) . "' id='pref' class='pref'>\n";
994 -// $prefs = get_option('usces_pref');
995 -//20110331ysk start
996 - //$prefs = $usces->options['province'];
997 - $prefs = get_usces_states(usces_get_local_addressform());
998 -//20110331ysk end
999 - foreach($prefs as $value) {
1000 - $selected = ($pref == $value) ? ' selected="selected"' : '';
1001 - $html .= "\t<option value='" . esc_attr($value) . "'{$selected}>" . esc_html($value) . "</option>\n";
1002 - }
1003 - $html .= "</select>\n";
1004 -
1005 - if( $out == 'return' ){
1006 - return $html;
1007 - }else{
1008 - echo $html;
1009 - }
1010 -}
1011 -
1012 -function usces_the_company_name(){
1013 - global $usces;
1014 - echo esc_html($usces->options['company_name']);
1015 -}
1016 -
1017 -function usces_the_zip_code(){
1018 - global $usces;
1019 - echo esc_html($usces->options['zip_code']);
1020 -}
1021 -
1022 -function usces_the_address1(){
1023 - global $usces;
1024 - echo esc_html($usces->options['address1']);
1025 -}
1026 -
1027 -function usces_the_address2(){
1028 - global $usces;
1029 - echo esc_html($usces->options['address2']);
1030 -}
1031 -
1032 -function usces_the_tel_number(){
1033 - global $usces;
1034 - echo esc_html($usces->options['tel_number']);
1035 -}
1036 -
1037 -function usces_the_fax_number(){
1038 - global $usces;
1039 - echo esc_html($usces->options['fax_number']);
1040 -}
1041 -
1042 -function usces_the_inquiry_mail(){
1043 - global $usces;
1044 - echo esc_html($usces->options['inquiry_mail']);
1045 -}
1046 -
1047 -function usces_the_postage_privilege(){
1048 - global $usces;
1049 - echo esc_html($usces->options['postage_privilege']);
1050 -}
1051 -
1052 -function usces_the_start_point(){
1053 - global $usces;
1054 - echo esc_html($usces->options['start_point']);
1055 -}
1056 -
1057 -function usces_point_rate( $post_id = NULL, $out = '' ){
1058 - global $usces;
1059 - if( $post_id == NULL ){
1060 - $rate = $usces->options['point_rate'];
1061 - }else{
1062 - $str = get_post_meta($post_id, '_itemPointrate', true);
1063 - $rate = (int)$str;
1064 - }
1065 - if( $out == 'return' ){
1066 - return $rate;
1067 - }else{
1068 - echo $rate;
1069 - }
1070 -}
1071 -
1072 -function usces_point_rate_discount( $post_id = NULL, $out = '' ) {
1073 - global $post, $usces;
1074 - if( $post_id == NULL )
1075 - $post_id = $post->ID;
1076 -
1077 - $str = get_post_meta( $post_id, '_itemPointrate', true );
1078 - $rate = (int)$str;
1079 - if( $usces->options['campaign_privilege'] == 'point' ) {
1080 - if( in_category((int)$usces->options['campaign_category'], $post_id) ) {
1081 - $rate *= $usces->options['privilege_point'];
1082 - }
1083 - }
1084 - if( $out == 'return' ) {
1085 - return $rate;
1086 - } else {
1087 - echo $rate;
1088 - }
1089 -}
1090 -
1091 -function usces_get_point( $post_id, $sku_code ){
1092 - global $usces;
1093 - if( $post_id == NULL ){
1094 - $rate = $usces->options['point_rate'];
1095 - }else{
1096 - $str = get_post_meta($post_id, '_itemPointrate', true);
1097 - $rate = (int)$str;
1098 - }
1099 -
1100 - $skus = $usces->get_skus($post_id, 'code');
1101 - $point = ceil($skus[$sku_code]['price'] * $rate / 100);
1102 -
1103 - return $point;
1104 -}
1105 -
1106 -function usces_the_payment_method( $value = '', $out = '' ){
1107 - global $usces;
1108 - $payments = usces_get_system_option( 'usces_payment_method', 'sort' );
1109 - $payments = apply_filters('usces_fiter_the_payment_method', $payments, $value);
1110 - //if( empty($payments) ) return; 20120328ysk 0000454
1111 -
1112 - $cart = $usces->cart->get_cart();
1113 - //$charging_type = $usces->getItemChargingType($cart[0]['post_id']);
1114 - $charging_type = $usces->getItemChargingType($cart[0]['post_id'], $cart);
1115 - $html = "<dl>\n";
1116 - $list = '';
1117 - $payment_ct = count($payments);
1118 -//20120328ysk start 0000454
1119 - //foreach ($payments as $id => $payment) {
1120 - foreach ((array)$payments as $id => $payment) {
1121 -//20120328ysk end
1122 - if( 'continue' == $charging_type ){
1123 - //if( 'acting' != substr($payments['settlement'], 0, 6) )
1124 -//20110412ysk start
1125 - //if( 'acting_remise_card' != $payment['settlement'] && 'acting_paypal_ec' != $payment['settlement']) {
1126 - $continue_payment_method = apply_filters( 'usces_filter_the_continue_payment_method', array( 'acting_remise_card', 'acting_paypal_ec' ) );
1127 - if( !in_array( $payment['settlement'], $continue_payment_method ) ) {
1128 - $payment_ct--;
1129 - continue;
1130 - }
1131 - //if( 'on' !== $usces->options['acting_settings']['remise']['continuation'] && 'acting_remise_card' == $payment['settlement'])
1132 - // continue;
1133 - if( 'on' !== $usces->options['acting_settings']['remise']['continuation'] && 'acting_remise_card' == $payment['settlement']) {
1134 - $payment_ct--;
1135 - continue;
1136 - } elseif( 'on' !== $usces->options['acting_settings']['paypal']['continuation'] && 'acting_paypal_ec' == $payment['settlement']) {
1137 - $payment_ct--;
1138 - continue;
1139 - }
1140 -//20110412ysk end
1141 - }
1142 - if( $payment['name'] != '' ) {
1143 - $module = trim($payment['module']);
1144 - if( !WCUtils::is_blank($value) ){
1145 - $checked = ($payment['name'] == $value) ? ' checked' : '';
1146 - }else if( 1 == $payment_ct ){//0000428
1147 - $checked = ' checked';
1148 - }else{
1149 - $checked = '';
1150 - }
1151 - if( (empty($module) || !file_exists($usces->options['settlement_path'] . $module)) && $payment['settlement'] == 'acting' ) {
1152 - $checked = '';
1153 - $list .= "\t".'<dt><label for="payment_name_' . $id . '"><input name="offer[payment_name]" id="payment_name_' . $id . '" type="radio" value="'.esc_attr($payment['name']).'"' . $checked . ' disabled onKeyDown="if (event.keyCode == 13) {return false;}" />'.esc_attr($payment['name'])."</label> <b> (" . __('cannot use this payment method now.','usces') . ") </b></dt>\n";
1154 - }else{
1155 - $list .= "\t".'<dt><label for="payment_name_' . $id . '"><input name="offer[payment_name]" id="payment_name_' . $id . '" type="radio" value="'.esc_attr($payment['name']).'"' . $checked . ' onKeyDown="if (event.keyCode == 13) {return false;}" />'.esc_attr($payment['name'])."</label></dt>\n";
1156 - }
1157 - $list .= "\t<dd>{$payment['explanation']}</dd>\n";
1158 - }
1159 - }
1160 -
1161 - $html .= $list . "</dl>\n";
1162 -
1163 - if( empty($list) )
1164 - $html = __('Not yet ready for the payment method. Please refer to a manager.', 'usces')."\n";
1165 -
1166 - if( $out == 'return' ){
1167 - return $html;
1168 - }else{
1169 - echo $html;
1170 - }
1171 -}
1172 -
1173 -function usces_get_payments_by_name( $name ){
1174 - global $usces;
1175 - $payments = usces_get_system_option( 'usces_payment_method', 'name' );
1176 - if( empty($payments) ) return false;
1177 -
1178 - if( isset($payments[$name]) ) {
1179 - return $payments[$name];
1180 - }
1181 -
1182 - return false;
1183 -}
1184 -
1185 -function usces_the_delivery_method( $value = '', $out = '' ){
1186 - global $usces;
1187 - $deli_id = apply_filters('usces_filter_get_available_delivery_method', $usces->get_available_delivery_method());
1188 - if( empty($deli_id) ){
1189 - $html = '<p>' . __('No valid shipping methods.', 'usces') . '</p>';
1190 - }else{
1191 - $cdeliid = count($deli_id);
1192 - $html = '<select name="offer[delivery_method]" id="delivery_method_select" class="delivery_time" onKeyDown="if (event.keyCode == 13) {return false;}">'."\n";
1193 - foreach ($deli_id as $id) {
1194 - $index = $usces->get_delivery_method_index($id);
1195 - $selected = ($id == $value || 1 === $cdeliid) ? ' selected="selected"' : '';
1196 - $html .= "\t<option value='{$id}'{$selected}>" . esc_html($usces->options['delivery_method'][$index]['name']) . "</option>\n";
1197 - }
1198 -
1199 - $html .= "</select>\n";
1200 - }
1201 -
1202 - if( $out == 'return' ){
1203 - return $html;
1204 - }else{
1205 - echo $html;
1206 - }
1207 -}
1208 -//20101208ysk start
1209 -function usces_the_delivery_date( $value = '', $out = '' ){
1210 - global $usces;
1211 -
1212 - $html = "<select name='offer[delivery_date]' id='delivery_date_select' class='delivery_date'>\n";
1213 - $html .= "</select>\n";
1214 -
1215 - if( $out == 'return' ){
1216 - return $html;
1217 - }else{
1218 - echo $html;
1219 - }
1220 -}
1221 -//20101208ysk end
1222 -function usces_the_delivery_time( $value = '', $out = '' ){
1223 - global $usces;
1224 -
1225 -//20101208ysk start
1226 - //$html = "<select name='offer[delivery_time]' id='delivery_time_select' class='delivery_time'>\n";
1227 - $html = "<div id='delivery_time_limit_message'></div>\n";
1228 - $html .= "<select name='offer[delivery_time]' id='delivery_time_select' class='delivery_time'>\n";
1229 -//20101208ysk end
1230 -
1231 - $html .= "</select>\n";
1232 -
1233 - if( $out == 'return' ){
1234 - return $html;
1235 - }else{
1236 - echo $html;
1237 - }
1238 -}
1239 -
1240 -function usces_the_campaign_schedule($flag, $kind){
1241 - global $usces;
1242 - $startdate = $usces->options['campaign_schedule']['start']['year'] . __('year','usces') . $usces->options['campaign_schedule']['start']['month'] . __('month','usces') . $usces->options['campaign_schedule']['start']['day'] . __('day','usces');
1243 - $starttime = $usces->options['campaign_schedule']['start']['hour'] . __('hour','usces') . $usces->options['campaign_schedule']['start']['min'] . __('min','usces');
1244 - $enddate = $usces->options['campaign_schedule']['end']['year'] . __('year','usces') . $usces->options['campaign_schedule']['end']['month'] . __('month','usces') . $usces->options['campaign_schedule']['end']['day'] . __('day','usces');
1245 - $endtime = $usces->options['campaign_schedule']['end']['hour'] . __('hour','usces') . $usces->options['campaign_schedule']['end']['min'] . __('min','usces');
1246 - if( 'start' == $flag ) {
1247 - if( 'date' == $kind ) {
1248 - echo esc_html($startdate);
1249 - }elseif( 'datetime' == $kind ) {
1250 - echo esc_html($startdate . ' ' . $starttime);
1251 - }
1252 - } elseif ( 'end' == $flag ) {
1253 - if( 'date' == $kind ) {
1254 - echo esc_html($enddate);
1255 - }elseif( 'datetime' == $kind ) {
1256 - echo esc_html($enddate . ' ' . $endtime);
1257 - }
1258 - }
1259 -}
1260 -
1261 -
1262 -function usces_the_confirm() {
1263 - global $usces;
1264 -
1265 - $usces->display_cart_confirm();
1266 -}
1267 -
1268 -function usces_inquiry_condition() {
1269 - global $error_message, $reserve, $inq_name, $inq_mailaddress, $inq_contents;
1270 - require(USCES_PLUGIN_DIR.'/includes/inquiry_condition.php');
1271 -}
1272 -
1273 -function usces_the_inquiry_form() {
1274 - global $usces;
1275 - $error_message = '';
1276 - if( isset($_POST['inq_name']) && !WCUtils::is_blank($_POST['inq_name']) ) {
1277 - $inq_name = trim($_POST['inq_name']);
1278 - }else{
1279 - $inq_name = '';
1280 - if($usces->page == 'deficiency')
1281 - $error_message .= __('Please input your name.', 'usces') . "<br />";
1282 - }
1283 - if( isset($_POST['inq_mailaddress']) && is_email(trim($_POST['inq_mailaddress'])) ) {
1284 - $inq_mailaddress = trim($_POST['inq_mailaddress']);
1285 - }elseif( isset($_POST['inq_mailaddress']) && !is_email(trim($_POST['inq_mailaddress'])) ) {
1286 - $inq_mailaddress = trim($_POST['inq_mailaddress']);
1287 - if($usces->page == 'deficiency')
1288 - $error_message .= __('E-mail address is not correct', 'usces') . "<br />";
1289 - }else{
1290 - $inq_mailaddress = '';
1291 - if($usces->page == 'deficiency')
1292 - $error_message .= __('Please input your e-mail address.', 'usces') . "<br />";
1293 - }
1294 - if( isset($_POST['inq_contents']) && !WCUtils::is_blank($_POST['inq_contents']) ) {
1295 - $inq_contents = trim($_POST['inq_contents']);
1296 - }else{
1297 - $inq_contents = '';
1298 - if($usces->page == 'deficiency')
1299 - $error_message .= __('Please input contents.', 'usces');
1300 - }
1301 -
1302 -
1303 - if($usces->page == 'inquiry_comp') :
1304 -?>
1305 - <div class="inquiry_comp"><?php _e('sending completed','usces') ?></div>
1306 - <div class="compbox"><?php _e('I send a reply email to a visitor. I ask in a few minutes to be able to have you refer in there being the fear that e-mail address is different again when the email from this shop does not arrive.','usces') ?></div>
1307 -<?php
1308 - elseif($usces->page == 'inquiry_error') :
1309 -?>
1310 - <div class="inquiry_comp"><?php _e('Failure in sending','usces') ?></div>
1311 -<?php
1312 - else :
1313 -?>
1314 -<?php if( !empty($error_message) ): ?>
1315 -<div class="error_message"><?php echo $error_message; ?></div>
1316 -<?php endif; ?>
1317 -<form name="inquiry_form" action="<?php //echo USCES_CART_URL; ?>" method="post">
1318 -<table border="0" cellpadding="0" cellspacing="0" class="inquiry_table">
1319 -<tr>
1320 -<th scope="row"><?php _e('Full name','usces') ?></th>
1321 -<td><input name="inq_name" type="text" class="inquiry_name" value="<?php echo esc_attr($inq_name); ?>" /></td>
1322 -</tr>
1323 -<tr>
1324 -<th scope="row"><?php _e('e-mail adress','usces') ?></th>
1325 -<td><input name="inq_mailaddress" type="text" class="inquiry_mailaddress" value="<?php echo esc_attr($inq_mailaddress); ?>" /></td>
1326 -</tr>
1327 -<tr>
1328 -<th scope="row"><?php _e('contents','usces') ?></th>
1329 -<td><textarea name="inq_contents" class="inquiry_contents"><?php echo esc_attr($inq_contents); ?></textarea></td>
1330 -</tr>
1331 -</table>
1332 -<div class="send"><input name="inquiry_button" type="submit" value="<?php _e('Admit to send it with this information.','usces') ?>" /></div>
1333 -</form>
1334 -<?php
1335 - endif;
1336 -}
1337 -
1338 -function usces_get_cat_id( $slug ) {
1339 - $cat = get_category_by_slug( $slug );
1340 - return $cat->term_id;
1341 -}
1342 -
1343 -function usces_the_calendar() {
1344 - global $usces;
1345 - include (USCES_PLUGIN_DIR . '/includes/widget_calendar.php');
1346 -}
1347 -
1348 -function usces_loginout( $out = '') {
1349 - global $usces;
1350 - if ( !$usces->is_member_logged_in() )
1351 - $res = '<a href="' . apply_filters('usces_filter_login_uri', USCES_LOGIN_URL) . '" class="usces_login_a">' . apply_filters('usces_filter_loginlink_label', __('Log-in','usces')) . '</a>';
1352 - else
1353 - $res = '<a href="' . apply_filters('usces_filter_logout_uri', USCES_LOGOUT_URL) . '" class="usces_logout_a">' . apply_filters('usces_filter_logoutlink_label', __('Log out','usces')) . '</a>';
1354 -
1355 - if( $out == 'return' ){
1356 - return $res;
1357 - }else{
1358 - echo $res;
1359 - }
1360 -}
1361 -
1362 -function usces_is_login() {
1363 - global $usces;
1364 -
1365 - if( false === $usces->is_member_logged_in() )
1366 - $res = false;
1367 - else
1368 - $res = true;
1369 -
1370 - return $res;
1371 -}
1372 -
1373 -function usces_the_member_name( $out = '') {
1374 - global $usces;
1375 - $usces->get_current_member();
1376 - $res = esc_html($usces->current_member['name']);
1377 - if( $out == 'return' ){
1378 - return $res;
1379 - }else{
1380 - echo $res;
1381 - }
1382 -
1383 -}
1384 -
1385 -function usces_the_member_point( $out = '' ) {
1386 - global $usces;
1387 -
1388 - if( !$usces->is_member_logged_in() ) return;
1389 -
1390 - $member = $usces->get_member();
1391 - if( $out == 'return' ){
1392 - return $member['point'];
1393 - }else{
1394 - echo number_format($member['point']);
1395 - }
1396 -}
1397 -
1398 -function usces_the_member_status( $out = '' ) {
1399 - global $usces;
1400 - if( !$usces->is_member_logged_in() ) return;
1401 -
1402 - $usces->get_current_member();
1403 - $member = $usces->get_member_info($usces->current_member['id']);
1404 - $status_name = $usces->member_status[$member['mem_status']];
1405 -
1406 - if( $out == 'return' ){
1407 - return $status_name;
1408 - }else{
1409 - echo esc_html($status_name);
1410 - }
1411 -}
1412 -
1413 -function usces_get_assistance_id_list($post_id) {
1414 - global $usces;
1415 - $names = $usces->get_tag_names($post_id);
1416 - $list = '';
1417 - foreach ( $names as $itemname )
1418 - $list .= $usces->get_ID_byItemName($itemname, 'publish') . ',';
1419 -
1420 - $list = trim($list, ',');
1421 -
1422 - return $list;
1423 -}
1424 -function usces_get_assistance_ids($post_id) {
1425 - global $usces;
1426 - $names = $usces->get_tag_names($post_id);
1427 - $ids = array();
1428 - foreach ( $names as $itemname )
1429 - $ids[] = $usces->get_ID_byItemName($itemname, 'publish');
1430 -
1431 - return $ids;
1432 -}
1433 -function usces_remembername( $out = '' ){
1434 - global $usces;
1435 - $value = $usces->get_cookie();
1436 -
1437 - if( $out == 'return' ){
1438 - if(isset($value['name']))
1439 - return $value['name'];
1440 - else
1441 - return '';
1442 - }else{
1443 - if(isset($value['name']))
1444 - echo esc_html($value['name']);
1445 - else
1446 - echo '';
1447 - }
1448 -}
1449 -function usces_rememberpass( $out = '' ){
1450 - global $usces;
1451 - $value = $usces->get_cookie();
1452 -
1453 - if( $out == 'return' ){
1454 - if(isset($value['pass']))
1455 - return $value['pass'];
1456 - else
1457 - return '';
1458 - }else{
1459 - if(isset($value['pass']))
1460 - echo esc_html($value['pass']);
1461 - else
1462 - echo '';
1463 - }
1464 -}
1465 -function usces_remembercheck( $out = '' ){
1466 - global $usces;
1467 - $value = $usces->get_cookie();
1468 -
1469 - if( $out == 'return' ){
1470 - if(isset($value['name']) && $value['name'] != '')
1471 - return ' checked="checked"';
1472 - else
1473 - return '';
1474 - }else{
1475 - if(isset($value['name']) && $value['name'] != '')
1476 - echo ' checked="checked"';
1477 - else
1478 - echo '';
1479 - }
1480 -}
1481 -function usces_shippingchargeTR( $index='' ) {
1482 - global $usces;
1483 - if($index == ""){
1484 - $index = 0;
1485 - }
1486 - $list = '';
1487 - if( !isset($usces->options['shipping_charge'][$index]) ) return;
1488 - $shipping_charge = $usces->options['shipping_charge'][$index];
1489 -//20120710ysk start 0000472
1490 - $entry = $usces->cart->get_entry();
1491 - $country = (isset($entry['delivery']['country']) && !empty($entry['delivery']['country'])) ? $entry['delivery']['country'] : $entry['customer']['country'];//20120710ysk 0000472
1492 - //foreach ($shipping_charge['value'] as $pref => $value) {
1493 - foreach ($shipping_charge[$country] as $pref => $value) {
1494 -//20120710ysk end
1495 - $list .= "<tr><th>" . esc_html($pref) . "</th>\n";
1496 - $list .= "<td class='rightnum'>" . number_format($value) . "</td>\n";
1497 - $list .= "</tr>\n";
1498 - }
1499 - echo $list;
1500 -}
1501 -function usces_sc_shipping_charge() {
1502 - global $usces;
1503 - echo esc_html($usces->sc_shipping_charge());
1504 -}
1505 -function usces_sc_postage_privilege() {
1506 - global $usces;
1507 - echo esc_html($usces->sc_postage_privilege());
1508 -}
1509 -function usces_sc_payment_title() {
1510 - global $usces;
1511 - echo $usces->sc_payment_title();
1512 -}
1513 -
1514 -
1515 -
1516 -function usces_posts_random_offset( $posts ){
1517 - $ids = array();
1518 - foreach( (array)$posts as $post ){
1519 - $ids[] = $post->ID;
1520 - }
1521 - $ct = count($ids);
1522 - $index = rand(0, ($ct-1));
1523 - return $index;
1524 -}
1525 -
1526 -function usces_get_category_link_by_slug( $slug ){
1527 - $category = get_category_by_slug($slug);
1528 - echo get_category_link( $category->term_id );
1529 -}
1530 -
1531 -function usces_get_page_ID_by_pname( $post_name, $return = 'echo' ){
1532 - $page = get_page_by_path( $post_name );
1533 - if($return == 'return')
1534 - return $page->ID;
1535 - else
1536 - echo $page->ID;
1537 -}
1538 -
1539 -function usces_list_bestseller($num, $days = ''){
1540 - global $usces;
1541 - $ids = $usces->get_bestseller_ids( $days );
1542 - $htm = "";
1543 - for($i=0; $i<$num; $i++){
1544 - if(isset($ids[$i])){
1545 - $post = get_post($ids[$i]);
1546 - if( !is_object($post) )
1547 - continue;
1548 -
1549 - $disp_text = apply_filters('usces_widget_bestseller_auto_text', esc_html($post->post_title), $ids[$i]);
1550 - $list = "<li><a href='" . get_permalink($ids[$i]) . "'>" . $disp_text . "</a></li>\n";
1551 - $htm .= apply_filters('usces_filter_bestseller', $list, $ids[$i], $i);
1552 - }
1553 - }
1554 - wp_reset_postdata();
1555 - echo $htm;
1556 -}
1557 -
1558 -function usces_list_post( $slug, $rownum, $widget_id=NULL ){
1559 - global $usces, $post;
1560 - usces_remove_filter();
1561 -
1562 - $li = '';
1563 - $infolist = new wp_query( array('category_name'=>$slug, 'post_status'=>'publish', 'posts_per_page'=>$rownum, 'order'=>'DESC', 'orderby'=>'date') );
1564 - if( NULL != $widget_id && $infolist->have_posts() ){
1565 - remove_filter( 'excerpt_length', 'welcart_excerpt_length' );
1566 - remove_filter( 'excerpt_mblength', 'welcart_excerpt_mblength' );
1567 - remove_filter( 'excerpt_more', 'welcart_auto_excerpt_more' );
1568 - if( function_exists('welcart_widget_post_excerpt_length_'.$widget_id) )
1569 - add_filter( 'excerpt_length', 'welcart_widget_post_excerpt_length_'.$widget_id );
1570 - if( function_exists('welcart_widget_post_excerpt_mblength_'.$widget_id) )
1571 - add_filter( 'excerpt_mblength', 'welcart_widget_post_excerpt_mblength_'.$widget_id );
1572 - }
1573 - $list_index = 0;
1574 - while ($infolist->have_posts()) {
1575 - $infolist->the_post();
1576 - $list = '<li class="post_list'. apply_filters('usces_filter_post_list_class', NULL, $list_index, count($infolist)) . '">'."\n";
1577 - $list .= "<div class='title'><a href='" . get_permalink($post->ID) . "'>" . get_the_title() . "</a></div>\n";
1578 - $list .= "<p>" . get_the_excerpt() . "</p>\n";
1579 - $list .= "</li>\n";
1580 - $li .= apply_filters( 'usces_filter_widget_post', $list, $post, $slug, $list_index);
1581 - $list_index++;
1582 - }
1583 - wp_reset_query();
1584 - usces_reset_filter();
1585 - if( NULL != $widget_id && $infolist->have_posts() ){
1586 - add_filter( 'excerpt_length', 'welcart_excerpt_length' );
1587 - add_filter( 'excerpt_mblength', 'welcart_excerpt_mblength' );
1588 - add_filter( 'excerpt_more', 'welcart_auto_excerpt_more' );
1589 - }
1590 - echo $li;
1591 -}
1592 -
1593 -function usces_categories_checkbox($output=''){
1594 - global $usces;
1595 - $retcats = apply_filters('usces_search_retcats', usces_search_categories());
1596 - $parent_id = apply_filters('usces_search_categories_checkbox_parent', USCES_ITEM_CAT_PARENT_ID);
1597 - $htm = usces_get_categories_checkbox($parent_id);
1598 - $htm = apply_filters('usces_filter_categories_checkbox', $htm, $parent_id);
1599 -
1600 - if($output == '' || $output == 'echo')
1601 - echo $htm;
1602 - else
1603 - return $htm;
1604 -}
1605 -
1606 -function usces_get_categories_checkbox($parent_id){
1607 - global $usces;
1608 - $htm = '';
1609 - $retcats = usces_search_categories();
1610 - $parent_cat = get_category($parent_id);
1611 - $categories = get_categories('parent='.$parent_id . "&hide_empty=0&orderby=" . $usces->options['fukugo_category_orderby'] . "&order=" . $usces->options['fukugo_category_order']);
1612 - $htm .= "<fieldset class='catfield-" . $parent_cat->term_id . "'><legend>" . $parent_cat->cat_name . "</legend><ul>\n";
1613 - foreach ($categories as $cat) {
1614 - $children = get_categories('parent='.$cat->term_id . "&hide_empty=0");
1615 - if( 0 === count($children) ){
1616 - $checked = in_array($cat->term_id, $retcats) ? " checked='checked'" : "";
1617 - $htm .= "<li><input name='category[".$cat->term_id."]' type='checkbox' id='category[".$cat->term_id."]' value='".$cat->term_id."'".$checked." /><label for='category[".$cat->term_id."]' class='catlabel-" . $cat->term_id . "'>".esc_html($cat->cat_name)."</label></li>\n";
1618 - }
1619 - }
1620 - $htm .= "</ul>\n";
1621 - foreach ($categories as $cat) {
1622 - $children = get_categories('parent='.$cat->term_id . "&hide_empty=0");
1623 - if( 0 < count($children) ){
1624 - $htm .= usces_get_categories_checkbox($cat->term_id);
1625 - }
1626 - }
1627 - $htm .= "</fieldset>\n";
1628 -
1629 - return $htm;
1630 -}
1631 -
1632 -function usces_search_categories(){
1633 - $cats = array();
1634 - //if(isset($_POST['category']))
1635 - // $cats = $_POST['category'];
1636 - if(isset($_REQUEST['category']))
1637 - $cats = $_REQUEST['category'];
1638 - else
1639 - $cats[] = USCES_ITEM_CAT_PARENT_ID;
1640 - sort($cats);
1641 - return $cats;
1642 -}
1643 -
1644 -function usces_delivery_method_name( $id, $out = '' ){
1645 - global $usces;
1646 -
1647 - if($id > -1){
1648 - $id =$usces->get_delivery_method_index($id);
1649 - $name = $usces->options['delivery_method'][$id]['name'];
1650 - }else{
1651 - $name = __('No preference','usces');
1652 - }
1653 -
1654 - if($out == 'return'){
1655 - return $name;
1656 - }else{
1657 - echo esc_html($name);
1658 - }
1659 -}
1660 -
1661 -function usces_is_membersystem_state(){
1662 - global $usces;
1663 -
1664 - if($usces->options['membersystem_state'] == 'activate') {
1665 - return true;
1666 - }else{
1667 - return false;
1668 - }
1669 -}
1670 -
1671 -function usces_is_membersystem_point(){
1672 - global $usces;
1673 -
1674 - if($usces->options['membersystem_point'] == 'activate') {
1675 - return true;
1676 - }else{
1677 - return false;
1678 - }
1679 -}
1680 -
1681 -function usces_copyright(){
1682 - global $usces;
1683 -
1684 - echo esc_html($usces->options['copyright']);
1685 -}
1686 -
1687 -function usces_totalprice_in_cart(){
1688 - global $usces;
1689 -
1690 - echo number_format($usces->get_total_price());
1691 -}
1692 -
1693 -function usces_totalquantity_in_cart(){
1694 - global $usces;
1695 -
1696 - echo number_format($usces->get_total_quantity());
1697 -}
1698 -
1699 -function usces_get_page_mode(){
1700 - global $usces;
1701 -
1702 - return $usces->page;
1703 -}
1704 -
1705 -function usces_is_cat_of_item( $cat_id ){
1706 - global $usces;
1707 - $ids = $usces->get_item_cat_ids();
1708 - $ids[] = USCES_ITEM_CAT_PARENT_ID;
1709 - if(in_array($cat_id, $ids)){
1710 - return true;
1711 - }else{
1712 - return false;
1713 - }
1714 -}
1715 -
1716 -function usces_get_item_custom( $post_id, $type = 'list', $out = '' ){
1717 - global $usces;
1718 - $cfields = $usces->get_post_custom($post_id);
1719 - switch( $type ){
1720 - case 'list':
1721 - $list = '';
1722 - $html = '<ul class="item_custom_field">'."\n";
1723 - foreach( $cfields as $key => $value ){
1724 - if( 'wccs_' == substr($key, 0, 5) ){
1725 - $list .= '<li>' . esc_html(substr($key, 5)) . ' : ' . nl2br(esc_html($value[0])) . '</li>'."\n";
1726 - }
1727 - }
1728 - if(empty($list)){
1729 - $html = '';
1730 - }else{
1731 - $html .= $list . '</ul>'."\n";
1732 - }
1733 - break;
1734 -
1735 - case 'table':
1736 - $list = '';
1737 - $html = '<table class="item_custom_field">'."\n";
1738 - foreach($cfields as $key => $value){
1739 - if( 'wccs_' == substr($key, 0, 5) ){
1740 - $list .= '<tr><th>' . esc_html(substr($key, 5)) . '</th><td>' . nl2br(esc_html($value[0])) . '</td></tr>'."\n";
1741 - }
1742 - }
1743 - if(empty($list)){
1744 - $html = '';
1745 - }else{
1746 - $html .= $list . '</table>'."\n";
1747 - }
1748 - break;
1749 -
1750 - case 'notag':
1751 - $list = '';
1752 - foreach($cfields as $key => $value){
1753 - if( 'wccs_' == substr($key, 0, 5) ){
1754 - $list .= esc_html(substr($key, 5)) . ' : ' . nl2br(esc_html($value[0])) . "\r\n";
1755 - }
1756 - }
1757 - if(empty($list)){
1758 - $html = '';
1759 - }else{
1760 - $html = $list;
1761 - }
1762 - break;
1763 - }
1764 - $html = apply_filters( 'usces_filter_item_custom', $html, $post_id);
1765 -
1766 - if( 'return' == $out){
1767 - return $html;
1768 - }else{
1769 - echo $html;
1770 - }
1771 -}
1772 -
1773 -function usces_settle_info_field( $order_id, $type='nl', $out='echo' ){
1774 - global $usces;
1775 - $str = '';
1776 - $fields = $usces->get_settle_info_field( $order_id );
1777 -//20101018ysk start
1778 - $acting = isset($fields['acting']) ? $fields['acting'] : '';
1779 - foreach($fields as $key => $value){
1780 -//20101018ysk end
1781 - $keys = array(
1782 - 'acting','order_no','tracking_no','status','error_message','money',
1783 - 'pay_cvs', 'pay_no1', 'pay_no2', 'pay_limit', 'error_code',
1784 - 'settlement_id','RECDATE','JOB_ID','S_TORIHIKI_NO','TOTAL','CENDATE',
1785 - 'gid', 'rst', 'ap', 'ec', 'god', 'ta', 'cv', 'no', 'cu', 'mf', 'nk', 'nkd', 'bank', 'exp',
1786 - 'order_number',
1787 - 'res_tracking_id', 'res_payment_date', 'res_payinfo_key',
1788 - 'SID', 'DATE', 'TIME', 'CVS', 'SHNO', 'FURL', 'settltment_status', 'settltment_errmsg',
1789 - 'stran', 'mbtran', 'bktrans', 'tranid'
1790 - );
1791 - $keys = apply_filters( 'usces_filter_settle_info_field_keys', $keys );
1792 - if( !in_array($key, $keys) ) {
1793 - continue;
1794 - }
1795 -
1796 - switch($acting){
1797 - case 'zeus_bank':
1798 - if( 'status' == $key){
1799 - if( '01' === $value ){
1800 - $value = '受付中';
1801 - }elseif( '02' === $value ){
1802 - $value = '未入金';
1803 - }elseif( '03' === $value ){
1804 - $value = '入金済';
1805 - }elseif( '04' === $value ){
1806 - $value = 'エラー';
1807 - }elseif( '05' === $value ){
1808 - $value = '入金失敗';
1809 - }
1810 - }elseif( 'error_message' == $key){
1811 - if( '0002' === $value ){
1812 - $value = '入金不足';
1813 - }elseif( '0003' === $value ){
1814 - $value = '過剰入金';
1815 - }
1816 - }
1817 - break;
1818 - case 'zeus_conv':
1819 - if( 'pay_cvs' == $key){
1820 - if( 'D001' === $value ){
1821 - $value = 'セブンイレブン';
1822 - }elseif( 'D002' === $value ){
1823 - $value = 'ローソン';
1824 - }elseif( 'D030' === $value ){
1825 - $value = 'ファミリーマート';
1826 - }elseif( 'D040' === $value ){
1827 - $value = 'サークルKサンクス';
1828 - }elseif( 'D015' === $value ){
1829 - $value = 'セイコーマート';
1830 - }
1831 - }elseif( 'status' == $key){
1832 - if( '01' === $value ){
1833 - $value = '未入金';
1834 - }elseif( '02' === $value ){
1835 - $value = '申込エラー';
1836 - }elseif( '03' === $value ){
1837 - $value = '期日切';
1838 - }elseif( '04' === $value ){
1839 - $value = '入金済';
1840 - }elseif( '05' === $value ){
1841 - $value = '売上確定';
1842 - }elseif( '06' === $value ){
1843 - $value = '入金取消';
1844 - }elseif( '11' === $value ){
1845 - $value = 'キャンセル後入金';
1846 - }elseif( '12' === $value ){
1847 - $value = 'キャンセル後売上';
1848 - }elseif( '13' === $value ){
1849 - $value = 'キャンセル後取消';
1850 - }
1851 - }elseif( 'pay_limit' == $key){
1852 - $value = substr($value, 0, 4).'年' . substr($value, 4, 2).'月' . substr($value, 6, 2).'日';
1853 - }
1854 - break;
1855 -//20101018ysk start
1856 - case 'jpayment_conv':
1857 - switch($key) {
1858 - case 'rst':
1859 - switch($value) {
1860 - case '1':
1861 - $value = 'OK'; break;
1862 - case '2':
1863 - $value = 'NG'; break;
1864 - }
1865 - break;
1866 - case 'ap':
1867 - switch($value) {
1868 - case 'CPL_PRE':
1869 - $value = 'コンビニペーパーレス決済識別コード'; break;
1870 - case 'CPL':
1871 - $value = '入金確定'; break;
1872 - case 'CVS_CAN':
1873 - $value = '入金取消'; break;
1874 - }
1875 - break;
1876 - case 'cv':
1877 - $value = esc_html(usces_get_conv_name($value));
1878 - break;
1879 - case 'mf':
1880 - case 'nk':
1881 - case 'nkd':
1882 - case 'bank':
1883 - case 'exp':
1884 - continue;
1885 - break;
1886 - }
1887 - break;
1888 -
1889 - case 'jpayment_bank':
1890 - switch($key) {
1891 - case 'rst':
1892 - switch($value) {
1893 - case '1':
1894 - $value = 'OK'; break;
1895 - case '2':
1896 - $value = 'NG'; break;
1 +<?php
2 +/**
3 + * Template functions
4 + *
5 + * @package Welcart
6 + */
7 +
8 +/**
9 + * Tax guid
10 + *
11 + * @param string $out Return value or echo.
12 + * @param bool $tag HTML tag.
13 + * @return string|void
14 + */
15 +function usces_guid_tax( $out = '', $tag = true ) {
16 + global $usces;
17 +
18 + $guid_tax = '';
19 + if ( $tag ) {
20 + $guid_tax = $usces->getGuidTax();
21 + } else {
22 + if ( isset( $usces->options['tax_display'] ) && 'deactivate' === $usces->options['tax_display'] ) {
23 + $guid_tax = '';
24 + } else {
25 + $tax_rate = (int) $usces->options['tax_rate'];
26 + if ( isset( $usces->options['tax_mode'] ) ) {
27 + if ( 'exclude' === $usces->options['tax_mode'] ) {
28 + $guid_tax = __( '(Excl. Tax)', 'usces' );
29 + } else {
30 + $guid_tax = __( '(Incl. Tax)', 'usces' );
31 + }
32 + } else {
33 + if ( 0 < $tax_rate ) {
34 + $guid_tax = __( '(Excl. Tax)', 'usces' );
35 + } else {
36 + $guid_tax = __( '(Incl. Tax)', 'usces' );
37 + }
38 + }
39 + }
40 + }
41 +
42 + $guid_tax = apply_filters( 'usces_filter_guid_tax', $guid_tax );
43 +
44 + if ( 'return' === $out ) {
45 + return wel_esc_script( $guid_tax );
46 + } else {
47 + wel_esc_script_e( $guid_tax );
48 + }
49 +}
50 +
51 +/**
52 + * Tax label
53 + *
54 + * @param array $data Order data.
55 + * @param string $out Return value or echo.
56 + * @return string|void
57 + */
58 +function usces_tax_label( $data = array(), $out = '' ) {
59 + global $usces;
60 +
61 + if ( empty( $data ) || ! array_key_exists( 'order_condition', $data ) ) {
62 + $condition = $usces->get_condition();
63 + $tax_mode = $usces->options['tax_mode'];
64 + } else {
65 + $condition = wel_safe_maybe_unserialize( $data['order_condition'] );
66 + $tax_mode = ( isset( $condition['tax_mode'] ) ) ? $condition['tax_mode'] : $usces->options['tax_mode'];
67 + }
68 + if ( 'exclude' === $tax_mode ) {
69 + $label = __( 'consumption tax', 'usces' );
70 + } else {
71 + if ( isset( $condition['tax_mode'] ) && ! empty( $data['ID'] ) ) {
72 + $materials = array(
73 + 'total_items_price' => $data['order_item_total_price'],
74 + 'discount' => $data['order_discount'],
75 + 'shipping_charge' => $data['order_shipping_charge'],
76 + 'cod_fee' => $data['order_cod_fee'],
77 + 'use_point' => $data['order_usedpoint'],
78 + 'carts' => usces_get_ordercartdata( $data['ID'] ),
79 + 'condition' => $condition,
80 + 'order_id' => $data['ID'],
81 + );
82 + $label = __( 'Internal tax', 'usces' ) . '( ' . usces_crform( usces_internal_tax( $materials, 'return' ), true, false, 'return' ) . ' )';
83 + } else {
84 + $label = __( 'Internal tax', 'usces' );
85 + }
86 + }
87 + $label = apply_filters( 'usces_filter_tax_label', $label );
88 +
89 + if ( 'return' === $out ) {
90 + return wel_esc_script( $label );
91 + } else {
92 + wel_esc_script_e( $label );
93 + }
94 +}
95 +
96 +/**
97 + * Tax Calculation
98 + *
99 + * @param array $data When the 'order' key in $data exist, entry data, unless order data.
100 + * @param string $out Return value or echo.
101 + * @return string|void
102 + */
103 +function usces_tax( $data, $out = '' ) {
104 + global $usces;
105 +
106 + if ( empty( $data ) || ! array_key_exists( 'order_condition', $data ) ) {
107 + $condition = $usces->get_condition();
108 + $tax_mode = $usces->options['tax_mode'];
109 + } else {
110 + $condition = wel_safe_maybe_unserialize( $data['order_condition'] );
111 + $tax_mode = ( isset( $condition['tax_mode'] ) ) ? $condition['tax_mode'] : $usces->options['tax_mode'];
112 + }
113 +
114 + if ( ! usces_is_tax_display() ) {
115 + $tax_str = '';
116 + } else {
117 + if ( 'exclude' === $tax_mode ) {
118 + if ( array_key_exists( 'order', $data ) && array_key_exists( 'tax', $data['order'] ) ) { /* from Entry */
119 + $tax = $data['order']['tax'];
120 + } elseif ( array_key_exists( 'order_tax', $data ) ) { /* from Order Data */
121 + $tax = $data['order_tax'];
122 + } elseif ( array_key_exists( 'tax', $data ) ) {
123 + $tax = $data['tax'];
124 + } else {
125 + $tax = 0;
126 + }
127 + $tax_str = usces_crform( $tax, true, false, 'return' );
128 + } else {
129 + if ( array_key_exists( 'order', $data ) ) { /* from Entry */
130 + $materials = array(
131 + 'total_items_price' => $data['order']['total_items_price'],
132 + 'discount' => ( isset( $data['order']['discount'] ) ) ? $data['order']['discount'] : 0,
133 + 'shipping_charge' => ( isset( $data['order']['shipping_charge'] ) ) ? $data['order']['shipping_charge'] : 0,
134 + 'cod_fee' => ( isset( $data['order']['cod_fee'] ) ) ? $data['order']['cod_fee'] : 0,
135 + 'use_point' => ( isset( $data['order']['use_point'] ) ) ? $data['order']['use_point'] : 0,
136 + );
137 + $tax_str = '( ' . usces_crform( usces_internal_tax( $materials, 'return' ), true, false, 'return' ) . ' )';
138 + } elseif ( array_key_exists( 'order_tax', $data ) ) { /* from Order Data */
139 + $materials = array(
140 + 'total_items_price' => $data['order_item_total_price'],
141 + 'discount' => $data['order_discount'],
142 + 'shipping_charge' => $data['order_shipping_charge'],
143 + 'cod_fee' => $data['order_cod_fee'],
144 + 'use_point' => $data['order_usedpoint'],
145 + 'carts' => usces_get_ordercartdata( $data['ID'] ),
146 + 'condition' => wel_safe_unserialize( $data['order_condition'] ),
147 + );
148 + $tax_str = '( ' . usces_crform( usces_internal_tax( $materials, 'return' ), true, false, 'return' ) . ' )';
149 + } elseif ( array_key_exists( 'tax', $data ) ) {
150 + $item_total_price = $usces->get_total_price( $data['cart'] );
151 + $materials = array(
152 + 'total_items_price' => $item_total_price,
153 + 'discount' => ( isset( $data['discount'] ) ) ? $data['discount'] : 0,
154 + 'shipping_charge' => ( isset( $data['shipping_charge'] ) ) ? $data['shipping_charge'] : 0,
155 + 'cod_fee' => ( isset( $data['cod_fee'] ) ) ? $data['cod_fee'] : 0,
156 + 'use_point' => ( isset( $data['usedpoint'] ) ) ? $data['usedpoint'] : 0,
157 + 'carts' => $data['cart'],
158 + );
159 + $tax_str = '( ' . usces_crform( usces_internal_tax( $materials, 'return' ), true, false, 'return' ) . ' )';
160 + } else {
161 + $materials = array();
162 + $tax_str = '( ' . usces_crform( usces_internal_tax( $materials, 'return' ), true, false, 'return' ) . ' )';
163 + }
164 + }
165 + $tax_str = apply_filters( 'usces_filter_tax', $tax_str );
166 + }
167 +
168 + if ( 'return' === $out ) {
169 + return wel_esc_script( $tax_str );
170 + } else {
171 + wel_esc_script_e( $tax_str );
172 + }
173 +}
174 +
175 +/**
176 + * Order data tax
177 + *
178 + * @param array $data Order data.
179 + * @param string $tax_mode 'exclude' or 'include'.
180 + * @return string
181 + */
182 +function usces_order_history_tax( $data, $tax_mode ) {
183 + global $usces;
184 +
185 + if ( 'exclude' === $tax_mode ) {
186 + $tax_str = usces_crform( $data['tax'], true, false, 'return' );
187 + } else {
188 + $materials = array(
189 + 'total_items_price' => $data['total_items_price'],
190 + 'discount' => $data['discount'],
191 + 'shipping_charge' => $data['shipping_charge'],
192 + 'cod_fee' => $data['cod_fee'],
193 + 'use_point' => $data['usedpoint'],
194 + 'carts' => $data['cart'],
195 + 'condition' => $data['condition'],
196 + );
197 + $tax_str = '( ' . usces_crform( usces_internal_tax( $materials, 'return' ), true, false, 'return' ) . ' )';
198 + }
199 + $tax_str = apply_filters( 'usces_filter_order_history_tax', $tax_str, $data, $tax_mode );
200 + return $tax_str;
201 +}
202 +
203 +/**
204 + * Tax-inclusive Calculation
205 + *
206 + * @param array $materials Breakdown of Amounts.
207 + * @param string $out Return value or echo.
208 + * @return string|void
209 + */
210 +function usces_internal_tax( $materials, $out = '' ) {
211 + global $usces;
212 +
213 + if ( ! usces_is_tax_display() ) {
214 + $tax = 0;
215 + } else {
216 + if ( ! empty( $materials['condition'] ) ) {
217 + $condition = $materials['condition'];
218 + } else {
219 + $condition = $usces->get_condition();
220 + }
221 + $reduced_taxrate = ( isset( $condition['applicable_taxrate'] ) && 'reduced' === $condition['applicable_taxrate'] ) ? true : false;
222 + if ( $reduced_taxrate ) {
223 + $usces_tax = Welcart_Tax::get_instance();
224 + $usces_tax->get_order_tax( $materials );
225 + $tax = apply_filters( 'usces_filter_internal_tax', $usces_tax->tax, $materials );
226 + } else {
227 + if ( 1 === (int) usces_point_coverage() ) {
228 + if ( 'products' === $condition['tax_target'] ) {
229 + $total = $materials['total_items_price'] + $materials['discount'];
230 + } else {
231 + $total = $materials['total_items_price'] + $materials['discount'] + $materials['shipping_charge'] + $materials['cod_fee'];
232 + }
233 + } else {
234 + if ( 'products' === $condition['tax_target'] ) {
235 + $total = $materials['total_items_price'] + $materials['discount'];
236 + } else {
237 + $use_point = ( empty( $materials['use_point'] ) ) ? 0 : $materials['use_point'];
238 + $total = $materials['total_items_price'] + $materials['discount'] - $use_point + $materials['shipping_charge'] + $materials['cod_fee'];
239 + }
240 + }
241 + $total = apply_filters( 'usces_filter_internal_tax_total', $total, $materials );
242 + $tax_rate = (float) $condition['tax_rate'];
243 + $tax_method = ( isset( $condition['tax_method'] ) ) ? $condition['tax_method'] : $usces->options['tax_method'];
244 + $tax = $total * $tax_rate / 100;
245 + $tax = $total - $total / ( 1 + ( $tax_rate / 100 ) );
246 + $tax = usces_tax_rounding_off( $tax, $tax_method );
247 + $tax = apply_filters( 'usces_filter_internal_tax', $tax, $materials );
248 + }
249 + }
250 +
251 + if ( 'return' === $out ) {
252 + return wel_esc_script( $tax );
253 + } else {
254 + wel_esc_script_e( $tax );
255 + }
256 +}
257 +
258 +/**
259 + * Currency Symbol
260 + *
261 + * @param string $out Return value or echo.
262 + * @return string|void
263 + */
264 +function usces_currency_symbol( $out = '' ) {
265 + global $usces;
266 +
267 + if ( 'return' === $out ) {
268 + return $usces->getCurrencySymbol();
269 + } else {
270 + echo esc_html( $usces->getCurrencySymbol() );
271 + }
272 +}
273 +
274 +/**
275 + * Error Verification
276 + *
277 + * @return bool
278 + */
279 +function usces_is_error_message() {
280 + global $usces;
281 +
282 + if ( '' !== $usces->error_message ) {
283 + return true;
284 + } else {
285 + return false;
286 + }
287 +}
288 +
289 +/**
290 + * Is item
291 + *
292 + * @param int $post_id Post ID.
293 + * @return bool
294 + */
295 +function usces_is_item( $post_id = null ) {
296 + if ( null === $post_id ) {
297 + global $post;
298 + if ( empty( $post->ID ) ) {
299 + return false;
300 + }
301 + $post_id = $post->ID;
302 + }
303 + $product = wel_get_product( $post_id );
304 + if ( isset( $product['_pst'] ) && 'item' === $product['_pst']->post_mime_type ) {
305 + return true;
306 + } else {
307 + return false;
308 + }
309 +}
310 +
311 +/**
312 + * Item code
313 + *
314 + * @param string $out Return value or echo.
315 + * @return string|void
316 + */
317 +function usces_the_itemCode( $out = '' ) {
318 + global $post;
319 +
320 + $product = wel_get_product( $post->ID );
321 + $str = $product['itemCode'];
322 +
323 + if ( 'return' === $out ) {
324 + return $str;
325 + } else {
326 + echo esc_html( $str );
327 + }
328 +}
329 +
330 +/**
331 + * Item name
332 + *
333 + * @param string $out Return value or echo.
334 + * @param object $post Post data.
335 + * @return string|void
336 + */
337 +function usces_the_itemName( $out = '', $post = null ) {
338 + if ( null === $post ) {
339 + global $post;
340 + }
341 +
342 + $product = wel_get_product( $post );
343 + $str = $product['itemName'];
344 +
345 + if ( 'return' === $out ) {
346 + return $str;
347 + } else {
348 + echo esc_html( $str );
349 + }
350 +}
351 +
352 +/**
353 + * Point rate
354 + *
355 + * @param string $out Return value or echo.
356 + * @return string|void
357 + */
358 +function usces_the_point_rate( $out = '' ) {
359 + global $post;
360 +
361 + $product = wel_get_product( $post );
362 + $str = $product['itemPointrate'];
363 + $rate = (int) $str;
364 +
365 + if ( 'return' === $out ) {
366 + return $rate;
367 + } else {
368 + echo esc_html( $rate );
369 + }
370 +}
371 +
372 +/**
373 + * Shipment
374 + *
375 + * @param string $out Return value or echo.
376 + * @return string|void
377 + */
378 +function usces_the_shipment_aim( $out = '' ) {
379 + global $post;
380 +
381 + $product = wel_get_product( $post );
382 + $str = $product['itemShipping'];
383 + $no = (int) $str;
384 + if ( 0 === $no ) {
385 + return '';
386 + }
387 + $rules = get_option( 'usces_shipping_rule', array() );
388 +
389 + if ( 'return' === $out ) {
390 + return $rules[ $no ];
391 + } else {
392 + echo esc_html( $rules[ $no ] );
393 + }
394 +}
395 +
396 +/**
397 + * Current item
398 + */
399 +function usces_the_item() {
400 + global $usces, $post;
401 +
402 + $usces->itemskus = wel_get_skus( $post );
403 + $usces->current_itemsku = -1;
404 + $usces->itemopts = wel_get_opts( $post );
405 + $usces->current_itemopt = -1;
406 +
407 + return;
408 +}
409 +
410 +/**
411 + * Get item meta
412 + *
413 + * @param string $metakey Meta key.
414 + * @param int $post_id Post ID.
415 + * @param string $out Return value or echo.
416 + * @return string|void
417 + */
418 +function usces_get_itemMeta( $metakey, $post_id, $out = '' ) {
419 + $product = wel_get_product( $post_id );
420 + $reserved_key = ltrim( $metakey, '_' );
421 +
422 + if ( array_key_exists( $reserved_key, $product ) ) {
423 + $meta = $product[ $reserved_key ];
424 + } else {
425 + $meta = $product[ $metakey ];
426 + }
427 + if ( is_array( $meta ) ) {
428 + $value = $meta[0];
429 + } else {
430 + $value = $meta;
431 + }
432 +
433 + if ( 'return' === $out ) {
434 + return $value;
435 + } else {
436 + echo esc_html( $value );
437 + }
438 +}
439 +
440 +/**
441 + * Count SKU
442 + *
443 + * @return int
444 + */
445 +function usces_sku_num() {
446 + global $usces;
447 +
448 + $sku_num = ( ! empty( $usces->itemskus ) && is_array( $usces->itemskus ) ) ? count( $usces->itemskus ) : 0;
449 + return $sku_num;
450 +}
451 +
452 +/**
453 + * Is SKU
454 + *
455 + * @return bool
456 + */
457 +function usces_is_skus() {
458 + global $usces;
459 +
460 + if ( ! empty( $usces->itemskus ) && is_array( $usces->itemskus ) && 0 < count( $usces->itemskus ) ) {
461 + $usces->current_itemsku = -1;
462 + reset( $usces->itemskus );
463 + $usces->itemsku = array();
464 + return true;
465 + } else {
466 + return false;
467 + }
468 +}
469 +
470 +/**
471 + * Reset SKU
472 + */
473 +function usces_reset_skus() {
474 + global $usces;
475 +
476 + $usces->current_itemsku = -1;
477 + reset( $usces->itemskus );
478 +}
479 +
480 +/**
481 + * Have SKU
482 + *
483 + * @return bool
484 + */
485 +function usces_have_skus() {
486 + global $usces;
487 +
488 + if ( null === $usces->current_itemsku ) {
489 + $usces->current_itemsku = -1;
490 + }
491 +
492 + if ( $usces->current_itemsku + 1 < usces_sku_num() ) {
493 + $usces->current_itemsku++;
494 + $usces->itemsku = $usces->itemskus[ $usces->current_itemsku ];
495 + return true;
496 + } else {
497 + return false;
498 + }
499 +}
500 +
501 +/**
502 + * SKU data
503 + *
504 + * @param string $out Return value or echo.
505 + * @return string|void
506 + */
507 +function usces_the_itemSku( $out = '' ) {
508 + global $usces;
509 +
510 + $skucode = isset( $usces->itemsku['code'] ) ? $usces->itemsku['code'] : '';
511 + if ( 'return' === $out ) {
512 + return $skucode;
513 + } else {
514 + echo esc_attr( $skucode );
515 + }
516 +}
517 +
518 +/**
519 + * SKU price
520 + *
521 + * @param string $out Return value or echo.
522 + * @return int|void
523 + */
524 +function usces_the_itemPrice( $out = '' ) {
525 + global $usces;
526 +
527 + if ( 'return' === $out ) {
528 + return $usces->itemsku['price'];
529 + } else {
530 + echo number_format( $usces->itemsku['price'] );
531 + }
532 +}
533 +
534 +/**
535 + * SKU normal price
536 + *
537 + * @param string $out Return value or echo.
538 + * @return int|void
539 + */
540 +function usces_the_itemCprice( $out = '' ) {
541 + global $usces;
542 +
543 + if ( 'return' === $out ) {
544 + return $usces->itemsku['cprice'];
545 + } else {
546 + echo number_format( $usces->itemsku['cprice'] );
547 + }
548 +}
549 +
550 +/**
551 + * Formatted SKU price
552 + *
553 + * @param string $out Return value or echo.
554 + * @return string|void
555 + */
556 +function usces_the_itemPriceCr( $out = '' ) {
557 + global $usces;
558 +
559 + $res = $usces->get_currency( $usces->itemsku['price'], true, false );
560 + $res = apply_filters( 'usces_filter_the_item_price_cr', $res, $usces->itemsku['price'], $out );
561 +
562 + if ( 'return' === $out ) {
563 + return $res;
564 + } else {
565 + echo esc_html( $res );
566 + }
567 +}
568 +
569 +/**
570 + * Formatted normal SKU price
571 + *
572 + * @param string $out Return value or echo.
573 + * @return string|void
574 + */
575 +function usces_the_itemCpriceCr( $out = '' ) {
576 + global $usces;
577 +
578 + $res = $usces->get_currency( $usces->itemsku['cprice'], true, false );
579 + $res = apply_filters( 'usces_filter_the_item_cprice_cr', $res, $usces->itemsku['cprice'], $out );
580 +
581 + if ( 'return' === $out ) {
582 + return $res;
583 + } else {
584 + echo esc_html( $res );
585 + }
586 +}
587 +
588 +/**
589 + * Currency code
590 + *
591 + * @param string $out Return value or echo.
592 + * @return string|void
593 + */
594 +function usces_crcode( $out = '' ) {
595 + global $usces;
596 +
597 + $res = esc_html( $usces->get_currency_code() );
598 +
599 + if ( 'return' === $out ) {
600 + return $res;
601 + } else {
602 + echo __( $res, 'usces' );
603 + }
604 +}
605 +
606 +/**
607 + * Currency symbol code
608 + *
609 + * @param string $out Return value or echo.
610 + * @param string $js Use js.
611 + * @return string|void
612 + */
613 +function usces_crsymbol( $out = '', $js = '' ) {
614 + global $usces;
615 +
616 + $res = $usces->getCurrencySymbol();
617 + if ( 'js' === $js && '&yen;' == $res ) {
618 + $res = mb_convert_encoding( $res, 'UTF-8', 'HTML-ENTITIES' );
619 + }
620 + if ( 'return' === $out ) {
621 + return $res;
622 + } else {
623 + echo esc_html( $res );
624 + }
625 +}
626 +
627 +/**
628 + * Stock
629 + *
630 + * @param string $out Return value or echo.
631 + * @return string|void
632 + */
633 +function usces_the_itemZaiko( $out = '' ) {
634 + global $usces, $post;
635 +
636 + $item_order_acceptable = $usces->getItemOrderAcceptable( $post->ID );
637 + $num = (int) $usces->itemsku['stock'];
638 + $stocknum = $usces->itemsku['stocknum'];
639 +
640 + if ( 1 !== $item_order_acceptable || WCUtils::is_blank( $stocknum ) ) {
641 + if ( 1 < $num || ( 0 === (int) $usces->itemsku['stocknum'] && ! WCUtils::is_blank( $usces->itemsku['stocknum'] ) ) ) {
642 + $res = $usces->zaiko_status[ $num ];
643 + } elseif ( 1 >= $num && ( 0 === (int) $usces->itemsku['stocknum'] && ! WCUtils::is_blank( $usces->itemsku['stocknum'] ) ) ) {
644 + $res = $usces->zaiko_status[2];
645 + } else {
646 + $res = $usces->zaiko_status[ $num ];
647 + }
648 + } else {
649 + if ( 1 < $num ) {
650 + $res = $usces->zaiko_status[ $num ];
651 + } elseif ( 1 >= $num && 0 >= (int) $stocknum ) {
652 + $res = ( ! empty( $usces->options['order_acceptable_label'] ) ) ? $usces->options['order_acceptable_label'] : __( 'Order acceptable', 'usces' );
653 + } else {
654 + $res = $usces->zaiko_status[ $num ];
655 + }
656 + }
657 +
658 + if ( 'return' === $out ) {
659 + return $res;
660 + } else {
661 + echo esc_html( $res );
662 + }
663 +}
664 +
665 +/**
666 + * Stock status
667 + *
668 + * @param string $out Return value or echo.
669 + * @return string|void
670 + */
671 +function usces_the_itemZaikoStatus( $out = '' ) {
672 + global $usces;
673 +
674 + if ( 'return' === $out ) {
675 + return usces_get_itemZaiko( 'name' );
676 + } else {
677 + echo esc_html( usces_get_itemZaiko( 'name' ) );
678 + }
679 +}
680 +
681 +/**
682 + * SKU stock
683 + *
684 + * @param string $field Key.
685 + * @param int $post_id Post ID.
686 + * @param string $sku SKU code.
687 + * @return string
688 + */
689 +function usces_get_itemZaiko( $field = 'name', $post_id = null, $sku = null ) {
690 + global $usces;
691 +
692 + if ( null === $post_id ) {
693 + global $post;
694 + $post_id = $post->ID;
695 + }
696 +
697 + if ( empty( $sku ) && ! empty( $usces->itemsku ) ) {
698 + $num = (int) $usces->itemsku['stock'];
699 + $stocknum = $usces->itemsku['stocknum'];
700 + } else {
701 + $skus = wel_get_skus( $post_id, 'code' );
702 + if ( null === $skus || ! isset( $skus[ $sku ] ) ) {
703 + return false;
704 + }
705 + $num = (int) $skus[ $sku ]['stock'];
706 + $stocknum = $skus[ $sku ]['stocknum'];
707 + }
708 +
709 + if ( 'id' === $field ) {
710 + $res = $num;
711 + } else {
712 + $item_order_acceptable = $usces->getItemOrderAcceptable( $post_id );
713 + if ( 1 !== (int) $item_order_acceptable || WCUtils::is_blank( $stocknum ) ) {
714 + $res = $usces->zaiko_status[ $num ];
715 + } else {
716 + if ( 2 > $num && 0 >= (int) $stocknum ) {
717 + $res = ( ! empty( $usces->options['order_acceptable_label'] ) ) ? $usces->options['order_acceptable_label'] : __( 'Order acceptable', 'usces' );
718 + } else {
719 + $res = $usces->zaiko_status[ $num ];
720 + }
721 + }
722 + }
723 + return $res;
724 +}
725 +
726 +/**
727 + * SKU stock
728 + *
729 + * @param string $out Return value or echo.
730 + * @return int|void
731 + */
732 +function usces_the_itemZaikoNum( $out = '' ) {
733 + global $usces;
734 +
735 + if ( ! isset( $usces->itemsku['stocknum'] ) ) {
736 + return false;
737 + }
738 +
739 + $num = $usces->itemsku['stocknum'];
740 + if ( '' !== $num ) {
741 + $num = (int) $num;
742 + }
743 +
744 + if ( 'return' === $out ) {
745 + return $num;
746 + } else {
747 + echo number_format( $num );
748 + }
749 +}
750 +
751 +/**
752 + * SKU title
753 + *
754 + * @param string $out Return value or echo.
755 + * @return string|void
756 + */
757 +function usces_the_itemSkuDisp( $out = '' ) {
758 + global $usces;
759 +
760 + if ( ! isset( $usces->itemsku['name'] ) ) {
761 + return false;
762 + }
763 +
764 + if ( 'return' === $out ) {
765 + return $usces->itemsku['name'];
766 + } else {
767 + echo esc_html( $usces->itemsku['name'] );
768 + }
769 +}
770 +
771 +/**
772 + * SKU unit
773 + *
774 + * @param string $out Return value or echo.
775 + * @return string|void
776 + */
777 +function usces_the_itemSkuUnit( $out = '' ) {
778 + global $usces;
779 +
780 + if ( ! isset( $usces->itemsku['unit'] ) ) {
781 + return false;
782 + }
783 +
784 + if ( 'return' === $out ) {
785 + return $usces->itemsku['unit'];
786 + } else {
787 + echo esc_html( $usces->itemsku['unit'] );
788 + }
789 +}
790 +
791 +/**
792 + * Top SKU code
793 + *
794 + * @param string $out Return value or echo.
795 + * @return string|void
796 + */
797 +function usces_the_firstSku( $out = '' ) {
798 + global $post, $usces;
799 +
800 + $post_id = $post->ID;
801 + $skus = wel_get_skus( $post_id );
802 +
803 + if ( null === $skus || ! isset( $skus[0]['code'] ) ) {
804 + return false;
805 + }
806 +
807 + if ( 'return' === $out ) {
808 + return $skus[0]['code'];
809 + } else {
810 + echo esc_html( $skus[0]['code'] );
811 + }
812 +}
813 +
814 +/**
815 + * Top SKU price
816 + *
817 + * @param string $out Return value or echo.
818 + * @param object $post Post data.
819 + * @return string|void
820 + */
821 +function usces_the_firstPrice( $out = '', $post = null ) {
822 + global $usces;
823 +
824 + if ( null === $post ) {
825 + global $post;
826 + }
827 + $post_id = $post->ID;
828 + $skus = wel_get_skus( $post_id );
829 +
830 + if ( empty( $skus ) ) {
831 + $price = null;
832 + } else {
833 + $price = $skus[0]['price'];
834 + }
835 +
836 + $price = apply_filters( 'usces_filter_the_first_price', $price, $post_id, $skus, $out );
837 +
838 + if ( 'return' === $out ) {
839 + return $price;
840 + } else {
841 + echo number_format( $price );
842 + }
843 +}
844 +
845 +/**
846 + * Top SKU normal price
847 + *
848 + * @param string $out Return value or echo.
849 + * @param object $post Post data.
850 + * @return string|void
851 + */
852 +function usces_the_firstCprice( $out = '', $post = null ) {
853 + global $usces;
854 +
855 + if ( null === $post ) {
856 + global $post;
857 + }
858 + $post_id = $post->ID;
859 + $skus = wel_get_skus( $post_id );
860 +
861 + if ( null === $skus || ! isset( $skus[0]['cprice'] ) ) {
862 + return false;
863 + }
864 +
865 + if ( 'return' === $out ) {
866 + return $skus[0]['cprice'];
867 + } else {
868 + echo number_format( $skus[0]['cprice'] );
869 + }
870 +}
871 +
872 +/**
873 + * Formatted top SKU price
874 + *
875 + * @param string $out Return value or echo.
876 + * @param object $post Post data.
877 + * @return string|void
878 + */
879 +function usces_the_firstPriceCr( $out = '', $post = null ) {
880 + global $usces;
881 +
882 + if ( null === $post ) {
883 + global $post;
884 + }
885 + $post_id = $post->ID;
886 + $skus = wel_get_skus( $post_id );
887 + if ( isset( $skus[0]['price'] ) ) {
888 + $res = $usces->get_currency( $skus[0]['price'], true, false );
889 + $price = apply_filters( 'usces_filter_the_first_price_cr', $res, $skus[0]['price'], $post_id, $skus, $out );
890 + } else {
891 + $price = apply_filters( 'usces_filter_the_first_price_cr', '', null, $post_id, $skus, $out );
892 + }
893 +
894 + if ( 'return' === $out ) {
895 + return $price;
896 + } else {
897 + echo esc_html( $price );
898 + }
899 +}
900 +
901 +/**
902 + * Formatted top SKU normal price
903 + *
904 + * @param string $out Return value or echo.
905 + * @param object $post Post data.
906 + * @return string|void
907 + */
908 +function usces_the_firstCpriceCr( $out = '', $post = null ) {
909 + global $usces;
910 +
911 + if ( null === $post ) {
912 + global $post;
913 + }
914 + $post_id = $post->ID;
915 + $skus = wel_get_skus( $post_id );
916 + if ( isset( $skus[0]['cprice'] ) ) {
917 + $res = $usces->get_currency( $skus[0]['cprice'], true, false );
918 + $cprice = apply_filters( 'usces_filter_the_first_cprice_cr', $res, $skus[0]['cprice'], $post_id, $skus, $out );
919 + } else {
920 + $cprice = apply_filters( 'usces_filter_the_first_cprice_cr', '', null, $post_id, $skus, $out );
921 + }
922 +
923 + if ( 'return' === $out ) {
924 + return $cprice;
925 + } else {
926 + echo esc_html( $cprice );
927 + }
928 +}
929 +
930 +/**
931 + * Top SKU stock
932 + *
933 + * @param string $out Return value or echo.
934 + * @param object $post Post data.
935 + * @return string|void
936 + */
937 +function usces_the_firstZaiko( $out = '', $post = null ) {
938 + global $usces;
939 +
940 + if ( null === $post ) {
941 + global $post;
942 + }
943 + $post_id = $post->ID;
944 + $skus = wel_get_skus( $post_id );
945 +
946 + if ( 'return' === $out ) {
947 + return $skus[0]['stock'];
948 + } else {
949 + echo esc_html( $skus[0]['stock'] );
950 + }
951 +}
952 +
953 +/**
954 + * Last SKU
955 + *
956 + * @param string $out Return value or echo.
957 + * @param object $post Post data.
958 + * @return string|void
959 + */
960 +function usces_the_lastSku( $out = '', $post = null ) {
961 + global $usces;
962 +
963 + if ( null === $post ) {
964 + global $post;
965 + }
966 + $post_id = $post->ID;
967 + $skus = wel_get_skus( $post_id );
968 + $sku = end( $skus );
969 +
970 + if ( 'return' === $out ) {
971 + return $sku['code'];
972 + } else {
973 + echo esc_html( $sku['code'] );
974 + }
975 +}
976 +
977 +/**
978 + * Last SKU price
979 + *
980 + * @param string $out Return value or echo.
981 + * @param object $post Post data.
982 + * @return string|void
983 + */
984 +function usces_the_lastPrice( $out = '', $post = null ) {
985 + global $usces;
986 +
987 + if ( null === $post ) {
988 + global $post;
989 + }
990 + $post_id = $post->ID;
991 + $skus = wel_get_skus( $post_id );
992 + $sku = end( $skus );
993 +
994 + if ( 'return' === $out ) {
995 + return $sku['price'];
996 + } else {
997 + echo number_format( $sku['price'] );
998 + }
999 +}
1000 +
1001 +/**
1002 + * Last SKU stock
1003 + *
1004 + * @param string $out Return value or echo.
1005 + * @param object $post Post data.
1006 + * @return string|void
1007 + */
1008 +function usces_the_lastZaiko( $out = '', $post = null ) {
1009 + global $usces;
1010 +
1011 + if ( null === $post ) {
1012 + global $post;
1013 + }
1014 + $post_id = $post->ID;
1015 + $skus = wel_get_skus( $post_id );
1016 + $sku = end( $skus );
1017 +
1018 + if ( 'return' === $out ) {
1019 + return $sku['stock'];
1020 + } else {
1021 + echo esc_html( $sku['stock'] );
1022 + }
1023 +}
1024 +
1025 +/**
1026 + * In stock
1027 + *
1028 + * @return bool
1029 + */
1030 +function usces_have_zaiko() {
1031 + global $post, $usces;
1032 +
1033 + $post_id = isset( $post->ID ) ? $post->ID : 0;
1034 + $sku_code = isset( $usces->itemsku['code'] ) ? $usces->itemsku['code'] : '';
1035 +
1036 + return $usces->is_item_zaiko( $post_id, $sku_code );
1037 +}
1038 +
1039 +/**
1040 + * In stock
1041 + *
1042 + * @param int $post_id Post ID.
1043 + * @return bool
1044 + */
1045 +function usces_have_zaiko_anyone( $post_id = null ) {
1046 + global $post, $usces;
1047 +
1048 + if ( null === $post_id ) {
1049 + $post_id = $post->ID;
1050 + }
1051 +
1052 + $skus = wel_get_skus( $post_id );
1053 + $status = false;
1054 +
1055 + foreach ( $skus as $sku ) {
1056 + if ( $usces->is_item_zaiko( $post_id, $sku['code'] ) ) {
1057 + $status = true;
1058 + break;
1059 + }
1060 + }
1061 + return apply_filters( 'usces_have_zaiko_anyone', $status, $post_id, $skus );
1062 +}
1063 +
1064 +/**
1065 + * Low or not stock
1066 + *
1067 + * @param int $post_id Post ID.
1068 + * @return bool
1069 + */
1070 +function usces_have_fewstock( $post_id = null ) {
1071 + global $post, $usces;
1072 +
1073 + if ( null === $post_id ) {
1074 + $post_id = $post->ID;
1075 + }
1076 +
1077 + $skus = wel_get_skus( $post_id );
1078 + $res = false;
1079 + foreach ( $skus as $sku ) {
1080 + if ( 1 === (int) $sku['stock'] ) {
1081 + $res = true;
1082 + break;
1083 + }
1084 + }
1085 + return $res;
1086 +}
1087 +
1088 +/**
1089 + * Is applied large-lot discount
1090 + *
1091 + * @param int $post_id Post ID.
1092 + * @param string $sku SKU code.
1093 + * @param int $quant Quantity.
1094 + * @return bool
1095 + */
1096 +function usces_is_gptekiyo( $post_id, $sku, $quant ) {
1097 + global $usces;
1098 + return $usces->is_gptekiyo( $post_id, $sku, $quant );
1099 +}
1100 +
1101 +/**
1102 + * Large-lot discount
1103 + *
1104 + * @param string $out Return value or echo.
1105 + * @return string|void
1106 + */
1107 +function usces_the_itemGpExp( $out = '' ) {
1108 + global $post, $usces;
1109 +
1110 + $post_id = $post->ID;
1111 + $sku = $usces->itemsku['code'];
1112 + $gpn1 = $usces->getItemGpNum1( $post_id );
1113 + $gpn2 = $usces->getItemGpNum2( $post_id );
1114 + $gpn3 = $usces->getItemGpNum3( $post_id );
1115 + $gpd1 = $usces->getItemGpDis1( $post_id );
1116 + $gpd2 = $usces->getItemGpDis2( $post_id );
1117 + $gpd3 = $usces->getItemGpDis3( $post_id );
1118 + $unit = $usces->getItemSkuUnit( $post_id, $sku );
1119 + $price = $usces->getItemPrice( $post_id, $sku );
1120 +
1121 + if ( ( 0 === (int) $usces->itemsku['gp'] ) || empty( $gpn1 ) || empty( $gpd1 ) ) {
1122 + return;
1123 + }
1124 +
1125 + if ( ( isset( $usces->options['tax_display'] ) && 'deactivate' === $usces->options['tax_display'] ) || ( isset( $usces->options['tax_mode'] ) && 'include' === $usces->options['tax_mode'] ) ) {
1126 + $tax_rate = 0;
1127 + } else {
1128 + $usces_tax = Welcart_Tax::get_instance();
1129 + $tax_rate = $usces_tax->get_sku_tax_rate( $post_id, $sku );
1130 + }
1131 +
1132 + $html = "<dl class='itemGpExp'>\n<dt>" . apply_filters( 'usces_filter_itemGpExp_title', __( 'Business package discount', 'usces' ) ) . "</dt>\n<dd>\n<ul>\n";
1133 + if ( ! empty( $gpn1 ) && ! empty( $gpd1 ) ) {
1134 + if ( empty( $gpn2 ) || empty( $gpd2 ) ) {
1135 + $price1 = wel_gp_price_discount( $price, $gpd1 );
1136 + $html .= '<li>';
1137 + $html .= sprintf( __( '<span class=%5$s>%1$s</span>%2$s par 1%3$s for more than %4$s%3$s', 'usces' ),
1138 + $usces->get_currency( $price1, true, false ),
1139 + $usces->getGuidTax(),
1140 + esc_html( $unit ),
1141 + $gpn1,
1142 + "'price'"
1143 + );
1144 + if ( 0 < $tax_rate ) {
1145 + $html .= usces_crform_the_itemGpExp_taxincluded( $price1, $tax_rate );
1146 + }
1147 + $html .= "</li>\n";
1148 + } else {
1149 + $price1 = wel_gp_price_discount( $price, $gpd1 );
1150 + $html .= '<li>';
1151 + $html .= sprintf( __( '<span class=%6$s>%1$s</span>%2$s par 1%3$s for %4$s-%5$s%3$s', 'usces' ),
1152 + $usces->get_currency( $price1, true, false ),
1153 + $usces->getGuidTax(),
1154 + esc_html( $unit ),
1155 + $gpn1,
1156 + $gpn2 - 1,
1157 + "'price'"
1158 + );
1159 + if ( 0 < $tax_rate ) {
1160 + $html .= usces_crform_the_itemGpExp_taxincluded( $price1, $tax_rate );
1161 + }
1162 + $html .= "</li>\n";
1163 + if ( empty( $gpn3 ) || empty( $gpd3 ) ) {
1164 + $price2 = wel_gp_price_discount( $price, $gpd2 );
1165 + $html .= '<li>';
1166 + $html .= sprintf( __( '<span class=%5$s>%1$s</span>%2$s par 1%3$s for more than %4$s%3$s', 'usces' ),
1167 + $usces->get_currency( $price2, true, false ),
1168 + $usces->getGuidTax(),
1169 + esc_html( $unit ),
1170 + $gpn2,
1171 + "'price'"
1172 + );
1173 + if ( 0 < $tax_rate ) {
1174 + $html .= usces_crform_the_itemGpExp_taxincluded( $price2, $tax_rate );
1175 + }
1176 + $html .= "</li>\n";
1177 + } else {
1178 + $price2 = wel_gp_price_discount( $price, $gpd2 );
1179 + $html .= '<li>';
1180 + $html .= sprintf( __( '<span class=%6$s>%1$s</span>%2$s par 1%3$s for %4$s-%5$s%3$s', 'usces' ),
1181 + $usces->get_currency( $price2, true, false ),
1182 + $usces->getGuidTax(),
1183 + esc_html( $unit ),
1184 + $gpn2,
1185 + $gpn3 - 1,
1186 + "'price'"
1187 + );
1188 + if ( 0 < $tax_rate ) {
1189 + $html .= usces_crform_the_itemGpExp_taxincluded( $price2, $tax_rate );
1190 + }
1191 + $html .= "</li>\n";
1192 + $price3 = wel_gp_price_discount( $price, $gpd3 );
1193 + $html .= '<li>';
1194 + $html .= sprintf( __( '<span class=%5$s>%1$s</span>%2$s par 1%3$s for more than %4$s%3$s', 'usces' ),
1195 + $usces->get_currency( $price3, true, false ),
1196 + $usces->getGuidTax(),
1197 + esc_html( $unit ),
1198 + $gpn3,
1199 + "'price'"
1200 + );
1201 + if ( 0 < $tax_rate ) {
1202 + $html .= usces_crform_the_itemGpExp_taxincluded( $price3, $tax_rate );
1203 + }
1204 + $html .= "</li>\n";
1205 + }
1206 + }
1207 + }
1208 + $html .= '</ul></dd></dl>';
1209 +
1210 + $html = apply_filters( 'usces_filter_itemGpExp', $html );
1211 +
1212 + if ( 'return' === $out ) {
1213 + return $html;
1214 + } else {
1215 + echo $html; // no escape due to filter.
1216 + }
1217 +}
1218 +
1219 +/**
1220 + * Calculation of the discount based on the unit price per float.
1221 + *
1222 + * @param float $price Price.
1223 + * @param int $rate Discount rate.
1224 + * @return float
1225 + */
1226 +function wel_gp_price_discount( $price, $rate ) {
1227 + global $usces;
1228 +
1229 + $decimal = $usces->get_currency_decimal();
1230 + if ( 0 === (int) $decimal ) {
1231 + $discount = round( $price * ( 100 - $rate ) / 100 );
1232 + } else {
1233 + $discount = (float) sprintf( "%.{$decimal}f", (float) $price * ( 100 - $rate ) / 100 );
1234 + }
1235 + return $discount;
1236 +}
1237 +
1238 +/**
1239 + * Formatted tax included amount
1240 + *
1241 + * @param float $price Price.
1242 + * @param float $tax_rate Tax rate.
1243 + * @param bool $label_pre Forward label.
1244 + * @param string $label Label.
1245 + * @param string $start_tag Start tag.
1246 + * @param string $end_tag End tag.
1247 + * @param bool $symbol_pre Forward symbol.
1248 + * @param bool $symbol_post Backward symbol.
1249 + * @param bool $seperator_flag Seperator.
1250 + * @return string
1251 + */
1252 +function usces_crform_the_itemGpExp_taxincluded( $price, $tax_rate, $label_pre = true, $label = '', $start_tag = '', $end_tag = '', $symbol_pre = true, $symbol_post = false, $seperator_flag = true ) {
1253 + global $usces;
1254 +
1255 + if ( ( isset( $usces->options['tax_display'] ) && 'deactivate' === $usces->options['tax_display'] ) || ( isset( $usces->options['tax_mode'] ) && 'include' === $usces->options['tax_mode'] ) ) {
1256 + $res = '';
1257 + } else {
1258 + $tax = (float) sprintf( '%.3f', (float) $price * (float) $tax_rate / 100 );
1259 + $tax = usces_tax_rounding_off( $tax );
1260 + $price_gpexp = esc_html( $usces->get_currency( $price + $tax, $symbol_pre, $symbol_post, $seperator_flag ) );
1261 + if ( empty( $label ) ) {
1262 + $label_tag = '<em class="tax tax_inc_label">' . __( 'tax-included', 'usces' ) . '</em>';
1263 + } else {
1264 + $label_tag = '<em class="tax tax_inc_label">' . $label . '</em>';
1265 + }
1266 + if ( empty( $start_tag ) ) {
1267 + $start_tag = '<span class="tax_inc_block">( ';
1268 + }
1269 + if ( $label_pre ) {
1270 + $start_tag = $start_tag . $label_tag;
1271 + }
1272 + if ( empty( $end_tag ) ) {
1273 + $end_tag = ' )</span>';
1274 + }
1275 + if ( true !== $label_pre ) {
1276 + $end_tag = $label_tag . $end_tag;
1277 + }
1278 + $res = apply_filters( 'usces_filter_crform_the_itemGpExp_taxincluded', $start_tag . $price_gpexp . $end_tag, $price, $tax_rate, $label_pre, $label, $symbol_pre, $symbol_post, $seperator_flag );
1279 + }
1280 + return $res;
1281 +}
1282 +
1283 +/**
1284 + * Quantity field
1285 + *
1286 + * @param string $out Return value or echo.
1287 + * @return string|void
1288 + */
1289 +function usces_the_itemQuant( $out = '' ) {
1290 + global $usces, $post;
1291 +
1292 + $post_id = $post->ID;
1293 + $sku = urlencode( $usces->itemsku['code'] );
1294 + $value = isset( $_SESSION['usces_singleitem']['quant'][ $post_id ][ $sku ] ) ? $_SESSION['usces_singleitem']['quant'][ $post_id ][ $sku ] : 1;
1295 + $quant = "<input name=\"quant[{$post_id}][" . $sku . "]\" type=\"text\" id=\"quant[{$post_id}][" . $sku . "]\" class=\"skuquantity\" value=\"" . esc_attr( $value ) . "\" onKeyDown=\"if (event.keyCode == 13) {return false;}\" />";
1296 + $html = apply_filters( 'usces_filter_the_itemQuant', $quant, $post );
1297 +
1298 + if ( 'return' === $out ) {
1299 + return $html;
1300 + } else {
1301 + echo $html; // no escape due to filter.
1302 + }
1303 +}
1304 +
1305 +/**
1306 + * Add to Cart
1307 + *
1308 + * @param mixed $value Value.
1309 + * @param int $type Submit or button.
1310 + * @param string $out Return value or echo.
1311 + * @return string|void
1312 + */
1313 +function usces_the_itemSkuButton( $value, $type = 0, $out = '' ) {
1314 + global $usces, $post;
1315 +
1316 + $post_id = (int) $post->ID;
1317 + $zaikonum = esc_attr( $usces->itemsku['stocknum'] );
1318 + $zaiko_status = esc_attr( $usces->itemsku['stock'] );
1319 + $gptekiyo = esc_attr( $usces->itemsku['gp'] );
1320 + $skuprice = esc_attr( $usces->getItemPrice( $post_id, $usces->itemsku['code'] ) );
1321 + $value = esc_attr( apply_filters( 'usces_filter_incart_button_label', $value ) );
1322 + $sku = esc_attr( urlencode( $usces->itemsku['code'] ) );
1323 +
1324 + if ( 1 === (int) $type ) {
1325 + $type = 'button';
1326 + } else {
1327 + $type = 'submit';
1328 + }
1329 + $html = "<input name=\"zaikonum[{$post_id}][{$sku}]\" type=\"hidden\" id=\"zaikonum[{$post_id}][{$sku}]\" value=\"{$zaikonum}\" />\n";
1330 + $html .= "<input name=\"zaiko[{$post_id}][{$sku}]\" type=\"hidden\" id=\"zaiko[{$post_id}][{$sku}]\" value=\"{$zaiko_status}\" />\n";
1331 + $html .= "<input name=\"gptekiyo[{$post_id}][{$sku}]\" type=\"hidden\" id=\"gptekiyo[{$post_id}][{$sku}]\" value=\"{$gptekiyo}\" />\n";
1332 + $html .= "<input name=\"skuPrice[{$post_id}][{$sku}]\" type=\"hidden\" id=\"skuPrice[{$post_id}][{$sku}]\" value=\"{$skuprice}\" />\n";
1333 + if ( $usces->use_js ) {
1334 + $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}' )\" />";
1335 + } else {
1336 + $html .= "<a name=\"cart_button\"></a><input name=\"inCart[{$post_id}][{$sku}]\" type=\"{$type}\" id=\"inCart[{$post_id}][{$sku}]\" class=\"skubutton\" value=\"{$value}\" />";
1337 + }
1338 + $html .= "<input name=\"usces_referer\" type=\"hidden\" value=\"" . esc_url( $_SERVER['REQUEST_URI'] ) . "\" />\n";
1339 + $html = apply_filters( 'usces_filter_item_sku_button', $html, $value, $type );
1340 +
1341 + if ( 'return' === $out ) {
1342 + return $html;
1343 + } else {
1344 + echo $html; // no escape due to filter.
1345 + }
1346 +}
1347 +
1348 +/**
1349 + * Add to Cart ( direct mode )
1350 + *
1351 + * @param int $post_id Post ID.
1352 + * @param string $sku SKU code.
1353 + * @param bool $force Force.
1354 + * @param mixed $value Value.
1355 + * @param bool $options Have options.
1356 + * @param string $out Return value or echo.
1357 + * @return string|void
1358 + */
1359 +function usces_direct_intoCart( $post_id, $sku, $force = false, $value = null, $options = null, $out = '' ) {
1360 + global $usces;
1361 +
1362 + if ( empty( $value ) ) {
1363 + $value = __( 'Add To Cart', 'usces' );
1364 + }
1365 + $skus = wel_get_skus( $post_id, 'code' );
1366 +
1367 + $zaikonum = $skus[ $sku ]['stocknum'];
1368 + $zaiko = $skus[ $sku ]['stock'];
1369 + $gptekiyo = $skus[ $sku ]['gp'];
1370 + $skuprice = $skus[ $sku ]['price'];
1371 + $enc_sku = urlencode( $sku );
1372 +
1373 + $usces->itemopts = wel_get_opts( $post_id, 'sort' );
1374 + $usces->current_itemopt = -1;
1375 +
1376 + $usces->itemsku = $skus[ $sku ];
1377 +
1378 + $html = "<form action=\"" . USCES_CART_URL . "\" method=\"post\" name=\"" . $post_id . '-' . $enc_sku . "\">\n";
1379 + $html .= "<input name=\"zaikonum[{$post_id}][{$enc_sku}]\" type=\"hidden\" id=\"zaikonum[{$post_id}][{$enc_sku}]\" value=\"" . esc_attr( $zaikonum ) . "\" />\n";
1380 + $html .= "<input name=\"zaiko[{$post_id}][{$enc_sku}]\" type=\"hidden\" id=\"zaiko[{$post_id}][{$enc_sku}]\" value=\"" . esc_attr( $zaiko ) . "\" />\n";
1381 + $html .= "<input name=\"gptekiyo[{$post_id}][{$enc_sku}]\" type=\"hidden\" id=\"gptekiyo[{$post_id}][{$enc_sku}]\" value=\"" . esc_attr( $gptekiyo ) . "\" />\n";
1382 + $html .= "<input name=\"skuPrice[{$post_id}][{$enc_sku}]\" type=\"hidden\" id=\"skuPrice[{$post_id}][{$enc_sku}]\" value=\"" . esc_attr( $skuprice ) . "\" />\n";
1383 +
1384 + if ( $options && usces_is_options() ) {
1385 + while ( usces_have_options() ) {
1386 + $html .= '<div class="itemopt_row">' . usces_get_itemopt_filed( $post_id, $sku, $usces->itemopt ) . "</div>\n";
1387 + }
1388 + }
1389 +
1390 + $html .= "<a name=\"cart_button\"></a><input name=\"inCart[{$post_id}][{$enc_sku}]\" type=\"submit\" id=\"inCart[{$post_id}][{$enc_sku}]\" class=\"skubutton\" value=\"" . esc_attr( $value ) . "\" " . apply_filters( 'usces_filter_direct_intocart_button', null, $post_id, $sku, $force, $options ) . ' />';
1391 + $html .= "<input name=\"usces_referer\" type=\"hidden\" value=\"" . esc_url( $_SERVER['REQUEST_URI'] ) . "\" />\n";
1392 + if ( $force ) {
1393 + $html .= "<input name=\"usces_force\" type=\"hidden\" value=\"incart\" />\n";
1394 + }
1395 + $html = apply_filters( 'usces_filter_single_item_inform', $html );
1396 +
1397 + $html .= '</form>';
1398 + $html .= '<div class="direct_error_message">' . usces_singleitem_error_message( $post_id, $sku, 'return' ) . '</div>' . "\n";
1399 +
1400 + if ( 'return' === $out ) {
1401 + return $html;
1402 + } else {
1403 + echo $html; // no escape due to filter.
1404 + }
1405 +}
1406 +
1407 +/**
1408 + * Product Image
1409 + *
1410 + * @param int $number Image number.
1411 + * @param int $width Width.
1412 + * @param int $height Height.
1413 + * @param object $post Post data.
1414 + * @param string $out Return value or echo.
1415 + * @param string $media Media.
1416 + * @return string|void
1417 + */
1418 +function usces_the_itemImage( $number = 0, $width = 60, $height = 60, $post = '', $out = '', $media = 'item' ) {
1419 + global $usces;
1420 +
1421 + if ( '' === $post ) {
1422 + global $post;
1423 + }
1424 + $post_id = $post->ID;
1425 +
1426 + $ptitle = '';
1427 + if ( is_string( $number ) ) {
1428 + $ptitle = $number;
1429 + }
1430 + if ( $ptitle ) {
1431 +
1432 + $picposts = new WP_Query( array( 'post_type' => 'attachment', 'name' => $ptitle ) );
1433 + $pictid = ( $picposts->have_posts() ) ? $picposts[0]->ID : 0;
1434 + $html = wp_get_attachment_image( $pictid, array( $width, $height ), false );
1435 + if ( 'item' === $media ) {
1436 + $product = wel_get_product( $post_id );
1437 + $code = $product['itemCode'];
1438 + if ( ! $code ) {
1439 + return false;
1440 + }
1441 + $name = $product['itemName'];
1442 +
1443 + $alt = trim( strip_tags( get_post_meta( $pictid, '_wp_attachment_image_alt', true ) ) );
1444 + if ( empty( $alt ) ) {
1445 + $alt = $code;
1446 + }
1447 + $alt = 'alt="' . esc_attr( $alt ) . '"';
1448 + $alt = apply_filters( 'usces_filter_img_alt', $alt, $post_id, $pictid, $width, $height );
1449 +
1450 + $html = preg_replace( '/alt=\"[^\"]*\"/', $alt, $html );
1451 +
1452 + $title = 'title="' . esc_attr( $name ) . '"';
1453 + $title = apply_filters( 'usces_filter_img_title', $title, $post_id, $pictid, $width, $height );
1454 +
1455 + $html = preg_replace( '/title=\"[^\"]+\"/', $title, $html );
1456 + $html = apply_filters( 'usces_filter_main_img', $html, $post_id, $pictid, $width, $height );
1457 + }
1458 +
1459 + } else {
1460 +
1461 + $product = wel_get_product( $post_id );
1462 + $code = $product['itemCode'];
1463 + if ( ! $code ) {
1464 + return false;
1465 + }
1466 + $name = $product['itemName'];
1467 +
1468 + if ( 0 === (int) $number ) {
1469 +
1470 + $pictid = (int) $usces->get_mainpictid( $code );
1471 + $html = wp_get_attachment_image( $pictid, array( $width, $height ), true );/* '<img src="#" height="60" width="60" alt="" />'; */
1472 + if ( 'item' === $media ) {
1473 + $alt = trim( strip_tags( get_post_meta( $pictid, '_wp_attachment_image_alt', true ) ) );
1474 + if ( empty( $alt ) ) {
1475 + $alt = $code;
1476 + }
1477 + $alt = 'alt="' . esc_attr( $alt ) . '"';
1478 + $alt = apply_filters( 'usces_filter_img_alt', $alt, $post_id, $pictid, $width, $height );
1479 +
1480 + $html = preg_replace( '/alt=\"[^\"]*\"/', $alt, $html );
1481 +
1482 + $title = 'title="' . esc_attr( $name ) . '"';
1483 + $title = apply_filters( 'usces_filter_img_title', $title, $post_id, $pictid, $width, $height );
1484 +
1485 + $html = preg_replace( '/title=\"[^\"]+\"/', $title, $html );
1486 + $html = apply_filters( 'usces_filter_main_img', $html, $post_id, $pictid, $width, $height );
1487 + }
1488 +
1489 + } else {
1490 +
1491 + $pictids = $usces->get_pictids( $code );
1492 + $ind = $number - 1;
1493 + $pictid = ( isset( $pictids[ $ind ] ) && (int) $pictids[ $ind ] ) ? $pictids[ $ind ] : 0;
1494 + $html = wp_get_attachment_image( $pictid, array( $width, $height ), false );/* '<img src="#" height="60" width="60" alt="" />'; */
1495 + if ( 'item' === $media ) {
1496 + $alt = trim( strip_tags( get_post_meta( $pictid, '_wp_attachment_image_alt', true ) ) );
1497 + if ( empty( $alt ) ) {
1498 + $alt = $code;
1499 + }
1500 + $alt = 'alt="' . esc_attr( $alt ) . '"';
1501 + $alt = apply_filters( 'usces_filter_img_alt', $alt, $post_id, $pictid, $width, $height );
1502 +
1503 + $html = preg_replace( '/alt=\"[^\"]*\"/', $alt, $html );
1504 +
1505 + $title = 'title="' . esc_attr( $name ) . '"';
1506 + $title = apply_filters( 'usces_filter_img_title', $title, $post_id, $pictid, $width, $height );
1507 +
1508 + $html = preg_replace( '/title=\"[^\"]+\"/', $title, $html );
1509 + $html = apply_filters( 'usces_filter_sub_img', $html, $post_id, $pictid, $width, $height );
1510 + }
1511 + }
1512 + }
1513 +
1514 + if ( 'return' === $out ) {
1515 + return wel_esc_script( $html );
1516 + } else {
1517 + wel_esc_script_e( $html );
1518 + }
1519 +}
1520 +
1521 +/**
1522 + * Product Image URL
1523 + *
1524 + * @param int $number Image number.
1525 + * @param string $out Return value or echo.
1526 + * @param object $post Post data.
1527 + * @return string|void
1528 + */
1529 +function usces_the_itemImageURL( $number = 0, $out = '', $post = '' ) {
1530 + global $usces;
1531 +
1532 + $ptitle = $number;
1533 + if ( $ptitle && is_string( $number ) ) {
1534 +
1535 + $picposts = new WP_Query( array( 'post_type' => 'attachment', 'name' => $ptitle ) );
1536 + $pictid = ( $picposts->have_posts() ) ? $picposts[0]->ID : 0;
1537 + $html = wp_get_attachment_url( $pictid );
1538 +
1539 + } else {
1540 +
1541 + if ( '' === $post ) {
1542 + global $post;
1543 + }
1544 + $post_id = $post->ID;
1545 + $product = wel_get_product( $post_id );
1546 + $code = $product['itemCode'];
1547 + if ( ! $code ) {
1548 + return false;
1549 + }
1550 + $name = $product['itemName'];
1551 + if ( 0 === (int) $number ) {
1552 + $pictid = (int) $usces->get_mainpictid( $code );
1553 + $html = wp_get_attachment_url( $pictid );
1554 + } else {
1555 + $pictids = $usces->get_pictids( $code );
1556 + $ind = $number - 1;
1557 + $pictid = ( isset( $pictids[ $ind ] ) && (int) $pictids[ $ind ] ) ? $pictids[ $ind ] : 0;
1558 + $html = wp_get_attachment_url( $pictid );
1559 + }
1560 + }
1561 +
1562 + if ( 'return' === $out ) {
1563 + return wel_esc_script( $html );
1564 + } else {
1565 + wel_esc_script_e( $html );
1566 + }
1567 +}
1568 +
1569 +/**
1570 + * Product Image caption
1571 + *
1572 + * @param int $number Image number.
1573 + * @param object $post Post data.
1574 + * @param string $out Return value or echo.
1575 + * @return string|void
1576 + */
1577 +function usces_the_itemImageCaption( $number = 0, $post = '', $out = '' ) {
1578 + global $usces;
1579 +
1580 + $ptitle = $number;
1581 + if ( $ptitle && 0 === (int) $number ) {
1582 +
1583 + $picposts = new WP_Query( array( 'post_type' => 'attachment', 'name' => $ptitle ) );
1584 + $excerpt = ( $picposts->have_posts() ) ? $picposts[0]->post_excerpt : '';
1585 +
1586 + } else {
1587 +
1588 + if ( '' === $post ) {
1589 + global $post;
1590 + }
1591 + $post_id = $post->ID;
1592 + $product = wel_get_product( $post_id );
1593 +
1594 + $code = $product['itemCode'];
1595 + if ( ! $code ) {
1596 + return false;
1597 + }
1598 + $name = $product['itemName'];
1599 +
1600 + if ( 0 === (int) $number ) {
1601 + $pictid = $usces->get_mainpictid( $code );
1602 + if ( $pictid ) {
1603 + $attach_ob = get_post( $pictid );
1604 + $excerpt = ( isset( $attach_ob->post_excerpt ) ) ? $attach_ob->post_excerpt : '';
1605 + } else {
1606 + $excerpt = '';
1607 + }
1608 + } else {
1609 + $pictids = $usces->get_pictids( $code );
1610 + $ind = $number - 1;
1611 + if ( isset( $pictids[ $ind ] ) ) {
1612 + $attach_ob = get_post( $pictids[ $ind ] );
1613 + $excerpt = ( isset( $attach_ob->post_excerpt ) ) ? $attach_ob->post_excerpt : '';
1614 + } else {
1615 + $excerpt = '';
1616 + }
1617 + }
1618 + }
1619 +
1620 + if ( 'return' === $out ) {
1621 + return $excerpt;
1622 + } else {
1623 + echo esc_html( $excerpt );
1624 + }
1625 +}
1626 +
1627 +/**
1628 + * Product Image description
1629 + *
1630 + * @param int $number Image number.
1631 + * @param object $post Post data.
1632 + * @param string $out Return value or echo.
1633 + * @return string|void
1634 + */
1635 +function usces_the_itemImageDescription( $number = 0, $post = '', $out = '' ) {
1636 + global $usces;
1637 +
1638 + $ptitle = $number;
1639 + if ( $ptitle && 0 === (int) $number ) {
1640 +
1641 + $picposts = new WP_Query( array( 'post_type' => 'attachment', 'name' => $ptitle ) );
1642 + $description = ( $picposts->have_posts() ) ? $picposts[0]->post_content : '';
1643 +
1644 + } else {
1645 +
1646 + if ( '' === $post ) {
1647 + global $post;
1648 + }
1649 + $post_id = $post->ID;
1650 + $product = wel_get_product( $post_id );
1651 +
1652 + $code = $product['itemCode'];
1653 + if ( ! $code ) {
1654 + return false;
1655 + }
1656 + $name = $product['itemName'];
1657 +
1658 + if ( 0 === (int) $number ) {
1659 + $pictid = $usces->get_mainpictid( $code );
1660 + if ( $pictid ) {
1661 + $attach_ob = get_post( $pictid );
1662 + $description = ( isset( $attach_ob->post_content ) ) ? $attach_ob->post_content : '';
1663 + } else {
1664 + $description = '';
1665 + }
1666 + } else {
1667 + $pictids = $usces->get_pictids( $code );
1668 + $ind = $number - 1;
1669 + if ( isset( $pictids[ $ind ] ) ) {
1670 + $attach_ob = get_post( $pictids[ $ind ] );
1671 + $description = ( isset( $attach_ob->post_content ) ) ? $attach_ob->post_content : '';
1672 + } else {
1673 + $description = '';
1674 + }
1675 + }
1676 + }
1677 +
1678 + if ( 'return' === $out ) {
1679 + return $description;
1680 + } else {
1681 + echo esc_html( $description );
1682 + }
1683 +}
1684 +
1685 +/**
1686 + * Product sub image
1687 + *
1688 + * @return array
1689 + */
1690 +function usces_get_itemSubImageNums() {
1691 + global $post, $usces;
1692 +
1693 + $post_id = $post->ID;
1694 + $res = array();
1695 +
1696 + $product = wel_get_product( $post_id );
1697 + $code = $product['itemCode'];
1698 + if ( ! $code ) {
1699 + return false;
1700 + }
1701 + $name = $product['itemName'];
1702 +
1703 + $pictids = $usces->get_pictids( $code );
1704 + $pictids_count = ( $pictids && is_array( $pictids ) ) ? count( $pictids ) : 0;
1705 + for ( $i = 1; $i <= $pictids_count; $i++ ) {
1706 + $res[] = $i;
1707 + }
1708 + return $res;
1709 +}
1710 +
1711 +/**
1712 + * Is item option
1713 + *
1714 + * @return bool
1715 + */
1716 +function usces_is_options() {
1717 + global $usces;
1718 +
1719 + if ( ! empty( $usces->itemopts ) && is_array( $usces->itemopts ) && 0 < count( $usces->itemopts ) ) {
1720 + reset( $usces->itemopts );
1721 + $usces->itemopt = array();
1722 + $usces->current_itemopt = -1;
1723 + return true;
1724 + } else {
1725 + return false;
1726 + }
1727 +}
1728 +
1729 +/**
1730 + * Have item option
1731 + *
1732 + * @return bool
1733 + */
1734 +function usces_have_options() {
1735 + global $usces;
1736 +
1737 + if ( null === $usces->current_itemopt ) {
1738 + $usces->current_itemopt = -1;
1739 + }
1740 +
1741 + if ( ! empty( $usces->itemopts ) && is_array( $usces->itemopts ) && ( $usces->current_itemopt + 1 < count( $usces->itemopts ) ) ) {
1742 + $usces->current_itemopt++;
1743 + $usces->itemopt = ( isset( $usces->itemopts[ $usces->current_itemopt ] ) ) ? $usces->itemopts[ $usces->current_itemopt ] : array();
1744 + return true;
1745 + } else {
1746 + return false;
1747 + }
1748 +}
1749 +
1750 +/**
1751 + * Item option name
1752 + *
1753 + * @return string
1754 + */
1755 +function usces_getItemOptName() {
1756 + global $usces;
1757 + return $usces->itemopt['name'];
1758 +}
1759 +
1760 +/**
1761 + * Item option name
1762 + *
1763 + * @param string $out Return value or echo.
1764 + * @return string|void
1765 + */
1766 +function usces_the_itemOptName( $out = '' ) {
1767 + global $usces;
1768 +
1769 + if ( 'return' === $out ) {
1770 + return $usces->itemopt['name'];
1771 + } else {
1772 + echo esc_html( $usces->itemopt['name'] );
1773 + }
1774 +}
1775 +
1776 +/**
1777 + * Item option field
1778 + *
1779 + * @param string $name Option name.
1780 + * @param string $label Label.
1781 + * @param string $out Return value or echo.
1782 + * @return string|void
1783 + */
1784 +function usces_the_itemOption( $name, $label = '#default#', $out = '' ) {
1785 + global $post, $usces;
1786 + $post_id = $post->ID;
1787 +
1788 + if ( '#default#' === $label ) {
1789 + $label = $name;
1790 + }
1791 +
1792 + $opts = wel_get_opts( $post_id, 'name' );
1793 + if ( ! $opts || ! isset( $opts[ $name ] ) ) {
1794 + return false;
1795 + }
1796 +
1797 + $opt = $opts[ $name ];
1798 + $opt['value'] = usces_change_line_break( $opt['value'] );
1799 + $means = (int) $opt['means'];
1800 + $essential = (int) $opt['essential'];
1801 +
1802 + $sku = esc_attr( urlencode( $usces->itemsku['code'] ) );
1803 + $optcode = esc_attr( urlencode( $name ) );
1804 + $name = esc_attr( $name );
1805 + $label = esc_attr( $label );
1806 +
1807 + $session_value = isset( $_SESSION['usces_singleitem']['itemOption'][ $post_id ][ $sku ][ $optcode ] ) ? $_SESSION['usces_singleitem']['itemOption'][ $post_id ][ $sku ][ $optcode ] : null;
1808 +
1809 + $html = '';
1810 + $html .= "\n<label for='itemOption[{$post_id}][{$sku}][{$optcode}]' class='iopt_label'>{$label}</label>\n";
1811 +
1812 + switch ( $means ) {
1813 + case 0: // Single-select.
1814 + case 1: // Multi-select.
1815 + $selects = explode( "\n", $opt['value'] );
1816 + $multiple = ( 0 === $means ) ? '' : ' multiple';
1817 + $multiple_array = ( 0 === $means ) ? '' : '[]';
1818 +
1819 + $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";
1820 + if ( 1 === $essential ) {
1821 + if ( 0 === $means && ( '#NONE#' === $session_value || null === $session_value ) ) {
1822 + $selected = ' selected="selected"';
1823 + } else {
1824 + $selected = '';
1825 + }
1826 + $html .= "\t<option value='#NONE#'{$selected}>" . __( 'Choose', 'usces' ) . "</option>\n";
1827 + }
1828 + $i = 0;
1829 + foreach ( (array) $selects as $v ) {
1830 + $v = trim( $v );
1831 + if ( ( 0 === $i && 0 === $essential && null === $session_value ) || esc_attr( $v ) === $session_value ) {
1832 + $selected = ' selected="selected"';
1833 + } else {
1834 + $selected = '';
1835 + }
1836 + $html .= "\t<option value='" . esc_attr( $v ) . "'{$selected}>" . esc_attr( $v ) . "</option>\n";
1837 + $i++;
1838 + }
1839 + $html .= "</select>\n";
1840 + break;
1841 + case 2: // Text.
1842 + $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";
1843 + break;
1844 + case 3: // Radio-button.
1845 + $selects = explode( "\n", $opt['value'] );
1846 + $i = 0;
1847 + foreach ( (array) $selects as $v ) {
1848 + $v = trim( $v );
1849 + if ( $v === $session_value ) {
1850 + $checked = ' checked="checked"';
1851 + } else {
1852 + $checked = '';
1853 + }
1854 + $html .= "\t<label for='itemOption[{$post_id}][{$sku}][{$optcode}]{$i}' class='iopt_radio_label'><input name='itemOption[{$post_id}][{$sku}][{$optcode}]' id='itemOption[{$post_id}][{$sku}][{$optcode}]{$i}' class='iopt_radio' type='radio' value='" . urlencode( $v ) . "'{$checked}>" . esc_html( $v ) . "</label>\n";
1855 + $i++;
1856 + }
1857 + break;
1858 + case 4: // Check-box.
1859 + $selects = explode( "\n", $opt['value'] );
1860 + $i = 0;
1861 + foreach ( (array) $selects as $v ) {
1862 + $v = trim( $v );
1863 + if ( $v === $session_value ) {
1864 + $checked = ' checked="checked"';
1865 + } else {
1866 + $checked = '';
1867 + }
1868 + $html .= "\t<label for='itemOption[{$post_id}][{$sku}][{$optcode}]{$i}' class='iopt_checkbox_label'><input name='itemOption[{$post_id}][{$sku}][{$optcode}][]' id='itemOption[{$post_id}][{$sku}][{$optcode}]{$i}' class='iopt_checkbox' type='checkbox' value='" . urlencode( $v ) . "'{$checked}>" . esc_html( $v ) . "</label><br />\n";
1869 + $i++;
1870 + }
1871 + break;
1872 + case 5: // Text-area.
1873 + $html .= "\n<textarea name='itemOption[{$post_id}][{$sku}][{$optcode}]' id='itemOption[{$post_id}][{$sku}][{$optcode}]' class='iopt_textarea'>" . esc_attr( $session_value ) . "</textarea>\n";
1874 + break;
1875 + }
1876 +
1877 + $html = apply_filters( 'usces_filter_the_itemOption', $html, $opts, $name, $label, $post_id, $usces->itemsku['code'] );
1878 +
1879 + if ( 'return' === $out ) {
1880 + return $html;
1881 + } else {
1882 + echo $html; // no escape due to filter.
1883 + }
1884 +}
1885 +
1886 +/**
1887 + * Display cart
1888 + */
1889 +function usces_the_cart() {
1890 + global $usces;
1891 + $usces->display_cart();
1892 +}
1893 +
1894 +/**
1895 + * Is cart page
1896 + *
1897 + * @return bool
1898 + */
1899 +function usces_is_cart_page() {
1900 + global $usces;
1901 +
1902 + if ( $usces->is_cart_page( $_SERVER['REQUEST_URI'] ) ) {
1903 + if ( 'cart' === $usces->page ) {
1904 + return true;
1905 + }
1906 + if ( 'customer' !== $usces->page && 'delivery' !== $usces->page && 'confirm' !== $usces->page && 'ordercompletion' !== $usces->page && 'error' !== $usces->page && 'search_item' !== $usces->page ) {
1907 + return true;
1908 + }
1909 + }
1910 + return false;
1911 +}
1912 +
1913 +/**
1914 + * Is cart
1915 + *
1916 + * @return bool
1917 + */
1918 +function usces_is_cart() {
1919 + global $usces;
1920 +
1921 + if ( 0 < $usces->cart->num_row() ) {
1922 + if ( apply_filters( 'usces_is_cart_check', true ) ) {
1923 + return true;
1924 + } else {
1925 + return false;
1926 + }
1927 + } else {
1928 + return false;
1929 + }
1930 +}
1931 +
1932 +/**
1933 + * Is category
1934 + *
1935 + * @param string $str categpry slug.
1936 + * @return bool
1937 + */
1938 +function usces_is_category( $str ) {
1939 +
1940 + $cat = get_the_category();
1941 + $slugs = array();
1942 + foreach ( $cat as $value ) {
1943 + $slugs[] = $value->slug;
1944 + }
1945 +
1946 + $str = utf8_uri_encode( $str );
1947 +
1948 + if ( in_array( $str, $slugs, true ) ) {
1949 + return true;
1950 + } else {
1951 + return false;
1952 + }
1953 +}
1954 +
1955 +/**
1956 + * Pref field
1957 + *
1958 + * @param string $flag Member or not.
1959 + * @param string $out Return value or echo.
1960 + * @return string|void
1961 + */
1962 +function usces_the_pref( $flag, $out = '' ) {
1963 + global $usces;
1964 +
1965 + $usces_entries = $usces->cart->get_entry();
1966 + $name = esc_attr( $flag ) . '[pref]';
1967 + $pref = $usces_entries[ $flag ]['pref'];
1968 + if ( 'member' === $flag ) {
1969 + $usces_members = $usces->get_member();
1970 + $pref = $usces_members['pref'];
1971 + }
1972 + $html = "<select name=\"" . esc_attr( $name ) . "\" id=\"pref\" class=\"pref\">\n";
1973 + $prefs = get_usces_states( usces_get_local_addressform() );
1974 + foreach ( $prefs as $value ) {
1975 + $selected = ( $pref === $value ) ? ' selected="selected"' : '';
1976 + $html .= "\t<option value=\"" . esc_attr( $value ) . "\"{$selected}>" . esc_html( $value ) . "</option>\n";
1977 + }
1978 + $html .= "</select>\n";
1979 +
1980 + if ( 'return' === $out ) {
1981 + return wel_esc_script( $html );
1982 + } else {
1983 + wel_esc_script_e( $html );
1984 + }
1985 +}
1986 +
1987 +/**
1988 + * Company name
1989 + */
1990 +function usces_the_company_name() {
1991 + global $usces;
1992 + echo esc_html( $usces->options['company_name'] );
1993 +}
1994 +
1995 +/**
1996 + * Zip code
1997 + */
1998 +function usces_the_zip_code() {
1999 + global $usces;
2000 + echo esc_html( $usces->options['zip_code'] );
2001 +}
2002 +
2003 +/**
2004 + * Address1
2005 + */
2006 +function usces_the_address1() {
2007 + global $usces;
2008 + echo esc_html( $usces->options['address1'] );
2009 +}
2010 +
2011 +/**
2012 + * Address2
2013 + */
2014 +function usces_the_address2() {
2015 + global $usces;
2016 + echo esc_html( $usces->options['address2'] );
2017 +}
2018 +
2019 +/**
2020 + * Tel number
2021 + */
2022 +function usces_the_tel_number() {
2023 + global $usces;
2024 + echo esc_html( $usces->options['tel_number'] );
2025 +}
2026 +
2027 +/**
2028 + * Fax number
2029 + */
2030 +function usces_the_fax_number() {
2031 + global $usces;
2032 + echo esc_html( $usces->options['fax_number'] );
2033 +}
2034 +
2035 +/**
2036 + * Inquiry email address
2037 + */
2038 +function usces_the_inquiry_mail() {
2039 + global $usces;
2040 + echo esc_html( $usces->options['inquiry_mail'] );
2041 +}
2042 +
2043 +/**
2044 + * Postage privilege
2045 + */
2046 +function usces_the_postage_privilege() {
2047 + global $usces;
2048 + echo esc_html( $usces->options['postage_privilege'] );
2049 +}
2050 +
2051 +/**
2052 + * Initial point
2053 + */
2054 +function usces_the_start_point() {
2055 + global $usces;
2056 + echo esc_html( $usces->options['start_point'] );
2057 +}
2058 +
2059 +/**
2060 + * Point rate
2061 + *
2062 + * @param int $post_id Post ID.
2063 + * @param string $out Return value or echo.
2064 + * @return string|void
2065 + */
2066 +function usces_point_rate( $post_id = null, $out = '' ) {
2067 + global $usces;
2068 +
2069 + if ( null === $post_id ) {
2070 + $rate = $usces->options['point_rate'];
2071 + } else {
2072 + $product = wel_get_product( $post_id );
2073 + $str = $product['itemPointrate'];
2074 + $rate = (int) $str;
2075 + }
2076 + if ( 'return' === $out ) {
2077 + return wel_esc_script( $rate );
2078 + } else {
2079 + wel_esc_script_e( $rate );
2080 + }
2081 +}
2082 +
2083 +/**
2084 + * Point discount
2085 + *
2086 + * @param int $post_id Post ID.
2087 + * @param string $out Return value or echo.
2088 + * @return string|void
2089 + */
2090 +function usces_point_rate_discount( $post_id = null, $out = '' ) {
2091 + global $post, $usces;
2092 +
2093 + if ( null === $post_id ) {
2094 + $post_id = $post->ID;
2095 + }
2096 +
2097 + $product = wel_get_product( $post_id );
2098 + $str = $product['itemPointrate'];
2099 + $rate = (int) $str;
2100 + if ( 'point' === $usces->options['campaign_privilege'] ) {
2101 + if ( in_category( (int) $usces->options['campaign_category'], $post_id ) ) {
2102 + $rate *= $usces->options['privilege_point'];
2103 + }
2104 + }
2105 + if ( 'return' === $out ) {
2106 + return wel_esc_script( $rate );
2107 + } else {
2108 + wel_esc_script_e( $rate );
2109 + }
2110 +}
2111 +
2112 +/**
2113 + * Item point
2114 + *
2115 + * @param int $post_id Post ID.
2116 + * @param string $sku_code SKU code.
2117 + * @return int
2118 + */
2119 +function usces_get_point( $post_id, $sku_code ) {
2120 + global $usces;
2121 +
2122 + if ( null === $post_id ) {
2123 + $rate = $usces->options['point_rate'];
2124 + } else {
2125 + $product = wel_get_product( $post_id );
2126 + $str = $product['itemPointrate'];
2127 + $rate = (int) $str;
2128 + }
2129 +
2130 + $skus = wel_get_skus( $post_id, 'code' );
2131 + $point = ceil( $skus[ $sku_code ]['price'] * $rate / 100 );
2132 +
2133 + return $point;
2134 +}
2135 +
2136 +/**
2137 + * Payment method field
2138 + *
2139 + * @param string $value Value.
2140 + * @param string $out Return value or echo.
2141 + * @return string|void
2142 + */
2143 +function usces_the_payment_method( $value = '', $out = '' ) {
2144 + global $usces;
2145 +
2146 + $payments = usces_get_system_option( 'usces_payment_method', 'sort' );
2147 + $payments = apply_filters( 'usces_fiter_the_payment_method', $payments, $value );
2148 +
2149 + if ( defined( 'WCEX_DLSELLER_VERSION' ) && version_compare( WCEX_DLSELLER_VERSION, '2.2-beta', '<=' ) ) {
2150 + $cart = $usces->cart->get_cart();
2151 + $have_continue_charge = usces_have_continue_charge( $cart );
2152 + $continue_payment_method = apply_filters( 'usces_filter_the_continue_payment_method', array( 'acting_remise_card', 'acting_paypal_ec' ) );
2153 + }
2154 +
2155 + $list = '';
2156 + $payment_ct = ( $payments && is_array( $payments ) ) ? count( $payments ) : 0;
2157 + foreach ( (array) $payments as $id => $payment ) {
2158 + if ( defined( 'WCEX_DLSELLER_VERSION' ) && version_compare( WCEX_DLSELLER_VERSION, '2.2-beta', '<=' ) ) {
2159 + if ( $have_continue_charge ) {
2160 + if ( ! in_array( $payment['settlement'], $continue_payment_method, true ) ) {
2161 + $payment_ct--;
2162 + continue;
2163 + }
2164 + if ( isset( $usces->options['acting_settings']['remise']['continuation'] ) && 'on' !== $usces->options['acting_settings']['remise']['continuation'] && 'acting_remise_card' === $payment['settlement'] ) {
2165 + $payment_ct--;
2166 + continue;
2167 + } elseif ( isset( $usces->options['acting_settings']['paypal']['continuation'] ) && 'on' !== $usces->options['acting_settings']['paypal']['continuation'] && 'acting_paypal_ec' === $payment['settlement'] ) {
2168 + $payment_ct--;
2169 + continue;
2170 + }
2171 + }
2172 + }
2173 + if ( '' !== $payment['name'] && 'deactivate' !== $payment['use'] ) {
2174 + $module = trim( $payment['module'] );
2175 + if ( ! WCUtils::is_blank( $value ) ) {
2176 + $checked = ( $payment['name'] === $value ) ? ' checked' : '';
2177 + } elseif ( 1 === $payment_ct ) {
2178 + $checked = ' checked';
2179 + } else {
2180 + $checked = '';
2181 + }
2182 + $payment_row = '';
2183 + $checked = apply_filters( 'usces_fiter_the_payment_method_checked', $checked, $payment, $value );
2184 + $explanation = apply_filters( 'usces_fiter_the_payment_method_explanation', $payment['explanation'], $payment, $value );
2185 + if ( ( empty( $module ) || ! file_exists( $usces->options['settlement_path'] . $module ) ) && 'acting' === $payment['settlement'] ) {
2186 + $checked = '';
2187 + $payment_row .= '<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>';
2188 + } else {
2189 + $payment_row .= '<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>';
2190 + }
2191 + if ( ! empty( $explanation ) ) {
2192 + $explanation = wel_esc_script( $explanation );
2193 + $payment_row .= '<dd class="payment_' . $id . '">' . $explanation . '</dd>';
2194 + }
2195 + $payment_row = apply_filters( 'usces_filter_the_payment_method_row', $payment_row, $id, $payment, $checked, $module, $value, $explanation );
2196 + if ( ! empty( $payment_row ) ) {
2197 + $list .= $payment_row;
2198 + }
2199 + }
2200 + }
2201 +
2202 + if ( ! empty( $list ) ) {
2203 + $html = '<dl>' . $list . '</dl>';
2204 + } else {
2205 + $html = '<div>' . __( 'Not yet ready for the payment method. Please refer to a manager.', 'usces' ) . '</div>';
2206 + }
2207 +
2208 + $html = apply_filters( 'usces_filter_the_payment_method_choices', $html, $payments );
2209 + if ( 'return' === $out ) {
2210 + return $html;
2211 + } else {
2212 + echo $html; // no escape due to filter.
2213 + }
2214 +}
2215 +
2216 +/**
2217 + * Payment method
2218 + *
2219 + * @param string $name Payment method name.
2220 + * @return array
2221 + */
2222 +function usces_get_payments_by_name( $name ) {
2223 +
2224 + $init = array(
2225 + 'id' => null,
2226 + 'name' => null,
2227 + 'explanation' => null,
2228 + 'settlement' => null,
2229 + 'module' => null,
2230 + 'sort' => null,
2231 + 'use' => null,
2232 + );
2233 + $payments = usces_get_system_option( 'usces_payment_method', 'name' );
2234 + if ( empty( $payments ) ) {
2235 + return $init;
2236 + }
2237 + if ( isset( $payments[ $name ] ) ) {
2238 + return $payments[ $name ];
2239 + }
2240 +
2241 + return $init;
2242 +}
2243 +
2244 +/**
2245 + * Delivery method field
2246 + *
2247 + * @param string $value Value.
2248 + * @param string $out Return value or echo.
2249 + * @return string|void
2250 + */
2251 +function usces_the_delivery_method( $value = '', $out = '' ) {
2252 + global $usces;
2253 +
2254 + $deli_id = apply_filters( 'usces_filter_get_available_delivery_method', $usces->get_available_delivery_method() );
2255 + if ( empty( $deli_id ) ) {
2256 + $html = '<p>' . __( 'No valid shipping methods.', 'usces' ) . '</p>';
2257 + } else {
2258 + $cdeliid = ( is_array( $deli_id ) ) ? count( $deli_id ) : 0;
2259 + $html = '<select name="offer[delivery_method]" id="delivery_method_select" class="delivery_time" onKeyDown="if (event.keyCode == 13) {return false;}">' . "\n";
2260 + foreach ( (array) $deli_id as $id ) {
2261 + $index = $usces->get_delivery_method_index( $id );
2262 + if ( 0 <= $index ) {
2263 + $selected = ( (string) $id === (string) $value || 1 === $cdeliid ) ? ' selected="selected"' : '';
2264 + $html .= "\t<option value=\"{$id}\"{$selected}>" . esc_html( $usces->options['delivery_method'][ $index ]['name'] ) . "</option>\n";
2265 + }
2266 + }
2267 + $html .= "</select>\n";
2268 + }
2269 +
2270 + $html = apply_filters( 'usces_filter_the_delivery_method', $html, $deli_id );
2271 +
2272 + if ( 'return' === $out ) {
2273 + return $html;
2274 + } else {
2275 + echo $html; // no escape due to filter.
2276 + }
2277 +}
2278 +
2279 +/**
2280 + * Delivery date field
2281 + *
2282 + * @param string $value Value.
2283 + * @param string $out Return value or echo.
2284 + * @return string|void
2285 + */
2286 +function usces_the_delivery_date( $value = '', $out = '' ) {
2287 +
2288 + $html = "<select name=\"offer[delivery_date]\" id=\"delivery_date_select\" class=\"delivery_date\">\n";
2289 + $html .= "</select>\n";
2290 + $html = apply_filters( 'the_delivery_date', $html );
2291 +
2292 + if ( 'return' === $out ) {
2293 + return $html;
2294 + } else {
2295 + echo $html; // no escape due to filter.
2296 + }
2297 +}
2298 +
2299 +/**
2300 + * Delivery time field
2301 + *
2302 + * @param string $value Value.
2303 + * @param string $out Return value or echo.
2304 + * @return string|void
2305 + */
2306 +function usces_the_delivery_time( $value = '', $out = '' ) {
2307 +
2308 + $html = "<div id=\"delivery_time_limit_message\"></div>\n";
2309 + $html .= "<select name=\"offer[delivery_time]\" id=\"delivery_time_select\" class=\"delivery_time\">\n";
2310 + $html .= "</select>\n";
2311 + $html = apply_filters( 'the_delivery_time', $html );
2312 +
2313 + if ( 'return' === $out ) {
2314 + return $html;
2315 + } else {
2316 + echo $html; // no escape due to filter.
2317 + }
2318 +}
2319 +
2320 +/**
2321 + * Campaign Schedule
2322 + *
2323 + * @param string $flag Flag.
2324 + * @param string $kind Kind.
2325 + */
2326 +function usces_the_campaign_schedule( $flag, $kind ) {
2327 + global $usces;
2328 +
2329 + $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' );
2330 + $starttime = $usces->options['campaign_schedule']['start']['hour'] . __( 'hour', 'usces' ) . $usces->options['campaign_schedule']['start']['min'] . __( 'min', 'usces' );
2331 + $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' );
2332 + $endtime = $usces->options['campaign_schedule']['end']['hour'] . __( 'hour', 'usces' ) . $usces->options['campaign_schedule']['end']['min'] . __( 'min', 'usces' );
2333 + if ( 'start' === $flag ) {
2334 + if ( 'date' === $kind ) {
2335 + echo esc_html( $startdate );
2336 + } elseif ( 'datetime' === $kind ) {
2337 + echo esc_html( $startdate . ' ' . $starttime );
2338 + }
2339 + } elseif ( 'end' === $flag ) {
2340 + if ( 'date' === $kind ) {
2341 + echo esc_html( $enddate );
2342 + } elseif ( 'datetime' === $kind ) {
2343 + echo esc_html( $enddate . ' ' . $endtime );
2344 + }
2345 + }
2346 +}
2347 +
2348 +/**
2349 + * Display cart confirm
2350 + */
2351 +function usces_the_confirm() {
2352 + global $usces;
2353 + $usces->display_cart_confirm();
2354 +}
2355 +
2356 +/**
2357 + * Inquiry
2358 + */
2359 +function usces_inquiry_condition() {
2360 + global $error_message, $reserve, $inq_name, $inq_mailaddress, $inq_contents;
2361 + require USCES_PLUGIN_DIR . '/includes/inquiry_condition.php';
2362 +}
2363 +
2364 +/**
2365 + * Inquiry form
2366 + */
2367 +function usces_the_inquiry_form() {
2368 + global $usces;
2369 +
2370 + $error_message = '';
2371 + if ( isset( $_POST['inq_name'] ) && ! WCUtils::is_blank( $_POST['inq_name'] ) ) {
2372 + $inq_name = trim( wp_unslash( $_POST['inq_name'] ) );
2373 + } else {
2374 + $inq_name = '';
2375 + if ( 'deficiency' === $usces->page ) {
2376 + $error_message .= __( 'Please input your name.', 'usces' ) . '<br />';
2377 + }
2378 + }
2379 + if ( isset( $_POST['inq_mailaddress'] ) && is_email( trim( wp_unslash( $_POST['inq_mailaddress'] ) ) ) ) {
2380 + $inq_mailaddress = trim( wp_unslash( $_POST['inq_mailaddress'] ) );
2381 + } elseif ( isset( $_POST['inq_mailaddress'] ) && ! is_email( trim( wp_unslash( $_POST['inq_mailaddress'] ) ) ) ) {
2382 + $inq_mailaddress = trim( wp_unslash( $_POST['inq_mailaddress'] ) );
2383 + if ( 'deficiency' === $usces->page ) {
2384 + $error_message .= __( 'E-mail address is not correct', 'usces' ) . '<br />';
2385 + }
2386 + } else {
2387 + $inq_mailaddress = '';
2388 + if ( 'deficiency' === $usces->page ) {
2389 + $error_message .= __( 'Please input your e-mail address.', 'usces' ) . '<br />';
2390 + }
2391 + }
2392 + if ( isset( $_POST['inq_contents'] ) && ! WCUtils::is_blank( $_POST['inq_contents'] ) ) {
2393 + $inq_contents = trim( wp_unslash( $_POST['inq_contents'] ) );
2394 + } else {
2395 + $inq_contents = '';
2396 + if ( 'deficiency' === $usces->page ) {
2397 + $error_message .= __( 'Please input contents.', 'usces' );
2398 + }
2399 + }
2400 +
2401 + if ( 'inquiry_comp' === $usces->page ) :
2402 + $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' ) );
2403 + ?>
2404 + <div class="inquiry_comp"><?php esc_html_e( 'sending completed', 'usces' ); ?></div>
2405 + <div class="compbox"><?php wel_esc_script_e( $inq_message ); ?></div>
2406 + <?php
2407 + elseif ( 'inquiry_error' === $usces->page ) :
2408 + ?>
2409 + <div class="inquiry_comp"><?php esc_html_e( 'Failure in sending', 'usces' ); ?></div>
2410 + <?php
2411 + else :
2412 + ?>
2413 + <?php if ( ! empty( $error_message ) ) : ?>
2414 +<div class="error_message"><?php wel_esc_script_e( $error_message ); ?></div>
2415 + <?php endif; ?>
2416 +<form name="inquiry_form" method="post">
2417 +<input type="hidden" name="kakuninyou" />
2418 +<table border="0" cellpadding="0" cellspacing="0" class="inquiry_table">
2419 +<tr>
2420 +<th scope="row"><?php esc_html_e( 'Full name', 'usces' ); ?></th>
2421 +<td><input name="inq_name" type="text" class="inquiry_name" value="<?php echo esc_attr( $inq_name ); ?>" /></td>
2422 +</tr>
2423 +<tr>
2424 +<th scope="row"><?php esc_html_e( 'e-mail adress', 'usces' ); ?></th>
2425 +<td><input name="inq_mailaddress" type="text" class="inquiry_mailaddress" value="<?php echo esc_attr( $inq_mailaddress ); ?>" /></td>
2426 +</tr>
2427 +<tr>
2428 +<th scope="row"><?php esc_html_e( 'contents', 'usces' ); ?></th>
2429 +<td><textarea name="inq_contents" class="inquiry_contents"><?php echo esc_attr( $inq_contents ); ?></textarea></td>
2430 +</tr>
2431 +</table>
2432 +<div class="send"><input name="inquiry_button" type="submit" value="<?php esc_attr_e( 'Admit to send it with this information.', 'usces' ); ?>" /></div>
2433 +</form>
2434 + <?php
2435 + endif;
2436 +}
2437 +
2438 +/**
2439 + * Get Category ID
2440 + *
2441 + * @param string $slug Slag.
2442 + * @return int
2443 + */
2444 +function usces_get_cat_id( $slug ) {
2445 + $cat = get_category_by_slug( $slug );
2446 + $term_id = $cat->term_id ?? 0;
2447 + return $term_id;
2448 +}
2449 +
2450 +/**
2451 + * Widget Calendar
2452 + */
2453 +function usces_the_calendar() {
2454 + global $usces;
2455 + include USCES_PLUGIN_DIR . '/includes/widget_calendar.php';
2456 +}
2457 +
2458 +/**
2459 + * Login/Logout link
2460 + *
2461 + * @param string $out Return value or echo.
2462 + * @return string|void
2463 + */
2464 +function usces_loginout( $out = '' ) {
2465 + global $usces;
2466 +
2467 + if ( ! $usces->is_member_logged_in() ) {
2468 + $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>';
2469 + } else {
2470 + $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>';
2471 + }
2472 + if ( 'return' === $out ) {
2473 + return wel_esc_script( $res );
2474 + } else {
2475 + wel_esc_script_e( $res );
2476 + }
2477 +}
2478 +
2479 +/**
2480 + * Is Login
2481 + *
2482 + * @return bool
2483 + */
2484 +function usces_is_login() {
2485 + global $usces;
2486 +
2487 + if ( false === $usces->is_member_logged_in() ) {
2488 + $res = false;
2489 + } else {
2490 + $res = true;
2491 + }
2492 + return $res;
2493 +}
2494 +
2495 +/**
2496 + * Member Name
2497 + *
2498 + * @param string $out Return value or echo.
2499 + * @return string|void
2500 + */
2501 +function usces_the_member_name( $out = '' ) {
2502 + global $usces;
2503 +
2504 + $usces->get_current_member();
2505 + $res = esc_html( $usces->current_member['name'] );
2506 + if ( 'return' === $out ) {
2507 + return wel_esc_script( $res );
2508 + } else {
2509 + wel_esc_script_e( $res );
2510 + }
2511 +}
2512 +
2513 +/**
2514 + * Membership Point
2515 + *
2516 + * @param string $out Return value or echo.
2517 + * @return string|void
2518 + */
2519 +function usces_the_member_point( $out = '' ) {
2520 + global $usces;
2521 +
2522 + if ( ! $usces->is_member_logged_in() ) {
2523 + return;
2524 + }
2525 +
2526 + $member = $usces->get_member();
2527 +
2528 + if ( 'return' === $out ) {
2529 + return $member['point'];
2530 + } else {
2531 + echo number_format( $member['point'] );
2532 + }
2533 +}
2534 +
2535 +/**
2536 + * Membership Rank
2537 + *
2538 + * @param string $out Return value or echo.
2539 + * @return string|void
2540 + */
2541 +function usces_the_member_status( $out = '' ) {
2542 + global $usces;
2543 +
2544 + if ( ! $usces->is_member_logged_in() ) {
2545 + return;
2546 + }
2547 +
2548 + $usces->get_current_member();
2549 + $member = $usces->get_member_info( $usces->current_member['id'] );
2550 + $status_name = $usces->member_status[ $member['mem_status'] ];
2551 +
2552 + if ( 'return' === $out ) {
2553 + return $status_name;
2554 + } else {
2555 + echo esc_html( $status_name );
2556 + }
2557 +}
2558 +
2559 +/**
2560 + * Related item list
2561 + *
2562 + * @param int $post_id Post ID.
2563 + * @return array
2564 + */
2565 +function usces_get_assistance_id_list( $post_id ) {
2566 + global $usces;
2567 +
2568 + $names = $usces->get_tag_names( $post_id );
2569 + $list = '';
2570 + foreach ( (array) $names as $itemname ) {
2571 + $list .= $usces->get_ID_byItemName( $itemname, 'publish' ) . ',';
2572 + }
2573 + $list = trim( $list, ',' );
2574 + return $list;
2575 +}
2576 +
2577 +/**
2578 + * Related item
2579 + *
2580 + * @param int $post_id Post ID.
2581 + * @return array
2582 + */
2583 +function usces_get_assistance_ids( $post_id ) {
2584 + global $usces;
2585 +
2586 + $names = $usces->get_tag_names( $post_id );
2587 + $ids = array();
2588 + foreach ( $names as $itemname ) {
2589 + $ids[] = $usces->get_ID_byItemName( $itemname, 'publish' );
2590 + }
2591 + return $ids;
2592 +}
2593 +
2594 +/**
2595 + * Forgot account
2596 + *
2597 + * @param string $out Return value or echo.
2598 + * @return string|void
2599 + */
2600 +function usces_remembername( $out = '' ) {
2601 + global $usces;
2602 +
2603 + $value = $usces->get_cookie();
2604 + if ( 'return' === $out ) {
2605 +// if ( isset( $value['name'] ) )
2606 +// return $value['name'];
2607 +// else
2608 + return '';
2609 + } else {
2610 +// if ( isset( $value['name'] ) )
2611 +// echo esc_html( $value['name'] );
2612 +// else
2613 + echo '';
2614 + }
2615 +}
2616 +
2617 +/**
2618 + * Forgot password
2619 + *
2620 + * @param string $out Return value or echo.
2621 + * @return string|void
2622 + */
2623 +function usces_rememberpass( $out = '' ) {
2624 + global $usces;
2625 +
2626 + $value = $usces->get_cookie();
2627 + if ( 'return' === $out ) {
2628 +// if ( isset( $value['pass'] ) )
2629 +// return $value['pass'];
2630 +// else
2631 + return '';
2632 + } else {
2633 +// if ( isset( $value['pass'] ) )
2634 +// echo esc_html( $value['pass'] );
2635 +// else
2636 + echo '';
2637 + }
2638 +}
2639 +
2640 +/**
2641 + * Forgot account check
2642 + *
2643 + * @param string $out Return value or echo.
2644 + * @return string|void
2645 + */
2646 +function usces_remembercheck( $out = '' ) {
2647 + global $usces;
2648 +
2649 + $value = $usces->get_cookie();
2650 + if ( 'return' === $out ) {
2651 +// if ( isset( $value['name'] ) && $value['name'] != '' )
2652 +// return ' checked="checked"';
2653 +// else
2654 + return '';
2655 + } else {
2656 +// if ( isset( $value['name'] ) && $value['name'] != '' )
2657 +// echo ' checked="checked"';
2658 +// else
2659 + echo '';
2660 + }
2661 +}
2662 +
2663 +/**
2664 + * Shipping charge table
2665 + *
2666 + * @param string $index Index.
2667 + */
2668 +function usces_shippingchargeTR( $index = '' ) {
2669 + global $usces;
2670 +
2671 + if ( '' === $index ) {
2672 + $index = 0;
2673 + }
2674 + $list = '';
2675 + if ( ! isset( $usces->options['shipping_charge'][ $index ] ) ) {
2676 + return;
2677 + }
2678 + $shipping_charge = $usces->options['shipping_charge'][ $index ];
2679 + $entry = $usces->cart->get_entry();
2680 + $country = ( isset( $entry['delivery']['country'] ) && ! empty( $entry['delivery']['country'] ) ) ? $entry['delivery']['country'] : $entry['customer']['country'];
2681 + foreach ( $shipping_charge[ $country ] as $pref => $value ) {
2682 + $list .= '<tr><th>' . esc_html( $pref ) . "</th>\n";
2683 + $list .= '<td class="rightnum">' . number_format( $value ) . "</td>\n";
2684 + $list .= "</tr>\n";
2685 + }
2686 + wel_esc_script_e( $list );
2687 +}
2688 +
2689 +/**
2690 + * Shipping charge
2691 + */
2692 +function usces_sc_shipping_charge() {
2693 + global $usces;
2694 + echo esc_html( $usces->sc_shipping_charge() );
2695 +}
2696 +
2697 +/**
2698 + * Postage privilege
2699 + */
2700 +function usces_sc_postage_privilege() {
2701 + global $usces;
2702 + echo esc_html( $usces->sc_postage_privilege() );
2703 +}
2704 +
2705 +/**
2706 + * Payment title
2707 + */
2708 +function usces_sc_payment_title() {
2709 + global $usces;
2710 + wel_esc_script_e( $usces->sc_payment_title() );
2711 +}
2712 +
2713 +/**
2714 + * Posts offset
2715 + *
2716 + * @param object $posts Post data.
2717 + * @return int
2718 + */
2719 +function usces_posts_random_offset( $posts ) {
2720 + $ids = array();
2721 + foreach ( (array) $posts as $post ) {
2722 + $ids[] = $post->ID;
2723 + }
2724 + $ct = count( $ids );
2725 + $index = rand( 0, ( $ct - 1 ) );
2726 + return $index;
2727 +}
2728 +
2729 +/**
2730 + * Get category link
2731 + *
2732 + * @param string $slug Slug.
2733 + */
2734 +function usces_get_category_link_by_slug( $slug ) {
2735 + $category = get_category_by_slug( $slug );
2736 + echo get_category_link( $category->term_id );
2737 +}
2738 +
2739 +/**
2740 + * Get page ID
2741 + *
2742 + * @param string $post_name Post name.
2743 + * @param string $return Return value or echo.
2744 + * @return string|void
2745 + */
2746 +function usces_get_page_ID_by_pname( $post_name, $return = 'echo' ) {
2747 + $page = get_page_by_path( $post_name );
2748 + if ( 'return' === $return ) {
2749 + return $page->ID;
2750 + } else {
2751 + echo esc_attr( $page->ID );
2752 + }
2753 +}
2754 +
2755 +/**
2756 + * Bestseller
2757 + *
2758 + * @param int $num Number.
2759 + * @param string $days Days.
2760 + */
2761 +function usces_list_bestseller( $num, $days = '' ) {
2762 + global $usces;
2763 +
2764 + $ids = $usces->get_bestseller_ids( $days );
2765 + $htm = '';
2766 + for ( $i = 0; $i < $num; $i++ ) {
2767 + if ( isset( $ids[ $i ] ) ) {
2768 + $post_id = (int) $ids[ $i ];
2769 + $product = wel_get_product( $post_id );
2770 + $post = $product['_pst'];
2771 +
2772 + if ( false === $product ) {
2773 + continue;
2774 + }
2775 +
2776 + $disp_text = apply_filters( 'usces_widget_bestseller_auto_text', esc_html( $post->post_title ), $post_id );
2777 + $list = '<li><a href="' . get_permalink( $post_id ) . '">' . $disp_text . "</a></li>\n";
2778 + $htm .= apply_filters( 'usces_filter_bestseller', $list, $post_id, $i );
2779 + }
2780 + }
2781 + wp_reset_postdata();
2782 + wel_esc_script_e( $htm );
2783 +}
2784 +
2785 +/**
2786 + * Post list
2787 + *
2788 + * @param string $slug Slug.
2789 + * @param string $rownum Page number.
2790 + * @param string $widget_id Widget ID.
2791 + */
2792 +function usces_list_post( $slug, $rownum, $widget_id = null ) {
2793 + global $post;
2794 +
2795 + usces_remove_filter();
2796 +
2797 + $li = '';
2798 + $infolist = new WP_Query( array( 'category_name' => $slug, 'post_status' => 'publish', 'posts_per_page' => $rownum, 'order' => 'DESC', 'orderby' => 'date' ) );
2799 + if ( null !== $widget_id && $infolist->have_posts() ) {
2800 + remove_filter( 'excerpt_length', 'welcart_excerpt_length' );
2801 + remove_filter( 'excerpt_mblength', 'welcart_excerpt_mblength' );
2802 + remove_filter( 'excerpt_more', 'welcart_auto_excerpt_more' );
2803 + if ( function_exists( 'welcart_widget_post_excerpt_length_' . $widget_id ) ) {
2804 + add_filter( 'excerpt_length', 'welcart_widget_post_excerpt_length_' . $widget_id );
2805 + }
2806 + if ( function_exists( 'welcart_widget_post_excerpt_mblength_' . $widget_id ) ) {
2807 + add_filter( 'excerpt_mblength', 'welcart_widget_post_excerpt_mblength_' . $widget_id );
2808 + }
2809 + }
2810 + $list_index = 0;
2811 + while ( $infolist->have_posts() ) {
2812 + $infolist->the_post();
2813 + $list = '<li class="post_list' . apply_filters( 'usces_filter_post_list_class', null, $list_index, $infolist->post_count ) . '">' . "\n";
2814 + $list .= "<div class='title'><a href='" . get_permalink( $post->ID ) . "'>" . get_the_title() . "</a></div>\n";
2815 + $list .= '<p>' . get_the_excerpt() . "</p>\n";
2816 + $list .= "</li>\n";
2817 + $li .= apply_filters( 'usces_filter_widget_post', $list, $post, $slug, $list_index );
2818 + $list_index++;
2819 + }
2820 + wp_reset_postdata();
2821 + usces_reset_filter();
2822 + if ( null !== $widget_id && $infolist->have_posts() ) {
2823 + add_filter( 'excerpt_length', 'welcart_excerpt_length' );
2824 + add_filter( 'excerpt_mblength', 'welcart_excerpt_mblength' );
2825 + add_filter( 'excerpt_more', 'welcart_auto_excerpt_more' );
2826 + }
2827 + wel_esc_script_e( $li );
2828 +}
2829 +
2830 +/**
2831 + * Category checkbox
2832 + *
2833 + * @param string $output Return value or echo.
2834 + * @return string|void
2835 + */
2836 +function usces_categories_checkbox( $output = '' ) {
2837 +
2838 + $retcats = apply_filters( 'usces_search_retcats', usces_search_categories() );
2839 + $parent_id = apply_filters( 'usces_search_categories_checkbox_parent', USCES_ITEM_CAT_PARENT_ID );
2840 + $htm = usces_get_categories_checkbox( $parent_id );
2841 + $htm = apply_filters( 'usces_filter_categories_checkbox', $htm, $parent_id );
2842 +
2843 + if ( '' === $output || 'echo' === $output ) {
2844 + wel_esc_script_e( $htm );
2845 + } else {
2846 + return wel_esc_script( $htm );
2847 + }
2848 +}
2849 +
2850 +/**
2851 + * Category checkbox
2852 + *
2853 + * @param int $parent_id Parent category ID.
2854 + */
2855 +function usces_get_categories_checkbox( $parent_id ) {
2856 + global $usces;
2857 +
2858 + $htm = '';
2859 + $retcats = usces_search_categories();
2860 + $parent_cat = get_category( $parent_id );
2861 + $categories = get_categories( 'parent=' . $parent_id . '&hide_empty=0&orderby=' . $usces->options['fukugo_category_orderby'] . '&order=' . $usces->options['fukugo_category_order'] );
2862 + $htm .= '<fieldset class="catfield-' . $parent_cat->term_id . '"><legend>' . $parent_cat->cat_name . "</legend><ul>\n";
2863 + foreach ( $categories as $cat ) {
2864 + $children = get_categories( 'parent=' . $cat->term_id . '&hide_empty=0' );
2865 + if ( 0 === count( $children ) ) {
2866 + $checked = in_array( $cat->term_id, $retcats ) ? ' checked="checked"' : '';
2867 + $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";
2868 + }
2869 + }
2870 + $htm .= "</ul>\n";
2871 + foreach ( $categories as $cat ) {
2872 + $children = get_categories( 'parent=' . $cat->term_id . '&hide_empty=0' );
2873 + if ( 0 < count( $children ) ) {
2874 + $htm .= usces_get_categories_checkbox( $cat->term_id );
2875 + }
2876 + }
2877 + $htm .= "</fieldset>\n";
2878 +
2879 + return $htm;
2880 +}
2881 +
2882 +/**
2883 + * Search categories
2884 + *
2885 + * @return array
2886 + */
2887 +function usces_search_categories() {
2888 + $cats = array();
2889 + if ( isset( $_REQUEST['category'] ) ) {
2890 + $cats = wp_unslash( $_REQUEST['category'] );
2891 + } else {
2892 + $cats[] = USCES_ITEM_CAT_PARENT_ID;
2893 + }
2894 + sort( $cats );
2895 + return $cats;
2896 +}
2897 +
2898 +/**
2899 + * Delivery method name
2900 + *
2901 + * @param int $id Delivery ID.
2902 + * @param string $out Return value or echo.
2903 + * @return string|void
2904 + */
2905 +function usces_delivery_method_name( $id, $out = '' ) {
2906 + global $usces;
2907 +
2908 + $id = $usces->get_delivery_method_index( $id );
2909 + if ( $id > -1 ) {
2910 + $name = $usces->options['delivery_method'][ $id ]['name'];
2911 + } else {
2912 + $name = __( 'No preference', 'usces' );
2913 + }
2914 +
2915 + if ( 'return' === $out ) {
2916 + return $name;
2917 + } else {
2918 + echo esc_html( $name );
2919 + }
2920 +}
2921 +
2922 +/**
2923 + * Use membership system
2924 + *
2925 + * @return bool
2926 + */
2927 +function usces_is_membersystem_state() {
2928 + global $usces;
2929 +
2930 + if ( 'activate' === $usces->options['membersystem_state'] ) {
2931 + return true;
2932 + } else {
2933 + return false;
2934 + }
2935 +}
2936 +
2937 +/**
2938 + * Use membership point
2939 + *
2940 + * @return bool
2941 + */
2942 +function usces_is_membersystem_point() {
2943 + global $usces;
2944 +
2945 + if ( 'activate' === $usces->options['membersystem_point'] ) {
2946 + return true;
2947 + } else {
2948 + return false;
2949 + }
2950 +}
2951 +
2952 +/**
2953 + * Copyright
2954 + */
2955 +function usces_copyright() {
2956 + global $usces;
2957 + echo esc_html( $usces->options['copyright'] );
2958 +}
2959 +
2960 +/**
2961 + * Total amount in cart
2962 + */
2963 +function usces_totalprice_in_cart() {
2964 + global $usces;
2965 + echo number_format( $usces->get_total_price() );
2966 +}
2967 +
2968 +/**
2969 + * Total quantities in cart
2970 + */
2971 +function usces_totalquantity_in_cart() {
2972 + global $usces;
2973 + echo number_format( $usces->get_total_quantity() );
2974 +}
2975 +
2976 +/**
2977 + * Page mode
2978 + *
2979 + * @return string
2980 + */
2981 +function usces_get_page_mode() {
2982 + global $usces;
2983 + return $usces->page;
2984 +}
2985 +
2986 +/**
2987 + * Is in item category
2988 + *
2989 + * @param int $cat_id Category ID.
2990 + * @return bool
2991 + */
2992 +function usces_is_cat_of_item( $cat_id ) {
2993 + global $usces;
2994 +
2995 + $ids = $usces->get_item_cat_ids();
2996 + $ids[] = USCES_ITEM_CAT_PARENT_ID;
2997 + if ( in_array( $cat_id, $ids ) ) {
2998 + return true;
2999 + } else {
3000 + return false;
3001 + }
3002 +}
3003 +
3004 +/**
3005 + * Item custom field
3006 + *
3007 + * @param int $post_id Post ID.
3008 + * @param string $type Type.
3009 + * @param string $out Return value or echo.
3010 + * @return string|void
3011 + */
3012 +function usces_get_item_custom( $post_id, $type = 'list', $out = '' ) {
3013 + global $usces;
3014 +
3015 + $cfields = wel_get_extra_data( $post_id );
3016 + $html = '';
3017 +
3018 + switch ( $type ) {
3019 + case 'list':
3020 + $list = '';
3021 + $html = '<ul class="item_custom_field">' . "\n";
3022 + foreach ( $cfields as $key => $values ) {
3023 + if ( 'wccs_' === substr( $key, 0, 5 ) ) {
3024 + if ( is_array( $values ) ) {
3025 + foreach ( $values as $value ) {
3026 + $list .= '<li>' . esc_html( substr( $key, 5 ) ) . ' : ' . nl2br( esc_html( $value ) ) . '</li>' . "\n";
3027 + }
3028 + } else {
3029 + $list .= '<li>' . esc_html( substr( $key, 5 ) ) . ' : ' . nl2br( esc_html( $values ) ) . '</li>' . "\n";
1897 3030 }
1898 - break;
1899 - case 'ap':
1900 - switch($value) {
1901 - case 'BANK':
1902 - $value = '受付完了'; break;
1903 - case 'BAN_SAL':
1904 - $value = '入金完了'; break;
1905 - }
1906 - break;
1907 - case 'mf':
1908 - switch($value) {
1909 - case '1':
1910 - $value = 'マッチ'; break;
1911 - case '2':
1912 - $value = '過少'; break;
1913 - case '3':
1914 - $value = '過剰'; break;
1915 - }
1916 - break;
1917 - case 'nkd':
1918 - $value = substr($value, 0, 4).'年'.substr($value, 4, 2).'月'.substr($value, 6, 2).'日';
1919 - break;
1920 - case 'exp':
1921 - $value = substr($value, 0, 4).'年'.substr($value, 4, 2).'月'.substr($value, 6, 2).'日';
1922 - break;
1923 - case 'cv':
1924 - case 'no':
1925 - case 'cu':
1926 - continue;
1927 - break;
1928 - }
1929 - break;
1930 -//20101018ysk end
1931 - }
1932 - $value = apply_filters( 'usces_filter_settle_info_field_value', $value, $key, $acting );
1933 - switch($type){
1934 - case 'nl':
1935 - $str .= $key . ' : ' . $value . "<br />\n";
1936 - break;
1937 -
1938 - case 'tr':
1939 - $str .= '<tr><td class="label">' . $key . '</td><td>' . $value . "</td></tr>\n";
1940 - break;
1941 -
1942 - case 'li':
1943 - $str .= '<li>' . $key . ' : ' . $value . "</li>\n";
1944 - break;
1945 - }
1946 - }
1947 - if( 'return' == $out){
1948 - return $str;
1949 - }else{
1950 - echo $str;
1951 - }
1952 -}
1953 -
1954 -//20100818ysk start
1955 -function usces_custom_field_input( $data, $custom_field, $position, $out = '' ) {
1956 -
1957 - $html = '';
1958 - switch($custom_field) {
1959 - case 'order':
1960 - $label = 'custom_order';
1961 - $field = 'usces_custom_order_field';
1962 - break;
1963 - case 'customer':
1964 - $label = 'custom_customer';
1965 - $field = 'usces_custom_customer_field';
1966 - break;
1967 - case 'delivery':
1968 - $label = 'custom_delivery';
1969 - $field = 'usces_custom_delivery_field';
1970 - break;
1971 - case 'member':
1972 - $label = 'custom_member';
1973 - $field = 'usces_custom_member_field';
1974 - break;
1975 - default:
1976 - return;
1977 - }
1978 -
1979 - $meta = usces_has_custom_field_meta($custom_field);
1980 -
1981 - if(!empty($meta) and is_array($meta)) {
1982 - foreach($meta as $key => $entry) {
1983 - if($custom_field == 'order' or $entry['position'] == $position) {
1984 - $name = $entry['name'];
1985 - $means = $entry['means'];
1986 - $essential = $entry['essential'];
1987 - $value = '';
1988 - if(is_array($entry['value'])) {
1989 - foreach($entry['value'] as $k => $v) {
1990 - $value .= $v."\n";
1991 - }
1992 - }
1993 - $value = trim($value);
1994 -
1995 - $e = ($essential == 1) ? '<em>' . __('*', 'usces') . '</em>' : '';
1996 - $html .= '
1997 - <tr class="customkey_' . $key . '">
1998 - <th scope="row">'.$e.esc_html($name).apply_filters('usces_filter_custom_field_input_label', NULL, $key, $entry).'</th>';
1999 - $html .= apply_filters( 'usces_filter_custom_field_input_td', '<td colspan="2">', $key, $entry);
2000 - switch($means) {
2001 - case 0://シングルセレクト
2002 - case 1://マルチセレクト
2003 - $selects = explode("\n", $value);
2004 - $multiple = ($means == 0) ? '' : ' multiple';
2005 - $multiple_array = ($means == 0) ? '' : '[]';
2006 - $html .= '<select name="'.$label.'['.esc_attr($key).']'.$multiple_array.'" class="iopt_select"'.$multiple.'>';
2007 - if($essential == 1)
2008 - $html .= '
2009 - <option value="#NONE#">'.__('Choose','usces').'</option>';
2010 - foreach($selects as $v) {
2011 - $selected = (isset($data[$label][$key]) && $data[$label][$key] == $v) ? ' selected' : '';
2012 - $html .= '
2013 - <option value="'.esc_attr($v).'"'.$selected.'>'.esc_html($v).'</option>';
2014 - }
2015 - $html .= '
2016 - </select>';
2017 - break;
2018 - case 2://テキスト
2019 - $text = isset($data[$label][$key]) ? $data[$label][$key] : '';
2020 - $html .= '<input type="text" name="'.$label.'['.esc_attr($key).']" value="'.esc_attr($text).'" />';
2021 - break;
2022 - case 3://ラジオボタン
2023 - $selects = explode("\n", $value);
2024 - foreach($selects as $v) {
2025 - $checked = ( isset($data[$label][$key]) && $data[$label][$key] == $v) ? ' checked' : '';
2026 - $html .= '
2027 - <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>';
2028 - }
2029 - break;
2030 - case 4://チェックボックス
2031 - $selects = explode("\n", $value);
2032 - foreach($selects as $v) {
2033 - if( isset($data[$label][$key]) && is_array($data[$label][$key]) ) {
2034 - $checked = (isset($data[$label][$key]) && array_key_exists($v, $data[$label][$key])) ? ' checked' : '';
2035 - } else {
2036 - $checked = (isset($data[$label][$key]) && $data[$label][$key] == $v) ? ' checked' : '';
2037 - }
2038 - $html .= '
2039 - <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>';
2040 - }
2041 - break;
2042 - }
2043 - $html .= apply_filters('usces_filter_custom_field_input_value', NULL, $key, $entry).'</td>';
2044 - $html .= '
2045 - </tr>';
2046 - }
2047 - }
2048 - }
2049 -
2050 - $html = apply_filters('usces_filter_custom_field_input', $html, $data, $custom_field, $position);
2051 -
2052 - if($out == 'return') {
2053 - return stripslashes($html);
2054 - } else {
2055 - echo stripslashes($html);
2056 - }
2057 -}
2058 -
2059 -function usces_custom_field_info( $data, $custom_field, $position, $out = '' ) {
2060 -
2061 - $html = '';
2062 - switch($custom_field) {
2063 - case 'order':
2064 - $label = 'custom_order';
2065 - $field = 'usces_custom_order_field';
2066 - break;
2067 - case 'customer':
2068 - $label = 'custom_customer';
2069 - $field = 'usces_custom_customer_field';
2070 - break;
2071 - case 'delivery':
2072 - $label = 'custom_delivery';
2073 - $field = 'usces_custom_delivery_field';
2074 - break;
2075 - case 'member':
2076 - $label = 'custom_member';
2077 - $field = 'usces_custom_member_field';
2078 - break;
2079 - default:
2080 - return;
2081 - }
2082 -
2083 - $meta = usces_has_custom_field_meta($custom_field);
2084 -
2085 - if(!empty($meta) and is_array($meta)) {
2086 - foreach($meta as $key => $entry) {
2087 - if($custom_field == 'order' or $entry['position'] == $position) {
2088 - $name = $entry['name'];
2089 - $means = $entry['means'];
2090 -
2091 - $html .= '<tr>
2092 - <th>'.esc_html($name).'</th>
2093 - <td>';
2094 - if(!empty($data[$label][$key])) {
2095 - switch($means) {
2096 - case 0://シングルセレクト
2097 - case 2://テキスト
2098 - case 3://ラジオボタン
2099 - $html .= esc_html($data[$label][$key]);
2100 - break;
2101 - case 1://マルチセレクト
2102 - case 4://チェックボックス
2103 - if(is_array($data[$label][$key])) {
2104 - $c = '';
2105 - foreach($data[$label][$key] as $v) {
2106 - $html .= $c.esc_html($v);
2107 - $c = ', ';
2108 - }
2109 - } else {
2110 - if(!empty($data[$label][$key])) $html .= esc_html($data[$label][$key]);
2111 - }
2112 - break;
2113 - }
2114 - }
2115 - $html .= '
2116 - </td>
2117 - </tr>';
2118 - }
2119 - }
2120 - }
2121 -
2122 - $html = apply_filters('usces_filter_custom_field_info', $html, $data, $custom_field, $position);
2123 -
2124 - if($out == 'return') {
2125 - return stripslashes($html);
2126 - } else {
2127 - echo stripslashes($html);
2128 - }
2129 -}
2130 -
2131 -function usces_admin_custom_field_input( $meta, $custom_field, $position, $out = '' ) {
2132 -
2133 - $html = '';
2134 - switch($custom_field) {
2135 - case 'order':
2136 - $label = 'custom_order';
2137 - $class = '';
2138 - break;
2139 - case 'customer':
2140 - $label = 'custom_customer';
2141 - $class = ' class="col2"';
2142 - break;
2143 - case 'delivery':
2144 - $label = 'custom_delivery';
2145 - $class = ' class="col3"';
2146 - break;
2147 - case 'member':
2148 - $label = 'custom_member';
2149 - $class = '';
2150 - break;
2151 - default:
2152 - return;
2153 - }
2154 -
2155 -
2156 - if(!empty($meta) and is_array($meta)) {
2157 - foreach($meta as $key => $entry) {
2158 - if($custom_field == 'order' or $entry['position'] == $position) {
2159 - $name = $entry['name'];
2160 - $means = $entry['means'];
2161 - $essential = $entry['essential'];
2162 - $value = '';
2163 - if(is_array($entry['value'])) {
2164 - foreach($entry['value'] as $k => $v) {
2165 - $value .= $v."\n";
2166 - }
2167 - }
2168 - $value = trim($value);
2169 - $data = $entry['data'];
2170 -
2171 - $html .= '
2172 - <tr>
2173 - <td class="label">'.esc_html($name).'</td>';
2174 - switch($means) {
2175 - case 0://シングルセレクト
2176 - case 1://マルチセレクト
2177 - $selects = explode("\n", $value);
2178 - $multiple = ($means == 0) ? '' : ' multiple';
2179 - $multiple_array = ($means == 0) ? '' : '[]';
2180 - $html .= '
2181 - <td'.$class.'>
2182 - <select name="'.$label.'['.esc_attr($key).']'.$multiple_array.'" id="'.$label.'['.esc_attr($key).']" class="iopt_select"'.$multiple.'>';
2183 - if($essential == 1)
2184 - $html .= '
2185 - <option value="#NONE#">'.__('Choose','usces').'</option>';
2186 - foreach($selects as $v) {
2187 - $selected = ($data == $v) ? ' selected' : '';
2188 - $html .= '
2189 - <option value="'.esc_attr($v).'"'.$selected.'>'.esc_html($v).'</option>';
2190 - }
2191 - $html .= '
2192 - </select></td>';
2193 - break;
2194 - case 2://テキスト
2195 - $html .= '
2196 - <td'.$class.'><input type="text" name="'.$label.'['.esc_attr($key).']" id="'.$label.'['.esc_attr($key).']" size="30" value="'.esc_attr($data).'" /></td>';
2197 - break;
2198 - case 3://ラジオボタン
2199 - $selects = explode("\n", $value);
2200 - $html .= '
2201 - <td'.$class.'>';
2202 - foreach($selects as $v) {
2203 - $checked = ($data == $v) ? ' checked' : '';
2204 - $html .= '
2205 - <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>';
2206 - }
2207 - $html .= '
2208 - </td>';
2209 - break;
2210 - case 4://チェックボックス
2211 - $selects = explode("\n", $value);
2212 - $html .= '
2213 - <td'.$class.'>';
2214 - foreach($selects as $v) {
2215 - if(is_array($data)) {
2216 - $checked = (array_key_exists($v, $data)) ? ' checked' : '';
2217 - } else {
2218 - $checked = ($data == $v) ? ' checked' : '';
2219 - }
2220 - $html .= '
2221 - <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>';
2222 - }
2223 - $html .= '
2224 - </td>';
2225 - break;
2226 - }
2227 - $html .= '
2228 - </tr>';
2229 - }
2230 -
2231 - }
2232 - }
2233 - $html = apply_filters( 'usces_filter_admin_custom_field_input', $html, $meta, $custom_field, $position, $out );
2234 -
2235 - if($out == 'return') {
2236 - return stripslashes($html);
2237 - } else {
2238 - echo stripslashes($html);
2239 - }
2240 -}
2241 -
2242 -function has_custom_customer_field_essential() {
2243 -
2244 - $mes = '';
2245 - $essential = array();
2246 -
2247 - $csmb_meta = usces_has_custom_field_meta('member');
2248 - if(!empty($csmb_meta) and is_array($csmb_meta)) {
2249 - foreach($csmb_meta as $key => $entry) {
2250 - if($entry['essential'] == 1) {
2251 - $essential[$key] = $key;
2252 - }
2253 - }
2254 - }
2255 - if(!empty($essential)) {
2256 - $cscs_meta = usces_has_custom_field_meta('customer');
2257 - if(!empty($cscs_meta) and is_array($cscs_meta)) {
2258 - foreach($cscs_meta as $key => $entry) {
2259 - if($entry['essential'] == 1) {
2260 - if(!array_key_exists($key, $essential)) {
2261 - if($entry['means'] == 2) {//Text
2262 - $mes .= sprintf(__("Input the %s", 'usces'), esc_html($entry['name']))."<br />";
2263 - } else {
2264 - $mes .= sprintf(__("Chose the %s", 'usces'), esc_html($entry['name']))."<br />";
2265 - }
2266 - }
2267 - }
2268 - }
2269 - }
2270 - }
2271 - return $mes;
2272 -}
2273 -//20100818ysk end
2274 -
2275 -function usces_order_discount( $out = '' ){
2276 - global $usces;
2277 - $res = abs($usces->get_order_discount());
2278 -
2279 - if($out == 'return') {
2280 - return $res;
2281 - } else {
2282 - echo number_format($res);
2283 - }
2284 -}
2285 -
2286 -function usces_item_discount( $out = '', $post_id = '', $sku = '' ){
2287 - global $usces, $post;
2288 -
2289 - if( '' == $post_id )
2290 - $post_id = $post->ID;
2291 - if( '' == $sku )
2292 - $sku = $usces->itemsku['code'];
2293 -
2294 - $res = $usces->getItemDiscount($post_id, $sku);
2295 -
2296 - if($out == 'return') {
2297 - return $res;
2298 - } else {
2299 - echo number_format($res);
2300 - }
2301 -}
2302 -
2303 -function usces_singleitem_error_message($post_id, $skukey, $out = ''){
2304 - if( !isset($_SESSION['usces_singleitem']['error_message'][$post_id][$skukey]) )
2305 - $ret = '';
2306 - else
2307 - $ret = $_SESSION['usces_singleitem']['error_message'][$post_id][$skukey];
2308 -
2309 - if($out == 'return') {
2310 - return $ret;
2311 - } else {
2312 - echo $ret;
2313 - }
2314 -}
2315 -
2316 -function usces_crform( $float, $symbol_pre = true, $symbol_post = true, $out = '', $seperator_flag = true ) {
2317 - global $usces;
2318 - $price = esc_html($usces->get_currency($float, $symbol_pre, $symbol_post, $seperator_flag ));
2319 - $res = apply_filters('usces_filter_crform', $price, $float);
2320 -
2321 - if($out == 'return'){
2322 - return $res;
2323 - }else{
2324 - echo $res;
2325 - }
2326 -}
2327 -
2328 -function usces_memberinfo( $key, $out = '' ){
2329 - global $usces, $wpdb;
2330 - $info = $usces->get_member();
2331 -
2332 - if( empty($key) ) return $info;
2333 -
2334 - switch ($key){
2335 - case 'registered':
2336 - $res = mysql2date(__('Mj, Y', 'usces'), $info['registered']);
2337 - break;
2338 -//20120919ysk start 0000573
2339 - case 'point':
2340 - $member_table = $wpdb->prefix."usces_member";
2341 - $query = $wpdb->prepare("SELECT mem_point FROM $member_table WHERE ID = %d", $info['ID']);
2342 - $res = $wpdb->get_var( $query );
2343 - break;
2344 -//20120919ysk end
2345 - default:
2346 - $res = isset($info[$key]) ? $info[$key] : '';
2347 - }
2348 -
2349 - if($out == 'return'){
2350 - return $res;
2351 - }else{
2352 - echo esc_html($res);
2353 - }
2354 -}
2355 -
2356 -function usces_localized_name( $Familly_name, $Given_name, $out = '' ){
2357 - global $usces_settings, $usces;
2358 -
2359 - $options = get_option('usces');
2360 - $form = $options['system']['addressform'];
2361 - if( $usces_settings['nameform'][$form] ){
2362 - $res = $Given_name . ' ' . $Familly_name;
2363 - }else{
2364 - $res = $Familly_name . ' ' . $Given_name;
2365 - }
2366 -
2367 - if($out == 'return'){
2368 - return $res;
2369 - }else{
2370 - echo esc_html($res);
2371 - }
2372 -}
2373 -
2374 -function usces_member_history( $out = '' ){
2375 - global $usces;
2376 -
2377 - $usces_members = $usces->get_member();
2378 - $usces_member_history = $usces->get_member_history($usces_members['ID']);
2379 - $colspan = usces_is_membersystem_point() ? 9 : 7;
2380 -
2381 - $html = '<table>';
2382 - if ( !count($usces_member_history) ) {
2383 - $html .= '<tr>
2384 - <td>' . __('There is no purchase history for this moment.', 'usces') . '</td>
2385 - </tr>';
2386 - }
2387 - foreach ( $usces_member_history as $umhs ) {
2388 - $cart = $umhs['cart'];
2389 - $history_member_head = '<tr>
2390 - <th class="historyrow">' . __('Order number', 'usces') . '</th>
2391 - <th class="historyrow">' . __('Purchase date', 'usces') . '</th>
2392 - <th class="historyrow">' . __('Purchase price', 'usces') . '</th>';
2393 - if( usces_is_membersystem_point() ){
2394 - $history_member_head .= '<th class="historyrow">' . __('Used points', 'usces') . '</th>';
2395 - }
2396 - $history_member_head .= '<th class="historyrow">' . apply_filters( 'usces_member_discount_label', __('Special Price', 'usces'), $umhs['ID'] ) . '</th>
2397 - <th class="historyrow">' . __('Shipping', 'usces') . '</th>
2398 - <th class="historyrow">' . __('C.O.D', 'usces') . '</th>
2399 - <th class="historyrow">' . __('consumption tax', 'usces') . '</th>';
2400 - if( usces_is_membersystem_point() ){
2401 - $history_member_head .= '<th class="historyrow">' . __('Acquired points', 'usces') . '</th>';
2402 - }
2403 - $history_member_head .= '</tr>
2404 - <tr>
2405 - <td class="rightnum">' . usces_get_deco_order_id($umhs['ID']) . '</td>
2406 - <td class="date">' . $umhs['date'] . '</td>
2407 - <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>';
2408 - if( usces_is_membersystem_point() ){
2409 - $history_member_head .= '<td class="rightnum">' . number_format($umhs['usedpoint']) . '</td>';
2410 - }
2411 - $history_member_head .= '<td class="rightnum">' . usces_crform($umhs['discount'], true, false, 'return') . '</td>
2412 - <td class="rightnum">' . usces_crform($umhs['shipping_charge'], true, false, 'return') . '</td>
2413 - <td class="rightnum">' . usces_crform($umhs['cod_fee'], true, false, 'return') . '</td>
2414 - <td class="rightnum">' . usces_crform($umhs['tax'], true, false, 'return') . '</td>';
2415 - if( usces_is_membersystem_point() ){
2416 - $history_member_head .= '<td class="rightnum">' . number_format($umhs['getpoint']) . '</td>';
2417 - }
2418 - $history_member_head .= '</tr>';
2419 - $html .= apply_filters( 'usces_filter_history_member_head', $history_member_head, $umhs );
2420 - $html .= apply_filters('usces_filter_member_history_header', NULL, $umhs);
2421 - $html .= '<tr>
2422 - <td class="retail" colspan="' . $colspan . '">
2423 - <table id="retail_table_' . $umhs['ID'] . '" class="retail">';
2424 - $history_cart_head = '<tr>
2425 - <th scope="row" class="num">No.</th>
2426 - <th class="thumbnail">&nbsp;</th>
2427 - <th>' . __('Items', 'usces') . '</th>
2428 - <th class="price ">' . __('Unit price', 'usces') . '</th>
2429 - <th class="quantity">' . __('Quantity', 'usces') . '</th>
2430 - <th class="subtotal">' . __('Amount', 'usces') . '</th>
2431 - </tr>';
2432 - $html .= apply_filters('usces_filter_history_cart_head', $history_cart_head, $umhs);
2433 -
2434 - for($i=0; $i<count($cart); $i++) {
2435 - $cart_row = $cart[$i];
2436 - $post_id = $cart_row['post_id'];
2437 - $sku = urldecode($cart_row['sku']);
2438 - $quantity = $cart_row['quantity'];
2439 - $options = $cart_row['options'];
2440 - $itemCode = $usces->getItemCode($post_id);
2441 - $itemName = $usces->getItemName($post_id);
2442 - $cartItemName = $usces->getCartItemName($post_id, $sku);
2443 - //$skuPrice = $usces->getItemPrice($post_id, $sku);
2444 - $skuPrice = $cart_row['price'];
2445 - $pictid = (int)$usces->get_mainpictid($itemCode);
2446 - $optstr = '';
2447 - if( is_array($options) && count($options) > 0 ){
2448 - $optstr = '';
2449 - foreach($options as $key => $value){
2450 -//20110629ysk start 0000190
2451 - //f( !empty($key) )
2452 - // $optstr .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
2453 - if( !empty($key) ) {
2454 - $key = urldecode($key);
2455 - if(is_array($value)) {
2456 - $c = '';
2457 - $optstr .= esc_html($key) . ' : ';
2458 - foreach($value as $v) {
2459 - $optstr .= $c.nl2br(esc_html(urldecode($v)));
2460 - $c = ', ';
2461 - }
2462 - $optstr .= "<br />\n";
2463 - } else {
2464 - $optstr .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
2465 - }
2466 - }
2467 -//20110629ysk end
2468 - }
2469 - $optstr = apply_filters( 'usces_filter_option_history', $optstr, $options);
2470 - }
2471 - $optstr = apply_filters( 'usces_filter_option_info_history', $optstr, $umhs, $cart_row, $i );
2472 -
2473 - $history_cart_row = '<tr>
2474 - <td>' . ($i + 1) . '</td>
2475 - <td>';
2476 - $cart_thumbnail = '<a href="' . get_permalink($post_id) . '">' . wp_get_attachment_image( $pictid, array(60, 60), true ) . '</a>';
2477 - $history_cart_row .= apply_filters('usces_filter_cart_thumbnail', $cart_thumbnail, $post_id, $pictid, $i, $cart_row);
2478 - $history_cart_row .= '</td>
2479 - <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>
2480 - <td class="rightnum">' . usces_crform($skuPrice, true, false, 'return') . '</td>
2481 - <td class="rightnum">' . number_format($cart_row['quantity']) . '</td>
2482 - <td class="rightnum">' . usces_crform($skuPrice * $cart_row['quantity'], true, false, 'return') . '</td>
2483 - </tr>';
2484 - $materials = compact( 'cart_thumbnail', 'post_id', 'pictid', 'cartItemName', 'optstr' );
2485 - $html .= apply_filters( 'usces_filter_history_cart_row', $history_cart_row, $umhs, $cart_row, $i, $materials );
2486 - }
2487 - $html .= '</table>
2488 - </td>
2489 - </tr>';
2490 - }
2491 -
2492 - $html .= '</table>';
2493 -
2494 - if($out == 'return'){
2495 - return $html;
2496 - }else{
2497 - echo $html;
2498 - }
2499 -}
2500 -
2501 -function usces_newmember_button($member_regmode){
2502 - $html = '<input name="member_regmode" type="hidden" value="' . $member_regmode . '" />';
2503 - $newmemberbutton = '<input name="regmember" type="submit" value="' . __('transmit a message', 'usces') . '" />';
2504 - $html .= apply_filters('usces_filter_newmember_button', $newmemberbutton);
2505 - echo $html;
2506 -}
2507 -
2508 -function usces_login_button(){
2509 - $loginbutton = '<input type="submit" name="member_login" id="member_login" class="member_login_button" value="' . __('Log-in', 'usces') . '" />';
2510 - $html = apply_filters('usces_filter_login_button', $loginbutton);
2511 - echo $html;
2512 -}
2513 -
2514 -function usces_assistance_item($post_id, $title ){
2515 - if (usces_get_assistance_id_list($post_id)) :
2516 - global $post;
2517 - $r = new WP_Query( array('post__in'=>usces_get_assistance_ids($post_id), 'ignore_sticky_posts'=>1) );
2518 - if($r->have_posts()) :
2519 - add_filter( 'excerpt_length', 'welcart_assistance_excerpt_length' );
2520 - add_filter( 'excerpt_mblength', 'welcart_assistance_excerpt_mblength' );
2521 - $width = apply_filters( 'usces_filter_assistance_item_width', 100 );
2522 - $height = apply_filters( 'usces_filter_assistance_item_height', 100 );
2523 -?>
2524 - <div class="assistance_item">
2525 - <h3><?php echo $title; ?></h3>
2526 - <ul class="clearfix">
2527 -<?php
2528 - while ($r->have_posts()) :
2529 - $r->the_post();
2530 - usces_remove_filter();
2531 - usces_the_item();
2532 - ob_start();
2533 -?>
2534 - <li>
2535 - <div class="listbox clearfix">
2536 - <div class="slit">
2537 - <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>
2538 - </div>
2539 - <div class="detail">
2540 - <div class="assist_excerpt">
2541 - <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php echo wp_filter_nohtml_kses(get_the_title()); ?>"><h4><?php usces_the_itemName(); ?></h4></a>
2542 - <?php the_excerpt(); ?>
2543 - </div>
2544 - <div class="assist_price">
2545 - <?php if (usces_is_skus()) : ?>
2546 - <?php _e('$', 'usces'); ?><?php usces_the_firstPrice(); ?>
2547 - <?php endif; ?>
2548 - </div>
2549 - </div>
2550 - </div>
2551 - </li>
2552 - <?php
2553 - $list = ob_get_contents();
2554 - ob_end_clean();
2555 - echo apply_filters('usces_filter_assistance_item_list', $list, $post);
2556 - endwhile; ?>
2557 -
2558 - </ul>
2559 - </div><!-- end of assistance_item -->
2560 -<?php
2561 - wp_reset_postdata();
2562 - usces_reset_filter();
2563 - remove_filter( 'excerpt_length', 'welcart_assistance_excerpt_length' );
2564 - remove_filter( 'excerpt_mblength', 'welcart_assistance_excerpt_mblength' );
2565 - endif;
2566 - endif;
2567 -}
2568 -
2569 -function usces_get_cart_rows( $out = '' ) {
2570 - global $usces, $usces_gp;
2571 - $cart = $usces->cart->get_cart();
2572 - $usces_gp = 0;
2573 - $res = '';
2574 -
2575 - for($i=0; $i<count($cart); $i++) {
2576 - $cart_row = $cart[$i];
2577 - $post_id = $cart_row['post_id'];
2578 - $sku = $cart_row['sku'];
2579 - $sku_code = esc_attr(urldecode($cart_row['sku']));
2580 - $quantity = $cart_row['quantity'];
2581 - $options = $cart_row['options'];
2582 - $advance = $usces->cart->wc_serialize($cart_row['advance']);
2583 - $itemCode = $usces->getItemCode($post_id);
2584 - $itemName = $usces->getItemName($post_id);
2585 - $cartItemName = $usces->getCartItemName($post_id, $sku_code);
2586 - $itemRestriction = $usces->getItemRestriction($post_id);
2587 - $skuPrice = $cart_row['price'];
2588 - $skuZaikonum = $usces->getItemZaikonum($post_id, $sku_code);
2589 - $stockid = $usces->getItemZaikoStatusId($post_id, $sku_code);
2590 - $stock = $usces->getItemZaiko($post_id, $sku_code);
2591 - $red = (in_array($stock, array(__('sellout','usces'), __('Out Of Stock','usces'), __('Out of print','usces')))) ? 'class="signal_red"' : '';
2592 - $pictid = (int)$usces->get_mainpictid($itemCode);
2593 - $args = compact('cart', 'i', 'cart_row', 'post_id', 'sku' );
2594 - $row = '';
2595 - if ( empty($options) ) {
2596 - $optstr = '';
2597 - $options = array();
2598 - }
2599 - $row .= '<tr>
2600 - <td>' . ($i + 1) . '</td>
2601 - <td>';
2602 - $cart_thumbnail = '<a href="' . get_permalink($post_id) . '">' . wp_get_attachment_image( $pictid, array(60, 60), true ) . '</a>';
2603 - $row .= apply_filters('usces_filter_cart_thumbnail', $cart_thumbnail, $post_id, $pictid, $i,$cart_row);
2604 - $row .= '</td><td class="aleft">' . esc_html($cartItemName) . '<br />';
2605 - if( is_array($options) && count($options) > 0 ){
2606 - $optstr = '';
2607 - foreach($options as $key => $value){
2608 -//20110629ysk start 0000190
2609 - //if( !empty($key) )
2610 - // $row .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
2611 - if( !empty($key) ) {
2612 - $key = urldecode($key);
2613 - if(is_array($value)) {
2614 - $c = '';
2615 - $optstr .= esc_html($key) . ' : ';
2616 - foreach($value as $v) {
2617 - $optstr .= $c.nl2br(esc_html(urldecode($v)));
2618 - $c = ', ';
2619 - }
2620 - $optstr .= "<br />\n";
2621 - } else {
2622 - $optstr .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
2623 - }
2624 - }
2625 -//20110629ysk end
2626 - }
2627 - $row .= apply_filters( 'usces_filter_option_cart', $optstr, $options);
2628 - }
2629 - $row .= apply_filters( 'usces_filter_option_info_cart', '', $cart_row, $args );
2630 - $row .= '</td>
2631 - <td class="aright">';
2632 - if( usces_is_gptekiyo($post_id, $sku_code, $quantity) ) {
2633 - $usces_gp = 1;
2634 - $Business_pack_mark = '<img src="' . get_template_directory_uri() . '/images/gp.gif" alt="' . __('Business package discount','usces') . '" /><br />';
2635 - $row .= apply_filters('usces_filter_itemGpExp_cart_mark', $Business_pack_mark);
2636 - }
2637 - $row .= usces_crform($skuPrice, true, false, 'return') . '
2638 - </td>
2639 - <td>';
2640 - $row_quant = '<input name="quant[' . $i . '][' . $post_id . '][' . $sku . ']" class="quantity" type="text" value="' . esc_attr($cart_row['quantity']) . '" />';
2641 - $row .= apply_filters( 'usces_filter_cart_rows_quant', $row_quant, $args );
2642 - $row .= '</td>
2643 - <td class="aright">' . usces_crform(($skuPrice * $cart_row['quantity']), true, false, 'return') . '</td>
2644 - <td ' . $red . '>' . $stock . '</td>
2645 - <td>';
2646 - foreach($options as $key => $value){
2647 -//20110629ysk start 0000190
2648 - //$row .= '<input name="itemOption[' . $i . '][' . $post_id . '][' . $sku . '][' . $key . ']" type="hidden" value="' . $value . '" />';
2649 - if(is_array($value)) {
2650 - foreach($value as $v) {
2651 - $row .= '<input name="itemOption[' . $i . '][' . $post_id . '][' . $sku . '][' . $key . '][' . $v . ']" type="hidden" value="' . $v . '" />';
2652 - }
2653 - } else {
2654 - $row .= '<input name="itemOption[' . $i . '][' . $post_id . '][' . $sku . '][' . $key . ']" type="hidden" value="' . $value . '" />';
2655 - }
2656 -//20110629ysk end
2657 - }
2658 - $row .= '<input name="itemRestriction[' . $i . ']" type="hidden" value="' . $itemRestriction . '" />
2659 - <input name="stockid[' . $i . ']" type="hidden" value="' . $stockid . '" />
2660 - <input name="itempostid[' . $i . ']" type="hidden" value="' . $post_id . '" />
2661 - <input name="itemsku[' . $i . ']" type="hidden" value="' . $sku . '" />
2662 - <input name="zaikonum[' . $i . '][' . $post_id . '][' . $sku . ']" type="hidden" value="' . esc_attr($skuZaikonum) . '" />
2663 - <input name="skuPrice[' . $i . '][' . $post_id . '][' . $sku . ']" type="hidden" value="' . esc_attr($skuPrice) . '" />
2664 - <input name="advance[' . $i . '][' . $post_id . '][' . $sku . ']" type="hidden" value="' . esc_attr($advance) . '" />
2665 - <input name="delButton[' . $i . '][' . $post_id . '][' . $sku . ']" class="delButton" type="submit" value="' . __('Delete','usces') . '" />
2666 - </td>
2667 - </tr>';
2668 - $materials = compact('i', 'cart_row', 'post_id', 'sku', 'sku_code', 'quantity', 'options', 'advance',
2669 - 'itemCode', 'itemName', 'cartItemName', 'itemRestriction', 'skuPrice', 'skuZaikonum',
2670 - 'stockid', 'stock', 'red', 'pictid');
2671 - $res .= apply_filters( 'usces_filter_cart_row', $row, $cart, $materials);
2672 - }
2673 -
2674 - $res = apply_filters( 'usces_filter_cart_rows', $res, $cart);
2675 -
2676 - if($out == 'return'){
2677 - return $res;
2678 - }else{
2679 - echo $res;
2680 - }
2681 -}
2682 -function usces_get_confirm_rows( $out = '' ) {
2683 - global $usces, $usces_members, $usces_entries;
2684 -// $usces_members = $usces->get_member();
2685 - $memid = ( empty($usces_members['ID']) ) ? 999999999 : $usces_members['ID'];
2686 -// $usces_entries = $usces->cart->get_entry();
2687 - $usces->set_cart_fees( $usces_members, $usces_entries );
2688 - $usces_entries = $usces->cart->get_entry();
2689 -
2690 - $cart = $usces->cart->get_cart();
2691 - $res = '';
2692 - for($i=0; $i<count($cart); $i++) {
2693 - $cart_row = $cart[$i];
2694 - $post_id = $cart_row['post_id'];
2695 - $sku = esc_attr($cart_row['sku']);
2696 - $sku_code = esc_attr(urldecode($cart_row['sku']));
2697 - $quantity = $cart_row['quantity'];
2698 - $options = $cart_row['options'];
2699 - $advance = $usces->cart->wc_serialize($cart_row['advance']);
2700 - $itemCode = $usces->getItemCode($post_id);
2701 - $itemName = $usces->getItemName($post_id);
2702 - $cartItemName = $usces->getCartItemName($post_id, $sku_code);
2703 - $skuPrice = $cart_row['price'];
2704 - $pictid = $usces->get_mainpictid($itemCode);
2705 - $args = compact('cart', 'i', 'cart_row', 'post_id', 'sku' );
2706 - $row = '';
2707 - if (empty($options)) {
2708 - $optstr = '';
2709 - $options = array();
2710 - }
2711 -
2712 - $row .= '<tr>
2713 - <td>' . ($i + 1) . '</td>
2714 - <td>';
2715 - $cart_thumbnail = wp_get_attachment_image( $pictid, array(60, 60), true );
2716 - $row .= apply_filters('usces_filter_cart_thumbnail', $cart_thumbnail, $post_id, $pictid, $i, $cart_row);
2717 - $row .= '</td><td class="aleft">' . $cartItemName . '<br />';
2718 - if( is_array($options) && count($options) > 0 ){
2719 - $optstr = '';
2720 - foreach($options as $key => $value){
2721 -//20110629ysk start 0000190
2722 - //if( !empty($key) )
2723 - // $row .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
2724 - if( !empty($key) ) {
2725 - $key = urldecode($key);
2726 - if(is_array($value)) {
2727 - $c = '';
2728 - $optstr .= esc_html($key) . ' : ';
2729 - foreach($value as $v) {
2730 - $optstr .= $c.nl2br(esc_html(urldecode($v)));
2731 - $c = ', ';
2732 - }
2733 - $optstr .= "<br />\n";
2734 - } else {
2735 - $optstr .= esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value))) . "<br />\n";
2736 - }
2737 - }
2738 -//20110629ysk end
2739 - }
2740 - $row .= apply_filters( 'usces_filter_option_confirm', $optstr, $options);
2741 - }
2742 - $row .= apply_filters( 'usces_filter_option_info_confirm', '', $cart_row, $args );
2743 - $row .= '</td>
2744 - <td class="aright">' . usces_crform($skuPrice, true, false, 'return') . '</td>
2745 - <td>' . $cart_row['quantity'] . '</td>
2746 - <td class="aright">' . usces_crform(($skuPrice * $cart_row['quantity']), true, false, 'return') . '</td>
2747 - <td>';
2748 - $res = apply_filters('usces_additional_confirm', $res, array($i, $post_id, $sku_code));
2749 - $row .= '</td>
2750 - </tr>';
2751 -
2752 - $materials = compact('i', 'cart_row', 'post_id', 'sku', 'sku_code', 'quantity', 'options', 'advance',
2753 - 'itemCode', 'itemName', 'cartItemName', 'skuPrice', 'pictid');
2754 - $res .= apply_filters( 'usces_filter_confirm_row', $row, $cart, $materials);
2755 - }
2756 -
2757 - $res = apply_filters( 'usces_filter_confirm_rows', $res, $cart);
2758 -
2759 - if($out == 'return'){
2760 - return $res;
2761 - }else{
2762 - echo $res;
2763 - }
2764 -}
2765 -
2766 -function uesces_addressform( $type, $data, $out = 'return' ){
2767 - global $usces, $usces_settings;
2768 - $options = get_option('usces');
2769 - $form = $options['system']['addressform'];
2770 - $nameform = $usces_settings['nameform'][$form];
2771 - $applyform = usces_get_apply_addressform($form);
2772 - $formtag = '';
2773 - switch( $type ){
2774 - case 'confirm':
2775 - case 'member':
2776 - $values = $data;
2777 - break;
2778 - case 'customer':
2779 - case 'delivery':
2780 - $values = $data[$type];
2781 - break;
2782 - }
2783 - $data['type'] = $type;
2784 - $values['country'] = !empty($values['country']) ? $values['country'] : usces_get_local_addressform();
2785 - $values = $usces->stripslashes_deep_post($values);
2786 - if( 'confirm' == $type ){
2787 -
2788 - switch ($applyform){
2789 -
2790 - case 'JP':
2791 - $formtag .= usces_custom_field_info($data, 'customer', 'name_pre', 'return');
2792 - $formtag .= '<tr><th>'.__('Full name', 'usces').'</th><td>' . esc_html($values['customer']['name1']) . ' ' . esc_html($values['customer']['name2']) . '</td></tr>';
2793 - $furigana_customer = '<tr><th>'.__('furigana', 'usces').'</th><td>' . esc_html($values['customer']['name3']) . ' ' . esc_html($values['customer']['name4']) . '</td></tr>';
2794 - $formtag .= apply_filters( 'usces_filter_furigana_confirm_customer', $furigana_customer, $type, $values );
2795 - $formtag .= usces_custom_field_info($data, 'customer', 'name_after', 'return');
2796 - $customer_country = (!empty($usces_settings['country'][$values['customer']['country']])) ? $usces_settings['country'][$values['customer']['country']] : '';
2797 - $formtag .= '
2798 - <tr><th>'.__('Zip/Postal Code', 'usces').'</th><td>' . esc_html($values['customer']['zipcode']) . '</td></tr>
2799 - <tr><th>'.__('Country', 'usces').'</th><td>' . esc_html($customer_country) . '</td></tr>
2800 - <tr><th>'.__('Province', 'usces').'</th><td>' . esc_html($values['customer']['pref']) . '</td></tr>
2801 - <tr><th>'.__('city', 'usces').'</th><td>' . esc_html($values['customer']['address1']) . '</td></tr>
2802 - <tr><th>'.__('numbers', 'usces').'</th><td>' . esc_html($values['customer']['address2']) . '</td></tr>
2803 - <tr><th>'.__('building name', 'usces').'</th><td>' . esc_html($values['customer']['address3']) . '</td></tr>
2804 - <tr><th>'.__('Phone number', 'usces').'</th><td>' . esc_html($values['customer']['tel']) . '</td></tr>
2805 - <tr><th>'.__('FAX number', 'usces').'</th><td>' . esc_html($values['customer']['fax']) . '</td></tr>';
2806 - $formtag .= usces_custom_field_info($data, 'customer', 'fax_after', 'return');
2807 -
2808 - $shipping_address_info = '<tr class="ttl"><td colspan="2"><h3>'.__('Shipping address information', 'usces').'</h3></td></tr>';
2809 - $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'name_pre', 'return');
2810 - $shipping_address_info .= '<tr><th>'.__('Full name', 'usces').'</th><td>' . esc_html($values['delivery']['name1']) . ' ' . esc_html($values['delivery']['name2']) . '</td></tr>';
2811 - $furigana_delivery = '<tr><th>'.__('furigana', 'usces').'</th><td>' . esc_html($values['delivery']['name3']) . ' ' . esc_html($values['delivery']['name4']) . '</td></tr>';
2812 - $shipping_address_info .= apply_filters( 'usces_filter_furigana_confirm_delivery', $furigana_delivery, $type, $values );
2813 - $shipping_address_info .= usces_custom_field_info($values, 'delivery', 'name_after', 'return');
2814 - $shipping_country = (!empty($usces_settings['country'][$values['delivery']['country']])) ? $usces_settings['country'][$values['delivery']['country']] : '';
2815 - $shipping_address_info .= '
2816 - <tr><th>'.__('Zip/Postal Code', 'usces').'</th><td>' . esc_html($values['delivery']['zipcode']) . '</td></tr>
2817 - <tr><th>'.__('Country', 'usces').'</th><td>' . esc_html($shipping_country) . '</td></tr>
2818 - <tr><th>'.__('Province', 'usces').'</th><td>' . esc_html($values['delivery']['pref']) . '</td></tr>
2819 - <tr><th>'.__('city', 'usces').'</th><td>' . esc_html($values['delivery']['address1']) . '</td></tr>
2820 - <tr><th>'.__('numbers', 'usces').'</th><td>' . esc_html($values['delivery']['address2']) . '</td></tr>
2821 - <tr><th>'.__('building name', 'usces').'</th><td>' . esc_html($values['delivery']['address3']) . '</td></tr>
2822 - <tr><th>'.__('Phone number', 'usces').'</th><td>' . esc_html($values['delivery']['tel']) . '</td></tr>
2823 - <tr><th>'.__('FAX number', 'usces').'</th><td>' . esc_html($values['delivery']['fax']) . '</td></tr>';
2824 - $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'fax_after', 'return');
2825 - $formtag .= apply_filters('usces_filter_shipping_address_info', $shipping_address_info);
2826 - break;
2827 -
2828 - case 'CN':
2829 - $formtag .= usces_custom_field_info($data, 'customer', 'name_pre', 'return');
2830 - $formtag .= '<tr><th>'.__('Full name', 'usces').'</th><td>' . esc_html(usces_localized_name( $values['customer']['name1'], $values['customer']['name2'], 'return' )) . '</td></tr>';
2831 - $formtag .= usces_custom_field_info($data, 'customer', 'name_after', 'return');
2832 - $formtag .= '
2833 - <tr><th>'.__('Country', 'usces').'</th><td>' . esc_html($usces_settings['country'][$values['customer']['country']]) . '</td></tr>
2834 - <tr><th>'.__('State', 'usces').'</th><td>' . esc_html($values['customer']['pref']) . '</td></tr>
2835 - <tr><th>'.__('city', 'usces').'</th><td>' . esc_html($values['customer']['address1']) . '</td></tr>
2836 - <tr><th>'.__('Address Line1', 'usces').'</th><td>' . esc_html($values['customer']['address2']) . '</td></tr>
2837 - <tr><th>'.__('Address Line2', 'usces').'</th><td>' . esc_html($values['customer']['address3']) . '</td></tr>
2838 - <tr><th>'.__('Zip', 'usces').'</th><td>' . esc_html($values['customer']['zipcode']) . '</td></tr>
2839 - <tr><th>'.__('Phone number', 'usces').'</th><td>' . esc_html($values['customer']['tel']) . '</td></tr>
2840 - <tr><th>'.__('FAX number', 'usces').'</th><td>' . esc_html($values['customer']['fax']) . '</td></tr>';
2841 - $formtag .= usces_custom_field_info($data, 'customer', 'fax_after', 'return');
2842 -
2843 - $shipping_address_info = '<tr class="ttl"><td colspan="2"><h3>'.__('Shipping address information', 'usces').'</h3></td></tr>';
2844 - $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'name_pre', 'return');
2845 - $shipping_address_info .= '<tr><th>'.__('Full name', 'usces').'</th><td>' . esc_html(usces_localized_name( $values['delivery']['name1'], $values['delivery']['name2'], 'return' )) . '</td></tr>';
2846 - $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'name_after', 'return');
2847 - $shipping_address_info .= '
2848 - <tr><th>'.__('Country', 'usces').'</th><td>' . esc_html($usces_settings['country'][$values['delivery']['country']]) . '</td></tr>
2849 - <tr><th>'.__('State', 'usces').'</th><td>' . esc_html($values['delivery']['pref']) . '</td></tr>
2850 - <tr><th>'.__('city', 'usces').'</th><td>' . esc_html($values['delivery']['address1']) . '</td></tr>
2851 - <tr><th>'.__('Address Line1', 'usces').'</th><td>' . esc_html($values['delivery']['address2']) . '</td></tr>
2852 - <tr><th>'.__('Address Line2', 'usces').'</th><td>' . esc_html($values['delivery']['address3']) . '</td></tr>
2853 - <tr><th>'.__('Zip', 'usces').'</th><td>' . esc_html($values['delivery']['zipcode']) . '</td></tr>
2854 - <tr><th>'.__('Phone number', 'usces').'</th><td>' . esc_html($values['delivery']['tel']) . '</td></tr>
2855 - <tr><th>'.__('FAX number', 'usces').'</th><td>' . esc_html($values['delivery']['fax']) . '</td></tr>';
2856 - $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'fax_after', 'return');
2857 - $formtag .= apply_filters('usces_filter_shipping_address_info', $shipping_address_info);
2858 - break;
2859 -
2860 - case 'US':
2861 - default :
2862 - $formtag .= usces_custom_field_info($data, 'customer', 'name_pre', 'return');
2863 - $formtag .= '<tr><th>'.__('Full name', 'usces').'</th><td>' . esc_html($values['customer']['name2']) . ' ' . esc_html($values['customer']['name1']) . '</td></tr>';
2864 - $formtag .= usces_custom_field_info($data, 'customer', 'name_after', 'return');
2865 - $customer_country = (!empty($usces_settings['country'][$values['customer']['country']])) ? $usces_settings['country'][$values['customer']['country']] : '';
2866 - $formtag .= '
2867 - <tr><th>'.__('Address Line1', 'usces').'</th><td>' . esc_html($values['customer']['address2']) . '</td></tr>
2868 - <tr><th>'.__('Address Line2', 'usces').'</th><td>' . esc_html($values['customer']['address3']) . '</td></tr>
2869 - <tr><th>'.__('city', 'usces').'</th><td>' . esc_html($values['customer']['address1']) . '</td></tr>
2870 - <tr><th>'.__('State', 'usces').'</th><td>' . esc_html($values['customer']['pref']) . '</td></tr>
2871 - <tr><th>'.__('Country', 'usces').'</th><td>' . esc_html($customer_country) . '</td></tr>
2872 - <tr><th>'.__('Zip', 'usces').'</th><td>' . esc_html($values['customer']['zipcode']) . '</td></tr>
2873 - <tr><th>'.__('Phone number', 'usces').'</th><td>' . esc_html($values['customer']['tel']) . '</td></tr>
2874 - <tr><th>'.__('FAX number', 'usces').'</th><td>' . esc_html($values['customer']['fax']) . '</td></tr>';
2875 - $formtag .= usces_custom_field_info($data, 'customer', 'fax_after', 'return');
2876 -
2877 - $shipping_address_info = '<tr class="ttl"><td colspan="2"><h3>'.__('Shipping address information', 'usces').'</h3></td></tr>';
2878 - $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'name_pre', 'return');
2879 - $shipping_address_info .= '<tr><th>'.__('Full name', 'usces').'</th><td>' . esc_html($values['delivery']['name2']) . ' ' . esc_html($values['delivery']['name1']) . '</td></tr>';
2880 - $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'name_after', 'return');
2881 - $shipping_country = (!empty($usces_settings['country'][$values['delivery']['country']])) ? $usces_settings['country'][$values['delivery']['country']] : '';
2882 - $shipping_address_info .= '
2883 - <tr><th>'.__('Address Line1', 'usces').'</th><td>' . esc_html($values['delivery']['address2']) . '</td></tr>
2884 - <tr><th>'.__('Address Line2', 'usces').'</th><td>' . esc_html($values['delivery']['address3']) . '</td></tr>
2885 - <tr><th>'.__('city', 'usces').'</th><td>' . esc_html($values['delivery']['address1']) . '</td></tr>
2886 - <tr><th>'.__('State', 'usces').'</th><td>' . esc_html($values['delivery']['pref']) . '</td></tr>
2887 - <tr><th>'.__('Country', 'usces').'</th><td>' . esc_html($shipping_country) . '</td></tr>
2888 - <tr><th>'.__('Zip', 'usces').'</th><td>' . esc_html($values['delivery']['zipcode']) . '</td></tr>
2889 - <tr><th>'.__('Phone number', 'usces').'</th><td>' . esc_html($values['delivery']['tel']) . '</td></tr>
2890 - <tr><th>'.__('FAX number', 'usces').'</th><td>' . esc_html($values['delivery']['fax']) . '</td></tr>';
2891 - $shipping_address_info .= usces_custom_field_info($data, 'delivery', 'fax_after', 'return');
2892 - $formtag .= apply_filters('usces_filter_shipping_address_info', $shipping_address_info);
2893 - break;
2894 -
2895 - }
2896 - $res = apply_filters('usces_filter_apply_addressform_confirm', $formtag, $type, $data);
2897 -
2898 - }else{
2899 -
2900 - switch ($applyform){
2901 -
2902 - case 'JP':
2903 - $formtag .= usces_custom_field_input($data, $type, 'name_pre', 'return');
2904 - $formtag .= '<tr class="inp1">
2905 - <th width="127" scope="row">' . usces_get_essential_mark('name1', $data) . __('Full name', 'usces').'</th>';
2906 - if( $nameform ){
2907 - $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>';
2908 - $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>';
2909 - }else{
2910 - $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>';
2911 - $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>';
2912 - }
2913 - $formtag .= '</tr>';
2914 - $furigana = '<tr class="inp1">
2915 - <th scope="row">' . usces_get_essential_mark('name3', $data).__('furigana', 'usces').'</th>';
2916 - if( $nameform ){
2917 - $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>';
2918 - $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>';
2919 - }else{
2920 - $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>';
2921 - $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>';
2922 - }
2923 - $furigana .= '</tr>';
2924 - $formtag .= apply_filters( 'usces_filter_furigana_form', $furigana, $type, $values );
2925 - $formtag .= usces_custom_field_input($data, $type, 'name_after', 'return');
2926 - $formtag .= '<tr>
2927 - <th scope="row">' . usces_get_essential_mark('zipcode', $data).__('Zip/Postal Code', 'usces').'</th>
2928 - <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>
2929 - </tr>
2930 - <tr>
2931 - <th scope="row">' . usces_get_essential_mark('country', $data) . __('Country', 'usces') . '</th>
2932 - <td colspan="2">' . uesces_get_target_market_form( $type, $values['country'] ) . apply_filters( 'usces_filter_after_country', NULL, $applyform ) . '</td>
2933 - </tr>
2934 - <tr>
2935 - <th scope="row">' . usces_get_essential_mark('states', $data).__('Province', 'usces').'</th>
2936 - <td colspan="2">' . usces_pref_select( $type, $values ) . apply_filters( 'usces_filter_after_states', NULL, $applyform ) . '</td>
2937 - </tr>
2938 - <tr class="inp2">
2939 - <th scope="row">' . usces_get_essential_mark('address1', $data).__('city', 'usces').'</th>
2940 - <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>
2941 - </tr>
2942 - <tr>
2943 - <th scope="row">' . usces_get_essential_mark('address2', $data).__('numbers', 'usces').'</th>
2944 - <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>
2945 - </tr>
2946 - <tr>
2947 - <th scope="row">' . usces_get_essential_mark('address3', $data).__('building name', 'usces').'</th>
2948 - <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>
2949 - </tr>
2950 - <tr>
2951 - <th scope="row">' . usces_get_essential_mark('tel', $data).__('Phone number', 'usces').'</th>
2952 - <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>
2953 - </tr>
2954 - <tr>
2955 - <th scope="row">' . usces_get_essential_mark('fax', $data).__('FAX number', 'usces').'</th>
2956 - <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>
2957 - </tr>';
2958 - $formtag .= usces_custom_field_input($data, $type, 'fax_after', 'return');
2959 - break;
2960 -
2961 - case 'CN':
2962 - $formtag .= usces_custom_field_input($data, $type, 'name_pre', 'return');
2963 - $formtag .= '<tr class="inp1">
2964 - <th scope="row">' . usces_get_essential_mark('name1', $data) . __('Full name', 'usces') . '</th>';
2965 - if( $nameform ){
2966 - $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>';
2967 - $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>';
2968 - }else{
2969 - $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>';
2970 - $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>';
2971 - }
2972 - $formtag .= '</tr>';
2973 - $formtag .= usces_custom_field_input($data, $type, 'name_after', 'return');
2974 - $formtag .= '
2975 - <tr>
2976 - <th scope="row">' . usces_get_essential_mark('country', $data) . __('Country', 'usces') . '</th>
2977 - <td colspan="2">' . uesces_get_target_market_form( $type, $values['country'] ) . apply_filters( 'usces_filter_after_country', NULL, $applyform ) . '</td>
2978 - </tr>
2979 - <tr>
2980 - <th scope="row">' . usces_get_essential_mark('states', $data) . __('State', 'usces') . '</th>
2981 - <td colspan="2">' . usces_pref_select( $type, $values ) . apply_filters( 'usces_filter_after_states', NULL, $applyform ) . '</td>
2982 - </tr>
2983 - <tr class="inp2">
2984 - <th scope="row">' . usces_get_essential_mark('address1', $data) . __('city', 'usces') . '</th>
2985 - <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>
2986 - </tr>
2987 - <tr>
2988 - <th scope="row">' . usces_get_essential_mark('address2', $data) . __('Address Line1', 'usces') . '</th>
2989 - <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>
2990 - </tr>
2991 - <tr>
2992 - <th scope="row">' . usces_get_essential_mark('address3', $data) . __('Address Line2', 'usces') . '</th>
2993 - <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>
2994 - </tr>
2995 - <tr>
2996 - <th scope="row">' . usces_get_essential_mark('zipcode', $data) . __('Zip', '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;}" />' . apply_filters( 'usces_filter_after_zipcode', NULL, $applyform ) . '</td>
2998 - </tr>
2999 - <tr>
3000 - <th scope="row">' . usces_get_essential_mark('tel', $data) . __('Phone number', 'usces') . '</th>
3001 - <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>
3002 - </tr>
3003 - <tr>
3004 - <th scope="row">' . usces_get_essential_mark('fax', $data) . __('FAX number', 'usces') . '</th>
3005 - <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>
3006 - </tr>';
3007 - $formtag .= usces_custom_field_input($data, $type, 'fax_after', 'return');
3008 - break;
3009 -
3010 - case 'US':
3011 - default :
3012 - $formtag .= usces_custom_field_input($data, $type, 'name_pre', 'return');
3013 - $formtag .= '<tr class="inp1">
3014 - <th scope="row">' . usces_get_essential_mark('name1', $data) . __('Full name', 'usces') . '</th>';
3015 - if( $nameform ){
3016 - $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>';
3017 - $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>';
3018 - }else{
3019 - $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>';
3020 - $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>';
3021 - }
3022 - $formtag .= '</tr>';
3023 - $formtag .= usces_custom_field_input($data, $type, 'name_after', 'return');
3024 - $formtag .= '
3025 - <tr>
3026 - <th scope="row">' . usces_get_essential_mark('address2', $data) . __('Address Line1', 'usces') . '</th>
3027 - <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>
3028 - </tr>
3029 - <tr>
3030 - <th scope="row">' . usces_get_essential_mark('address3', $data) . __('Address Line2', 'usces') . '</th>
3031 - <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>
3032 - </tr>
3033 - <tr class="inp2">
3034 - <th scope="row">' . usces_get_essential_mark('address1', $data) . __('city', 'usces') . '</th>
3035 - <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>
3036 - </tr>
3037 - <tr>
3038 - <th scope="row">' . usces_get_essential_mark('states', $data) . __('State', 'usces') . '</th>
3039 - <td colspan="2">' . usces_pref_select( $type, $values ) . apply_filters( 'usces_filter_after_states', NULL, $applyform ) . '</td>
3040 - </tr>
3041 - <tr>
3042 - <th scope="row">' . usces_get_essential_mark('country', $data) . __('Country', 'usces') . '</th>
3043 - <td colspan="2">' . uesces_get_target_market_form( $type, $values['country'] ) . apply_filters( 'usces_filter_after_country', NULL, $applyform ) . '</td>
3044 - </tr>
3045 - <tr>
3046 - <th scope="row">' . usces_get_essential_mark('zipcode', $data) . __('Zip', 'usces') . '</th>
3047 - <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>
3048 - </tr>
3049 - <tr>
3050 - <th scope="row">' . usces_get_essential_mark('tel', $data) . __('Phone number', 'usces') . '</th>
3051 - <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>
3052 - </tr>
3053 - <tr>
3054 - <th scope="row">' . usces_get_essential_mark('fax', $data) . __('FAX number', 'usces') . '</th>
3055 - <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>
3056 - </tr>';
3057 - $formtag .= usces_custom_field_input($data, $type, 'fax_after', 'return');
3058 - break;
3059 - }
3060 - $res = apply_filters('usces_filter_apply_addressform', $formtag, $type, $data);
3061 -
3062 - }
3063 -
3064 - if($out == 'return') {
3065 - return $res;
3066 - } else {
3067 - echo $res;
3068 - }
3069 -}
3070 -
3071 -function usces_item_option_fileds( $post_id, $sku, $label=1, $out='echo' ){
3072 - $options = usces_get_opts($post_id, 'sort');
3073 - if( 0 == count($options) )
3074 - return false;
3075 -
3076 - $sku_enc = urlencode($sku);
3077 - $html ='';
3078 - foreach( $options as $opt ){
3079 - $name = $opt['name'];
3080 - $opt_code = urlencode($name);
3081 - $html .= "\n" . '<div class="opt_field" id="opt_' . $post_id . '_' . $sku_enc . '_' . $opt_code . '">';
3082 - if( $label ){
3083 - $html .= '<label for="itemOption[' . $post_id . '][' . $sku_enc . '][' . $opt_code . ']">' . esc_html($name) . '</label>';
3084 - }
3085 - $html .= usces_get_itemopt_filed($post_id, $sku, $opt);
3086 - $html .= '</div>';
3087 - }
3088 - if( $out == 'return' ){
3089 - return $html;
3090 - }else{
3091 - echo $html;
3092 - }
3093 -}
3094 -
3095 -function usces_facebook_like(){
3096 - global $post, $usces;
3097 - $like = array(
3098 - 'url' => urlencode(get_permalink($post->ID)),
3099 - 'send' => 'false',
3100 - 'layout' => 'button_count', //standard, button_count, box_count
3101 - 'width' => '450',
3102 - 'height' => '35',
3103 - 'show_faces' => 'false',
3104 - 'action' => 'like', //like, recommend
3105 - );
3106 - $like = apply_filters( 'usces_filter_facebook_like', $like, $post->ID );
3107 -?>
3108 -<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>
3109 -<?php
3110 -}
3111 -
3112 -function usces_action_confirm_page_point_inform_zeus() {
3113 - $html = usces_point_inform_zeus();
3114 - echo $html;
3115 -}
3116 -
3117 -function usces_filter_confirm_point_inform_zeus( $html ) {
3118 - $html .= usces_point_inform_zeus();
3119 - return $html;
3120 -}
3121 -
3122 -function usces_point_inform_zeus() {
3123 - global $usces, $usces_entries;
3124 - $html = '';
3125 -
3126 - $payments = usces_get_payments_by_name( $usces_entries['order']['payment_name'] );
3127 - $acting_flag = ( 'acting' == $payments['settlement'] ) ? $payments['module'] : $payments['settlement'];
3128 -
3129 - switch( $acting_flag ) {
3130 - case 'acting_zeus_card':
3131 - $html .= '<input type="hidden" name="cnum1" value="'.$_POST['cnum1'].'">';
3132 - if( isset($_POST['securecode']) ) {
3133 - $html .= '<input type="hidden" name="securecode" value="'.$_POST['securecode'].'">';
3134 - }
3135 - $html .= '<input type="hidden" name="expyy" value="'.$_POST['expyy'].'">';
3136 - $html .= '<input type="hidden" name="expmm" value="'.$_POST['expmm'].'">';
3137 - $html .= '<input type="hidden" name="username" value="'.$_POST['username'].'">';
3138 - if( isset($_POST['howpay']) ) {
3139 - $html .= '<input type="hidden" name="howpay" value="'.$_POST['howpay'].'">';
3140 - }
3141 - if( isset($_POST['cbrand']) ) {
3142 - $html .= '<input type="hidden" name="cbrand" value="'.$_POST['cbrand'].'">';
3143 - $html .= '<input type="hidden" name="div_1" value="'.$_POST['div_1'].'">';
3144 - $html .= '<input type="hidden" name="div_2" value="'.$_POST['div_2'].'">';
3145 - $html .= '<input type="hidden" name="div_3" value="'.$_POST['div_3'].'">';
3146 - }
3147 - break;
3148 -
3149 - case 'acting_zeus_conv':
3150 - if( isset($_POST['pay_cvs']) ) {
3151 - $html = '<input type="hidden" name="pay_cvs" value="'.$_POST['pay_cvs'].'">';
3152 - }
3153 - break;
3154 - }
3155 - return $html;
3156 -}
3157 -
3158 -function usces_checked( $chk, $key, $out = '' ) {
3159 - $checked = ( isset($chk[$key]) and $chk[$key] == 1 ) ? ' checked' : '';
3160 - if( $out == 'return' ) {
3161 - return $checked;
3162 - } else {
3163 - echo $checked;
3164 - }
3165 -}
3166 -
3167 -function usces_get_custom_field_value( $field, $key, $id, $out = '' ) {
3168 - global $usces;
3169 -
3170 - $value = '';
3171 - switch( $field ) {
3172 - case 'order':
3173 - $value = $usces->get_order_meta_value( 'csod_'.$key, $id );
3174 - break;
3175 - case 'customer':
3176 - $value = $usces->get_order_meta_value( 'cscs_'.$key, $id );
3177 - break;
3178 - case 'delivery':
3179 - $value = $usces->get_order_meta_value( 'csde_'.$key, $id );
3180 - break;
3181 - case 'member':
3182 - $value = $usces->get_member_meta_value( 'csmb_'.$key, $id );
3183 - break;
3184 - }
3185 -
3186 - if( $out == 'return' ) {
3187 - return $value;
3188 - } else {
3189 - echo $value;
3190 - }
3191 -}
3192 -
3193 -?>
3031 + }
3032 + }
3033 + if ( empty( $list ) ) {
3034 + $html = '';
3035 + } else {
3036 + $html .= $list . '</ul>' . "\n";
3037 + }
3038 + break;
3039 +
3040 + case 'table':
3041 + $list = '';
3042 + $html = '<table class="item_custom_field">' . "\n";
3043 + foreach ( $cfields as $key => $values ) {
3044 + if ( 'wccs_' === substr( $key, 0, 5 ) ) {
3045 + if ( is_array( $values ) ) {
3046 + foreach ( $values as $value ) {
3047 + $list .= '<tr><th>' . esc_html( substr( $key, 5 ) ) . '</th><td>' . nl2br( esc_html( $value ) ) . '</td></tr>' . "\n";
3048 + }
3049 + } else {
3050 + $list .= '<tr><th>' . esc_html( substr( $key, 5 ) ) . '</th><td>' . nl2br( esc_html( $values ) ) . '</td></tr>' . "\n";
3051 + }
3052 + }
3053 + }
3054 + if ( empty( $list ) ) {
3055 + $html = '';
3056 + } else {
3057 + $html .= $list . '</table>' . "\n";
3058 + }
3059 + break;
3060 +
3061 + case 'notag':
3062 + $list = '';
3063 + foreach ( $cfields as $key => $values ) {
3064 + if ( 'wccs_' === substr( $key, 0, 5 ) ) {
3065 + if ( is_array( $values ) ) {
3066 + foreach ( $values as $value ) {
3067 + $list .= esc_html( substr( $key, 5 ) ) . ' : ' . nl2br( esc_html( $value ) ) . "\r\n";
3068 + }
3069 + } else {
3070 + $list .= esc_html( substr( $key, 5 ) ) . ' : ' . nl2br( esc_html( $values ) ) . "\r\n";
3071 + }
3072 + }
3073 + }
3074 + if ( empty( $list ) ) {
3075 + $html = '';
3076 + } else {
3077 + $html = $list;
3078 + }
3079 + break;
3080 +
3081 + case 'mail_html':
3082 + $list = '';
3083 + foreach ( $cfields as $key => $values ) {
3084 + if ( 'wccs_' === substr( $key, 0, 5 ) ) {
3085 + if ( is_array( $values ) ) {
3086 + foreach ( $values as $value ) {
3087 + $list .= '<tr>
3088 + <td style="padding: 0 0 10px; text-align: left; width: 100px; font-weight: normal; vertical-align: text-top;">' . esc_html( substr( $key, 5 ) ) . '</td>
3089 + <td style="padding: 0 0 10px 50px; width: calc( 100% - 100px );">' . nl2br( esc_html( $value ) ) . '</td>
3090 + </tr>';
3091 + }
3092 + } else {
3093 + $list .= '<tr>
3094 + <td style="padding: 0 0 10px; text-align: left; width: 100px; font-weight: normal; vertical-align: text-top;">' . esc_html( substr( $key, 5 ) ) . '</td>
3095 + <td style="padding: 0 0 10px 50px; width: calc( 100% - 100px );">' . nl2br( esc_html( $values ) ) . '</td>
3096 + </tr>';
3097 + }
3098 + }
3099 + }
3100 + if ( empty( $list ) ) {
3101 + $html = '';
3102 + } else {
3103 + $html = '<table style="font-size: 14px; width: 100%; border-collapse: collapse;">';
3104 + $html .= '<tbody><tr><td style="background-color: #f9f9f9; padding: 30px;">';
3105 + $html .= '<table style="width: 100%;"><tbody>';
3106 + $html .= $list;
3107 + $html .= '</tbody></table></td></tr></tbody></table>';
3108 + }
3109 + break;
3110 + }
3111 + $html = apply_filters( 'usces_filter_item_custom', $html, $post_id, $type );
3112 +
3113 + if ( 'return' === $out ) {
3114 + return $html;
3115 + } else {
3116 + echo $html; // no escape due to filter.
3117 + }
3118 +}
3119 +
3120 +/**
3121 + * Settlement information
3122 + *
3123 + * @param int $order_id Order ID.
3124 + * @param string $type Type.
3125 + * @param string $out Return value or echo.
3126 + * @return string|void
3127 + */
3128 +function usces_settle_info_field( $order_id, $type = 'nl', $out = 'echo' ) {
3129 + global $usces;
3130 +
3131 + $str = '';
3132 + $fields = $usces->get_settle_info_field( $order_id );
3133 + $acting = isset( $fields['acting'] ) ? $fields['acting'] : '';
3134 + $keys = array(
3135 + 'acting',
3136 + 'order_no',
3137 + 'tracking_no',
3138 + 'status',
3139 + 'error_message',
3140 + 'money',
3141 + 'pay_cvs',
3142 + 'pay_no1',
3143 + 'pay_no2',
3144 + 'pay_limit',
3145 + 'error_code',
3146 + 'settlement_id',
3147 + 'RECDATE',
3148 + 'JOB_ID',
3149 + 'S_TORIHIKI_NO',
3150 + 'TOTAL',
3151 + 'CENDATE',
3152 + 'gid',
3153 + 'rst',
3154 + 'ap',
3155 + 'ec',
3156 + 'god',
3157 + 'ta',
3158 + 'cv',
3159 + 'no',
3160 + 'cu',
3161 + 'mf',
3162 + 'nk',
3163 + 'nkd',
3164 + 'bank',
3165 + 'exp',
3166 + 'txn_id',
3167 + 'order_number',
3168 + 'res_tracking_id',
3169 + 'res_payment_date',
3170 + 'res_payinfo_key',
3171 + 'settltment_status',
3172 + 'settltment_errmsg',
3173 + 'stran',
3174 + 'mbtran',
3175 + 'bktrans',
3176 + 'tranid',
3177 + 'TransactionId',
3178 + 'mStatus',
3179 + 'vResultCode',
3180 + 'orderId',
3181 + 'cvsType',
3182 + 'receiptNo',
3183 + 'receiptDate',
3184 + 'rcvAmount',
3185 + 'trading_id',
3186 + 'payment_type',
3187 + 'seq_payment_id',
3188 + 'sendpoint',
3189 + 'option',
3190 + 'LINK_KEY',
3191 + );
3192 + $keys = apply_filters( 'usces_filter_settle_info_field_keys', $keys, $fields );
3193 + foreach ( $fields as $key => $value ) {
3194 + if ( ! in_array( $key, $keys, true ) ) {
3195 + continue;
3196 + }
3197 +
3198 + if ( 'jpayment_conv' === $acting ) {
3199 + if ( 'rst' === $key ) {
3200 + if ( '1' === $value ) {
3201 + $value = 'OK';
3202 + } elseif ( '2' === $value ) {
3203 + $value = 'NG';
3204 + }
3205 + } elseif ( 'ap' === $key ) {
3206 + if ( 'CPL_PRE' === $value ) {
3207 + $value = 'コンビニペーパーレス決済識別コード';
3208 + } elseif ( 'CPL' === $value ) {
3209 + $value = '入金確定';
3210 + } elseif ( 'CVS_CAN' === $value ) {
3211 + $value = '入金取消';
3212 + }
3213 + } elseif ( 'cv' === $key ) {
3214 + $value = esc_html( usces_get_conv_name( $value ) );
3215 + } else {
3216 + continue;
3217 + }
3218 + } elseif ( 'jpayment_bank' === $acting ) {
3219 + if ( 'rst' === $key ) {
3220 + if ( '1' === $value ) {
3221 + $value = 'OK';
3222 + } elseif ( '2' === $value ) {
3223 + $value = 'NG';
3224 + }
3225 + } elseif ( 'ap' === $key ) {
3226 + if ( 'BANK' === $value ) {
3227 + $value = '受付完了';
3228 + } elseif ( 'BAN_SAL' === $value ) {
3229 + $value = '入金完了';
3230 + }
3231 + } elseif ( 'mf' === $key ) {
3232 + if ( '1' === $value ) {
3233 + $value = 'マッチ';
3234 + } elseif ( '2' === $value ) {
3235 + $value = '過少';
3236 + } elseif ( '3' === $value ) {
3237 + $value = '過剰';
3238 + }
3239 + } elseif ( 'nkd' === $key ) {
3240 + $value = substr( $value, 0, 4 ) . '年' . substr( $value, 4, 2 ) . '月' . substr( $value, 6, 2 ) . '日';
3241 + } elseif ( 'exp' === $key ) {
3242 + $value = substr( $value, 0, 4 ) . '年' . substr( $value, 4, 2 ) . '月' . substr( $value, 6, 2 ) . '日';
3243 + } else {
3244 + continue;
3245 + }
3246 + } elseif ( 'veritrans_conv' === $acting ) {
3247 + if ( 'cvsType' === $key ) {
3248 + switch ( $value ) {
3249 + case 'sej':
3250 + $value = 'セブン-イレブン';
3251 + break;
3252 + case 'econ-lw':
3253 + $value = 'ローソン';
3254 + break;
3255 + case 'econ-fm':
3256 + $value = 'ファミリーマート';
3257 + break;
3258 + case 'econ-mini':
3259 + $value = 'ミニストップ';
3260 + break;
3261 + case 'econ-other':
3262 + $value = 'セイコーマート';
3263 + break;
3264 + case 'econ-sn':
3265 + $value = 'サンクス';
3266 + break;
3267 + case 'econ-ck':
3268 + $value = 'サークルK';
3269 + break;
3270 + }
3271 + }
3272 + }
3273 + $value = apply_filters( 'usces_filter_settle_info_field_value', $value, $key, $acting );
3274 + switch ( $type ) {
3275 + case 'nl':
3276 + $str .= $key . ' : ' . $value . "<br />\n";
3277 + break;
3278 + case 'tr':
3279 + $str .= '<tr><td class="label">' . $key . '</td><td>' . $value . "</td></tr>\n";
3280 + break;
3281 + case 'li':
3282 + $str .= '<li>' . $key . ' : ' . $value . "</li>\n";
3283 + break;
3284 + }
3285 + }
3286 + if ( 'return' === $out ) {
3287 + return wel_esc_script( $str );
3288 + } else {
3289 + wel_esc_script_e( $str );
3290 + }
3291 +}
3292 +
3293 +/**
3294 + * Custom field
3295 + *
3296 + * @param array $data Order data.
3297 + * @param string $custom_field Custom field.
3298 + * @param string $position Position.
3299 + * @param string $out Return value or echo.
3300 + * @return string|void
3301 + */
3302 +function usces_custom_field_input( $data, $custom_field, $position, $out = '' ) {
3303 +
3304 + $html = '';
3305 +
3306 + switch ( $custom_field ) {
3307 + case 'order':
3308 + $label = 'custom_order';
3309 + $field = 'usces_custom_order_field';
3310 + break;
3311 + case 'customer':
3312 + $label = 'custom_customer';
3313 + $field = 'usces_custom_customer_field';
3314 + break;
3315 + case 'delivery':
3316 + $label = 'custom_delivery';
3317 + $field = 'usces_custom_delivery_field';
3318 + break;
3319 + case 'member':
3320 + $label = 'custom_member';
3321 + $field = 'usces_custom_member_field';
3322 + break;
3323 + default:
3324 + return;
3325 + }
3326 +
3327 + $meta = usces_has_custom_field_meta( $custom_field );
3328 +
3329 + if ( ! empty( $meta ) && is_array( $meta ) ) {
3330 + foreach ( $meta as $key => $entry ) {
3331 + if ( 'order' === $custom_field || $entry['position'] === $position ) {
3332 + $name = $entry['name'];
3333 + $means = (int) $entry['means'];
3334 + $essential = (int) $entry['essential'];
3335 + $value = '';
3336 + if ( is_array( $entry['value'] ) ) {
3337 + foreach ( $entry['value'] as $k => $v ) {
3338 + $value .= $v . "\n";
3339 + }
3340 + }
3341 + $value = usces_change_line_break( $value );
3342 +
3343 + $e = ( 1 === $essential ) ? '<em>' . __( '*', 'usces' ) . '</em>' : '';
3344 + $html .= '
3345 + <tr class="customkey_' . $key . '">
3346 + <th scope="row">' . $e . esc_html( $name ) . apply_filters( 'usces_filter_custom_field_input_label', null, $key, $entry ) . '</th>';
3347 + $html .= apply_filters( 'usces_filter_custom_field_input_td', '<td colspan="2">', $key, $entry );
3348 + switch ( $means ) {
3349 + case 0: // Single-select.
3350 + case 1: // Multi-select.
3351 + $selects = explode( "\n", $value );
3352 + $multiple = ( 0 === $means ) ? '' : ' multiple';
3353 + $multiple_array = ( 0 === $means ) ? '' : '[]';
3354 + $html .= '<select name="' . $label . '[' . esc_attr( $key ) . ']' . $multiple_array . '" class="iopt_select"' . $multiple . '>';
3355 + if ( 1 === $essential ) {
3356 + $html .= '
3357 + <option value="#NONE#">' . __( 'Choose', 'usces' ) . '</option>';
3358 + }
3359 + foreach ( (array) $selects as $v ) {
3360 + $selected = ( isset( $data[ $label ][ $key ] ) && $data[ $label ][ $key ] == $v ) ? ' selected' : '';
3361 + $html .= '
3362 + <option value="' . esc_attr( $v ) . '"' . $selected . '>' . esc_html( $v ) . '</option>';
3363 + }
3364 + $html .= '
3365 + </select>';
3366 + break;
3367 + case 2: // Text.
3368 + $text = isset( $data[ $label ][ $key ] ) ? $data[ $label ][ $key ] : '';
3369 + $html .= '<input type="text" name="' . $label . '[' . esc_attr( $key ) . ']" class="iopt_text" value="' . esc_attr( $text ) . '" />';
3370 + break;
3371 + case 3: // Radio-button.
3372 + $selects = explode( "\n", $value );
3373 + foreach ( (array) $selects as $v ) {
3374 + $checked = ( isset( $data[ $label ][ $key ] ) && $data[ $label ][ $key ] == $v ) ? ' checked' : '';
3375 + $html .= '
3376 + <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>';
3377 + }
3378 + break;
3379 + case 4: // Check-box.
3380 + $selects = explode( "\n", $value );
3381 + foreach ( $selects as $v ) {
3382 + if ( isset( $data[ $label ][ $key ] ) && is_array( $data[ $label ][ $key ] ) ) {
3383 + $checked = ( isset( $data[ $label ][ $key ] ) && array_key_exists( $v, $data[ $label ][ $key ] ) ) ? ' checked' : '';
3384 + } else {
3385 + $checked = ( isset( $data[ $label ][ $key ] ) && $data[ $label ][ $key ] == $v ) ? ' checked' : '';
3386 + }
3387 + $html .= '
3388 + <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>';
3389 + }
3390 + break;
3391 + case 5: // Text-area.
3392 + $text = ( isset( $data[ $label ][ $key ] ) ) ? $data[ $label ][ $key ] : '';
3393 + $html .= '<textarea name="' . $label . '[' . esc_attr( $key ) . ']" class="iopt_textarea">' . esc_attr( $text ) . '</textarea>';
3394 + break;
3395 + }
3396 + $html .= apply_filters( 'usces_filter_custom_field_input_value', null, $key, $entry ) . '</td>';
3397 + $html .= '
3398 + </tr>';
3399 + }
3400 + }
3401 + }
3402 +
3403 + $html = apply_filters( 'usces_filter_custom_field_input', $html, $data, $custom_field, $position );
3404 +
3405 + if ( 'return' === $out ) {
3406 + return stripslashes( $html );
3407 + } else {
3408 + echo stripslashes( $html );
3409 + }
3410 +}
3411 +
3412 +/**
3413 + * Custom field information
3414 + *
3415 + * @param array $data Order data.
3416 + * @param string $custom_field Custom field.
3417 + * @param string $position Position.
3418 + * @param string $out Return value or echo.
3419 + * @return string|void
3420 + */
3421 +function usces_custom_field_info( $data, $custom_field, $position, $out = '' ) {
3422 +
3423 + $html = '';
3424 + switch ( $custom_field ) {
3425 + case 'order':
3426 + $label = 'custom_order';
3427 + $field = 'usces_custom_order_field';
3428 + break;
3429 + case 'customer':
3430 + $label = 'custom_customer';
3431 + $field = 'usces_custom_customer_field';
3432 + break;
3433 + case 'delivery':
3434 + $label = 'custom_delivery';
3435 + $field = 'usces_custom_delivery_field';
3436 + break;
3437 + case 'member':
3438 + $label = 'custom_member';
3439 + $field = 'usces_custom_member_field';
3440 + break;
3441 + default:
3442 + return;
3443 + }
3444 +
3445 + $meta = usces_has_custom_field_meta( $custom_field );
3446 +
3447 + if ( ! empty( $meta ) && is_array( $meta ) ) {
3448 + foreach ( $meta as $key => $entry ) {
3449 + if ( 'order' === $custom_field || $entry['position'] === $position ) {
3450 + $name = $entry['name'];
3451 + $means = (int) $entry['means'];
3452 +
3453 + $html .= '<tr>
3454 + <th>' . esc_html( $name ) . '</th>
3455 + <td>';
3456 + if ( ! empty( $data[ $label ][ $key ] ) ) {
3457 + switch ( $means ) {
3458 + case 0: // Single-select.
3459 + case 2: // Text.
3460 + case 3: // Radio-button.
3461 + case 5: // Text-area.
3462 + $html .= esc_html( $data[ $label ][ $key ] );
3463 + break;
3464 + case 1: // Multi-select.
3465 + case 4: // Check-box.
3466 + if ( is_array( $data[ $label ][ $key ] ) ) {
3467 + $c = '';
3468 + foreach ( $data[ $label ][ $key ] as $v ) {
3469 + $html .= $c . esc_html( $v );
3470 + $c = ', ';
3471 + }
3472 + } else {
3473 + if ( ! empty( $data[ $label ][ $key ] ) ) {
3474 + $html .= esc_html( $data[ $label ][ $key ] );
3475 + }
3476 + }
3477 + break;
3478 + }
3479 + }
3480 + $html .= '
3481 + </td>
3482 + </tr>';
3483 + }
3484 + }
3485 + }
3486 +
3487 + $html = apply_filters( 'usces_filter_custom_field_info', $html, $data, $custom_field, $position );
3488 +
3489 + if ( 'return' === $out ) {
3490 + return stripslashes( $html );
3491 + } else {
3492 + echo stripslashes( $html );
3493 + }
3494 +}
3495 +
3496 +/**
3497 + * Admin Custom field
3498 + *
3499 + * @param array $meta Order meta data.
3500 + * @param string $custom_field Custom field.
3501 + * @param string $position Position.
3502 + * @param string $out Return value or echo.
3503 + * @return string|void
3504 + */
3505 +function usces_admin_custom_field_input( $meta, $custom_field, $position, $out = '' ) {
3506 +
3507 + $html = '';
3508 + switch ( $custom_field ) {
3509 + case 'order':
3510 + $label = 'custom_order';
3511 + $class = '';
3512 + break;
3513 + case 'customer':
3514 + $label = 'custom_customer';
3515 + $class = ' class="col2"';
3516 + break;
3517 + case 'delivery':
3518 + $label = 'custom_delivery';
3519 + $class = ' class="col3"';
3520 + break;
3521 + case 'member':
3522 + $label = 'custom_member';
3523 + $class = '';
3524 + break;
3525 + case 'admin_member':
3526 + $label = 'admin_custom_member';
3527 + $class = '';
3528 + break;
3529 + default:
3530 + return;
3531 + }
3532 +
3533 + if ( ! empty( $meta ) && is_array( $meta ) ) {
3534 + foreach ( $meta as $key => $entry ) {
3535 + if ( 'order' === $custom_field || $entry['position'] === $position ) {
3536 + $name = $entry['name'];
3537 + $means = (int) $entry['means'];
3538 + $essential = (int) $entry['essential'];
3539 + $value = '';
3540 + if ( is_array( $entry['value'] ) ) {
3541 + foreach ( $entry['value'] as $k => $v ) {
3542 + $value .= $v . "\n";
3543 + }
3544 + }
3545 + $value = usces_change_line_break( $value );
3546 + $value = apply_filters( 'usces_filter_admin_custom_field_input_value', $value, $key, $entry, $custom_field );
3547 + $data = ( isset( $entry['data'] ) ) ? $entry['data'] : null;
3548 +
3549 + $html .= '
3550 + <tr>
3551 + <td class="label">' . esc_html( $name ) . '</td>';
3552 + switch ( $means ) {
3553 + case 0: /* Single-select */
3554 + case 1: /* Multi-select */
3555 + $selects = explode( "\n", $value );
3556 + $multiple = ( 0 === $means ) ? '' : ' multiple';
3557 + $multiple_array = ( 0 === $means ) ? '' : '[]';
3558 + $html .= '
3559 + <td' . $class . '>
3560 + <select name="' . $label . '[' . esc_attr( $key ) . ']' . $multiple_array . '" id="' . $label . '[' . esc_attr( $key ) . ']" class="iopt_select"' . $multiple . '>';
3561 + if ( 1 === $essential ) {
3562 + $html .= '
3563 + <option value="#NONE#">' . __( 'Choose', 'usces' ) . '</option>';
3564 + }
3565 + foreach ( $selects as $v ) {
3566 + $selected = ( $data == $v ) ? ' selected' : '';
3567 + $html .= '
3568 + <option value="' . esc_attr( $v ) . '"' . $selected . '>' . esc_html( $v ) . '</option>';
3569 + }
3570 + $html .= '
3571 + </select></td>';
3572 + break;
3573 + case 2: /* Text */
3574 + $html .= '
3575 + <td' . $class . '><input type="text" name="' . $label . '[' . esc_attr( $key ) . ']" id="' . $label . '[' . esc_attr( $key ) . ']" size="30" value="' . esc_attr( $data ) . '" /></td>';
3576 + break;
3577 + case 3: /* Radio-button */
3578 + $selects = explode( "\n", $value );
3579 + $html .= '
3580 + <td' . $class . '>';
3581 + foreach ( $selects as $v ) {
3582 + $checked = ( $data == $v ) ? ' checked' : '';
3583 + $html .= '
3584 + <input type="radio" name="' . $label . '[' . esc_attr( $key ) . ']" id="' . $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>';
3585 + }
3586 + $html .= '
3587 + </td>';
3588 + break;
3589 + case 4: /* Check-box */
3590 + $selects = explode( "\n", $value );
3591 + $html .= '
3592 + <td' . $class . '>';
3593 + foreach ( $selects as $v ) {
3594 + if ( is_array( $data ) ) {
3595 + $checked = ( array_key_exists( $v, $data ) ) ? ' checked' : '';
3596 + } else {
3597 + $checked = ( $data == $v ) ? ' checked' : '';
3598 + }
3599 + $html .= '
3600 + <input type="checkbox" name="' . $label . '[' . esc_attr( $key ) . '][' . esc_attr( $v ) . ']" id="' . $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>';
3601 + }
3602 + $html .= '
3603 + </td>';
3604 + break;
3605 + case 5: /* Text-area */
3606 + $html .= '
3607 + <td' . $class . '><textarea name="' . $label . '[' . esc_attr( $key ) . ']" id="' . $label . '[' . esc_attr( $key ) . ']" >' . esc_attr( $data ) . '</textarea></td>';
3608 + break;
3609 + }
3610 + $html .= '
3611 + </tr>';
3612 + }
3613 + }
3614 + }
3615 + $html = apply_filters( 'usces_filter_admin_custom_field_input', $html, $meta, $custom_field, $position, $out );
3616 +
3617 + if ( 'return' === $out ) {
3618 + return stripslashes( $html );
3619 + } else {
3620 + echo stripslashes( $html );
3621 + }
3622 +}
3623 +
3624 +/**
3625 + * Required Custom Field
3626 + *
3627 + * @return string
3628 + */
3629 +function has_custom_customer_field_essential() {
3630 +
3631 + $mes = '';
3632 + $essential = array();
3633 +
3634 + $csmb_meta = usces_has_custom_field_meta( 'member' );
3635 + if ( ! empty( $csmb_meta ) && is_array( $csmb_meta ) ) {
3636 + foreach ( $csmb_meta as $key => $entry ) {
3637 + if ( 1 === (int) $entry['essential'] ) {
3638 + $essential[ $key ] = $key;
3639 + }
3640 + }
3641 + }
3642 + if ( ! empty( $essential ) ) {
3643 + $cscs_meta = usces_has_custom_field_meta( 'customer' );
3644 + if ( ! empty( $cscs_meta ) && is_array( $cscs_meta ) ) {
3645 + foreach ( $cscs_meta as $key => $entry ) {
3646 + if ( 1 === (int) $entry['essential'] ) {
3647 + if ( ! array_key_exists( $key, $essential ) ) {
3648 + if ( 2 === (int) $entry['means'] ) { // Text.
3649 + $mes .= sprintf( __( "Input the %s", 'usces' ), esc_html( $entry['name'] ) ) . '<br />';
3650 + } else {
3651 + $mes .= sprintf( __( "Chose the %s", 'usces' ), esc_html( $entry['name'] ) ) . '<br />';
3652 + }
3653 + }
3654 + }
3655 + }
3656 + }
3657 + }
3658 + return $mes;
3659 +}
3660 +
3661 +/**
3662 + * Discount
3663 + *
3664 + * @param string $out Return value or echo.
3665 + * @return string|void
3666 + */
3667 +function usces_order_discount( $out = '' ) {
3668 + global $usces;
3669 +
3670 + $res = abs( $usces->get_order_discount() );
3671 +
3672 + if ( 'return' === $out ) {
3673 + return $res;
3674 + } else {
3675 + echo number_format( $res );
3676 + }
3677 +}
3678 +
3679 +/**
3680 + * Item discount
3681 + *
3682 + * @param string $out Return value or echo.
3683 + * @param int $post_id Post ID.
3684 + * @param string $sku SKU code.
3685 + * @return string|void
3686 + */
3687 +function usces_item_discount( $out = '', $post_id = '', $sku = '' ) {
3688 + global $usces, $post;
3689 +
3690 + if ( '' === $post_id ) {
3691 + $post_id = $post->ID;
3692 + }
3693 + if ( '' === $sku ) {
3694 + $sku = $usces->itemsku['code'];
3695 + }
3696 + $res = $usces->getItemDiscount( $post_id, $sku );
3697 +
3698 + if ( 'return' === $out ) {
3699 + return $res;
3700 + } else {
3701 + echo number_format( $res );
3702 + }
3703 +}
3704 +
3705 +/**
3706 + * Item page error message
3707 + *
3708 + * @param int $post_id Post ID.
3709 + * @param string $skukey SKU code.
3710 + * @param string $out Return value or echo.
3711 + * @return string|void
3712 + */
3713 +function usces_singleitem_error_message( $post_id, $skukey, $out = '' ) {
3714 + if ( ! isset( $_SESSION['usces_singleitem']['error_message'][ $post_id ][ $skukey ] ) ) {
3715 + $ret = '';
3716 + } else {
3717 + $ret = $_SESSION['usces_singleitem']['error_message'][ $post_id ][ $skukey ];
3718 + }
3719 + if ( 'return' === $out ) {
3720 + return wel_esc_script( $ret );
3721 + } else {
3722 + wel_esc_script_e( $ret );
3723 + }
3724 +}
3725 +
3726 +/**
3727 + * Amount Formatting
3728 + *
3729 + * @param float $float Price.
3730 + * @param bool $symbol_pre Forward symbol.
3731 + * @param bool $symbol_post Backward symbol.
3732 + * @param string $out Return value or echo.
3733 + * @param bool $seperator_flag Seperator.
3734 + * @return string|void
3735 + */
3736 +function usces_crform( $float, $symbol_pre = true, $symbol_post = true, $out = '', $seperator_flag = true ) {
3737 + global $usces;
3738 +
3739 + $price = esc_html( $usces->get_currency( $float, $symbol_pre, $symbol_post, $seperator_flag ) );
3740 + $res = apply_filters( 'usces_filter_crform', $price, $float );
3741 +
3742 + if ( 'return' === $out ) {
3743 + return $res;
3744 + } else {
3745 + echo $res; // no escape due to filter.
3746 + }
3747 +}
3748 +
3749 +/**
3750 + * Member Information
3751 + *
3752 + * @param string $key Key.
3753 + * @param string $out Return value or echo.
3754 + * @return string|void
3755 + */
3756 +function usces_memberinfo( $key, $out = '' ) {
3757 + global $usces, $wpdb;
3758 +
3759 + $info = $usces->get_member();
3760 +
3761 + if ( empty( $key ) ) {
3762 + return $info;
3763 + }
3764 +
3765 + switch ( $key ) {
3766 + case 'registered':
3767 + $res = mysql2date( __( 'Mj, Y', 'usces' ), $info['registered'] );
3768 + break;
3769 + case 'point':
3770 + $member_table = usces_get_tablename( 'usces_member' );
3771 + $query = $wpdb->prepare( "SELECT mem_point FROM $member_table WHERE ID = %d", $info['ID'] );
3772 + $res = $wpdb->get_var( $query );
3773 + break;
3774 + default:
3775 + $res = isset( $info[ $key ] ) ? $info[ $key ] : '';
3776 + }
3777 +
3778 + if ( 'return' === $out ) {
3779 + return $res;
3780 + } else {
3781 + echo esc_html( $res );
3782 + }
3783 +}
3784 +
3785 +/**
3786 + * Member Purchase History
3787 + *
3788 + * @param string $out Return value or echo.
3789 + * @return string|void
3790 + */
3791 +function usces_member_history( $out = '' ) {
3792 + global $usces;
3793 +
3794 + $usces_members = $usces->get_member();
3795 + $history = $usces->get_member_history( $usces_members['ID'], true );
3796 + $usces_member_history = apply_filters( 'usces_filter_get_member_history', $history, $usces_members['ID'] );
3797 +
3798 + $usces_member_history_count = ( $usces_member_history && is_array( $usces_member_history ) ) ? count( $usces_member_history ) : 0;
3799 +
3800 + $html = usces_load_filter_purchase_date();
3801 + $html .= '<div class="history-area">';
3802 + if ( 0 === $usces_member_history_count ) {
3803 + $no_history_message = apply_filters( 'usces_filter_no_history_message', __( 'There is no purchase history during the period.', 'usces' ) );
3804 + $html .= '<table id="history_head"><tr>
3805 + <td>' . $no_history_message . '</td>
3806 + </tr></table>';
3807 + } else {
3808 + $management_status = apply_filters( 'usces_filter_management_status', get_option( 'usces_management_status' ) );
3809 + foreach ( $usces_member_history as $umhs ) {
3810 + $condition = $umhs['condition'];
3811 + $tax_display = ( isset( $condition['tax_display'] ) ) ? $condition['tax_display'] : usces_get_tax_display();
3812 + $tax_mode = ( isset( $condition['tax_mode'] ) ) ? $condition['tax_mode'] : usces_get_tax_mode();
3813 + $tax_target = ( isset( $condition['tax_target'] ) ) ? $condition['tax_target'] : usces_get_tax_target();
3814 + $tax_label = ( 'exclude' === $tax_mode ) ? __( 'consumption tax', 'usces' ) : __( 'Internal tax', 'usces' );
3815 + $member_system_point = ( isset( $condition['membersystem_point'] ) && 'activate' === $condition['membersystem_point'] ) ? true : usces_is_membersystem_point();
3816 + $point_coverage = ( isset( $condition['point_coverage'] ) ) ? (int) $condition['point_coverage'] : (int) usces_point_coverage();
3817 + $cart = $umhs['cart'];
3818 + $value = $umhs['order_status'];
3819 +
3820 + $p_status = '';
3821 + if ( $usces->is_status( 'duringorder', $value ) ) {
3822 + $p_status = isset( $management_status['duringorder'] ) ? esc_html( $management_status['duringorder'] ) : '';
3823 + } elseif ( $usces->is_status( 'cancel', $value ) ) {
3824 + $p_status = isset( $management_status['cancel'] ) ? esc_html( $management_status['cancel'] ) : '';
3825 + } elseif ( $usces->is_status( 'completion', $value ) ) {
3826 + $p_status = isset( $management_status['completion'] ) ? esc_html( $management_status['completion'] ) : '';
3827 + } else {
3828 + $p_status = esc_html( __( 'new order', 'usces' ) );
3829 + }
3830 + $p_status = apply_filters( 'usces_filter_orderlist_process_status', $p_status, $value, $management_status, $umhs['ID'] );
3831 +
3832 + $r_status = '';
3833 + if ( $usces->is_status( 'noreceipt', $value ) ) {
3834 + $r_status = isset( $management_status['noreceipt'] ) ? esc_html( $management_status['noreceipt'] ) : '';
3835 + } elseif ( $usces->is_status( 'pending', $value ) ) {
3836 + $r_status = isset( $management_status['pending'] ) ? esc_html( $management_status['pending'] ) : '';
3837 + } elseif ( $usces->is_status( 'receipted', $value ) ) {
3838 + $r_status = isset( $management_status['receipted'] ) ? esc_html( $management_status['receipted'] ) : '';
3839 + }
3840 + $r_status = apply_filters( 'usces_filter_orderlist_receipt_status', $r_status, $value, $management_status, $umhs['ID'] );
3841 +
3842 + $shipping = usces_have_shipped( $cart );
3843 + $delivery_company = '';
3844 + $tracking_number = '';
3845 + $delivery_company_url = '';
3846 + if ( $shipping ) {
3847 + $tracking_number = $usces->get_order_meta_value( apply_filters( 'usces_filter_tracking_meta_key', 'tracking_number' ), $umhs['ID'] );
3848 + $delivery_company = $usces->get_order_meta_value( 'delivery_company', $umhs['ID'] );
3849 + $delivery_company_url = usces_get_delivery_company_url( $delivery_company, $tracking_number );
3850 + }
3851 +
3852 + $head_col = 4;
3853 + $history_member_head = '<table id="history_head"><thead>
3854 + <tr class="order_head_label">
3855 + <th class="historyrow order_number">' . __( 'Order number', 'usces' ) . '</th>
3856 + <th class="historyrow purchase_date">' . __( 'Purchase date', 'usces' ) . '</th>';
3857 + if ( ! empty( $p_status ) ) {
3858 + $history_member_head .= '<th class="historyrow processing_status">' . __( 'Processing status', 'usces' ) . '</th>';
3859 + $head_col++;
3860 + }
3861 + if ( ! empty( $r_status ) ) {
3862 + $history_member_head .= '<th class="historyrow transfer_statement">' . __( 'transfer statement', 'usces' ) . '</th>';
3863 + $head_col++;
3864 + }
3865 + $history_member_head .= '<th class="historyrow purchase_price">' . __( 'Purchase price', 'usces' ) . '</th>
3866 + <th class="historyrow discount">' . apply_filters( 'usces_member_discount_label', __( 'Discount', 'usces' ), $umhs['ID'] ) . '</th>';
3867 + if ( $tax_display && 'products' === $tax_target ) {
3868 + $history_member_head .= '<th class="historyrow tax">' . $tax_label . '</th>';
3869 + $head_col++;
3870 + }
3871 + if ( $member_system_point && 0 === $point_coverage ) {
3872 + $history_member_head .= '<th class="historyrow used_point">' . __( 'Used points', 'usces' ) . '</th>';
3873 + $head_col++;
3874 + }
3875 + if ( $shipping ) {
3876 + $history_member_head .= '<th class="historyrow shipping">' . __( 'Shipping', 'usces' ) . '</th>';
3877 + $head_col++;
3878 + }
3879 + if ( ! empty( $umhs['cod_fee'] ) ) {
3880 + $payment = usces_get_payments_by_name( $umhs['payment_name'] );
3881 + $cod_label = ( isset( $payment['settlement'] ) && 'COD' === $payment['settlement'] ) ? __( 'C.O.D', 'usces' ) : __( 'Fee', 'usces' );
3882 + $cod_label = apply_filters( 'usces_filter_member_history_cod_label', $cod_label, $umhs['ID'] );
3883 + $history_member_head .= '<th class="historyrow cod">' . $cod_label . '</th>';
3884 + $head_col++;
3885 + }
3886 + if ( $tax_display && 'all' === $tax_target ) {
3887 + $history_member_head .= '<th class="historyrow tax">' . $tax_label . '</th>';
3888 + $head_col++;
3889 + }
3890 + if ( $member_system_point && 1 === $point_coverage ) {
3891 + $history_member_head .= '<th class="historyrow used_point">' . __( 'Used points', 'usces' ) . '</th>';
3892 + $head_col++;
3893 + }
3894 + if ( $member_system_point ) {
3895 + $history_member_head .= '<th class="historyrow get_point">' . __( 'Acquired points', 'usces' ) . '</th>';
3896 + $head_col++;
3897 + }
3898 + if ( ! empty( $tracking_number ) ) {
3899 + $history_member_head .= '<th class="historyrow">' . __( 'Tracking number', 'usces' ) . '</th>';
3900 + $head_col++;
3901 + }
3902 + $total_price = $umhs['total_items_price'] - $umhs['usedpoint'] + $umhs['discount'] + $umhs['shipping_charge'] + $umhs['cod_fee'] + $umhs['tax'];
3903 + if ( $total_price < 0 ) {
3904 + $total_price = 0;
3905 + }
3906 + $history_member_head .= '</tr></thead>
3907 + <tbody>
3908 + <tr class="order_head_value">
3909 + <td class="order_number" data-label="' . __( 'Order number', 'usces' ) . '">' . usces_get_deco_order_id( $umhs['ID'] ) . '</td>
3910 + <td class="date purchase_date" data-label="' . __( 'Purchase date', 'usces' ) . '">' . $umhs['date'] . '</td>';
3911 + if ( ! empty( $p_status ) ) {
3912 + $history_member_head .= '<td class="rightnum" data-label="' . __( 'Processing status', 'usces' ) . '">' . $p_status . '</td>';
3913 + }
3914 + if ( ! empty( $r_status ) ) {
3915 + $history_member_head .= '<td class="rightnum" data-label="' . __( 'transfer statement', 'usces' ) . '">' . $r_status . '</td>';
3916 + }
3917 + $history_member_head .= '<td class="rightnum purchase_price" data-label="' . __( 'Purchase price', 'usces' ) . '">' . usces_crform( $total_price, true, false, 'return' ) . '</td>
3918 + <td class="rightnum discount" data-label="' . apply_filters( 'usces_filter_discount_label', __( 'Discount', 'usces' ) ) . '">' . usces_crform( $umhs['discount'], true, false, 'return' ) . '</td>';
3919 + if ( $tax_display && 'products' === $tax_target ) {
3920 + $history_member_head .= '<td class="rightnum tax" data-label="' . $tax_label . '">' . usces_order_history_tax( $umhs, $tax_mode ) . '</td>';
3921 + }
3922 + if ( $member_system_point && 0 === $point_coverage ) {
3923 + $history_member_head .= '<td class="rightnum used_point" data-label="' . __( 'Used points', 'usces' ) . '">' . number_format( $umhs['usedpoint'] ) . '</td>';
3924 + }
3925 + if ( $shipping ) {
3926 + $history_member_head .= '<td class="rightnum shipping" data-label="' . __( 'Shipping', 'usces' ) . '">' . usces_crform( $umhs['shipping_charge'], true, false, 'return' ) . '</td>';
3927 + }
3928 + if ( ! empty( $umhs['cod_fee'] ) ) {
3929 + $history_member_head .= '<td class="rightnum cod" data-label="' . apply_filters( 'usces_filter_cod_label', __( 'C.O.D', 'usces' ) ) . '">' . usces_crform( $umhs['cod_fee'], true, false, 'return' ) . '</td>';
3930 + }
3931 + if ( $tax_display && 'all' === $tax_target ) {
3932 + $history_member_head .= '<td class="rightnum tax" data-label="' . $tax_label . '">' . usces_order_history_tax( $umhs, $tax_mode ) . '</td>';
3933 + }
3934 + if ( $member_system_point && 1 === $point_coverage ) {
3935 + $history_member_head .= '<td class="rightnum used_point" data-label="' . __( 'Used points', 'usces' ) . '">' . number_format( $umhs['usedpoint'] ) . '</td>';
3936 + }
3937 + if ( $member_system_point ) {
3938 + $history_member_head .= '<td class="rightnum get_point" data-label="' . __( 'Acquired points', 'usces' ) . '">' . number_format( $umhs['getpoint'] ) . '</td>';
3939 + }
3940 + if ( ! empty( $tracking_number ) ) {
3941 + if ( ! empty( $delivery_company_url ) ) {
3942 + $history_member_head .= '<td data-label="' . __( 'Tracking number', 'usces' ) . '"><a href="' . esc_url( $delivery_company_url ) . '">' . esc_attr( $tracking_number ) . '</a></td>';
3943 + } else {
3944 + $history_member_head .= '<td data-label="' . __( 'Tracking number', 'usces' ) . '">' . esc_attr( $tracking_number ) . '</td>';
3945 + }
3946 + }
3947 + $history_member_head .= '</tr>';
3948 + $html .= apply_filters( 'usces_filter_history_member_head', $history_member_head, $umhs );
3949 + $html .= apply_filters( 'usces_filter_member_history_header', null, $umhs, $head_col );
3950 + $html .= '</tbody></table>
3951 + <table id="retail_table_' . $umhs['ID'] . '" class="retail">';
3952 + $history_cart_head = '<thead><tr>
3953 + <th scope="row" class="cartrownum">No.</th>
3954 + <th class="thumbnail">&nbsp;</th>
3955 + <th class="productname">' . __( 'Items', 'usces' ) . '</th>
3956 + <th class="price">' . __( 'Unit price', 'usces' ) . '</th>
3957 + <th class="quantity">' . __( 'Quantity', 'usces' ) . '</th>
3958 + <th class="subtotal">' . __( 'Amount', 'usces' ) . '</th>
3959 + </tr></thead><tbody>';
3960 + $html .= apply_filters( 'usces_filter_history_cart_head', $history_cart_head, $umhs );
3961 + $cart_count = ( $cart && is_array( $cart ) ) ? count( $cart ) : 0;
3962 + for ( $i = 0; $i < $cart_count; $i++ ) {
3963 + $cart_row = $cart[ $i ];
3964 + $ordercart_id = $cart_row['cart_id'];
3965 + $post_id = $cart_row['post_id'];
3966 + $sku = $cart_row['sku'];
3967 + $sku_code = urldecode( $cart_row['sku'] );
3968 + $quantity = $cart_row['quantity'];
3969 + $options = ( ! empty( $cart_row['options'] ) ) ? $cart_row['options'] : array();
3970 + $itemCode = $cart_row['item_code'];
3971 + $itemName = $cart_row['item_name'];
3972 + $cartItemName = $usces->getCartItemName_byOrder( $cart_row );
3973 + $skuPrice = $cart_row['price'];
3974 + $pictid = (int) $usces->get_mainpictid( $itemCode );
3975 + $optstr = '';
3976 + if ( is_array( $options ) && count( $options ) > 0 ) {
3977 + foreach ( $options as $key => $value ) {
3978 + if ( ! empty( $key ) ) {
3979 + $key = urldecode( $key );
3980 + $value = wel_safe_maybe_unserialize( $value );
3981 + if ( is_array( $value ) ) {
3982 + $c = '';
3983 + $optstr .= esc_html( $key ) . ' : ';
3984 + foreach ( $value as $v ) {
3985 + $optstr .= $c . nl2br( esc_html( rawurldecode( $v ) ) );
3986 + $c = ', ';
3987 + }
3988 + $optstr .= "<br />\n";
3989 + } else {
3990 + $optstr .= esc_html( $key ) . ' : ' . nl2br( esc_html( rawurldecode( $value ) ) ) . "<br />\n";
3991 + }
3992 + }
3993 + }
3994 + $optstr = apply_filters( 'usces_filter_option_history', $optstr, $options );
3995 + }
3996 + $optstr = apply_filters( 'usces_filter_option_info_history', $optstr, $umhs, $cart_row, $i );
3997 + $args = compact( 'cart', 'i', 'cart_row', 'post_id', 'sku' );
3998 +
3999 + $cart_item_name = '<a href="' . get_permalink( $post_id ) . '">' . apply_filters( 'usces_filter_cart_item_name', esc_html( $cartItemName ), $args ) . '<br />' . $optstr . '</a>' . apply_filters( 'usces_filter_history_item_name', null, $umhs, $cart_row, $i );
4000 + $cart_item_name = apply_filters( 'usces_filter_history_cart_item_name', $cart_item_name, $cartItemName, $optstr, $cart_row, $i, $umhs );
4001 +
4002 + $history_cart_row = '<tr>
4003 + <td class="cartrownum">' . ( $i + 1 ) . '</td>
4004 + <td class="thumbnail">';
4005 + $cart_thumbnail = '<a href="' . get_permalink( $post_id ) . '">' . wp_get_attachment_image( $pictid, array( 60, 60 ), true ) . '</a>';
4006 + $history_cart_row .= apply_filters( 'usces_filter_cart_thumbnail', $cart_thumbnail, $post_id, $pictid, $i, $cart_row );
4007 + $history_cart_row .= '</td>
4008 + <td class="aleft productname" data-label="' . __( 'Items', 'usces' ) . '">' . $cart_item_name . '</td>
4009 + <td class="rightnum price" data-label="' . __( 'Unit price', 'usces' ) . '">' . usces_crform( $skuPrice, true, false, 'return' ) . '</td>
4010 + <td class="rightnum quantity" data-label="' . __( 'Quantity', 'usces' ) . '">' . number_format( $cart_row['quantity'] ) . '</td>
4011 + <td class="rightnum subtotal" data-label="' . __( 'Amount', 'usces' ) . '">' . usces_crform( $skuPrice * $cart_row['quantity'], true, false, 'return' ) . '</td>
4012 + </tr>';
4013 + $materials = compact( 'cart_thumbnail', 'post_id', 'pictid', 'cartItemName', 'optstr' );
4014 + $html .= apply_filters( 'usces_filter_history_cart_row', $history_cart_row, $umhs, $cart_row, $i, $materials );
4015 + }
4016 + $html .= '</tbody></table>';
4017 + $html .= apply_filters( 'usces_filter_member_history_row', '', $umhs, $cart );
4018 + }
4019 + }
4020 + $html .= '</div>';
4021 + $html = apply_filters( 'usces_filter_member_history', $html, $usces_member_history );
4022 +
4023 + if ( 'return' === $out ) {
4024 + return $html;
4025 + } else {
4026 + echo $html; // no escape due to filter.
4027 + }
4028 +}
4029 +
4030 +/**
4031 + * Load select list filter purchase history.
4032 + */
4033 +function usces_load_filter_purchase_date() {
4034 + global $usces;
4035 +
4036 + $pur_date = $usces->usces_get_member_cookies( 'pur-date' );
4037 + $current_year = (int) gmdate( 'Y' );
4038 + $year_filter = 11;
4039 + $arr_filter = array(
4040 + '' => __( 'All of period', 'usces' ),
4041 + 'm_0' => __( 'This month', 'usces' ),
4042 + 'm_1' => __( 'Previous month', 'usces' ),
4043 + 'm_2' => __( 'Two months ago', 'usces' ),
4044 + 'd_30' => __( 'Last 30 days', 'usces' ),
4045 + 'd_60' => __( 'Last 60 days', 'usces' ),
4046 + );
4047 + for ( $i = 0; $i < $year_filter; $i++ ) {
4048 + $year = $current_year - $i;
4049 + $arr_filter[ 'y_' . $year ] = $year . __( 'year', 'usces' );
4050 + }
4051 + $exclude_cancel = $usces->usces_get_member_cookies( 'ord_ex_cancel' );
4052 + $add_ex_args = array(
4053 + 'ord_ex_cancel' => ( 'on' === (string) $exclude_cancel ) ? 'off' : 'on',
4054 + 'pur-date' => $pur_date,
4055 + );
4056 + $url_ex_filter = add_query_arg( $add_ex_args, USCES_MEMBER_URL ) . '#usces_history';
4057 + $html = '<div id="usces_history" class="usces_filter_history">';
4058 + $content = '<div class="exclude_cancel">';
4059 + $content .= '<label for="ord_exclude_cancel">';
4060 + $content .= '<input type="checkbox" id="ord_exclude_cancel" name="ord_exclude_cancel" onchange="memberOrderHistory.onChangeFilter(this);" value="' . esc_url( $url_ex_filter ) . '" ' . checked( $exclude_cancel, 'on', false ) . ' />';
4061 + $content .= __( 'Exclude cancellations', 'usces' ) . '</label>';
4062 + $content .= '</div>';
4063 + $content .= '<div class="usce_period">';
4064 + $content .= '<span>' . __( 'Period', 'usces' ) . '</span>';
4065 + $content .= '<select name="usces_purdate" id="usces_purdate" onchange="memberOrderHistory.onChangeFilter(this);">';
4066 + foreach ( $arr_filter as $key => $name ) {
4067 + $selected = '';
4068 + $add_args = array(
4069 + 'pur-date' => $key,
4070 + );
4071 + if ( (string) $key === (string) $pur_date ) {
4072 + $selected = 'selected';
4073 + }
4074 + $url_filter = add_query_arg( $add_args, USCES_MEMBER_URL ) . '#usces_history';
4075 + $content .= '<option cvalue="' . $key . '" value="' . esc_url( $url_filter ) . '" ' . esc_attr( $selected ) . '>' . esc_attr( $name ) . '</option>';
4076 + }
4077 + $content .= '</select>';
4078 + $content .= '</div>';
4079 + $html .= apply_filters( 'usces_filter_member_history_top_navi', $content );
4080 + $html .= '</div>';
4081 + return $html;
4082 +}
4083 +
4084 +/**
4085 + * New registration button
4086 + *
4087 + * @param string $member_regmode Registration mode.
4088 + */
4089 +function usces_newmember_button( $member_regmode ) {
4090 + $html = '<input name="member_regmode" type="hidden" value="' . $member_regmode . '" />';
4091 + $newmemberbutton = '<input name="regmember" type="submit" value="' . __( 'transmit a message', 'usces' ) . '" />';
4092 + $html .= apply_filters( 'usces_filter_newmember_button', $newmemberbutton );
4093 + wel_esc_script_e( $html );
4094 +}
4095 +
4096 +/**
4097 + * Login button
4098 + */
4099 +function usces_login_button() {
4100 + $loginbutton = '<input type="submit" name="member_login" id="member_login" class="member_login_button" value="' . __( 'Log-in', 'usces' ) . '" />';
4101 + $html = apply_filters( 'usces_filter_login_button', $loginbutton );
4102 + wel_esc_script_e( $html );
4103 +}
4104 +
4105 +/**
4106 + * Related item
4107 + *
4108 + * @param int $post_id Post ID.
4109 + * @param string $title Title.
4110 + */
4111 +function usces_assistance_item( $post_id, $title ) {
4112 + if ( usces_get_assistance_id_list( $post_id ) ) :
4113 + global $post;
4114 + $r = new WP_Query( array( 'post__in' => usces_get_assistance_ids( $post_id ), 'ignore_sticky_posts' => 1 ) );
4115 + if ( $r->have_posts() ) :
4116 + add_filter( 'excerpt_length', 'welcart_assistance_excerpt_length' );
4117 + add_filter( 'excerpt_mblength', 'welcart_assistance_excerpt_mblength' );
4118 + $width = apply_filters( 'usces_filter_assistance_item_width', 100 );
4119 + $height = apply_filters( 'usces_filter_assistance_item_height', 100 );
4120 + ?>
4121 + <div class="assistance_item">
4122 + <h3><?php wel_esc_script_e( $title ); ?></h3>
4123 + <ul class="clearfix">
4124 + <?php
4125 + while ( $r->have_posts() ) :
4126 + $r->the_post();
4127 + usces_remove_filter();
4128 + usces_the_item();
4129 + ob_start();
4130 + ?>
4131 + <li>
4132 + <div class="listbox clearfix">
4133 + <div class="slit">
4134 + <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>
4135 + </div>
4136 + <div class="detail">
4137 + <div class="assist_excerpt">
4138 + <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php echo wp_filter_nohtml_kses( get_the_title() ); ?>"><h4><?php usces_the_itemName(); ?></h4></a>
4139 + <?php the_excerpt(); ?>
4140 + </div>
4141 + <?php if ( usces_is_skus() ) : ?>
4142 + <div class="assist_price">
4143 + <?php usces_crform( usces_the_firstPrice( 'return' ), true, false ); ?>
4144 + </div>
4145 + <?php usces_crform_the_itemPriceCr_taxincluded(); ?>
4146 + <?php endif; ?>
4147 + </div>
4148 + </div>
4149 + </li>
4150 + <?php
4151 + $list = ob_get_contents();
4152 + ob_end_clean();
4153 + echo apply_filters( 'usces_filter_assistance_item_list', $list, $post );
4154 + endwhile;
4155 + ?>
4156 + </ul>
4157 + </div><!-- end of assistance_item -->
4158 + <?php
4159 + wp_reset_postdata();
4160 + usces_reset_filter();
4161 + remove_filter( 'excerpt_length', 'welcart_assistance_excerpt_length' );
4162 + remove_filter( 'excerpt_mblength', 'welcart_assistance_excerpt_mblength' );
4163 + endif;
4164 + endif;
4165 +}
4166 +
4167 +/**
4168 + * Cart Item Details
4169 + *
4170 + * @param string $out Return value or echo.
4171 + * @return string|void
4172 + */
4173 +function usces_get_cart_rows( $out = '' ) {
4174 + global $usces, $usces_gp;
4175 +
4176 + $cart = $usces->cart->get_cart();
4177 + $usces_gp = 0;
4178 + $cart_count = ( $cart && is_array( $cart ) ) ? count( $cart ) : 0;
4179 + $res = '';
4180 +
4181 + for ( $i = 0; $i < $cart_count; $i++ ) {
4182 + $cart_row = $cart[ $i ];
4183 + $post_id = (int) $cart_row['post_id'];
4184 + $sku = $cart_row['sku'];
4185 + $sku_code = urldecode( $cart_row['sku'] );
4186 + $quantity = $cart_row['quantity'];
4187 + $options = ( ! empty( $cart_row['options'] ) ) ? $cart_row['options'] : array();
4188 + $advance = ( ! empty( $cart_row['advance'] ) ) ? $cart_row['advance'] : '';
4189 + $itemCode = $usces->getItemCode( $post_id );
4190 + $itemName = $usces->getItemName( $post_id );
4191 + $cartItemName = $usces->getCartItemName( $post_id, $sku_code );
4192 + $itemRestriction = $usces->getItemRestriction( $post_id );
4193 + $itemOrderAcceptable = $usces->getItemOrderAcceptable( $post_id );
4194 + $skuPrice = $cart_row['price'];
4195 + $skuZaikonum = $usces->getItemZaikonum( $post_id, $sku_code );
4196 + $stockid = $usces->getItemZaikoStatusId( $post_id, $sku_code );
4197 + $stock = $usces->getItemZaiko( $post_id, $sku_code );
4198 + $red = ( 1 < $stockid ) ? 'class="signal_red stock"' : 'class="stock"';
4199 + $pictid = (int) $usces->get_mainpictid( $itemCode );
4200 + $args = compact( 'cart', 'i', 'cart_row', 'post_id', 'sku' );
4201 +
4202 + $row = '';
4203 + $row .= '<tr>
4204 + <td class="num">' . ( $i + 1 ) . '</td>
4205 + <td class="thumbnail">';
4206 + $cart_thumbnail = '<a href="' . get_permalink( $post_id ) . '">' . wp_get_attachment_image( $pictid, array( 60, 60 ), true ) . '</a>';
4207 + $row .= apply_filters( 'usces_filter_cart_thumbnail', $cart_thumbnail, $post_id, $pictid, $i, $cart_row );
4208 + $row .= '</td>
4209 + <td class="aleft productname" data-label="' . esc_html__( 'Items', 'usces' ) . '">' . apply_filters( 'usces_filter_cart_item_name', esc_html( $cartItemName ), $args ) . '<br />';
4210 + if ( is_array( $options ) && count( $options ) > 0 ) {
4211 + $optstr = '';
4212 + foreach ( $options as $key => $value ) {
4213 + if ( ! empty( $key ) ) {
4214 + $key = urldecode( $key );
4215 + if ( is_array( $value ) ) {
4216 + $c = '';
4217 + $optstr .= esc_html( $key ) . ' : ';
4218 + foreach ( $value as $v ) {
4219 + $optstr .= $c . nl2br( esc_html( urldecode( $v ) ) );
4220 + $c = ', ';
4221 + }
4222 + $optstr .= "<br />\n";
4223 + } else {
4224 + $optstr .= esc_html( $key ) . ' : ' . nl2br( esc_html( urldecode( $value ) ) ) . "<br />\n";
4225 + }
4226 + }
4227 + }
4228 + $row .= apply_filters( 'usces_filter_option_cart', $optstr, $options, $args );
4229 + }
4230 + $row .= apply_filters( 'usces_filter_option_info_cart', '', $cart_row, $args );
4231 + $row .= '</td>
4232 + <td class="aright unitprice" data-label="' . esc_html__( 'Unit price', 'usces' ) . '">';
4233 + if ( usces_is_gptekiyo( $post_id, $sku_code, $quantity ) ) {
4234 + $usces_gp = 1;
4235 + $gp_src = file_exists( get_template_directory() . '/images/gp.gif' ) ? get_template_directory_uri() . '/images/gp.gif' : USCES_PLUGIN_URL . '/images/gp.gif';
4236 + $Business_pack_mark = '<img src="' . $gp_src . '" alt="' . __( 'Business package discount', 'usces' ) . '" /><br />';
4237 + $row .= apply_filters( 'usces_filter_itemGpExp_cart_mark', $Business_pack_mark );
4238 + }
4239 + $row .= usces_crform( $skuPrice, true, false, 'return' ) . '
4240 + </td>
4241 + <td class="quantity" data-label="' . esc_html__( 'Quantity', 'usces' ) . '">';
4242 + $row_quant = '<input name="quant[' . $i . '][' . $post_id . '][' . esc_attr( $sku ) . ']" class="quantity" type="text" value="' . esc_attr( $cart_row['quantity'] ) . '" />';
4243 + $row .= apply_filters( 'usces_filter_cart_rows_quant', $row_quant, $args );
4244 + $row .= '</td>
4245 + <td class="aright subtotal" data-label="' . esc_html__( 'Amount', 'usces' ) . usces_guid_tax( 'return', false ) . '">' . usces_crform( ( $skuPrice * $cart_row['quantity'] ), true, false, 'return' ) . '</td>';
4246 + $stock_column = '<td ' . $red . ' data-label="' . esc_html__( 'stock status', 'usces' ) . '">' . esc_html( $stock ) . '</td>';
4247 + $row .= apply_filters( 'usces_filter_cart_rows_stock', $stock_column, $args, $red, $stock );
4248 + $row .= '<td class="action">';
4249 + if ( is_array( $options ) && count( $options ) > 0 ) {
4250 + foreach ( $options as $key => $value ) {
4251 + if ( is_array( $value ) ) {
4252 + foreach ( $value as $v ) {
4253 + $row .= '<input name="itemOption[' . $i . '][' . $post_id . '][' . esc_attr( $sku ) . '][' . esc_attr( $key ) . '][' . esc_attr( $v ) . ']" type="hidden" value="' . esc_attr( $v ) . '" />' . "\n";
4254 + }
4255 + } else {
4256 + $row .= '<input name="itemOption[' . $i . '][' . $post_id . '][' . esc_attr( $sku ) . '][' . esc_attr( $key ) . ']" type="hidden" value="' . esc_attr( $value ) . '" />' . "\n";
4257 + }
4258 + }
4259 + }
4260 + $row .= '<input name="itemRestriction[' . $i . ']" type="hidden" value="' . esc_attr( $itemRestriction ) . '" />
4261 + <input name="itemOrderAcceptable[' . $i . ']" type="hidden" value="' . $itemOrderAcceptable . '" />
4262 + <input name="stockid[' . $i . ']" type="hidden" value="' . esc_attr( $stockid ) . '" />
4263 + <input name="itempostid[' . $i . ']" type="hidden" value="' . esc_attr( $post_id ) . '" />
4264 + <input name="itemsku[' . $i . ']" type="hidden" value="' . esc_attr( $sku ) . '" />
4265 + <input name="zaikonum[' . $i . '][' . $post_id . '][' . esc_attr( $sku ) . ']" type="hidden" value="' . esc_attr( $skuZaikonum ) . '" />
4266 + <input name="skuPrice[' . $i . '][' . $post_id . '][' . esc_attr( $sku ) . ']" type="hidden" value="' . esc_attr( $skuPrice ) . '" />
4267 + <input name="advance[' . $i . '][' . $post_id . '][' . esc_attr( $sku ) . ']" type="hidden" value="' . esc_attr( $advance ) . '" />
4268 + <input name="delButton[' . $i . '][' . $post_id . '][' . esc_attr( $sku ) . ']" class="delButton" type="submit" value="' . __( 'Delete', 'usces' ) . '" />
4269 + </td>
4270 + </tr>';
4271 + $materials = compact( 'i', 'cart_row', 'post_id', 'sku', 'sku_code', 'quantity', 'options', 'advance', 'itemCode', 'itemName', 'cartItemName', 'itemRestriction', 'skuPrice', 'skuZaikonum', 'stockid', 'stock', 'red', 'pictid' );
4272 + $res .= apply_filters( 'usces_filter_cart_row', $row, $cart, $materials );
4273 + }
4274 +
4275 + $res = apply_filters( 'usces_filter_cart_rows', $res, $cart );
4276 +
4277 + if ( 'return' === $out ) {
4278 + return $res;
4279 + } else {
4280 + echo $res; // no escape due to filter.
4281 + }
4282 +}
4283 +
4284 +/**
4285 + * Confirm Cart Item Details
4286 + *
4287 + * @param string $out Return value or echo.
4288 + * @return string|void
4289 + */
4290 +function usces_get_confirm_rows( $out = '' ) {
4291 + global $usces, $usces_members, $usces_entries;
4292 +
4293 + $memid = ( empty( $usces_members['ID'] ) ) ? 999999999 : $usces_members['ID'];
4294 + $usces->set_cart_fees( $usces_members, $usces_entries );
4295 + $usces_entries = $usces->cart->get_entry();
4296 +
4297 + $cart = $usces->cart->get_cart();
4298 + $cart_count = ( $cart && is_array( $cart ) ) ? count( $cart ) : 0;
4299 + $res = '';
4300 +
4301 + for ( $i = 0; $i < $cart_count; $i++ ) {
4302 + $cart_row = $cart[ $i ];
4303 + $post_id = (int) $cart_row['post_id'];
4304 + $sku = $cart_row['sku'];
4305 + $sku_code = urldecode( $cart_row['sku'] );
4306 + $quantity = $cart_row['quantity'];
4307 + $options = ( ! empty( $cart_row['options'] ) ) ? $cart_row['options'] : array();
4308 + $advance = $cart_row['advance'];
4309 + $itemCode = $usces->getItemCode( $post_id );
4310 + $itemName = $usces->getItemName( $post_id );
4311 + $cartItemName = $usces->getCartItemName( $post_id, $sku_code );
4312 + $skuPrice = $cart_row['price'];
4313 + $pictid = $usces->get_mainpictid( $itemCode );
4314 + $args = compact( 'cart', 'i', 'cart_row', 'post_id', 'sku' );
4315 +
4316 + $row = '';
4317 + $row .= '<tr>
4318 + <td class="num">' . ( $i + 1 ) . '</td>
4319 + <td class="thumbnail">';
4320 + $cart_thumbnail = wp_get_attachment_image( $pictid, array( 60, 60 ), true );
4321 + $row .= apply_filters( 'usces_filter_cart_thumbnail', $cart_thumbnail, $post_id, $pictid, $i, $cart_row );
4322 + $row .= '</td><td class="productname" data-label="' . esc_html__( 'Items', 'usces' ) . '">' . apply_filters( 'usces_filter_cart_item_name', esc_html( $cartItemName ), $args ) . '<br />';
4323 + if ( is_array( $options ) && count( $options ) > 0 ) {
4324 + $optstr = '';
4325 + foreach ( $options as $key => $value ) {
4326 + if ( ! empty( $key ) ) {
4327 + $key = urldecode( $key );
4328 + if ( is_array( $value ) ) {
4329 + $c = '';
4330 + $optstr .= esc_html( $key ) . ' : ';
4331 + foreach ( $value as $v ) {
4332 + $optstr .= $c . nl2br( esc_html( urldecode( $v ) ) );
4333 + $c = ', ';
4334 + }
4335 + $optstr .= "<br />\n";
4336 + } else {
4337 + $optstr .= esc_html( $key ) . ' : ' . nl2br( esc_html( urldecode( $value ) ) ) . "<br />\n";
4338 + }
4339 + }
4340 + }
4341 + $row .= apply_filters( 'usces_filter_option_confirm', $optstr, $options, $args );
4342 + }
4343 + $row .= apply_filters( 'usces_filter_option_info_confirm', '', $cart_row, $args );
4344 + $row .= '</td>
4345 + <td class="unitprice" data-label="' . esc_html__( 'Unit price', 'usces' ) . '">' . esc_html( usces_crform( $skuPrice, true, false, 'return' ) ) . '</td>
4346 + <td class="quantity" data-label="' . esc_html__( 'Quantity', 'usces' ) . '">' . esc_html( $cart_row['quantity'] ) . '</td>
4347 + <td class="subtotal" data-label="' . esc_html__( 'Amount', 'usces' ) . '">' . esc_html( usces_crform( ( $skuPrice * $cart_row['quantity'] ), true, false, 'return' ) ) . '</td>
4348 + <td class="action">';
4349 + $row .= apply_filters( 'usces_additional_confirm', '', array( $i, $post_id, $sku_code ) );
4350 + $row .= '</td>
4351 + </tr>';
4352 +
4353 + $materials = compact( 'i', 'cart_row', 'post_id', 'sku', 'sku_code', 'quantity', 'options', 'advance', 'itemCode', 'itemName', 'cartItemName', 'skuPrice', 'pictid' );
4354 + $res .= apply_filters( 'usces_filter_confirm_row', $row, $cart, $materials );
4355 + }
4356 +
4357 + $res = apply_filters( 'usces_filter_confirm_rows', $res, $cart );
4358 +
4359 + if ( 'return' === $out ) {
4360 + return $res;
4361 + } else {
4362 + echo $res; // no escape due to filter.
4363 + }
4364 +}
4365 +
4366 +/**
4367 + * Address Information
4368 + *
4369 + * @param string $type Type.
4370 + * @param array $data Entry data.
4371 + * @param string $out Return value or echo.
4372 + * @return string|void
4373 + */
4374 +function uesces_addressform( $type, $data, $out = 'return' ) {
4375 + global $usces, $usces_settings;
4376 +
4377 + $options = get_option( 'usces', array() );
4378 + $form = $options['system']['addressform'];
4379 + $nameform = $usces_settings['nameform'][ $form ];
4380 + $applyform = usces_get_apply_addressform( $form );
4381 + $formtag = '';
4382 + switch ( $type ) {
4383 + case 'confirm':
4384 + case 'member':
4385 + $values = $data;
4386 + break;
4387 + case 'customer':
4388 + case 'delivery':
4389 + $values = $data[ $type ];
4390 + break;
4391 + }
4392 + $data['type'] = $type;
4393 + $values['country'] = ! empty( $values['country'] ) ? $values['country'] : usces_get_local_addressform();
4394 + $values = $usces->stripslashes_deep_post( $values );
4395 + $target_market_count = ( isset( $options['system']['target_market'] ) && is_array( $options['system']['target_market'] ) ) ? count( $options['system']['target_market'] ) : 1;
4396 +
4397 + if ( 'confirm' === $type ) {
4398 +
4399 + switch ( $applyform ) {
4400 +
4401 + case 'JP':
4402 + $formtag .= usces_custom_field_info( $data, 'customer', 'name_pre', 'return' );
4403 + $formtag .= '<tr class="name-row member-name-row"><th>' . apply_filters( 'usces_filters_addressform_name_label', __( 'Full name', 'usces' ), $type, $values, $applyform ) . '</th><td>' . esc_html( sprintf( _x( '%s', 'honorific', 'usces' ), ( esc_html( $values['customer']['name1'] ) . ' ' . esc_html( $values['customer']['name2'] ) ) ) ) . '</td></tr>';
4404 + $furigana = ( '' === ( trim( $values['customer']['name3'] ) . trim( $values['customer']['name4'] ) ) ) ? '' : sprintf( _x( '%s', 'honorific', 'usces' ), ( esc_html( $values['customer']['name3'] ) . ' ' . esc_html( $values['customer']['name4'] ) ) );
4405 + $furigana_customer = '<tr class="furikana-row member-furikana-row"><th>' . __( 'furigana', 'usces' ) . '</th><td>' . $furigana . '</td></tr>';
4406 + $formtag .= apply_filters( 'usces_filter_furigana_confirm_customer', $furigana_customer, $type, $values );
4407 + $formtag .= usces_custom_field_info( $data, 'customer', 'name_after', 'return' );
4408 + $formtag .= '<tr class="zipcode-row member-zipcode-row"><th>' . __( 'Zip/Postal Code', 'usces' ) . '</th><td>' . esc_html( $values['customer']['zipcode'] ) . '</td></tr>';
4409 + if ( 1 < $target_market_count ) {
4410 + $customer_country = ( ! empty( $usces_settings['country'][ $values['customer']['country'] ] ) ) ? $usces_settings['country'][ $values['customer']['country'] ] : '';
4411 + $formtag .= '<tr class="country-row member-country-row"><th>' . __( 'Country', 'usces' ) . '</th><td>' . esc_html( $customer_country ) . '</td></tr>';
4412 + }
4413 + $customer_pref = ( __( '-- Select --', 'usces' ) === $values['customer']['pref'] || '-- Select --' === $values['customer']['pref'] ) ? '' : $values['customer']['pref'];
4414 + $formtag .= '
4415 + <tr class="states-row member-states-row"><th>' . __( 'Province', 'usces' ) . '</th><td>' . esc_html( $customer_pref ) . '</td></tr>
4416 + <tr class="address1-row member-address1-row"><th>' . __( 'city', 'usces' ) . '</th><td>' . esc_html( $values['customer']['address1'] ) . '</td></tr>
4417 + <tr class="address2-row member-address2-row"><th>' . __( 'numbers', 'usces' ) . '</th><td>' . esc_html( $values['customer']['address2'] ) . '</td></tr>
4418 + <tr class="address3-row member-address3-row"><th>' . __( 'building name', 'usces' ) . '</th><td>' . esc_html( $values['customer']['address3'] ) . '</td></tr>
4419 + <tr class="tel-row member-tel-row"><th>' . __( 'Phone number', 'usces' ) . '</th><td>' . esc_html( $values['customer']['tel'] ) . '</td></tr>
4420 + <tr class="fax-row member-fax-row"><th>' . __( 'FAX number', 'usces' ) . '</th><td>' . esc_html( $values['customer']['fax'] ) . '</td></tr>';
4421 + $formtag .= usces_custom_field_info( $data, 'customer', 'fax_after', 'return' );
4422 +
4423 + $shipping_address_info = '';
4424 + if ( isset( $values['delivery'] ) ) {
4425 + $shipping_address_info = '<tr class="ttl"><td colspan="2"><h3>' . __( 'Shipping address information', 'usces' ) . '</h3></td></tr>';
4426 + $shipping_address_info .= usces_custom_field_info( $data, 'delivery', 'name_pre', 'return' );
4427 + $shipping_address_info .= '<tr class="name-row delivery-name-row"><th>' . apply_filters( 'usces_filters_addressform_name_label', __( 'Full name', 'usces' ), $type, $values, $applyform ) . '</th><td>' . sprintf( _x( '%s', 'honorific', 'usces' ), ( esc_html( $values['delivery']['name1'] ) . ' ' . esc_html( $values['delivery']['name2'] ) ) ) . '</td></tr>';
4428 + $deli_furigana = ( '' === ( trim( $values['delivery']['name3'] ) . trim( $values['delivery']['name4'] ) ) ) ? '' : sprintf( _x( '%s', 'honorific', 'usces' ), ( esc_html( $values['delivery']['name3'] ) . ' ' . esc_html( $values['delivery']['name4'] ) ) );
4429 + $furigana_delivery = '<tr class="furikana-row delivery-furikana-row"><th>' . __( 'furigana', 'usces' ) . '</th><td>' . $deli_furigana . '</td></tr>';
4430 + $shipping_address_info .= apply_filters( 'usces_filter_furigana_confirm_delivery', $furigana_delivery, $type, $values );
4431 + $shipping_address_info .= usces_custom_field_info( $values, 'delivery', 'name_after', 'return' );
4432 + $shipping_address_info .= '<tr class="zipcode-row delivery-zipcode-row"><th>' . __( 'Zip/Postal Code', 'usces' ) . '</th><td>' . esc_html( $values['delivery']['zipcode'] ) . '</td></tr>';
4433 + if ( 1 < $target_market_count ) {
4434 + $shipping_country = ( ! empty( $usces_settings['country'][ $values['delivery']['country'] ] ) ) ? $usces_settings['country'][ $values['delivery']['country'] ] : '';
4435 + $shipping_address_info .= '<tr class="country-row delivery-country-row"><th>' . __( 'Country', 'usces' ) . '</th><td>' . esc_html( $shipping_country ) . '</td></tr>';
4436 + }
4437 + $delivery_pref = ( __( '-- Select --', 'usces' ) === $values['delivery']['pref'] || '-- Select --' === $values['delivery']['pref'] ) ? '' : $values['delivery']['pref'];
4438 + $shipping_address_info .= '
4439 + <tr class="states-row delivery-states-row"><th>' . __( 'Province', 'usces' ) . '</th><td>' . esc_html( $delivery_pref ) . '</td></tr>
4440 + <tr class="address1-row delivery-address1-row"><th>' . __( 'city', 'usces' ) . '</th><td>' . esc_html( $values['delivery']['address1'] ) . '</td></tr>
4441 + <tr class="address2-row delivery-address2-row"><th>' . __( 'numbers', 'usces' ) . '</th><td>' . esc_html( $values['delivery']['address2'] ) . '</td></tr>
4442 + <tr class="address3-row delivery-address3-row"><th>' . __( 'building name', 'usces' ) . '</th><td>' . esc_html( $values['delivery']['address3'] ) . '</td></tr>
4443 + <tr class="tel-row delivery-tel-row"><th>' . __( 'Phone number', 'usces' ) . '</th><td>' . esc_html( $values['delivery']['tel'] ) . '</td></tr>
4444 + <tr class="fax-row delivery-fax-row"><th>' . __( 'FAX number', 'usces' ) . '</th><td>' . esc_html( $values['delivery']['fax'] ) . '</td></tr>';
4445 + $shipping_address_info .= usces_custom_field_info( $data, 'delivery', 'fax_after', 'return' );
4446 + }
4447 + $formtag .= apply_filters( 'usces_filter_shipping_address_info', $shipping_address_info );
4448 + break;
4449 +
4450 + case 'CN':
4451 + $formtag .= usces_custom_field_info( $data, 'customer', 'name_pre', 'return' );
4452 + $formtag .= '<tr class="name-row member-name-row"><th>' . apply_filters( 'usces_filters_addressform_name_label', __( 'Full name', 'usces' ), $type, $values, $applyform ) . '</th><td>' . sprintf( _x( '%s', 'honorific', 'usces' ), esc_html( usces_localized_name( $values['customer']['name1'], $values['customer']['name2'], 'return' ) ) ) . '</td></tr>';
4453 + $formtag .= usces_custom_field_info( $data, 'customer', 'name_after', 'return' );
4454 + if ( 1 < $target_market_count ) {
4455 + $customer_country = ( ! empty( $usces_settings['country'][ $values['customer']['country'] ] ) ) ? $usces_settings['country'][ $values['customer']['country'] ] : '';
4456 + $formtag .= '<tr class="country-row member-country-row"><th>' . __( 'Country', 'usces' ) . '</th><td>' . esc_html( $customer_country ) . '</td></tr>';
4457 + }
4458 + $customer_pref = ( __( '-- Select --', 'usces' ) === $values['customer']['pref'] || '-- Select --' === $values['customer']['pref'] ) ? '' : $values['customer']['pref'];
4459 + $formtag .= '
4460 + <tr class="states-row member-states-row"><th>' . __( 'State', 'usces' ) . '</th><td>' . esc_html( $customer_pref ) . '</td></tr>
4461 + <tr class="address1-row member-address1-row"><th>' . __( 'city', 'usces' ) . '</th><td>' . esc_html( $values['customer']['address1'] ) . '</td></tr>
4462 + <tr class="address2-row member-address2-row"><th>' . __( 'Address Line1', 'usces' ) . '</th><td>' . esc_html( $values['customer']['address2'] ) . '</td></tr>
4463 + <tr class="address3-row member-address3-row"><th>' . __( 'Address Line2', 'usces' ) . '</th><td>' . esc_html( $values['customer']['address3'] ) . '</td></tr>
4464 + <tr class="zipcode-row member-zipcode-row"><th>' . __( 'Zip', 'usces' ) . '</th><td>' . esc_html( $values['customer']['zipcode'] ) . '</td></tr>
4465 + <tr class="tel-row member-tel-row"><th>' . __( 'Phone number', 'usces' ) . '</th><td>' . esc_html( $values['customer']['tel'] ) . '</td></tr>
4466 + <tr class="fax-row member-fax-row"><th>' . __( 'FAX number', 'usces' ) . '</th><td>' . esc_html( $values['customer']['fax'] ) . '</td></tr>';
4467 + $formtag .= usces_custom_field_info( $data, 'customer', 'fax_after', 'return' );
4468 +
4469 + $shipping_address_info = '';
4470 + if ( isset( $values['delivery'] ) ) {
4471 + $shipping_address_info = '<tr class="ttl"><td colspan="2"><h3>' . __( 'Shipping address information', 'usces' ) . '</h3></td></tr>';
4472 + $shipping_address_info .= usces_custom_field_info( $data, 'delivery', 'name_pre', 'return' );
4473 + $shipping_address_info .= '<tr class="name-row delivery-name-row"><th>' . apply_filters( 'usces_filters_addressform_name_label', __( 'Full name', 'usces' ), $type, $values, $applyform ) . '</th><td>' . sprintf( _x( '%s', 'honorific', 'usces' ), esc_html( usces_localized_name( $values['delivery']['name1'], $values['delivery']['name2'], 'return' ) ) ) . '</td></tr>';
4474 + $shipping_address_info .= usces_custom_field_info( $data, 'delivery', 'name_after', 'return' );
4475 + if ( 1 < $target_market_count ) {
4476 + $shipping_country = ( ! empty( $usces_settings['country'][ $values['delivery']['country'] ] ) ) ? $usces_settings['country'][ $values['delivery']['country'] ] : '';
4477 + $shipping_address_info .= '<tr class="country-row delivery-country-row"><th>' . __( 'Country', 'usces' ) . '</th><td>' . esc_html( $shipping_country ) . '</td></tr>';
4478 + }
4479 + $delivery_pref = ( __( '-- Select --', 'usces' ) === $values['delivery']['pref'] || '-- Select --' === $values['delivery']['pref'] ) ? '' : $values['delivery']['pref'];
4480 + $shipping_address_info .= '
4481 + <tr class="states-row delivery-states-row"><th>' . __( 'State', 'usces' ) . '</th><td>' . esc_html( $delivery_pref ) . '</td></tr>
4482 + <tr class="address1-row delivery-address1-row"><th>' . __( 'city', 'usces' ) . '</th><td>' . esc_html( $values['delivery']['address1'] ) . '</td></tr>
4483 + <tr class="address2-row delivery-address2-row"><th>' . __( 'Address Line1', 'usces' ) . '</th><td>' . esc_html( $values['delivery']['address2'] ) . '</td></tr>
4484 + <tr class="address3-row delivery-address3-row"><th>' . __( 'Address Line2', 'usces' ) . '</th><td>' . esc_html( $values['delivery']['address3'] ) . '</td></tr>
4485 + <tr class="zipcode-row delivery-zipcode-row"><th>' . __( 'Zip', 'usces' ) . '</th><td>' . esc_html( $values['delivery']['zipcode'] ) . '</td></tr>
4486 + <tr class="tel-row delivery-tel-row"><th>' . __( 'Phone number', 'usces' ) . '</th><td>' . esc_html( $values['delivery']['tel'] ) . '</td></tr>
4487 + <tr class="fax-row delivery-fax-row"><th>' . __( 'FAX number', 'usces' ) . '</th><td>' . esc_html( $values['delivery']['fax'] ) . '</td></tr>';
4488 + $shipping_address_info .= usces_custom_field_info( $data, 'delivery', 'fax_after', 'return' );
4489 + }
4490 + $formtag .= apply_filters( 'usces_filter_shipping_address_info', $shipping_address_info );
4491 + break;
4492 +
4493 + case 'US':
4494 + default:
4495 + $customer_pref = ( __( '-- Select --', 'usces' ) === $values['customer']['pref'] || '-- Select --' === $values['customer']['pref'] ) ? '' : $values['customer']['pref'];
4496 + $formtag .= usces_custom_field_info( $data, 'customer', 'name_pre', 'return' );
4497 + $formtag .= '<tr class="name-row member-name-row"><th>' . apply_filters( 'usces_filters_addressform_name_label', __( 'Full name', 'usces' ), $type, $values, $applyform ) . '</th><td>' . sprintf( _x( '%s', 'honorific', 'usces' ), ( esc_html( $values['customer']['name2'] ) . ' ' . esc_html( $values['customer']['name1'] ) ) ) . '</td></tr>';
4498 + $formtag .= usces_custom_field_info( $data, 'customer', 'name_after', 'return' );
4499 + $formtag .= '
4500 + <tr class="address2-row member-address2-row"><th>' . __( 'Address Line1', 'usces' ) . '</th><td>' . esc_html( $values['customer']['address2'] ) . '</td></tr>
4501 + <tr class="address3-row member-address3-row"><th>' . __( 'Address Line2', 'usces' ) . '</th><td>' . esc_html( $values['customer']['address3'] ) . '</td></tr>
4502 + <tr class="address1-row member-address1-row"><th>' . __( 'city', 'usces' ) . '</th><td>' . esc_html( $values['customer']['address1'] ) . '</td></tr>
4503 + <tr class="states-row member-states-row"><th>' . __( 'State', 'usces' ) . '</th><td>' . esc_html( $customer_pref ) . '</td></tr>';
4504 + if ( 1 < $target_market_count ) {
4505 + $customer_country = ( ! empty( $usces_settings['country'][ $values['customer']['country'] ] ) ) ? $usces_settings['country'][ $values['customer']['country'] ] : '';
4506 + $formtag .= '<tr class="country-row member-country-row"><th>' . __( 'Country', 'usces' ) . '</th><td>' . esc_html( $customer_country ) . '</td></tr>';
4507 + }
4508 + $formtag .= '
4509 + <tr class="zipcode-row member-zipcode-row"><th>' . __( 'Zip', 'usces' ) . '</th><td>' . esc_html( $values['customer']['zipcode'] ) . '</td></tr>
4510 + <tr class="tel-row member-tel-row"><th>' . __( 'Phone number', 'usces' ) . '</th><td>' . esc_html( $values['customer']['tel'] ) . '</td></tr>
4511 + <tr class="fax-row member-fax-row"><th>' . __( 'FAX number', 'usces' ) . '</th><td>' . esc_html( $values['customer']['fax'] ) . '</td></tr>';
4512 + $formtag .= usces_custom_field_info( $data, 'customer', 'fax_after', 'return' );
4513 +
4514 + $shipping_address_info = '';
4515 + if ( isset( $values['delivery'] ) ) {
4516 + $delivery_pref = ( __( '-- Select --', 'usces' ) === $values['delivery']['pref'] || '-- Select --' === $values['delivery']['pref'] ) ? '' : $values['delivery']['pref'];
4517 + $shipping_address_info = '<tr class="ttl"><td colspan="2"><h3>' . __( 'Shipping address information', 'usces' ) . '</h3></td></tr>';
4518 + $shipping_address_info .= usces_custom_field_info( $data, 'delivery', 'name_pre', 'return' );
4519 + $shipping_address_info .= '<tr class="name-row delivery-name-row"><th>' . apply_filters( 'usces_filters_addressform_name_label', __( 'Full name', 'usces' ), $type, $values, $applyform ) . '</th><td>' . sprintf( _x( '%s', 'honorific', 'usces' ), ( esc_html( $values['delivery']['name2'] ) . ' ' . esc_html( $values['delivery']['name1'] )) ) . '</td></tr>';
4520 + $shipping_address_info .= usces_custom_field_info( $data, 'delivery', 'name_after', 'return' );
4521 + $shipping_address_info .= '
4522 + <tr class="address2-row delivery-address2-row"><th>' . __( 'Address Line1', 'usces' ) . '</th><td>' . esc_html( $values['delivery']['address2'] ) . '</td></tr>
4523 + <tr class="address3-row delivery-address3-row"><th>' . __( 'Address Line2', 'usces' ) . '</th><td>' . esc_html( $values['delivery']['address3'] ) . '</td></tr>
4524 + <tr class="address1-row delivery-address1-row"><th>' . __( 'city', 'usces' ) . '</th><td>' . esc_html( $values['delivery']['address1'] ) . '</td></tr>
4525 + <tr class="states-row delivery-states-row"><th>' . __( 'State', 'usces' ) . '</th><td>' . esc_html( $delivery_pref ) . '</td></tr>';
4526 + if ( 1 < $target_market_count ) {
4527 + $shipping_country = ( ! empty( $usces_settings['country'][ $values['delivery']['country'] ] ) ) ? $usces_settings['country'][ $values['delivery']['country'] ] : '';
4528 + $shipping_address_info .= '<tr class="country-row delivery-country-row"><th>' . __( 'Country', 'usces' ) . '</th><td>' . esc_html( $shipping_country ) . '</td></tr>';
4529 + }
4530 + $shipping_address_info .= '
4531 + <tr class="zipcode-row delivery-zipcode-row"><th>' . __( 'Zip', 'usces' ) . '</th><td>' . esc_html( $values['delivery']['zipcode'] ) . '</td></tr>
4532 + <tr class="tel-row delivery-tel-row"><th>' . __( 'Phone number', 'usces' ) . '</th><td>' . esc_html( $values['delivery']['tel'] ) . '</td></tr>
4533 + <tr class="fax-row delivery-fax-row"><th>' . __( 'FAX number', 'usces' ) . '</th><td>' . esc_html( $values['delivery']['fax'] ) . '</td></tr>';
4534 + $shipping_address_info .= usces_custom_field_info( $data, 'delivery', 'fax_after', 'return' );
4535 + }
4536 + $formtag .= apply_filters( 'usces_filter_shipping_address_info', $shipping_address_info );
4537 + break;
4538 + }
4539 + $res = apply_filters( 'usces_filter_apply_addressform_confirm', $formtag, $type, $data );
4540 +
4541 + } else {
4542 +
4543 + switch ( $applyform ) {
4544 +
4545 + case 'JP':
4546 + $formtag .= usces_custom_field_input( $data, $type, 'name_pre', 'return' );
4547 + $formtag .= '<tr id="name_row" class="inp1">
4548 + <th width="127" scope="row">' . usces_get_essential_mark( 'name1', $data ) . apply_filters( 'usces_filters_addressform_name_label', __( 'Full name', 'usces' ), $type, $values, $applyform ) . '</th>';
4549 + if ( $nameform ) {
4550 + $formtag .= '<td class="name_td"><span class="member_name">' . __( 'Given name', 'usces' ) . '</span><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>';
4551 + $formtag .= '<td class="name_td"><span class="member_name">' . __( 'Familly name', 'usces' ) . '</span><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>';
4552 + } else {
4553 + $formtag .= '<td class="name_td"><span class="member_name">' . __( 'Familly name', 'usces' ) . '</span><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>';
4554 + $formtag .= '<td class="name_td"><span class="member_name">' . __( 'Given name', 'usces' ) . '</span><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>';
4555 + }
4556 + $formtag .= '</tr>';
4557 + $furigana = '<tr id="furikana_row" class="inp1">
4558 + <th scope="row">' . usces_get_essential_mark( 'name3', $data ) . __( 'furigana', 'usces' ) . '</th>';
4559 + if ( $nameform ) {
4560 + $furigana .= '<td><span class="member_furigana">' . _x( 'Given name', 'furigana', 'usces' ) . '</span><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>';
4561 + $furigana .= '<td><span class="member_furigana">' . _x( 'Familly name', 'furigana', 'usces' ) . '</span><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>';
4562 + } else {
4563 + $furigana .= '<td><span class="member_furigana">' . _x( 'Familly name', 'furigana', 'usces' ) . '</span><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>';
4564 + $furigana .= '<td><span class="member_furigana">' . _x( 'Given name', 'furigana', 'usces' ) . '</span><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>';
4565 + }
4566 + $furigana .= '</tr>';
4567 + $formtag .= apply_filters( 'usces_filter_furigana_form', $furigana, $type, $values );
4568 + $formtag .= usces_custom_field_input( $data, $type, 'name_after', 'return' );
4569 + $formtag .= '<tr id="zipcode_row">
4570 + <th scope="row">' . usces_get_essential_mark( 'zipcode', $data ) . __( 'Zip/Postal Code', 'usces' ) . '</th>
4571 + <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" />' . usces_postal_code_address_search( $type ) . apply_filters( 'usces_filter_addressform_zipcode', null, $type ) . apply_filters( 'usces_filter_after_zipcode', '100-1000', $applyform ) . '</td>
4572 + </tr>';
4573 + if ( 1 < $target_market_count ) {
4574 + $formtag .= '<tr id="country_row">
4575 + <th scope="row">' . usces_get_essential_mark( 'country', $data ) . __( 'Country', 'usces' ) . '</th>
4576 + <td colspan="2">' . uesces_get_target_market_form( $type, $values['country'] ) . apply_filters( 'usces_filter_after_country', null, $applyform ) . '</td>
4577 + </tr>';
4578 + } else {
4579 + $formtag .= '<input type="hidden" name="' . $type . '[country]" id="' . $type . '_country" value="' . $options['system']['target_market'][0] . '">';
4580 + }
4581 + $formtag .= '<tr id="states_row">
4582 + <th scope="row">' . usces_get_essential_mark( 'states', $data ) . __( 'Province', 'usces' ) . '</th>
4583 + <td colspan="2">' . usces_pref_select( $type, $values ) . apply_filters( 'usces_filter_after_states', null, $applyform ) . '</td>
4584 + </tr>
4585 + <tr id="address1_row" class="inp2">
4586 + <th scope="row">' . usces_get_essential_mark( 'address1', $data ) . __( 'city', 'usces' ) . '</th>
4587 + <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>
4588 + </tr>
4589 + <tr id="address2_row">
4590 + <th scope="row">' . usces_get_essential_mark( 'address2', $data ) . __( 'numbers', 'usces' ) . '</th>
4591 + <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>
4592 + </tr>
4593 + <tr id="address3_row">
4594 + <th scope="row">' . usces_get_essential_mark( 'address3', $data ) . __( 'building name', 'usces' ) . '</th>
4595 + <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>
4596 + </tr>
4597 + <tr id="tel_row">
4598 + <th scope="row">' . usces_get_essential_mark( 'tel', $data ) . __( 'Phone number', 'usces' ) . '</th>
4599 + <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>
4600 + </tr>
4601 + <tr id="fax_row">
4602 + <th scope="row">' . usces_get_essential_mark( 'fax', $data ) . __( 'FAX number', 'usces' ) . '</th>
4603 + <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>
4604 + </tr>';
4605 + $formtag .= usces_custom_field_input( $data, $type, 'fax_after', 'return' );
4606 + break;
4607 +
4608 + case 'CN':
4609 + $formtag .= usces_custom_field_input( $data, $type, 'name_pre', 'return' );
4610 + $formtag .= '<tr id="name_row" class="inp1">
4611 + <th scope="row">' . usces_get_essential_mark( 'name1', $data ) . apply_filters( 'usces_filters_addressform_name_label', __( 'Full name', 'usces' ), $type, $values, $applyform ) . '</th>';
4612 + if ( $nameform ) {
4613 + $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>';
4614 + $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>';
4615 + } else {
4616 + $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>';
4617 + $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>';
4618 + }
4619 + $formtag .= '</tr>';
4620 + $formtag .= usces_custom_field_input( $data, $type, 'name_after', 'return' );
4621 + if ( 1 < $target_market_count ) {
4622 + $formtag .= '<tr id="country_row">
4623 + <th scope="row">' . usces_get_essential_mark( 'country', $data ) . __( 'Country', 'usces' ) . '</th>
4624 + <td colspan="2">' . uesces_get_target_market_form( $type, $values['country'] ) . apply_filters( 'usces_filter_after_country', null, $applyform ) . '</td>
4625 + </tr>';
4626 + } else {
4627 + $formtag .= '<input type="hidden" name="' . $type . '[country]" id="' . $type . '_country" value="' . $options['system']['target_market'][0] . '">';
4628 + }
4629 + $formtag .= '<tr id="states_row">
4630 + <th scope="row">' . usces_get_essential_mark( 'states', $data ) . __( 'State', 'usces' ) . '</th>
4631 + <td colspan="2">' . usces_pref_select( $type, $values ) . apply_filters( 'usces_filter_after_states', null, $applyform ) . '</td>
4632 + </tr>
4633 + <tr id="address1_row" class="inp2">
4634 + <th scope="row">' . usces_get_essential_mark( 'address1', $data ) . __( 'city', 'usces' ) . '</th>
4635 + <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>
4636 + </tr>
4637 + <tr id="address2_row">
4638 + <th scope="row">' . usces_get_essential_mark( 'address2', $data ) . __( 'Address Line1', 'usces' ) . '</th>
4639 + <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>
4640 + </tr>
4641 + <tr id="address3_row">
4642 + <th scope="row">' . usces_get_essential_mark( 'address3', $data ) . __( 'Address Line2', 'usces' ) . '</th>
4643 + <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>
4644 + </tr>
4645 + <tr id="zipcode_row">
4646 + <th scope="row">' . usces_get_essential_mark( 'zipcode', $data ) . __( 'Zip', 'usces' ) . '</th>
4647 + <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>
4648 + </tr>
4649 + <tr id="tel_row">
4650 + <th scope="row">' . usces_get_essential_mark( 'tel', $data ) . __( 'Phone number', 'usces' ) . '</th>
4651 + <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>
4652 + </tr>
4653 + <tr id="fax_row">
4654 + <th scope="row">' . usces_get_essential_mark( 'fax', $data ) . __( 'FAX number', 'usces' ) . '</th>
4655 + <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>
4656 + </tr>';
4657 + $formtag .= usces_custom_field_input( $data, $type, 'fax_after', 'return' );
4658 + break;
4659 +
4660 + case 'US':
4661 + default:
4662 + $formtag .= usces_custom_field_input( $data, $type, 'name_pre', 'return' );
4663 + $formtag .= '<tr id="name_row" class="inp1">
4664 + <th scope="row">' . usces_get_essential_mark( 'name1', $data ) . apply_filters( 'usces_filters_addressform_name_label', __( 'Full name', 'usces' ), $type, $values, $applyform ) . '</th>';
4665 + if ( $nameform ) {
4666 + $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>';
4667 + $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>';
4668 + } else {
4669 + $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>';
4670 + $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>';
4671 + }
4672 + $formtag .= '</tr>';
4673 + $formtag .= usces_custom_field_input( $data, $type, 'name_after', 'return' );
4674 + $formtag .= '
4675 + <tr id="address2_row">
4676 + <th scope="row">' . usces_get_essential_mark( 'address2', $data ) . __( 'Address Line1', 'usces' ) . '</th>
4677 + <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>
4678 + </tr>
4679 + <tr id="address3_row">
4680 + <th scope="row">' . usces_get_essential_mark( 'address3', $data ) . __( 'Address Line2', 'usces' ) . '</th>
4681 + <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>
4682 + </tr>
4683 + <tr id="address1_row" class="inp2">
4684 + <th scope="row">' . usces_get_essential_mark( 'address1', $data ) . __( 'city', 'usces' ) . '</th>
4685 + <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>
4686 + </tr>
4687 + <tr id="states_row">
4688 + <th scope="row">' . usces_get_essential_mark( 'states', $data ) . __( 'State', 'usces' ) . '</th>
4689 + <td colspan="2">' . usces_pref_select( $type, $values ) . apply_filters( 'usces_filter_after_states', null, $applyform ) . '</td>
4690 + </tr>';
4691 + if ( 1 < $target_market_count ) {
4692 + $formtag .= '<tr id="country_row">
4693 + <th scope="row">' . usces_get_essential_mark( 'country', $data ) . __( 'Country', 'usces' ) . '</th>
4694 + <td colspan="2">' . uesces_get_target_market_form( $type, $values['country'] ) . apply_filters( 'usces_filter_after_country', null, $applyform ) . '</td>
4695 + </tr>';
4696 + } else {
4697 + $formtag .= '<input type="hidden" name="' . $type . '[country]" id="' . $type . '_country" value="' . esc_attr( $options['system']['target_market'][0] ) . '">';
4698 + }
4699 + $formtag .= '<tr id="zipcode_row">
4700 + <th scope="row">' . usces_get_essential_mark( 'zipcode', $data ) . __( 'Zip', 'usces' ) . '</th>
4701 + <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>
4702 + </tr>
4703 + <tr id="tel_row">
4704 + <th scope="row">' . usces_get_essential_mark( 'tel', $data ) . __( 'Phone number', 'usces' ) . '</th>
4705 + <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>
4706 + </tr>
4707 + <tr id="fax_row">
4708 + <th scope="row">' . usces_get_essential_mark( 'fax', $data ) . __( 'FAX number', 'usces' ) . '</th>
4709 + <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>
4710 + </tr>';
4711 + $formtag .= usces_custom_field_input( $data, $type, 'fax_after', 'return' );
4712 + break;
4713 + }
4714 + $res = apply_filters( 'usces_filter_apply_addressform', $formtag, $type, $data );
4715 + }
4716 +
4717 + if ( 'return' === $out ) {
4718 + return $res;
4719 + } else {
4720 + echo $res; // no escape due to filter.
4721 + }
4722 +}
4723 +
4724 +/**
4725 + * Item option field
4726 + *
4727 + * @param int $post_id Post ID.
4728 + * @param string $sku SKU code.
4729 + * @param int $label Tabel.
4730 + * @param string $out Return value or echo.
4731 + * @return string|void
4732 + */
4733 +function usces_item_option_fileds( $post_id, $sku, $label = 1, $out = 'echo' ) {
4734 + $options = wel_get_opts( $post_id, 'sort' );
4735 + if ( ! $options || ! is_array( $options ) ) {
4736 + return false;
4737 + }
4738 + if ( 0 === count( $options ) ) {
4739 + return false;
4740 + }
4741 + $sku_enc = urlencode( $sku );
4742 +
4743 + $html = '';
4744 + foreach ( $options as $opt ) {
4745 + $name = $opt['name'];
4746 + $opt_code = urlencode( $name );
4747 + $html .= '<div class="opt_field" id="opt_' . $post_id . '_' . $sku_enc . '_' . $opt_code . '">';
4748 + if ( $label ) {
4749 + $html .= '<label for="itemOption[' . $post_id . '][' . $sku_enc . '][' . $opt_code . ']">' . esc_html( $name ) . '</label>';
4750 + }
4751 + $html .= usces_get_itemopt_filed( $post_id, $sku, $opt );
4752 + $html .= '</div>';
4753 + }
4754 + if ( 'return' === $out ) {
4755 + return wel_esc_script( $html );
4756 + } else {
4757 + wel_esc_script_e( $html );
4758 + }
4759 +}
4760 +
4761 +/**
4762 + * Facebook
4763 + */
4764 +function usces_facebook_like() {
4765 + global $post, $usces;
4766 + $like = array(
4767 + 'url' => urlencode( get_permalink( $post->ID ) ),
4768 + 'send' => 'false',
4769 + 'layout' => 'button_count', /* standard, button_count, box_count */
4770 + 'width' => '450',
4771 + 'height' => '35',
4772 + 'show_faces' => 'false',
4773 + 'action' => 'like', /* like, recommend */
4774 + );
4775 + $like = apply_filters( 'usces_filter_facebook_like', $like, $post->ID );
4776 + ?>
4777 +<iframe src="//www.facebook.com/plugins/like.php?href=<?php echo esc_url( $like['url'] ); ?>&amp;send=<?php echo esc_attr( $like['send'] ); ?>&amp;layout=<?php echo esc_attr( $like['layout'] ); ?>&amp;width=<?php echo esc_attr( $like['width'] ); ?>&amp;show_faces=<?php echo esc_attr( $like['show_faces'] ); ?>&amp;action=<?php echo esc_attr( $like['action'] ); ?>&amp;colorscheme=light&amp;font=arial&amp;height=<?php echo esc_attr( $like['height'] ); ?>" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:<?php echo esc_attr( $like['width'] ); ?>px; height:<?php echo esc_attr( $like['height'] ); ?>px;" allowTransparency="true"></iframe>
4778 + <?php
4779 +}
4780 +
4781 +/**
4782 + * Checked
4783 + *
4784 + * @param string $chk Checked.
4785 + * @param string $key Key.
4786 + * @param string $out Return value or echo.
4787 + * @return string|void
4788 + */
4789 +function usces_checked( $chk, $key, $out = '' ) {
4790 + $checked = ( isset( $chk[ $key ] ) && 1 === (int) $chk[ $key ] );
4791 + if ( 'return' === $out ) {
4792 + return checked( $checked, true, false );
4793 + } else {
4794 + checked( $checked, true, true );
4795 + }
4796 +}
4797 +
4798 +/**
4799 + * Custom field value
4800 + *
4801 + * @param string $field Field.
4802 + * @param string $key Key.
4803 + * @param string $id ID.
4804 + * @param string $out Return value or echo.
4805 + * @return string|void
4806 + */
4807 +function usces_get_custom_field_value( $field, $key, $id, $out = '' ) {
4808 + global $usces;
4809 +
4810 + $value = '';
4811 + switch ( $field ) {
4812 + case 'order':
4813 + $value = $usces->get_order_meta_value( 'csod_' . $key, $id );
4814 + break;
4815 + case 'customer':
4816 + $value = $usces->get_order_meta_value( 'cscs_' . $key, $id );
4817 + break;
4818 + case 'delivery':
4819 + $value = $usces->get_order_meta_value( 'csde_' . $key, $id );
4820 + break;
4821 + case 'member':
4822 + $value = $usces->get_member_meta_value( 'csmb_' . $key, $id );
4823 + break;
4824 + }
4825 +
4826 + if ( 'return' === $out ) {
4827 + return wel_esc_script( $value );
4828 + } else {
4829 + wel_esc_script_e( $value );
4830 + }
4831 +}
4832 +
4833 +/**
4834 + * Address search button
4835 + *
4836 + * @param string $type Type.
4837 + * @param string $out Return value or echo.
4838 + * @return string|void
4839 + */
4840 +function usces_postal_code_address_search( $type, $out = 'return' ) {
4841 + global $usces;
4842 +
4843 + $html = '';
4844 + if ( isset( $usces->options['address_search'] ) && 'activate' === $usces->options['address_search'] ) {
4845 + $address_search_label = apply_filters( 'usces_filter_postal_code_address_search_label', '住所検索' );
4846 + $html = '<input type="button" id="search_zipcode" class="search-zipcode button" value="' . $address_search_label . '" onClick="AjaxZip3.zip2addr(\'' . esc_js( $type . '[zipcode]' ) . '\', \'\', \'' . esc_js( $type . '[pref]' ) . '\', \'' . esc_js( $type . '[address1]' ) . '\' );" >';
4847 + if ( 'delivery' === $type ) {
4848 + $entry = $usces->cart->get_entry();
4849 + $zipcode = ( isset( $entry['delivery']['zipcode'] ) ) ? $entry['delivery']['zipcode'] : '';
4850 + $html .= '<input type="hidden" id="search_zipcode_change" value="' . esc_attr( $zipcode ) . '">';
4851 + }
4852 + }
4853 + if ( 'return' === $out ) {
4854 + return wel_esc_script( $html );
4855 + } else {
4856 + wel_esc_script_e( $html );
4857 + }
4858 +}
4859 +
4860 +/**
4861 + * Agreement Approval Field
4862 + *
4863 + * @param string $out Return value or echo.
4864 + * @return string|void
4865 + */
4866 +function usces_agree_member_field( $out = '' ) {
4867 + global $usces;
4868 +
4869 + $html = '';
4870 + if ( usces_is_membersystem_state() ) {
4871 + $row = '';
4872 + if ( isset( $usces->options['agree_member'] ) && 'activate' === $usces->options['agree_member'] ) {
4873 + $row .= '<div class="agree_member_area">';
4874 + if ( isset( $usces->options['member_page_data']['agree_member_exp'] ) ) {
4875 + $row .= '<div class="at_exp_text">' . stripslashes( nl2br( $usces->options['member_page_data']['agree_member_exp'] ) ) . '</div>';
4876 + }
4877 + if ( isset( $usces->options['member_page_data']['agree_member_cont'] ) ) {
4878 + $row .= '<textarea name="at_cont_text" class="at_cont_text" readonly="readonly">' . $usces->options['member_page_data']['agree_member_cont'] . '</textarea>
4879 + <div class="at_check_area"><input name="agree_member_check" value="1" id="agree_member_check" class="at_check" type="checkbox"><label for="agree_member_check" style="cursor:pointer;"> ' . __( 'Accept the membership agreement', 'usces' ) . '</label></div>';
4880 + }
4881 + $row .= '</div>';
4882 + }
4883 + $html = apply_filters( 'usces_filter_agree_member_field', $row );
4884 + }
4885 +
4886 + if ( 'return' === $out ) {
4887 + return wel_esc_script( $html );
4888 + } else {
4889 + wel_esc_script_e( $html );
4890 + }
4891 +}
4892 +
4893 +/**
4894 + * No image
4895 + *
4896 + * @param array $size Size.
4897 + * @param string $alt Alt.
4898 + * @return string
4899 + */
4900 +function usces_get_attachment_noimage( $size = array( 60, 60 ), $alt = '' ) {
4901 + $size_class = join( 'x', $size );
4902 + return '<img width="' . $size[0] . '" height="' . $size[1] . '" src="' . USCES_PLUGIN_URL . '/images/default.png" class="attachment-' . $size_class . ' size-' . $size_class . '" alt="' . $alt . '">';
4903 +}
4904 +
4905 +/**
4906 + * Tax rate
4907 + *
4908 + * @param string $out Return value or echo.
4909 + * @return string|void
4910 + */
4911 +function usces_the_taxrate( $out = '' ) {
4912 + global $usces;
4913 +
4914 + if ( isset( $usces->itemsku['taxrate'] ) ) {
4915 + $taxrate = ( 'reduced' === $usces->itemsku['taxrate'] ) ? $usces->options['tax_rate_reduced'] : $usces->options['tax_rate'];
4916 + } else {
4917 + $taxrate = $usces->options['tax_rate'];
4918 + }
4919 + $the_taxrate = '<em class="tax">' . sprintf( __( "Tax Rate %s%%", 'usces' ), $taxrate ) . '</em>';
4920 + $the_taxrate = apply_filters( 'usces_filter_the_taxrate', $the_taxrate, $usces->itemsku, $out );
4921 +
4922 + if ( 'return' === $out ) {
4923 + return wel_esc_script( $the_taxrate );
4924 + } else {
4925 + wel_esc_script_e( $the_taxrate );
4926 + }
4927 +}
4928 +
4929 +/**
4930 + * Tax amount
4931 + *
4932 + * @param string $out Return value or echo.
4933 + * @return string|void
4934 + */
4935 +function usces_cart_tax( $out = '' ) {
4936 + global $usces;
4937 +
4938 + $total_items_price = $usces->get_total_price();
4939 + $materials = array(
4940 + 'total_items_price' => $total_items_price,
4941 + 'discount' => 0,
4942 + 'shipping_charge' => 0,
4943 + 'cod_fee' => 0,
4944 + 'use_point' => 0,
4945 + );
4946 + $tax = $usces->getTax( $total_items_price, $materials );
4947 +
4948 + if ( 'return' === $out ) {
4949 + return wel_esc_script( $tax );
4950 + } else {
4951 + wel_esc_script_e( $tax );
4952 + }
4953 +}
4954 +
4955 +/**
4956 + * Total tax amount
4957 + *
4958 + * @param string $out Return value or echo.
4959 + * @return string|void
4960 + */
4961 +function usces_confirm_tax( $out = '' ) {
4962 + global $usces;
4963 +
4964 + if ( $usces->is_reduced_taxrate() ) {
4965 + if ( 'include' === $usces->options['tax_mode'] ) {
4966 + $po = '( ';
4967 + $pc = ' )';
4968 + } else {
4969 + $po = '';
4970 + $pc = '';
4971 + }
4972 + $usces_tax = Welcart_Tax::get_instance();
4973 + $entry = wel_get_entry();
4974 + $shipping_charge = isset( $entry['order']['shipping_charge'] ) ? $entry['order']['shipping_charge'] : 0;
4975 + $cod_fee = isset( $entry['order']['cod_fee'] ) ? $entry['order']['cod_fee'] : 0;
4976 + $materials = compact( 'shipping_charge', 'cod_fee');
4977 + $usces_tax->get_order_tax( $materials );
4978 + $tax = sprintf( __( "Applies to %s%%", 'usces' ), $usces->options['tax_rate'] ) . '&nbsp;&nbsp;' . usces_crform( $usces_tax->subtotal_standard + $usces_tax->discount_standard, true, false, 'return' ) . '&nbsp;&nbsp;';
4979 + $tax .= sprintf( __( "%s%% consumption tax", 'usces' ), $usces->options['tax_rate'] ) . '&nbsp;&nbsp;' . $po . usces_crform( $usces_tax->tax_standard, true, false, 'return' ) . $pc . '<br />';
4980 + if ( 0 < $usces_tax->tax_rate_reduced ) {
4981 + $tax .= sprintf( __( "Applies to %s%%", 'usces' ), $usces->options['tax_rate_reduced'] ) . '&nbsp;&nbsp;' . usces_crform( $usces_tax->subtotal_reduced + $usces_tax->discount_reduced, true, false, 'return' ) . '&nbsp;&nbsp;';
4982 + $tax .= sprintf( __( "%s%% consumption tax", 'usces' ), $usces->options['tax_rate_reduced'] ) . '&nbsp;&nbsp;' . $po . usces_crform( $usces_tax->tax_reduced, true, false, 'return' ) . $pc;
4983 + }
4984 + } else {
4985 + $tax = '';
4986 + }
4987 +
4988 + $tax = apply_filters( 'usces_filter_confirm_tax', $tax, $out );
4989 +
4990 + if ( 'return' === $out ) {
4991 + return wel_esc_script( $tax );
4992 + } else {
4993 + wel_esc_script_e( $tax );
4994 + }
4995 +}
4996 +
4997 +/**
4998 + * Tax-included amount
4999 + *
5000 + * @param string $out Return value or echo.
5001 + * @return string|void
5002 + */
5003 +function usces_the_itemPrice_taxincluded( $out = '' ) {
5004 + global $post, $usces;
5005 + $usces_tax = Welcart_Tax::get_instance();
5006 +
5007 + if ( empty( $usces->itemsku['code'] ) ) {
5008 + $skus = $usces->get_skus( $post->ID );
5009 + $skucode = $skus[0]['code'];
5010 + $skuprice = $skus[0]['price'];
5011 + } else {
5012 + $skucode = $usces->itemsku['code'];
5013 + $skuprice = $usces->itemsku['price'];
5014 + }
5015 + $tax_rate = $usces_tax->get_sku_tax_rate( $post->ID, $skucode );
5016 + $tax = (float) sprintf( '%.3f', (float) $skuprice * (float) $tax_rate / 100 );
5017 + $tax = usces_tax_rounding_off( $tax );
5018 + $price = $skuprice + $tax;
5019 +
5020 + if ( 'return' === $out ) {
5021 + return $price;
5022 + } else {
5023 + echo number_format( $price );
5024 + }
5025 +}
5026 +
5027 +/**
5028 + * Tax-included normal amount
5029 + *
5030 + * @param string $out Return value or echo.
5031 + * @return string|void
5032 + */
5033 +function usces_the_itemCprice_taxincluded( $out = '' ) {
5034 + global $post, $usces;
5035 + $usces_tax = Welcart_Tax::get_instance();
5036 +
5037 + if ( empty( $usces->itemsku['code'] ) ) {
5038 + $skus = $usces->get_skus( $post->ID );
5039 + $skucode = $skus[0]['code'];
5040 + $skucprice = $skus[0]['cprice'];
5041 + } else {
5042 + $skucode = $usces->itemsku['code'];
5043 + $skucprice = $usces->itemsku['cprice'];
5044 + }
5045 + $tax_rate = $usces_tax->get_sku_tax_rate( $post->ID, $skucode );
5046 + $tax = (float) sprintf( '%.3f', (float) $skucprice * (float) $tax_rate / 100 );
5047 + $tax = usces_tax_rounding_off( $tax );
5048 + $price = $skucprice + $tax;
5049 + if ( 'return' === $out ) {
5050 + return $price;
5051 + } else {
5052 + echo number_format( $price );
5053 + }
5054 +}
5055 +
5056 +/**
5057 + * Formatted tax included amount
5058 + *
5059 + * @param string $out Return value or echo.
5060 + * @return string|void
5061 + */
5062 +function usces_the_itemPriceCr_taxincluded( $out = '' ) {
5063 + global $usces;
5064 + $usces_tax = Welcart_Tax::get_instance();
5065 +
5066 + $price_taxincluded = usces_the_itemPrice_taxincluded( 'return' );
5067 + $price = $usces->get_currency( $price_taxincluded, true, false );
5068 + $price = apply_filters( 'usces_filter_the_item_price_cr_taxincluded', $price, $price_taxincluded, $out );
5069 + if ( 'return' === $out ) {
5070 + return $price;
5071 + } else {
5072 + echo esc_html( $price );
5073 + }
5074 +}
5075 +
5076 +/**
5077 + * Formatted tax included normal amount
5078 + *
5079 + * @param string $out Return value or echo.
5080 + * @return string|void
5081 + */
5082 +function usces_the_itemCpriceCr_taxincluded( $out = '' ) {
5083 + global $usces;
5084 + $usces_tax = Welcart_Tax::get_instance();
5085 +
5086 + $price_taxincluded = usces_the_itemCprice_taxincluded( 'return' );
5087 + $price = $usces->get_currency( $price_taxincluded, true, false );
5088 + $price = apply_filters( 'usces_filter_the_item_cprice_cr_taxincluded', $price, $price_taxincluded, $out );
5089 + if ( 'return' === $out ) {
5090 + return $price;
5091 + } else {
5092 + echo esc_html( $price );
5093 + }
5094 +}
5095 +
5096 +/**
5097 + * Password policy
5098 + *
5099 + * @param string $out Return value or echo.
5100 + * @return string|void
5101 + */
5102 +function usces_password_policy_message( $out = '' ) {
5103 +
5104 + $usces_options = get_option( 'usces', array() );
5105 + $rules = array();
5106 + $sep = '';
5107 +
5108 + if ( ! empty( $usces_options['system']['member_pass_rule_max'] ) ) {
5109 + if ( $usces_options['system']['member_pass_rule_max'] === $usces_options['system']['member_pass_rule_min'] ) {
5110 + $rules[] = sprintf( __( '%s characters long', 'usces' ), $usces_options['system']['member_pass_rule_min'] );
5111 + } else {
5112 + $rules[] = sprintf( __( '%1$s characters and no more than %2$s characters', 'usces' ), $usces_options['system']['member_pass_rule_min'], $usces_options['system']['member_pass_rule_max'] );
5113 + $sep = __( 'use', 'usces' );
5114 + }
5115 + } else {
5116 + $rules[] = sprintf( __( '%1$s characters and no more than %2$s characters', 'usces' ), $usces_options['system']['member_pass_rule_min'], '30' );
5117 + $sep = __( 'use', 'usces' );
5118 + }
5119 +
5120 + $and = __( 'and', 'usces' );
5121 +
5122 + if ( ! empty( $usces_options['system']['member_pass_rule_digit'] ) ) {
5123 + $rules[] = __( 'numeric character', 'usces' );
5124 + }
5125 +
5126 + if ( ! empty( $usces_options['system']['member_pass_rule_lowercase'] ) ) {
5127 + $rules[] = __( 'lower-case alphabetics', 'usces' );
5128 + }
5129 +
5130 + if ( ! empty( $usces_options['system']['member_pass_rule_upercase'] ) ) {
5131 + $rules[] = __( 'upper-case alphabetics', 'usces' );
5132 + }
5133 +
5134 + if ( ! empty( $usces_options['system']['member_pass_rule_symbol'] ) ) {
5135 + $rules[] = __( 'symbolic character', 'usces' );
5136 + }
5137 +
5138 + $first = array_shift( $rules );
5139 + $ret = '';
5140 + if ( 0 === count( $rules ) ) {
5141 + $ret = sprintf( __( 'Password must be at least %s.', 'usces' ), $first );
5142 + } elseif ( 1 === count( $rules ) ) {
5143 + $rule1 = sprintf( __( ' and include one or more %s', 'usces' ), $rules[0] );
5144 + $ret = sprintf( __( 'Password must be at least %1$s%2$s.', 'usces' ), $first, $rule1 );
5145 + } else {
5146 + $rule2 = '';
5147 + foreach ( $rules as $rule ) {
5148 + if ( '' !== $rule2 ) {
5149 + $rule2 .= __( ',', 'usces' );
5150 + }
5151 + $rule2 .= $rule;
5152 + }
5153 + $rule1 = sprintf( __( ' and include one or more %s', 'usces' ), $rule2 );
5154 + $ret = sprintf( __( 'Password must be at least %1$s%2$s.', 'usces' ), $first, $rule1 );
5155 + }
5156 +
5157 + $ret = apply_filters( 'usces_filter_password_policy_message', $ret );
5158 + if ( 'return' === $out ) {
5159 + return $ret;
5160 + }
5161 +
5162 + echo '<p class="password_policy">' . esc_html( $ret ) . '</p>';
5163 +}
5164 +
5165 +/**
5166 + * Formatted tax included amount
5167 + *
5168 + * @param bool $label_pre Forward label.
5169 + * @param string $label Label.
5170 + * @param string $start_tag Start tag.
5171 + * @param string $end_tag End tag.
5172 + * @param bool $symbol_pre Forward symbol.
5173 + * @param bool $symbol_post Backward symbol.
5174 + * @param bool $seperator_flag Seperator.
5175 + * @param string $out Return value or echo.
5176 + * @return string|void
5177 + */
5178 +function usces_crform_the_itemPriceCr_taxincluded( $label_pre = true, $label = '', $start_tag = '', $end_tag = '', $symbol_pre = true, $symbol_post = false, $seperator_flag = true, $out = '' ) {
5179 + global $usces;
5180 +
5181 + if ( ( isset( $usces->options['tax_display'] ) && 'deactivate' === $usces->options['tax_display'] ) || ( isset( $usces->options['tax_mode'] ) && 'include' === $usces->options['tax_mode'] ) ) {
5182 + $res = '';
5183 + } else {
5184 + $price_taxincluded = usces_the_itemPrice_taxincluded( 'return' );
5185 + $price = esc_html( $usces->get_currency( $price_taxincluded, $symbol_pre, $symbol_post, $seperator_flag ) );
5186 + if ( empty( $label ) ) {
5187 + $label_tag = '<em class="tax tax_inc_label">' . __( 'tax-included', 'usces' ) . '</em>';
5188 + } else {
5189 + $label_tag = '<em class="tax tax_inc_label">' . $label . '</em>';
5190 + }
5191 + if ( empty( $start_tag ) ) {
5192 + $start_tag = '<p class="tax_inc_block">( ';
5193 + }
5194 + if ( $label_pre ) {
5195 + $start_tag = $start_tag . $label_tag;
5196 + }
5197 + if ( empty( $end_tag ) ) {
5198 + $end_tag = ' )</p>';
5199 + }
5200 + if ( true !== $label_pre ) {
5201 + $end_tag = $label_tag . $end_tag;
5202 + }
5203 + $res = apply_filters( 'usces_filter_crform_the_itemPriceCr_taxincluded', $start_tag . $price . $end_tag, $label_pre, $label, $symbol_pre, $symbol_post, $seperator_flag );
5204 + }
5205 + if ( 'return' === $out ) {
5206 + return wel_esc_script( $res );
5207 + } else {
5208 + wel_esc_script_e( $res );
5209 + }
5210 +}
5211 +
5212 +/**
5213 + * Tax-included amount
5214 + *
5215 + * @param int $post_id Post ID.
5216 + * @return float
5217 + */
5218 +function usces_itemPrice_taxincluded( $post_id = null ) {
5219 + global $usces;
5220 +
5221 + if ( null === $post_id ) {
5222 + global $post;
5223 + $post_id = $post->ID;
5224 + }
5225 + $usces_tax = Welcart_Tax::get_instance();
5226 +
5227 + $skus = $usces->get_skus( $post_id );
5228 + $skucode = $skus[0]['code'];
5229 + $skuprice = $skus[0]['price'];
5230 + $tax_rate = $usces_tax->get_sku_tax_rate( $post_id, $skucode );
5231 + $tax = (float) sprintf( '%.3f', (float) $skuprice * (float) $tax_rate / 100 );
5232 + $tax = usces_tax_rounding_off( $tax );
5233 + $price = $skuprice + $tax;
5234 + return $price;
5235 +}
5236 +
5237 +/**
5238 + * Tax-included normal amount
5239 + *
5240 + * @param int $post_id Post ID.
5241 + * @param bool $label_pre Forward label.
5242 + * @param string $label Label.
5243 + * @param string $start_tag Start tag.
5244 + * @param string $end_tag End tag.
5245 + * @param bool $symbol_pre Forward symbol.
5246 + * @param bool $symbol_post Backward symbol.
5247 + * @param bool $seperator_flag Seperator.
5248 + * @return string
5249 + */
5250 +function usces_crform_itemPriceCr_taxincluded( $post_id = null, $label_pre = true, $label = '', $start_tag = '', $end_tag = '', $symbol_pre = true, $symbol_post = false, $seperator_flag = true ) {
5251 + global $usces;
5252 +
5253 + if ( ( isset( $usces->options['tax_display'] ) && 'deactivate' === $usces->options['tax_display'] ) || ( isset( $usces->options['tax_mode'] ) && 'include' === $usces->options['tax_mode'] ) ) {
5254 + $res = '';
5255 + } else {
5256 + $price_taxincluded = usces_itemPrice_taxincluded( $post_id );
5257 + $price = esc_html( $usces->get_currency( $price_taxincluded, $symbol_pre, $symbol_post, $seperator_flag ) );
5258 + if ( empty( $label ) ) {
5259 + $label_tag = '<em class="tax tax_inc_label">' . __( 'tax-included', 'usces' ) . '</em>';
5260 + } else {
5261 + $label_tag = '<em class="tax tax_inc_label">' . $label . '</em>';
5262 + }
5263 + if ( empty( $start_tag ) ) {
5264 + $start_tag = '<p class="tax_inc_block">( ';
5265 + }
5266 + if ( $label_pre ) {
5267 + $start_tag = $start_tag . $label_tag;
5268 + }
5269 + if ( empty( $end_tag ) ) {
5270 + $end_tag = ' )</p>';
5271 + }
5272 + if ( true !== $label_pre ) {
5273 + $end_tag = $label_tag . $end_tag;
5274 + }
5275 + $res = apply_filters( 'usces_filter_crform_itemPriceCr_taxincluded', $start_tag . $price . $end_tag, $post_id, $label_pre, $label, $symbol_pre, $symbol_post, $seperator_flag );
5276 + }
5277 + return $res;
5278 +}
5279 +
5280 +/**
5281 + * Cart Totals
5282 + *
5283 + * @param string $out Return value or echo.
5284 + * @return string|void
5285 + */
5286 +function usces_get_cart_total_rows( $out = '' ) {
5287 + global $usces;
5288 +
5289 + $res = '';
5290 + if ( isset( $usces->options['tax_display'] ) && 'deactivate' !== $usces->options['tax_display'] ) {
5291 + if ( isset( $usces->options['tax_mode'] ) && 'include' !== $usces->options['tax_mode'] ) {
5292 + $total = usces_total_price( 'return' );
5293 + $tax = usces_cart_tax( 'return' );
5294 + $res .= ' <tr>
5295 + <th class="num"></th>
5296 + <th class="thumbnail"></th>
5297 + <th colspan="3" scope="row" class="aright">' . __( 'Total', 'usces' ) . '</th>
5298 + <th class="aright amount">' . usces_crform( $total, true, false, true ) . '</th>
5299 + <th class="stock"></th>
5300 + <th class="action"></th>
5301 + </tr>' . "\n";
5302 + $res .= ' <tr class="tax">
5303 + <th class="num"></th>
5304 + <th class="thumbnail"></th>
5305 + <th colspan="3" scope="row" class="aright tax">' . __( 'Tax', 'usces' ) . '</th>
5306 + <th class="aright amount tax">' . usces_crform( usces_cart_tax( 'return' ), true, false, true ) . '</th>
5307 + <th class="stock"></th>
5308 + <th class="action"></th>
5309 + </tr>' . "\n";
5310 + $res .= ' <tr>
5311 + <th class="num"></th>
5312 + <th class="thumbnail"></th>
5313 + <th colspan="3" scope="row" class="aright">' . __( 'total items', 'usces' ) . '</th>
5314 + <th class="aright amount">' . usces_crform( $total + $tax, true, false, true ) . '</th>
5315 + <th class="stock"></th>
5316 + <th class="action"></th>
5317 + </tr>' . "\n";
5318 + } else {
5319 + $total = usces_total_price( 'return' );
5320 + $tax = usces_internal_tax( array( 'total_items_price' => $total ), 'return' );
5321 + $res .= ' <tr class="tax">
5322 + <th class="num"></th>
5323 + <th class="thumbnail"></th>
5324 + <th colspan="3" scope="row" class="aright tax">' . __( 'Internal tax', 'usces' ) . '</th>
5325 + <th class="aright amount tax">( ' . usces_crform( $tax, true, false, true ) . ' )</th>
5326 + <th class="stock"></th>
5327 + <th class="action"></th>
5328 + </tr>' . "\n";
5329 + $res .= ' <tr>
5330 + <th class="num"></th>
5331 + <th class="thumbnail"></th>
5332 + <th colspan="3" scope="row" class="aright">' . __( 'total items', 'usces' ) . '</th>
5333 + <th class="aright amount">' . usces_crform( $total, true, false, true ) . '</th>
5334 + <th class="stock"></th>
5335 + <th class="action"></th>
5336 + </tr>' . "\n";
5337 + }
5338 + }
5339 + if ( 'return' === $out ) {
5340 + return wel_esc_script( $res );
5341 + } else {
5342 + wel_esc_script_e( $res );
5343 + }
5344 +}
5345 +
5346 +if ( ! function_exists( 'welcart_assistance_excerpt_length' ) ) {
5347 + /**
5348 + * Assistance excerpt length
5349 + *
5350 + * @param int $length Length.
5351 + * @return int
5352 + */
5353 + function welcart_assistance_excerpt_length( $length ) {
5354 + return 10;
5355 + }
5356 +}
5357 +
5358 +if ( ! function_exists( 'welcart_assistance_excerpt_mblength' ) ) {
5359 + /**
5360 + * Assistance excerpt mobile length
5361 + *
5362 + * @param int $length Length.
5363 + * @return int
5364 + */
5365 + function welcart_assistance_excerpt_mblength( $length ) {
5366 + return 40;
5367 + }
5368 +}