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