PluginProbe
Welcart e-Commerce / 2.11.31
Welcart e-Commerce v2.11.31
2.12.4 2.12.3 2.11.35 2.12.2 2.12.1 2.11.34 2.11.33 2.11.32 2.11.31 2.11.30 1.3.16 1.3.17 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 All 292 releases
usc-e-shop / extensions / DataListUpgrade / data_list_upgrade.php

data_list_upgrade.php in Welcart e-Commerce 2.11.31, at extensions/DataListUpgrade/data_list_upgrade.php

2,726 lines 111.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Order & Member List Upgrade.
4 *
5 * @package Welcart
6 * @author Collne Inc.
7 * @since 1.8.0
8 */
9 class USCES_DATALIST_UPGRADE {
10
11 /**
12 * Extended Options.
13 *
14 * @var object
15 */
16 public static $opts;
17
18 /**
19 * Construct.
20 */
21 public function __construct() {
22
23 self::initialize_data();
24
25 if ( is_admin() ) {
26
27 add_action( 'usces_action_admin_system_extentions', array( $this, 'setting_form' ) );
28 add_action( 'init', array( $this, 'save_data' ) );
29
30 if ( self::$opts['orderlist_flag'] ) {
31 if ( isset( $_REQUEST['order_action'] ) && 'dlordernewlist' === wp_unslash( $_REQUEST['order_action'] ) ) {
32 add_action( 'admin_init', array( $this, 'download_order_list' ) );
33 } elseif ( isset( $_REQUEST['order_action'] ) && 'dlproductnewlist' === wp_unslash( $_REQUEST['order_action'] ) ) {
34 add_action( 'admin_init', array( $this, 'download_orderdetail_list' ) );
35 }
36 add_action( 'load-toplevel_page_usces_orderlist', 'usces_admin_order_list_hook' );
37 add_filter( 'screen_settings', 'usces_orderlist_screen_settings', 10, 2 );
38 add_filter( 'usces_admin_order_list', array( $this, 'change_orderlist' ) );
39 add_action( 'usces_action_chk_pro_order', array( $this, 'self_action_chk_pro_order' ), 30 );
40 add_action( 'usces_action_chk_ord_order', array( $this, 'self_action_chk_ord_order' ), 30 );
41 add_filter( 'usces_filter_chk_pro', array( $this, 'self_filter_chk_pro' ), 30 );
42 add_filter( 'usces_filter_chk_pro_label_order', array( $this, 'self_filter_chk_pro_label_order' ), 30, 3 );
43 add_filter( 'usces_filter_chk_pro_data_order', array( $this, 'self_filter_chk_pro_data_order' ), 30, 5 );
44 add_filter( 'usces_filter_chk_ord', array( $this, 'self_filter_chk_ord' ), 30 );
45 add_filter( 'usces_filter_chk_ord_label_order', array( $this, 'self_filter_chk_ord_label_order' ), 30, 4 );
46 add_filter( 'usces_filter_chk_ord_data_order', array( $this, 'self_filter_chk_ord_data_order' ), 30, 5 );
47 }
48 if ( self::$opts['memberlist_flag'] ) {
49 if ( isset( $_REQUEST['member_action'] ) && 'dlmembernewlist' === wp_unslash( $_REQUEST['member_action'] ) ) {
50 add_action( 'admin_init', array( $this, 'download_member_list' ) );
51 }
52 add_action( 'load-welcart-management_page_usces_memberlist', 'usces_admin_member_list_hook' );
53 add_filter( 'screen_settings', 'usces_memberlist_screen_settings', 10, 2 );
54 add_filter( 'usces_admin_member_list', array( $this, 'change_memberlist' ) );
55 }
56 }
57 }
58
59 /**
60 * Print mail values
61 */
62 public static function get_value_print_mail() {
63 return array(
64 'mail' => array(
65 0 => array(
66 'label' => __( "Don't send", 'usces' ),
67 'alias' => '',
68 ),
69 1 => array(
70 'label' => __( 'Send', 'usces' ),
71 'alias' => __( 'Done', 'usces' ),
72 ),
73 ),
74 'print' => array(
75 0 => array(
76 'label' => __( "Don't print", 'usces' ),
77 'alias' => '',
78 ),
79 1 => array(
80 'label' => __( 'Print', 'usces' ),
81 'alias' => __( 'Done', 'usces' ),
82 ),
83 ),
84
85 );
86 }
87
88 /**
89 * Initialize
90 * Modified:2 Nov.2015
91 */
92 public function initialize_data() {
93 global $usces;
94 $options = get_option( 'usces_ex', array() );
95 $options['system']['datalistup']['orderlist_flag'] = ( ! isset( $options['system']['datalistup']['orderlist_flag'] ) ) ? 1 : (int) $options['system']['datalistup']['orderlist_flag'];
96 $options['system']['datalistup']['memberlist_flag'] = ( ! isset( $options['system']['datalistup']['memberlist_flag'] ) ) ? 1 : (int) $options['system']['datalistup']['memberlist_flag'];
97 update_option( 'usces_ex', $options );
98 self::$opts = $options['system']['datalistup'];
99 }
100
101 /**
102 * Save option data
103 * Modified:10 Oct.2015
104 */
105 public function save_data() {
106 global $usces;
107
108 if ( isset( $_POST['usces_datalistup_option_update'] ) ) {
109
110 check_admin_referer( 'admin_system', 'wc_nonce' );
111 if ( ! current_user_can( 'wel_manage_setting' ) ) {
112 wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
113 }
114
115 self::$opts['orderlist_flag'] = ( isset( $_POST['datalistup_orderlist_flag'] ) ) ? (int) $_POST['datalistup_orderlist_flag'] : 1;
116 self::$opts['memberlist_flag'] = ( isset( $_POST['datalistup_memberlist_flag'] ) ) ? (int) $_POST['datalistup_memberlist_flag'] : 1;
117
118 $options = get_option( 'usces_ex', array() );
119 $options['system']['datalistup'] = self::$opts;
120 update_option( 'usces_ex', $options );
121 }
122 }
123
124 /**
125 * Setting_form
126 * Modified:10 Oct.2015
127 */
128 public function setting_form() {
129 $status = ( self::$opts['orderlist_flag'] || self::$opts['memberlist_flag'] ) ? '<span class="running">' . __( 'Running', 'usces' ) . '</span>' : '<span class="stopped">' . __( 'Stopped', 'usces' ) . '</span>';
130 $datalistup_orderlist_flag0 = ( 0 === self::$opts['orderlist_flag'] ) ? ' checked="checked"' : '';
131 $datalistup_orderlist_flag1 = ( 1 === self::$opts['orderlist_flag'] ) ? ' checked="checked"' : '';
132 $datalistup_memberlist_flag0 = ( 0 === self::$opts['memberlist_flag'] ) ? ' checked="checked"' : '';
133 $datalistup_memberlist_flag1 = ( 1 === self::$opts['memberlist_flag'] ) ? ' checked="checked"' : '';
134 ?>
135 <form action="" method="post" name="option_form" id="datalistup_form">
136 <div class="postbox">
137 <div class="postbox-header">
138 <h2><span><?php esc_attr_e( 'Data List Upgrade', 'usces' ); ?></span><?php wel_esc_script_e( $status ); ?></h2>
139 <div class="handle-actions"><button type="button" class="handlediv" id="datalistup"><span class="screen-reader-text"><?php echo esc_html( sprintf( __( 'Toggle panel: %s' ), __( 'Data List Upgrade', 'usces' ) ) ); ?></span><span class="toggle-indicator"></span></button></div>
140 </div>
141 <div class="inside">
142 <table class="form_table">
143 <tr height="35">
144 <th class="system_th"><a style="cursor:pointer;" onclick="toggleVisibility( 'ex_datalistup_orderlist_flag' );"><?php esc_attr_e( 'New Order List', 'usces' ); ?></a></th>
145 <td width="10"><input name="datalistup_orderlist_flag" id="datalistup_orderlist_flag0" type="radio" value="0"<?php echo esc_html( $datalistup_orderlist_flag0 ); ?> /></td><td width="100"><label for="datalistup_orderlist_flag0"><?php esc_attr_e( 'disable', 'usces' ); ?></label></td>
146 <td width="10"><input name="datalistup_orderlist_flag" id="datalistup_orderlist_flag1" type="radio" value="1"<?php echo esc_html( $datalistup_orderlist_flag1 ); ?> /></td><td width="100"><label for="datalistup_orderlist_flag1"><?php esc_attr_e( 'enable', 'usces' ); ?></label></td>
147 <td><div id="ex_datalistup_orderlist_flag" class="explanation"></div></td>
148 </tr>
149 <tr height="35">
150 <th class="system_th"><a style="cursor:pointer;" onclick="toggleVisibility( 'ex_datalistup_memberlist_flag' );"><?php esc_attr_e( 'New Member List', 'usces' ); ?></a></th>
151 <td width="10"><input name="datalistup_memberlist_flag" id="datalistup_memberlist_flag0" type="radio" value="0"<?php echo esc_html( $datalistup_memberlist_flag0 ); ?> /></td><td width="100"><label for="datalistup_memberlist_flag0"><?php esc_attr_e( 'disable', 'usces' ); ?></label></td>
152 <td width="10"><input name="datalistup_memberlist_flag" id="datalistup_memberlist_flag1" type="radio" value="1"<?php echo esc_html( $datalistup_memberlist_flag1 ); ?> /></td><td width="100"><label for="datalistup_memberlist_flag1"><?php esc_attr_e( 'enable', 'usces' ); ?></label></td>
153 <td><div id="ex_datalistup_memberlist_flag" class="explanation"></div></td>
154 </tr>
155 </table>
156 <hr />
157 <input name="usces_datalistup_option_update" type="submit" class="button button-primary" value="<?php esc_html_e( 'change decision', 'usces' ); ?>" />
158 </div>
159 </div><!--postbox-->
160 <?php wp_nonce_field( 'admin_system', 'wc_nonce' ); ?>
161 </form>
162 <?php
163 }
164
165 /**
166 * Change member list.
167 */
168 public function change_memberlist() {
169 return USCES_PLUGIN_DIR . '/includes/memberlist_page.php';
170 }
171
172 /**
173 * Change order list.
174 */
175 public function change_orderlist() {
176 return USCES_PLUGIN_DIR . '/includes/orderlist_page.php';
177 }
178
179 /**
180 * Member list download.
181 */
182 public function download_member_list() {
183 global $wpdb, $usces, $usces_settings;
184
185 if ( ! current_user_can( 'wel_manage_order' ) ) {
186 wp_die( __( 'You do not have sufficient privileges to perform this operation.', 'usces' ) );
187 }
188 check_admin_referer( 'member_list', 'wc_nonce' );
189
190 require_once USCES_PLUGIN_DIR . '/classes/memberList.class.php';
191
192 $memberlist = new WlcMemberList();
193 $memberlist->pageLimit = 'off';
194 $arr_column = $memberlist->get_column();
195 $res = $memberlist->MakeTable();
196 $arr_search = $memberlist->GetSearchs();
197 $rows = $memberlist->rows;
198
199 if ( ! empty( $_REQUEST['listcheck'] ) ) {
200 $listcheck = ( is_array( $_REQUEST['listcheck'] ) ) ? $_REQUEST['listcheck'] : explode( ',', $_REQUEST['listcheck'] );
201 $rows = array_filter( $rows, function( $row ) use ( $listcheck ) {
202 return in_array( (int)$row['ID'], array_map( 'intval', $listcheck ), true );
203 } );
204 }
205
206 $ext = wp_unslash( $_REQUEST['ftype'] );
207 if ( 'csv' === $ext ) {
208 $table_h = '';
209 $table_f = '';
210 $tr_h = '';
211 $tr_f = '';
212 $th_h1 = '"';
213 $th_h = ',"';
214 $th_f = '"';
215 $td_h1 = '"';
216 $td_h = ',"';
217 $td_f = '"';
218 $lf = "\n";
219 } else {
220 exit();
221 }
222
223 // ==========================================================================
224
225 $usces_opt_member = get_option( 'usces_opt_member' );
226 if ( ! is_array( $usces_opt_member ) ) {
227 $usces_opt_member = array();
228 }
229 $usces_opt_member['ftype_mem'] = $ext;
230 $chk_mem = array();
231 foreach ( $arr_column as $key => $label ) {
232 if ( 'csod_' === substr( $key, 0, 5 ) ) {
233 continue;
234 }
235 $chk_mem[ $key ] = ( isset( $_REQUEST['check'][ $key ] ) ) ? 1 : 0;
236 }
237 $usces_opt_member['chk_mem'] = apply_filters( 'usces_filter_chk_mem', $chk_mem );
238 update_option( 'usces_opt_member', $usces_opt_member );
239
240 // ==========================================================================
241
242 $line = $table_h;
243 $line .= $tr_h;
244 $line_col = '';
245 foreach ( $arr_column as $key => $label ) {
246 if ( 'csod_' === substr( $key, 0, 5 ) ) {
247 continue;
248 }
249 if ( isset( $_REQUEST['check'][ $key ] ) ) {
250 $line_col .= $th_h . usces_entity_decode( $label, $ext ) . $th_f;
251 }
252 }
253 $line_col = ltrim( $line_col, ',' );
254 $line .= $line_col;
255 $line = apply_filters( 'usces_filter_mem_label', $line, $line, $line_col );
256 $line .= apply_filters( 'usces_filter_chk_mem_label', null, $usces_opt_member, $rows, $line_col );
257 $line .= $tr_f . $lf;
258
259 // ==========================================================================
260
261 foreach ( (array) $rows as $array ) {
262 $line .= $tr_h;
263 $line_row = '';
264 foreach ( $arr_column as $key => $label ) {
265 if ( 'csod_' === substr( $key, 0, 5 ) ) {
266 continue;
267 }
268 if ( 'csmb_' === substr( $key, 0, 5 ) ) {
269 $multi_value = maybe_unserialize( $array[ $key ] );
270 if ( is_array( $multi_value ) ) {
271 $value = '';
272 foreach ( $multi_value as $str ) {
273 $value .= $str . ' ';
274 }
275 $array[ $key ] = trim( $value );
276 }
277 }
278 if ( isset( $_REQUEST['check'][ $key ] ) ) {
279 $data_value = apply_filters( 'usces_filter_mem_csv_data_value', $array[ $key ], $key, $array );
280 $line_row .= $td_h . usces_entity_decode( $data_value, $ext ) . $td_f;
281 }
282 }
283 $line_row = preg_replace( "/\n,/", "\n", ltrim( $line_row, ',' ) );
284 $line .= $line_row;
285 $line = apply_filters( 'usces_filter_mem_data', $line, $line, $line_row );
286 $line .= apply_filters( 'usces_filter_chk_mem_data', null, $usces_opt_member, $array['ID'], $array, $line_row );
287 $line .= $tr_f . $lf;
288 }
289 $line .= $table_f;
290
291 // ==========================================================================
292
293 header( 'Content-Type: application/octet-stream' );
294 header( 'Content-Disposition: attachment; filename=usces_member_list.' . $ext );
295 mb_http_output( 'pass' );
296 print( mb_convert_encoding( $line, apply_filters( 'usces_filter_output_csv_encode', 'SJIS-win' ), 'UTF-8' ) );
297 exit();
298 }
299
300 /**
301 * Product list download.
302 */
303 public function download_orderdetail_list() {
304 global $wpdb, $usces, $usces_settings;
305
306 if ( ! current_user_can( 'wel_manage_order' ) ) {
307 wp_die( __( 'You do not have sufficient privileges to perform this operation.', 'usces' ) );
308 }
309 check_admin_referer( 'order_list', 'wc_nonce' );
310
311 require_once USCES_PLUGIN_DIR . '/classes/orderList2.class.php';
312
313 $all_column = true;
314 $orderlist = new WlcOrderList( $all_column );
315 $orderlist->pageLimit = 'off';
316 $arr_column = $orderlist->get_column();
317 $res = $orderlist->MakeTable();
318 $arr_search = $orderlist->GetSearchs();
319 $rows = $orderlist->rows;
320
321 if ( ! empty( $_REQUEST['listcheck'] ) ) {
322 $listcheck = ( is_array( $_REQUEST['listcheck'] ) ) ? $_REQUEST['listcheck'] : explode( ',', $_REQUEST['listcheck'] );
323 $rows = array_filter( $rows, function( $row ) use ( $listcheck ) {
324 return in_array( (int)$row['ID'], array_map( 'intval', $listcheck ), true );
325 } );
326 }
327
328 $ext = wp_unslash( $_REQUEST['ftype'] );
329 if ( 'csv' === $ext ) {
330 $table_h = '';
331 $table_f = '';
332 $tr_h = '';
333 $tr_f = '';
334 $th_h1 = '"';
335 $th_h = ',"';
336 $th_f = '"';
337 $td_h1 = '"';
338 $td_h = ',"';
339 $td_f = '"';
340 $sp = ':';
341 $nb = ' ';
342 $lf = "\n";
343 } else {
344 exit();
345 }
346
347 $csod_meta = usces_has_custom_field_meta( 'order' );
348 $cscs_meta = usces_has_custom_field_meta( 'customer' );
349 $csde_meta = usces_has_custom_field_meta( 'delivery' );
350 $applyform = usces_get_apply_addressform( $usces->options['system']['addressform'] );
351 $usces_tax = Welcart_Tax::get_instance();
352
353 // ==========================================================================
354
355 $usces_opt_order = get_option( 'usces_opt_order' );
356 if ( ! is_array( $usces_opt_order ) ) {
357 $usces_opt_order = array();
358 }
359 $usces_opt_order['ftype_pro'] = $ext;
360 $chk_pro = array();
361 $chk_pro['ID'] = ( isset( $_REQUEST['check']['ID'] ) ) ? 1 : 0;
362 $chk_pro['deco_id'] = ( isset( $_REQUEST['check']['deco_id'] ) ) ? 1 : 0;
363 $chk_pro['date'] = ( isset( $_REQUEST['check']['date'] ) ) ? 1 : 0;
364 $chk_pro['mem_id'] = ( isset( $_REQUEST['check']['mem_id'] ) ) ? 1 : 0;
365 $chk_pro['email'] = ( isset( $_REQUEST['check']['email'] ) ) ? 1 : 0;
366 if ( ! empty( $cscs_meta ) ) {
367 foreach ( $cscs_meta as $key => $entry ) {
368 if ( 'name_pre' === $entry['position'] ) {
369 $name = $entry['name'];
370 $cscs_key = 'cscs_' . $key;
371 $chk_pro[ $cscs_key ] = ( isset( $_REQUEST['check'][ $cscs_key ] ) ) ? 1 : 0;
372 }
373 }
374 }
375 $chk_pro['name'] = ( isset( $_REQUEST['check']['name'] ) ) ? 1 : 0;
376 if ( 'JP' === $applyform ) {
377 $chk_pro['kana'] = ( isset( $_REQUEST['check']['kana'] ) ) ? 1 : 0;
378 }
379 if ( ! empty( $cscs_meta ) ) {
380 foreach ( $cscs_meta as $key => $entry ) {
381 if ( 'name_after' === $entry['position'] ) {
382 $name = $entry['name'];
383 $cscs_key = 'cscs_' . $key;
384 $chk_pro[ $cscs_key ] = ( isset( $_REQUEST['check'][ $cscs_key ] ) ) ? 1 : 0;
385 }
386 }
387 }
388 $chk_pro['zip'] = ( isset( $_REQUEST['check']['zip'] ) ) ? 1 : 0;
389 $chk_pro['country'] = ( isset( $_REQUEST['check']['country'] ) ) ? 1 : 0;
390 $chk_pro['pref'] = ( isset( $_REQUEST['check']['pref'] ) ) ? 1 : 0;
391 $chk_pro['address1'] = ( isset( $_REQUEST['check']['address1'] ) ) ? 1 : 0;
392 $chk_pro['address2'] = ( isset( $_REQUEST['check']['address2'] ) ) ? 1 : 0;
393 $chk_pro['address3'] = ( isset( $_REQUEST['check']['address3'] ) ) ? 1 : 0;
394 $chk_pro['tel'] = ( isset( $_REQUEST['check']['tel'] ) ) ? 1 : 0;
395 $chk_pro['fax'] = ( isset( $_REQUEST['check']['fax'] ) ) ? 1 : 0;
396 if ( ! empty( $cscs_meta ) ) {
397 foreach ( $cscs_meta as $key => $entry ) {
398 if ( 'fax_after' === $entry['position'] ) {
399 $name = $entry['name'];
400 $cscs_key = 'cscs_' . $key;
401 $chk_pro[ $cscs_key ] = ( isset( $_REQUEST['check'][ $cscs_key ] ) ) ? 1 : 0;
402 }
403 }
404 }
405 // --------------------------------------------------------------------------
406 if ( ! empty( $csde_meta ) ) {
407 foreach ( $csde_meta as $key => $entry ) {
408 if ( 'name_pre' === $entry['position'] ) {
409 $name = $entry['name'];
410 $csde_key = 'csde_' . $key;
411 $chk_pro[ $csde_key ] = ( isset( $_REQUEST['check'][ $csde_key ] ) ) ? 1 : 0;
412 }
413 }
414 }
415 $chk_pro['delivery_name'] = ( isset( $_REQUEST['check']['delivery_name'] ) ) ? 1 : 0;
416 if ( 'JP' === $applyform ) {
417 $chk_pro['delivery_kana'] = ( isset( $_REQUEST['check']['delivery_kana'] ) ) ? 1 : 0;
418 }
419 if ( ! empty( $csde_meta ) ) {
420 foreach ( $csde_meta as $key => $entry ) {
421 if ( 'name_after' === $entry['position'] ) {
422 $name = $entry['name'];
423 $csde_key = 'csde_' . $key;
424 $chk_pro[ $csde_key ] = ( isset( $_REQUEST['check'][ $csde_key ] ) ) ? 1 : 0;
425 }
426 }
427 }
428 $chk_pro['delivery_zip'] = ( isset( $_REQUEST['check']['delivery_zip'] ) ) ? 1 : 0;
429 $chk_pro['delivery_country'] = ( isset( $_REQUEST['check']['delivery_country'] ) ) ? 1 : 0;
430 $chk_pro['delivery_pref'] = ( isset( $_REQUEST['check']['delivery_pref'] ) ) ? 1 : 0;
431 $chk_pro['delivery_address1'] = ( isset( $_REQUEST['check']['delivery_address1'] ) ) ? 1 : 0;
432 $chk_pro['delivery_address2'] = ( isset( $_REQUEST['check']['delivery_address2'] ) ) ? 1 : 0;
433 $chk_pro['delivery_address3'] = ( isset( $_REQUEST['check']['delivery_address3'] ) ) ? 1 : 0;
434 $chk_pro['delivery_tel'] = ( isset( $_REQUEST['check']['delivery_tel'] ) ) ? 1 : 0;
435 $chk_pro['delivery_fax'] = ( isset( $_REQUEST['check']['delivery_fax'] ) ) ? 1 : 0;
436 if ( ! empty( $csde_meta ) ) {
437 foreach ( $csde_meta as $key => $entry ) {
438 if ( 'fax_after' === $entry['position'] ) {
439 $name = $entry['name'];
440 $csde_key = 'csde_' . $key;
441 $chk_pro[ $csde_key ] = ( isset( $_REQUEST['check'][ $csde_key ] ) ) ? 1 : 0;
442 }
443 }
444 }
445 // --------------------------------------------------------------------------
446 $chk_pro['shipping_date'] = ( isset( $_REQUEST['check']['shipping_date'] ) ) ? 1 : 0;
447 $chk_pro['peyment_method'] = ( isset( $_REQUEST['check']['peyment_method'] ) ) ? 1 : 0;
448 $chk_pro['wc_trans_id'] = ( isset( $_REQUEST['check']['wc_trans_id'] ) ) ? 1 : 0;
449 $chk_pro['delivery_method'] = ( isset( $_REQUEST['check']['delivery_method'] ) ) ? 1 : 0;
450 $chk_pro['delivery_date'] = ( isset( $_REQUEST['check']['delivery_date'] ) ) ? 1 : 0;
451 $chk_pro['delivery_time'] = ( isset( $_REQUEST['check']['delivery_time'] ) ) ? 1 : 0;
452 $chk_pro['delidue_date'] = ( isset( $_REQUEST['check']['delidue_date'] ) ) ? 1 : 0;
453 $chk_pro['status'] = ( isset( $_REQUEST['check']['status'] ) ) ? 1 : 0;
454 $chk_pro['tracking_number'] = ( isset( $_REQUEST['check']['tracking_number'] ) ) ? 1 : 0;
455 $chk_pro['total_amount'] = ( isset( $_REQUEST['check']['total_amount'] ) ) ? 1 : 0;
456 $chk_pro['item_total_amount'] = ( isset( $_REQUEST['check']['item_total_amount'] ) ) ? 1 : 0;
457 if ( usces_is_member_system() && usces_is_member_system_point() ) {
458 $chk_pro['getpoint'] = ( isset( $_REQUEST['check']['getpoint'] ) ) ? 1 : 0;
459 $chk_pro['usedpoint'] = ( isset( $_REQUEST['check']['usedpoint'] ) ) ? 1 : 0;
460 }
461 $chk_pro['discount'] = ( isset( $_REQUEST['check']['discount'] ) ) ? 1 : 0;
462 $chk_pro['shipping_charge'] = ( isset( $_REQUEST['check']['shipping_charge'] ) ) ? 1 : 0;
463 $chk_pro['cod_fee'] = ( isset( $_REQUEST['check']['cod_fee'] ) ) ? 1 : 0;
464 if ( usces_is_tax_display() ) {
465 $chk_pro['tax'] = ( isset( $_REQUEST['check']['tax'] ) ) ? 1 : 0;
466 if ( usces_is_reduced_taxrate() ) {
467 $chk_pro['subtotal_standard'] = ( isset( $_REQUEST['check']['subtotal_standard'] ) ) ? 1 : 0;
468 $chk_pro['tax_standard'] = ( isset( $_REQUEST['check']['tax_standard'] ) ) ? 1 : 0;
469 $chk_pro['subtotal_reduced'] = ( isset( $_REQUEST['check']['subtotal_reduced'] ) ) ? 1 : 0;
470 $chk_pro['tax_reduced'] = ( isset( $_REQUEST['check']['tax_reduced'] ) ) ? 1 : 0;
471 }
472 }
473 $chk_pro['note'] = ( isset( $_REQUEST['check']['note'] ) ) ? 1 : 0;
474 if ( ! empty( $csod_meta ) ) {
475 foreach ( $csod_meta as $key => $entry ) {
476 $name = $entry['name'];
477 $csod_key = 'csod_' . $key;
478 $chk_pro[ $csod_key ] = ( isset( $_REQUEST['check'][ $csod_key ] ) ) ? 1 : 0;
479 }
480 }
481 // $usces_opt_order['chk_pro'] = apply_filters( 'usces_filter_chk_pro', $chk_pro );
482 // update_option( 'usces_opt_order', $usces_opt_order );
483
484 // ==========================================================================
485
486 if ( isset( $_REQUEST['check']['status'] ) ) {
487 $usces_management_status = apply_filters( 'usces_filter_management_status', get_option( 'usces_management_status' ) );
488 $usces_management_status['new'] = __( 'new order', 'usces' );
489 }
490 $chk_pro['item_code'] = ( isset( $_REQUEST['check']['item_code'] ) ) ? 1 : 0;
491 $chk_pro['sku_code'] = ( isset( $_REQUEST['check']['sku_code'] ) ) ? 1 : 0;
492 $chk_pro['item_name'] = ( isset( $_REQUEST['check']['item_name'] ) ) ? 1 : 0;
493 $chk_pro['sku_name'] = ( isset( $_REQUEST['check']['sku_name'] ) ) ? 1 : 0;
494 $chk_pro['options'] = ( isset( $_REQUEST['check']['options'] ) ) ? 1 : 0;
495 $chk_pro['quantity'] = ( isset( $_REQUEST['check']['quantity'] ) ) ? 1 : 0;
496 $chk_pro['price'] = ( isset( $_REQUEST['check']['price'] ) ) ? 1 : 0;
497 $chk_pro['unit'] = ( isset( $_REQUEST['check']['unit'] ) ) ? 1 : 0;
498 $chk_pro['admin_memo'] = ( isset( $_REQUEST['check']['admin_memo'] ) ) ? 1 : 0;
499 $usces_opt_order['chk_pro'] = apply_filters( 'usces_filter_chk_pro', $chk_pro );
500 update_option( 'usces_opt_order', $usces_opt_order );
501
502 // ==========================================================================
503
504 $line = $table_h;
505 $line .= $tr_h;
506 $line_col = '';
507 if ( isset( $_REQUEST['check']['ID'] ) ) {
508 $line_col .= $th_h1 . __( 'ID', 'usces' ) . $th_f;
509 }
510 if ( isset( $_REQUEST['check']['deco_id'] ) ) {
511 $line_col .= $th_h . __( 'Order number', 'usces' ) . $th_f;
512 }
513 if ( isset( $_REQUEST['check']['date'] ) ) {
514 $line_col .= $th_h . __( 'order date', 'usces' ) . $th_f;
515 }
516 if ( isset( $_REQUEST['check']['mem_id'] ) ) {
517 $line_col .= $th_h . __( 'membership number', 'usces' ) . $th_f;
518 }
519 if ( isset( $_REQUEST['check']['email'] ) ) {
520 $line_col .= $th_h . __( 'e-mail', 'usces' ) . $th_f;
521 }
522 if ( ! empty( $cscs_meta ) ) {
523 foreach ( $cscs_meta as $key => $entry ) {
524 if ( 'name_pre' === $entry['position'] ) {
525 $name = $entry['name'];
526 $cscs_key = 'cscs_' . $key;
527 if ( isset( $_REQUEST['check'][ $cscs_key ] ) ) {
528 $line_col .= $th_h . usces_entity_decode( $name, $ext ) . $th_f;
529 }
530 }
531 }
532 }
533 if ( isset( $_REQUEST['check']['name'] ) ) {
534 $line_col .= $th_h . __( 'name', 'usces' ) . $th_f;
535 }
536 if ( 'JP' === $applyform ) {
537 if ( isset( $_REQUEST['check']['kana'] ) ) {
538 $line_col .= $th_h . __( 'furigana', 'usces' ) . $th_f;
539 }
540 }
541 if ( ! empty( $cscs_meta ) ) {
542 foreach ( $cscs_meta as $key => $entry ) {
543 if ( 'name_after' === $entry['position'] ) {
544 $name = $entry['name'];
545 $cscs_key = 'cscs_' . $key;
546 if ( isset( $_REQUEST['check'][ $cscs_key ] ) ) {
547 $line_col .= $th_h . usces_entity_decode( $name, $ext ) . $th_f;
548 }
549 }
550 }
551 }
552
553 switch ( $applyform ) {
554 case 'JP':
555 if ( isset( $_REQUEST['check']['zip'] ) ) {
556 $line_col .= $th_h . __( 'Zip/Postal Code', 'usces' ) . $th_f;
557 }
558 if ( isset( $_REQUEST['check']['country'] ) ) {
559 $line_col .= $th_h . __( 'Country', 'usces' ) . $th_f;
560 }
561 if ( isset( $_REQUEST['check']['pref'] ) ) {
562 $line_col .= $th_h . __( 'Province', 'usces' ) . $th_f;
563 }
564 if ( isset( $_REQUEST['check']['address1'] ) ) {
565 $line_col .= $th_h . __( 'city', 'usces' ) . $th_f;
566 }
567 if ( isset( $_REQUEST['check']['address2'] ) ) {
568 $line_col .= $th_h . __( 'numbers', 'usces' ) . $th_f;
569 }
570 if ( isset( $_REQUEST['check']['address3'] ) ) {
571 $line_col .= $th_h . __( 'building name', 'usces' ) . $th_f;
572 }
573 if ( isset( $_REQUEST['check']['tel'] ) ) {
574 $line_col .= $th_h . __( 'Phone number', 'usces' ) . $th_f;
575 }
576 if ( isset( $_REQUEST['check']['fax'] ) ) {
577 $line_col .= $th_h . __( 'FAX number', 'usces' ) . $th_f;
578 }
579 break;
580 case 'US':
581 default:
582 if ( isset( $_REQUEST['check']['address2'] ) ) {
583 $line_col .= $th_h . __( 'Address Line1', 'usces' ) . $th_f;
584 }
585 if ( isset( $_REQUEST['check']['address3'] ) ) {
586 $line_col .= $th_h . __( 'Address Line2', 'usces' ) . $th_f;
587 }
588 if ( isset( $_REQUEST['check']['address1'] ) ) {
589 $line_col .= $th_h . __( 'city', 'usces' ) . $th_f;
590 }
591 if ( isset( $_REQUEST['check']['pref'] ) ) {
592 $line_col .= $th_h . __( 'State', 'usces' ) . $th_f;
593 }
594 if ( isset( $_REQUEST['check']['country'] ) ) {
595 $line_col .= $th_h . __( 'Country', 'usces' ) . $th_f;
596 }
597 if ( isset( $_REQUEST['check']['zip'] ) ) {
598 $line_col .= $th_h . __( 'Zip', 'usces' ) . $th_f;
599 }
600 if ( isset( $_REQUEST['check']['tel'] ) ) {
601 $line_col .= $th_h . __( 'Phone number', 'usces' ) . $th_f;
602 }
603 if ( isset( $_REQUEST['check']['fax'] ) ) {
604 $line_col .= $th_h . __( 'FAX number', 'usces' ) . $th_f;
605 }
606 break;
607 }
608
609 if ( ! empty( $cscs_meta ) ) {
610 foreach ( $cscs_meta as $key => $entry ) {
611 if ( 'fax_after' === $entry['position'] ) {
612 $name = $entry['name'];
613 $cscs_key = 'cscs_' . $key;
614 if ( isset( $_REQUEST['check'][ $cscs_key ] ) ) {
615 $line_col .= $th_h . usces_entity_decode( $name, $ext ) . $th_f;
616 }
617 }
618 }
619 }
620 $line_col .= apply_filters( 'usces_filter_chk_pro_label_customer', null, $usces_opt_order, $rows );
621 // --------------------------------------------------------------------------
622 if ( ! empty( $csde_meta ) ) {
623 foreach ( $csde_meta as $key => $entry ) {
624 if ( 'name_pre' === $entry['position'] ) {
625 $name = $entry['name'];
626 $csde_key = 'csde_' . $key;
627 if ( isset( $_REQUEST['check'][ $csde_key ] ) ) {
628 $line_col .= $th_h . usces_entity_decode( $name, $ext ) . $th_f;
629 }
630 }
631 }
632 }
633 if ( isset( $_REQUEST['check']['delivery_name'] ) ) {
634 $line_col .= $th_h . __( 'Shipping Name', 'usces' ) . $th_f;
635 }
636 if ( 'JP' === $applyform ) {
637 if ( isset( $_REQUEST['check']['delivery_kana'] ) ) {
638 $line_col .= $th_h . __( 'Shipping Furigana', 'usces' ) . $th_f;
639 }
640 }
641 if ( ! empty( $csde_meta ) ) {
642 foreach ( $csde_meta as $key => $entry ) {
643 if ( 'name_after' === $entry['position'] ) {
644 $name = $entry['name'];
645 $csde_key = 'csde_' . $key;
646 if ( isset( $_REQUEST['check'][ $csde_key ] ) ) {
647 $line_col .= $th_h . usces_entity_decode( $name, $ext ) . $th_f;
648 }
649 }
650 }
651 }
652
653 switch ( $applyform ) {
654 case 'JP':
655 if ( isset( $_REQUEST['check']['delivery_zip'] ) ) {
656 $line_col .= $th_h . __( 'Shipping Zip', 'usces' ) . $th_f;
657 }
658 if ( isset( $_REQUEST['check']['delivery_country'] ) ) {
659 $line_col .= $th_h . __( 'Shipping Country', 'usces' ) . $th_f;
660 }
661 if ( isset( $_REQUEST['check']['delivery_pref'] ) ) {
662 $line_col .= $th_h . __( 'Shipping State', 'usces' ) . $th_f;
663 }
664 if ( isset( $_REQUEST['check']['delivery_address1'] ) ) {
665 $line_col .= $th_h . __( 'Shipping City', 'usces' ) . $th_f;
666 }
667 if ( isset( $_REQUEST['check']['delivery_address2'] ) ) {
668 $line_col .= $th_h . __( 'Shipping Address1', 'usces' ) . $th_f;
669 }
670 if ( isset( $_REQUEST['check']['delivery_address3'] ) ) {
671 $line_col .= $th_h . __( 'Shipping Address2', 'usces' ) . $th_f;
672 }
673 if ( isset( $_REQUEST['check']['delivery_tel'] ) ) {
674 $line_col .= $th_h . __( 'Shipping Phone', 'usces' ) . $th_f;
675 }
676 if ( isset( $_REQUEST['check']['delivery_fax'] ) ) {
677 $line_col .= $th_h . __( 'Shipping FAX', 'usces' ) . $th_f;
678 }
679 break;
680 case 'US':
681 default:
682 if ( isset( $_REQUEST['check']['delivery_address2'] ) ) {
683 $line_col .= $th_h . __( 'Shipping Address1', 'usces' ) . $th_f;
684 }
685 if ( isset( $_REQUEST['check']['delivery_address3'] ) ) {
686 $line_col .= $th_h . __( 'Shipping Address2', 'usces' ) . $th_f;
687 }
688 if ( isset( $_REQUEST['check']['delivery_address1'] ) ) {
689 $line_col .= $th_h . __( 'Shipping City', 'usces' ) . $th_f;
690 }
691 if ( isset( $_REQUEST['check']['delivery_pref'] ) ) {
692 $line_col .= $th_h . __( 'Shipping State', 'usces' ) . $th_f;
693 }
694 if ( isset( $_REQUEST['check']['delivery_country'] ) ) {
695 $line_col .= $th_h . __( 'Shipping Country', 'usces' ) . $th_f;
696 }
697 if ( isset( $_REQUEST['check']['delivery_zip'] ) ) {
698 $line_col .= $th_h . __( 'Shipping Zip', 'usces' ) . $th_f;
699 }
700 if ( isset( $_REQUEST['check']['delivery_tel'] ) ) {
701 $line_col .= $th_h . __( 'Shipping Phone', 'usces' ) . $th_f;
702 }
703 if ( isset( $_REQUEST['check']['delivery_fax'] ) ) {
704 $line_col .= $th_h . __( 'Shipping FAX', 'usces' ) . $th_f;
705 }
706 break;
707 }
708
709 if ( ! empty( $csde_meta ) ) {
710 foreach ( $csde_meta as $key => $entry ) {
711 if ( 'fax_after' === $entry['position'] ) {
712 $name = $entry['name'];
713 $csde_key = 'csde_' . $key;
714 if ( isset( $_REQUEST['check'][ $csde_key ] ) ) {
715 $line_col .= $th_h . usces_entity_decode( $name, $ext ) . $th_f;
716 }
717 }
718 }
719 }
720 $line_col .= apply_filters( 'usces_filter_chk_pro_label_delivery', null, $usces_opt_order, $rows );
721 // --------------------------------------------------------------------------
722 if ( isset( $_REQUEST['check']['shipping_date'] ) ) {
723 $line_col .= $th_h . __( 'shpping date', 'usces' ) . $th_f;
724 }
725 if ( isset( $_REQUEST['check']['peyment_method'] ) ) {
726 $line_col .= $th_h . __( 'payment method', 'usces' ) . $th_f;
727 }
728 if ( isset( $_REQUEST['check']['wc_trans_id'] ) ) {
729 $line_col .= $th_h . __( 'Transaction ID', 'usces' ) . $th_f;
730 }
731 if ( isset( $_REQUEST['check']['delivery_method'] ) ) {
732 $line_col .= $th_h . __( 'shipping option', 'usces' ) . $th_f;
733 }
734 if ( isset( $_REQUEST['check']['delivery_date'] ) ) {
735 $line_col .= $th_h . __( 'Delivery date', 'usces' ) . $th_f;
736 }
737 if ( isset( $_REQUEST['check']['delivery_time'] ) ) {
738 $line_col .= $th_h . __( 'delivery time', 'usces' ) . $th_f;
739 }
740 if ( isset( $_REQUEST['check']['delidue_date'] ) ) {
741 $line_col .= $th_h . __( 'Shipping date', 'usces' ) . $th_f;
742 }
743 if ( isset( $_REQUEST['check']['status'] ) ) {
744 $line_col .= $th_h . __( 'Status', 'usces' ) . $th_f;
745 }
746 if ( isset( $_REQUEST['check']['tracking_number'] ) ) {
747 $line_col .= $th_h . __( 'Tracking number', 'usces' ) . $th_f;
748 }
749 if ( isset( $_REQUEST['check']['total_amount'] ) ) {
750 $line_col .= $th_h . __( 'Total Amount', 'usces' ) . $th_f;
751 }
752 if ( isset( $_REQUEST['check']['item_total_amount'] ) ) {
753 $line_col .= $th_h . __( 'total items', 'usces' ) . $th_f;
754 }
755 if ( usces_is_member_system() && usces_is_member_system_point() ) {
756 if ( isset( $_REQUEST['check']['getpoint'] ) ) {
757 $line_col .= $th_h . __( 'granted points', 'usces' ) . $th_f;
758 }
759 if ( isset( $_REQUEST['check']['usedpoint'] ) ) {
760 $line_col .= $th_h . __( 'Used points', 'usces' ) . $th_f;
761 }
762 }
763 if ( isset( $_REQUEST['check']['discount'] ) ) {
764 $line_col .= $th_h . __( 'Discount', 'usces' ) . $th_f;
765 }
766 if ( usces_is_tax_display() && 'products' === usces_get_tax_target() ) {
767 if ( isset( $_REQUEST['check']['tax'] ) ) {
768 $line_col .= $th_h . usces_tax_label( array(), 'return' ) . $th_f;
769 }
770 if ( usces_is_reduced_taxrate() ) {
771 if ( isset( $_REQUEST['check']['subtotal_standard'] ) ) {
772 $line_col .= $th_h . sprintf( __( 'Applies to %s%%', 'usces' ), $usces_tax->tax_rate_standard ) . $th_f;
773 }
774 if ( isset( $_REQUEST['check']['tax_standard'] ) ) {
775 $line_col .= $th_h . sprintf( __( '%s%% consumption tax', 'usces' ), $usces_tax->tax_rate_standard ) . $th_f;
776 }
777 if ( isset( $_REQUEST['check']['subtotal_reduced'] ) ) {
778 $line_col .= $th_h . sprintf( __( 'Applies to %s%%', 'usces' ), $usces_tax->tax_rate_reduced ) . $th_f;
779 }
780 if ( isset( $_REQUEST['check']['tax_reduced'] ) ) {
781 $line_col .= $th_h . sprintf( __( '%s%% consumption tax', 'usces' ), $usces_tax->tax_rate_reduced ) . $th_f;
782 }
783 }
784 }
785 if ( isset( $_REQUEST['check']['shipping_charge'] ) ) {
786 $line_col .= $th_h . __( 'Shipping', 'usces' ) . $th_f;
787 }
788 if ( isset( $_REQUEST['check']['cod_fee'] ) ) {
789 $line_col .= $th_h . apply_filters( 'usces_filter_cod_label', __( 'COD fee', 'usces' ) ) . $th_f;
790 }
791 if ( usces_is_tax_display() && 'products' !== usces_get_tax_target() ) {
792 if ( isset( $_REQUEST['check']['tax'] ) ) {
793 $line_col .= $th_h . usces_tax_label( array(), 'return' ) . $th_f;
794 }
795 if ( usces_is_reduced_taxrate() ) {
796 if ( isset( $_REQUEST['check']['subtotal_standard'] ) ) {
797 $line_col .= $th_h . sprintf( __( 'Applies to %s%%', 'usces' ), $usces_tax->tax_rate_standard ) . $th_f;
798 }
799 if ( isset( $_REQUEST['check']['tax_standard'] ) ) {
800 $line_col .= $th_h . sprintf( __( '%s%% consumption tax', 'usces' ), $usces_tax->tax_rate_standard ) . $th_f;
801 }
802 if ( isset( $_REQUEST['check']['subtotal_reduced'] ) ) {
803 $line_col .= $th_h . sprintf( __( 'Applies to %s%%', 'usces' ), $usces_tax->tax_rate_reduced ) . $th_f;
804 }
805 if ( isset( $_REQUEST['check']['tax_reduced'] ) ) {
806 $line_col .= $th_h . sprintf( __( '%s%% consumption tax', 'usces' ), $usces_tax->tax_rate_reduced ) . $th_f;
807 }
808 }
809 }
810 if ( isset( $_REQUEST['check']['note'] ) ) {
811 $line_col .= $th_h . __( 'Notes', 'usces' ) . $th_f;
812 }
813 if ( ! empty( $csod_meta ) ) {
814 foreach ( $csod_meta as $key => $entry ) {
815 $name = $entry['name'];
816 $csod_key = 'csod_' . $key;
817 if ( isset( $_REQUEST['check'][ $csod_key ] ) ) {
818 $line_col .= $th_h . usces_entity_decode( $name, $ext ) . $th_f;
819 }
820 }
821 }
822 $line_col .= apply_filters( 'usces_filter_chk_pro_label_order', null, $usces_opt_order, $rows );
823 if ( isset( $_REQUEST['check']['item_code'] ) ) {
824 $line_col .= $th_h . __( 'item code', 'usces' ) . $th_f;
825 }
826 if ( isset( $_REQUEST['check']['sku_code'] ) ) {
827 $line_col .= $th_h . __( 'SKU code', 'usces' ) . $th_f;
828 }
829 if ( isset( $_REQUEST['check']['item_name'] ) ) {
830 $line_col .= $th_h . __( 'item name', 'usces' ) . $th_f;
831 }
832 if ( isset( $_REQUEST['check']['sku_name'] ) ) {
833 $line_col .= $th_h . __( 'SKU display name ', 'usces' ) . $th_f;
834 }
835 if ( isset( $_REQUEST['check']['options'] ) ) {
836 $line_col .= apply_filters( 'usces_filter_csvpro_itemopt_label', ( $th_h . __( 'options for items', 'usces' ) . $th_f ), $usces_opt_order, $rows );
837 }
838 if ( isset( $_REQUEST['check']['quantity'] ) ) {
839 $line_col .= $th_h . __( 'Quantity', 'usces' ) . $th_f;
840 }
841 if ( isset( $_REQUEST['check']['price'] ) ) {
842 $line_col .= $th_h . __( 'Unit price', 'usces' ) . $th_f;
843 }
844 if ( isset( $_REQUEST['check']['unit'] ) ) {
845 $line_col .= $th_h . __( 'unit', 'usces' ) . $th_f;
846 }
847 if ( isset( $_REQUEST['check']['admin_memo'] ) ) {
848 $line_col .= $th_h . __( 'Administrator Note', 'usces' ) . $th_f;
849 }
850 $line_col = ltrim( $line_col, ',' );
851 $line_col = apply_filters( 'usces_filter_chk_pro_label_line_col', $line_col, $usces_opt_order );
852 $line .= $line_col;
853 $line .= apply_filters( 'usces_filter_chk_pro_label_detail', null, $usces_opt_order, $rows, $line_col );
854 $line .= $tr_f . $lf;
855
856 // ==========================================================================
857
858 foreach ( (array) $rows as $data ) {
859
860 $data = apply_filters( 'usces_filter_orderdetail_csv_data', $data );
861
862 $order_id = $data['ID'];
863 $deli = unserialize( $data['deli_name'] );
864 $cart = usces_get_ordercartdata( $order_id );
865 $cart_count = ( $cart && is_array( $cart ) ) ? count( $cart ) : 0;
866 $reduced_taxrate = usces_is_reduced_taxrate( $order_id );
867
868 if ( usces_is_tax_display() && $reduced_taxrate ) {
869 $condition = usces_get_order_condition( $order_id );
870 $materials = array(
871 'total_items_price' => $data['item_total_price'],
872 'discount' => $data['discount'],
873 'shipping_charge' => $data['shipping_charge'],
874 'cod_fee' => $data['cod_fee'],
875 'use_point' => $data['usedpoint'],
876 'carts' => $cart,
877 'condition' => $condition,
878 'order_id' => $order_id,
879 );
880 $usces_tax->get_order_tax( $materials );
881 }
882
883 for ( $i = 0; $i < $cart_count; $i++ ) {
884 $cart_row = $cart[ $i ];
885
886 $line .= $tr_h;
887 $line_row = '';
888 if ( isset( $_REQUEST['check']['ID'] ) ) {
889 $line_row .= $td_h1 . $order_id . $td_f;
890 }
891 if ( isset( $_REQUEST['check']['deco_id'] ) ) {
892 $line_row .= $td_h . usces_get_deco_order_id( $order_id ) . $td_f;
893 }
894 if ( isset( $_REQUEST['check']['date'] ) ) {
895 $line_row .= $td_h . $data['order_date'] . $td_f;
896 }
897 if ( isset( $_REQUEST['check']['mem_id'] ) ) {
898 $line_row .= $td_h . $data['mem_id'] . $td_f;
899 }
900 if ( isset( $_REQUEST['check']['email'] ) ) {
901 $line_row .= $td_h . usces_entity_decode( $data['email'], $ext ) . $td_f;
902 }
903 if ( ! empty( $cscs_meta ) ) {
904 foreach ( $cscs_meta as $key => $entry ) {
905 if ( 'name_pre' === $entry['position'] ) {
906 $name = $entry['name'];
907 $cscs_key = 'cscs_' . $key;
908 if ( isset( $_REQUEST['check'][ $cscs_key ] ) ) {
909 $value = maybe_unserialize( $usces->get_order_meta_value( $cscs_key, $order_id ) );
910 $value = apply_filters( 'usces_filter_csv_cscs_meta_value', $value, $key, $order_id );
911 if ( empty( $value ) ) {
912 $value = '';
913 } elseif ( is_array( $value ) ) {
914 $concatval = '';
915 $c = '';
916 foreach ( $value as $v ) {
917 $concatval .= $c . $v;
918 $c = ' ';
919 }
920 $value = $concatval;
921 }
922 $line_row .= $td_h . usces_entity_decode( $value, $ext ) . $td_f;
923 }
924 }
925 }
926 }
927
928 switch ( $applyform ) {
929 case 'JP':
930 if ( isset( $_REQUEST['check']['name'] ) ) {
931 $line_row .= $td_h . usces_entity_decode( $data['name1'] . ' ' . $data['name2'], $ext ) . $td_f;
932 }
933 if ( isset( $_REQUEST['check']['kana'] ) ) {
934 $line_row .= $td_h . usces_entity_decode( $data['name3'] . ' ' . $data['name4'], $ext ) . $td_f;
935 }
936 break;
937 case 'US':
938 default:
939 if ( isset( $_REQUEST['check']['name'] ) ) {
940 $line_row .= $td_h . usces_entity_decode( $data['name2'] . ' ' . $data['name1'], $ext ) . $td_f;
941 }
942 break;
943 }
944
945 if ( ! empty( $cscs_meta ) ) {
946 foreach ( $cscs_meta as $key => $entry ) {
947 if ( 'name_after' === $entry['position'] ) {
948 $name = $entry['name'];
949 $cscs_key = 'cscs_' . $key;
950 if ( isset( $_REQUEST['check'][ $cscs_key ] ) ) {
951 $value = maybe_unserialize( $usces->get_order_meta_value( $cscs_key, $order_id ) );
952 $value = apply_filters( 'usces_filter_csv_cscs_meta_value', $value, $key, $order_id );
953 if ( empty( $value ) ) {
954 $value = '';
955 } elseif ( is_array( $value ) ) {
956 $concatval = '';
957 $c = '';
958 foreach ( $value as $v ) {
959 $concatval .= $c . $v;
960 $c = ' ';
961 }
962 $value = $concatval;
963 }
964 $line_row .= $td_h . usces_entity_decode( $value, $ext ) . $td_f;
965 }
966 }
967 }
968 }
969
970 $address_info = '';
971 switch ( $applyform ) {
972 case 'JP':
973 if ( isset( $_REQUEST['check']['zip'] ) ) {
974 $address_info .= $td_h . usces_entity_decode( $data['zipcode'], $ext ) . $td_f;
975 }
976 if ( isset( $_REQUEST['check']['country'] ) ) {
977 $address_info .= $td_h . ( isset( $usces_settings['country'][ $data['country'] ] ) ? $usces_settings['country'][ $data['country'] ] : '' ) . $td_f;
978 }
979 if ( isset( $_REQUEST['check']['pref'] ) ) {
980 $address_info .= $td_h . usces_entity_decode( $data['pref'], $ext ) . $td_f;
981 }
982 if ( isset( $_REQUEST['check']['address1'] ) ) {
983 $address_info .= $td_h . usces_entity_decode( $data['address1'], $ext ) . $td_f;
984 }
985 if ( isset( $_REQUEST['check']['address2'] ) ) {
986 $address_info .= $td_h . usces_entity_decode( $data['address2'], $ext ) . $td_f;
987 }
988 if ( isset( $_REQUEST['check']['address3'] ) ) {
989 $address_info .= $td_h . usces_entity_decode( $data['address3'], $ext ) . $td_f;
990 }
991 if ( isset( $_REQUEST['check']['tel'] ) ) {
992 $address_info .= $td_h . usces_entity_decode( $data['tel'], $ext ) . $td_f;
993 }
994 if ( isset( $_REQUEST['check']['fax'] ) ) {
995 $address_info .= $td_h . usces_entity_decode( $data['fax'], $ext ) . $td_f;
996 }
997 break;
998 case 'US':
999 default:
1000 if ( isset( $_REQUEST['check']['address2'] ) ) {
1001 $address_info .= $td_h . usces_entity_decode( $data['address2'], $ext ) . $td_f;
1002 }
1003 if ( isset( $_REQUEST['check']['address3'] ) ) {
1004 $address_info .= $td_h . usces_entity_decode( $data['address3'], $ext ) . $td_f;
1005 }
1006 if ( isset( $_REQUEST['check']['address1'] ) ) {
1007 $address_info .= $td_h . usces_entity_decode( $data['address1'], $ext ) . $td_f;
1008 }
1009 if ( isset( $_REQUEST['check']['pref'] ) ) {
1010 $address_info .= $td_h . usces_entity_decode( $data['pref'], $ext ) . $td_f;
1011 }
1012 if ( isset( $_REQUEST['check']['country'] ) ) {
1013 $address_info .= $td_h . ( isset( $usces_settings['country'][ $data['country'] ] ) ? $usces_settings['country'][ $data['country'] ] : '' ) . $td_f;
1014 }
1015 if ( isset( $_REQUEST['check']['zip'] ) ) {
1016 $address_info .= $td_h . usces_entity_decode( $data['zipcode'], $ext ) . $td_f;
1017 }
1018 if ( isset( $_REQUEST['check']['tel'] ) ) {
1019 $address_info .= $td_h . usces_entity_decode( $data['tel'], $ext ) . $td_f;
1020 }
1021 if ( isset( $_REQUEST['check']['fax'] ) ) {
1022 $address_info .= $td_h . usces_entity_decode( $data['fax'], $ext ) . $td_f;
1023 }
1024 break;
1025 }
1026 $address_info_args = compact( 'td_h', 'td_f', 'ext', 'order_id', 'applyform' );
1027 $line_row .= apply_filters( 'usces_filter_pro_csv_address_info', $address_info, $data, $address_info_args );
1028
1029 if ( ! empty( $cscs_meta ) ) {
1030 foreach ( $cscs_meta as $key => $entry ) {
1031 if ( 'fax_after' === $entry['position'] ) {
1032 $name = $entry['name'];
1033 $cscs_key = 'cscs_' . $key;
1034 if ( isset( $_REQUEST['check'][ $cscs_key ] ) ) {
1035 $value = maybe_unserialize( $usces->get_order_meta_value( $cscs_key, $order_id ) );
1036 $value = apply_filters( 'usces_filter_csv_cscs_meta_value', $value, $key, $order_id );
1037 if ( empty( $value ) ) {
1038 $value = '';
1039 } elseif ( is_array( $value ) ) {
1040 $concatval = '';
1041 $c = '';
1042 foreach ( $value as $v ) {
1043 $concatval .= $c . $v;
1044 $c = ' ';
1045 }
1046 $value = $concatval;
1047 }
1048 $line_row .= $td_h . usces_entity_decode( $value, $ext ) . $td_f;
1049 }
1050 }
1051 }
1052 }
1053 $line_row .= apply_filters( 'usces_filter_chk_pro_data_customer', null, $usces_opt_order, $order_id, $data );
1054 // ----------------------------------------------------------------------
1055 if ( ! empty( $csde_meta ) ) {
1056 foreach ( $csde_meta as $key => $entry ) {
1057 if ( 'name_pre' === $entry['position'] ) {
1058 $name = $entry['name'];
1059 $csde_key = 'csde_' . $key;
1060 if ( isset( $_REQUEST['check'][ $csde_key ] ) ) {
1061 $value = maybe_unserialize( $usces->get_order_meta_value( $csde_key, $order_id ) );
1062 $value = apply_filters( 'usces_filter_csv_csde_meta_value', $value, $key, $order_id );
1063 if ( empty( $value ) ) {
1064 $value = '';
1065 } elseif ( is_array( $value ) ) {
1066 $concatval = '';
1067 $c = '';
1068 foreach ( $value as $v ) {
1069 $concatval .= $c . $v;
1070 $c = ' ';
1071 }
1072 $value = $concatval;
1073 }
1074 $line_row .= $td_h . usces_entity_decode( $value, $ext ) . $td_f;
1075 }
1076 }
1077 }
1078 }
1079
1080 switch ( $applyform ) {
1081 case 'JP':
1082 if ( isset( $_REQUEST['check']['delivery_name'] ) ) {
1083 $line_row .= $td_h . usces_entity_decode( $deli['name1'] . ' ' . $deli['name2'], $ext ) . $td_f;
1084 }
1085 if ( isset( $_REQUEST['check']['delivery_kana'] ) ) {
1086 $line_row .= $td_h . usces_entity_decode( $deli['name3'] . ' ' . $deli['name4'], $ext ) . $td_f;
1087 }
1088 break;
1089 case 'US':
1090 default:
1091 if ( isset( $_REQUEST['check']['delivery_name'] ) ) {
1092 $line_row .= $td_h . usces_entity_decode( $deli['name2'] . ' ' . $deli['name1'], $ext ) . $td_f;
1093 }
1094 break;
1095 }
1096
1097 if ( ! empty( $csde_meta ) ) {
1098 foreach ( $csde_meta as $key => $entry ) {
1099 if ( 'name_after' === $entry['position'] ) {
1100 $name = $entry['name'] . '</td>';
1101 $csde_key = 'csde_' . $key;
1102 if ( isset( $_REQUEST['check'][ $csde_key ] ) ) {
1103 $value = maybe_unserialize( $usces->get_order_meta_value( $csde_key, $order_id ) );
1104 $value = apply_filters( 'usces_filter_csv_csde_meta_value', $value, $key, $order_id );
1105 if ( empty( $value ) ) {
1106 $value = '';
1107 } elseif ( is_array( $value ) ) {
1108 $concatval = '';
1109 $c = '';
1110 foreach ( $value as $v ) {
1111 $concatval .= $c . $v;
1112 $c = ' ';
1113 }
1114 $value = $concatval;
1115 }
1116 $line_row .= $td_h . usces_entity_decode( $value, $ext ) . $td_f;
1117 }
1118 }
1119 }
1120 }
1121
1122 $address_info = '';
1123 switch ( $applyform ) {
1124 case 'JP':
1125 if ( isset( $_REQUEST['check']['delivery_zip'] ) ) {
1126 $address_info .= $td_h . usces_entity_decode( $deli['zipcode'], $ext ) . $td_f;
1127 }
1128 if ( isset( $_REQUEST['check']['delivery_country'] ) ) {
1129 $address_info .= $td_h . ( isset( $usces_settings['country'][ $deli['country'] ] ) ? $usces_settings['country'][ $deli['country'] ] : '' ) . $td_f;
1130 }
1131 if ( isset( $_REQUEST['check']['delivery_pref'] ) ) {
1132 $address_info .= $td_h . usces_entity_decode( $deli['pref'], $ext ) . $td_f;
1133 }
1134 if ( isset( $_REQUEST['check']['delivery_address1'] ) ) {
1135 $address_info .= $td_h . usces_entity_decode( $deli['address1'], $ext ) . $td_f;
1136 }
1137 if ( isset( $_REQUEST['check']['delivery_address2'] ) ) {
1138 $address_info .= $td_h . usces_entity_decode( $deli['address2'], $ext ) . $td_f;
1139 }
1140 if ( isset( $_REQUEST['check']['delivery_address3'] ) ) {
1141 $address_info .= $td_h . usces_entity_decode( $deli['address3'], $ext ) . $td_f;
1142 }
1143 if ( isset( $_REQUEST['check']['delivery_tel'] ) ) {
1144 $address_info .= $td_h . usces_entity_decode( $deli['tel'], $ext ) . $td_f;
1145 }
1146 if ( isset( $_REQUEST['check']['delivery_fax'] ) ) {
1147 $address_info .= $td_h . usces_entity_decode( $deli['fax'], $ext ) . $td_f;
1148 }
1149 break;
1150 case 'US':
1151 default:
1152 if ( isset( $_REQUEST['check']['delivery_address2'] ) ) {
1153 $address_info .= $td_h . usces_entity_decode( $deli['address2'], $ext ) . $td_f;
1154 }
1155 if ( isset( $_REQUEST['check']['delivery_address3'] ) ) {
1156 $address_info .= $td_h . usces_entity_decode( $deli['address3'], $ext ) . $td_f;
1157 }
1158 if ( isset( $_REQUEST['check']['delivery_address1'] ) ) {
1159 $address_info .= $td_h . usces_entity_decode( $deli['address1'], $ext ) . $td_f;
1160 }
1161 if ( isset( $_REQUEST['check']['delivery_pref'] ) ) {
1162 $address_info .= $td_h . usces_entity_decode( $deli['pref'], $ext ) . $td_f;
1163 }
1164 if ( isset( $_REQUEST['check']['delivery_country'] ) ) {
1165 $address_info .= $td_h . ( isset( $usces_settings['country'][ $deli['country'] ] ) ? $usces_settings['country'][ $deli['country'] ] : '' ) . $td_f;
1166 }
1167 if ( isset( $_REQUEST['check']['delivery_zip'] ) ) {
1168 $address_info .= $td_h . usces_entity_decode( $deli['zipcode'], $ext ) . $td_f;
1169 }
1170 if ( isset( $_REQUEST['check']['delivery_tel'] ) ) {
1171 $address_info .= $td_h . usces_entity_decode( $deli['tel'], $ext ) . $td_f;
1172 }
1173 if ( isset( $_REQUEST['check']['delivery_fax'] ) ) {
1174 $address_info .= $td_h . usces_entity_decode( $deli['fax'], $ext ) . $td_f;
1175 }
1176 break;
1177 }
1178 $line_row .= apply_filters( 'usces_filter_pro_csv_delivery_address_info', $address_info, $deli, $address_info_args );
1179
1180 if ( ! empty( $csde_meta ) ) {
1181 foreach ( $csde_meta as $key => $entry ) {
1182 if ( 'fax_after' === $entry['position'] ) {
1183 $name = $entry['name'];
1184 $csde_key = 'csde_' . $key;
1185 if ( isset( $_REQUEST['check'][ $csde_key ] ) ) {
1186 $value = maybe_unserialize( $usces->get_order_meta_value( $csde_key, $order_id ) );
1187 $value = apply_filters( 'usces_filter_csv_csde_meta_value', $value, $key, $order_id );
1188 if ( empty( $value ) ) {
1189 $value = '';
1190 } elseif ( is_array( $value ) ) {
1191 $concatval = '';
1192 $c = '';
1193 foreach ( $value as $v ) {
1194 $concatval .= $c . $v;
1195 $c = ' ';
1196 }
1197 $value = $concatval;
1198 }
1199 $line_row .= $td_h . usces_entity_decode( $value, $ext ) . $td_f;
1200 }
1201 }
1202 }
1203 }
1204 $line_row .= apply_filters( 'usces_filter_chk_pro_data_delivery', null, $usces_opt_order, $order_id, $deli );
1205 // ----------------------------------------------------------------------
1206 if ( isset( $_REQUEST['check']['shipping_date'] ) ) {
1207 $line_row .= $td_h . $data['order_modified'] . $td_f;
1208 }
1209 if ( isset( $_REQUEST['check']['peyment_method'] ) ) {
1210 $line_row .= $td_h . $data['payment_name'] . $td_f;
1211 }
1212 if ( isset( $_REQUEST['check']['wc_trans_id'] ) ) {
1213 $line_row .= $td_h . $data['wc_trans_id'] . $td_f;
1214 }
1215 if ( isset( $_REQUEST['check']['delivery_method'] ) ) {
1216 $delivery_method = '';
1217 if ( '#NONE#' === strtoupper( $data['deli_method'] ) ) {
1218 $delivery_method = __( 'No preference', 'usces' );
1219 } else {
1220 foreach ( (array) $usces->options['delivery_method'] as $dkey => $delivery ) {
1221 if ( $delivery['id'] == $data['deli_method'] ) {
1222 $delivery_method = $delivery['name'];
1223 break;
1224 }
1225 }
1226 }
1227 $line_row .= $td_h . $delivery_method . $td_f;
1228 }
1229 if ( isset( $_REQUEST['check']['delivery_date'] ) ) {
1230 $line_row .= $td_h . $data['deli_date'] . $td_f;
1231 }
1232 if ( isset( $_REQUEST['check']['delivery_time'] ) ) {
1233 $line_row .= $td_h . $data['deli_time'] . $td_f;
1234 }
1235 if ( isset( $_REQUEST['check']['delidue_date'] ) ) {
1236 $order_delidue_date = ( '#NONE#' === strtoupper( $data['delidue_date'] ) ) ? '' : $data['delidue_date'];
1237 $line_row .= $td_h . $order_delidue_date . $td_f;
1238 }
1239 if ( isset( $_REQUEST['check']['status'] ) ) {
1240 $order_status = explode( ',', $data['process_status'] );
1241 $status = '';
1242 foreach ( (array) $order_status as $os ) {
1243 if ( isset( $usces_management_status[ $os ] ) ) {
1244 $status .= $usces_management_status[ $os ] . $sp;
1245 }
1246 }
1247 $line_row .= $td_h . trim( $status, $sp ) . $td_f;
1248 }
1249 if ( isset( $_REQUEST['check']['tracking_number'] ) ) {
1250 $line_row .= $td_h . $data['tracking_number'] . $td_f;
1251 }
1252 if ( isset( $_REQUEST['check']['total_amount'] ) ) {
1253 $line_row .= $td_h . usces_crform( $data['total_price'], false, false, 'return', false ) . $td_f;
1254 }
1255 if ( isset( $_REQUEST['check']['item_total_amount'] ) ) {
1256 $line_row .= $td_h . usces_crform( $data['item_total_price'], false, false, 'return', false ) . $td_f;
1257 }
1258 if ( usces_is_member_system() && usces_is_member_system_point() ) {
1259 if ( isset( $_REQUEST['check']['getpoint'] ) ) {
1260 $line_row .= $td_h . $data['getpoint'] . $td_f;
1261 }
1262 if ( isset( $_REQUEST['check']['usedpoint'] ) ) {
1263 $line_row .= $td_h . $data['usedpoint'] . $td_f;
1264 }
1265 }
1266 if ( isset( $_REQUEST['check']['discount'] ) ) {
1267 $line_row .= $td_h . usces_crform( $data['discount'], false, false, 'return', false ) . $td_f;
1268 }
1269 if ( usces_is_tax_display() && 'products' === usces_get_tax_target() ) {
1270 if ( $reduced_taxrate ) {
1271 if ( isset( $_REQUEST['check']['tax'] ) ) {
1272 if ( 'include' === usces_get_tax_mode() ) {
1273 $tax = $usces_tax->tax;
1274 } else {
1275 $tax = $data['tax'];
1276 }
1277 $line_row .= $td_h . usces_crform( $tax, false, false, 'return', false ) . $td_f;
1278 }
1279 if ( isset( $_REQUEST['check']['subtotal_standard'] ) ) {
1280 $line_row .= $td_h . usces_crform( $usces_tax->subtotal_standard, false, false, 'return', false ) . $td_f;
1281 }
1282 if ( isset( $_REQUEST['check']['tax_standard'] ) ) {
1283 $line_row .= $td_h . usces_crform( $usces_tax->tax_standard, false, false, 'return', false ) . $td_f;
1284 }
1285 if ( isset( $_REQUEST['check']['subtotal_reduced'] ) ) {
1286 $line_row .= $td_h . usces_crform( $usces_tax->subtotal_reduced, false, false, 'return', false ) . $td_f;
1287 }
1288 if ( isset( $_REQUEST['check']['tax_reduced'] ) ) {
1289 $line_row .= $td_h . usces_crform( $usces_tax->tax_reduced, false, false, 'return', false ) . $td_f;
1290 }
1291 } else {
1292 if ( isset( $_REQUEST['check']['tax'] ) ) {
1293 if ( 'include' === usces_get_tax_mode() ) {
1294 $materials = array(
1295 'total_items_price' => $data['item_total_price'],
1296 'discount' => $data['discount'],
1297 'shipping_charge' => $data['shipping_charge'],
1298 'cod_fee' => $data['cod_fee'],
1299 'use_point' => $data['usedpoint'],
1300 'order_id' => $data['ID'],
1301 );
1302 $tax = usces_internal_tax( $materials, 'return' );
1303 } else {
1304 $tax = $data['tax'];
1305 }
1306 $line_row .= $td_h . usces_crform( $tax, false, false, 'return', false ) . $td_f;
1307 }
1308 if ( isset( $_REQUEST['check']['subtotal_standard'] ) ) {
1309 $line_row .= $td_h . '' . $td_f;
1310 }
1311 if ( isset( $_REQUEST['check']['tax_standard'] ) ) {
1312 $line_row .= $td_h . '' . $td_f;
1313 }
1314 if ( isset( $_REQUEST['check']['subtotal_reduced'] ) ) {
1315 $line_row .= $td_h . '' . $td_f;
1316 }
1317 if ( isset( $_REQUEST['check']['tax_reduced'] ) ) {
1318 $line_row .= $td_h . '' . $td_f;
1319 }
1320 }
1321 }
1322 if ( isset( $_REQUEST['check']['shipping_charge'] ) ) {
1323 $line_row .= $td_h . usces_crform( $data['shipping_charge'], false, false, 'return', false ) . $td_f;
1324 }
1325 if ( isset( $_REQUEST['check']['cod_fee'] ) ) {
1326 $line_row .= $td_h . usces_crform( $data['cod_fee'], false, false, 'return', false ) . $td_f;
1327 }
1328 if ( usces_is_tax_display() && 'products' !== usces_get_tax_target() ) {
1329 if ( $reduced_taxrate ) {
1330 if ( isset( $_REQUEST['check']['tax'] ) ) {
1331 if ( 'include' === usces_get_tax_mode() ) {
1332 $tax = $usces_tax->tax;
1333 } else {
1334 $tax = $data['tax'];
1335 }
1336 $line_row .= $td_h . usces_crform( $tax, false, false, 'return', false ) . $td_f;
1337 }
1338 if ( isset( $_REQUEST['check']['subtotal_standard'] ) ) {
1339 $line_row .= $td_h . usces_crform( $usces_tax->subtotal_standard, false, false, 'return', false ) . $td_f;
1340 }
1341 if ( isset( $_REQUEST['check']['tax_standard'] ) ) {
1342 $line_row .= $td_h . usces_crform( $usces_tax->tax_standard, false, false, 'return', false ) . $td_f;
1343 }
1344 if ( isset( $_REQUEST['check']['subtotal_reduced'] ) ) {
1345 $line_row .= $td_h . usces_crform( $usces_tax->subtotal_reduced, false, false, 'return', false ) . $td_f;
1346 }
1347 if ( isset( $_REQUEST['check']['tax_reduced'] ) ) {
1348 $line_row .= $td_h . usces_crform( $usces_tax->tax_reduced, false, false, 'return', false ) . $td_f;
1349 }
1350 } else {
1351 if ( isset( $_REQUEST['check']['tax'] ) ) {
1352 if ( 'include' === usces_get_tax_mode() ) {
1353 $materials = array(
1354 'total_items_price' => $data['item_total_price'],
1355 'discount' => $data['discount'],
1356 'shipping_charge' => $data['shipping_charge'],
1357 'cod_fee' => $data['cod_fee'],
1358 'use_point' => $data['usedpoint'],
1359 'order_id' => $data['ID'],
1360 );
1361 $tax = usces_internal_tax( $materials, 'return' );
1362 } else {
1363 $tax = $data['tax'];
1364 }
1365 $line_row .= $td_h . usces_crform( $tax, false, false, 'return', false ) . $td_f;
1366 }
1367 if ( isset( $_REQUEST['check']['subtotal_standard'] ) ) {
1368 $line_row .= $td_h . '' . $td_f;
1369 }
1370 if ( isset( $_REQUEST['check']['tax_standard'] ) ) {
1371 $line_row .= $td_h . '' . $td_f;
1372 }
1373 if ( isset( $_REQUEST['check']['subtotal_reduced'] ) ) {
1374 $line_row .= $td_h . '' . $td_f;
1375 }
1376 if ( isset( $_REQUEST['check']['tax_reduced'] ) ) {
1377 $line_row .= $td_h . '' . $td_f;
1378 }
1379 }
1380 }
1381 if ( isset( $_REQUEST['check']['note'] ) ) {
1382 $line_row .= $td_h . usces_entity_decode( $data['note'], $ext ) . $td_f;
1383 }
1384 if ( ! empty( $csod_meta ) ) {
1385 foreach ( $csod_meta as $key => $entry ) {
1386 $name = $entry['name'];
1387 $csod_key = 'csod_' . $key;
1388 if ( isset( $_REQUEST['check'][ $csod_key ] ) ) {
1389 $value = maybe_unserialize( $usces->get_order_meta_value( $csod_key, $order_id ) );
1390 $value = apply_filters( 'usces_filter_csv_csod_meta_value', $value, $key, $order_id );
1391 if ( empty( $value ) ) {
1392 $value = '';
1393 } elseif ( is_array( $value ) ) {
1394 $concatval = '';
1395 $c = '';
1396 foreach ( $value as $v ) {
1397 $concatval .= $c . $v;
1398 $c = ' ';
1399 }
1400 $value = $concatval;
1401 }
1402 $line_row .= $td_h . usces_entity_decode( $value, $ext ) . $td_f;
1403 }
1404 }
1405 }
1406 $line_row .= apply_filters( 'usces_filter_chk_pro_data_order', null, $usces_opt_order, $order_id, $data, $cart_row );
1407
1408 if ( isset( $_REQUEST['check']['item_code'] ) ) {
1409 $line_row .= $td_h . $cart_row['item_code'] . $td_f;
1410 }
1411 if ( isset( $_REQUEST['check']['sku_code'] ) ) {
1412 $line_row .= $td_h . $cart_row['sku_code'] . $td_f;
1413 }
1414 if ( isset( $_REQUEST['check']['item_name'] ) ) {
1415 $line_row .= $td_h . usces_entity_decode( $cart_row['item_name'], $ext ) . $td_f;
1416 }
1417 if ( isset( $_REQUEST['check']['sku_name'] ) ) {
1418 $line_row .= $td_h . usces_entity_decode( $cart_row['sku_name'], $ext ) . $td_f;
1419 }
1420 if ( isset( $_REQUEST['check']['options'] ) ) {
1421 $options = usces_get_ordercart_meta( 'option', $cart_row['cart_id'] );
1422 $optstr = '';
1423 if ( $options && is_array( $options ) && count( $options ) > 0 ) {
1424 foreach ( (array) $options as $key => $value ) {
1425 if ( ! empty( $value['meta_key'] ) ) {
1426 $meta_value = maybe_unserialize( $value['meta_value'] );
1427 if ( is_array( $meta_value ) ) {
1428 $meta_vals = '';
1429 foreach ( $meta_value as $array_val ) {
1430 $meta_vals .= $nb . urldecode( $array_val );
1431 }
1432 $optstr .= usces_entity_decode( urldecode( $value['meta_key'] ) . $sp . $meta_vals, $ext ) . $nb;
1433 } else {
1434 $optstr .= usces_entity_decode( urldecode( $value['meta_key'] ) . $sp . urldecode( $value['meta_value'] ), $ext ) . $nb;
1435 }
1436 }
1437 }
1438 }
1439 $optstr = apply_filters( 'usces_filter_csvpro_itemopt_value', $optstr, $options, $cart_row, $usces_opt_order, $order_id, $data );
1440 $line_row .= $td_h . $optstr . $td_f;
1441 }
1442 if ( isset( $_REQUEST['check']['quantity'] ) ) {
1443 $line_row .= $td_h . $cart_row['quantity'] . $td_f;
1444 }
1445 if ( isset( $_REQUEST['check']['price'] ) ) {
1446 $line_row .= $td_h . usces_crform( $cart_row['price'], false, false, 'return', false ) . $td_f;
1447 }
1448 if ( isset( $_REQUEST['check']['unit'] ) ) {
1449 $line_row .= $td_h . usces_entity_decode( $cart_row['unit'], $ext ) . $td_f;
1450 }
1451 if ( isset( $_REQUEST['check']['admin_memo'] ) ) {
1452 $line_row .= $td_h . usces_entity_decode( $data['admin_memo'], $ext ) . $td_f;
1453 }
1454 $line_row = preg_replace( "/\n,/", "\n", ltrim( $line_row, ',' ) );
1455 $line_row = apply_filters( 'usces_filter_chk_pro_data_detail_line_row', $line_row, $usces_opt_order, $data, $cart_row );
1456 $line .= $line_row;
1457 $line .= apply_filters( 'usces_filter_chk_pro_data_detail', null, $usces_opt_order, $data, $cart_row, $line_row );
1458 $line .= $tr_f . $lf;
1459 }
1460 }
1461 $line .= $table_f;
1462 $line = apply_filters( 'wc_filter_chk_pro_data_order', $line );
1463
1464 // ==========================================================================
1465
1466 header( 'Content-Type: application/octet-stream' );
1467 header( 'Content-Disposition: attachment; filename=usces_product_list.' . $ext );
1468 mb_http_output( 'pass' );
1469 print( mb_convert_encoding( $line, apply_filters( 'usces_filter_output_csv_encode', 'SJIS-win' ), 'UTF-8' ) );
1470 exit();
1471 }
1472
1473 /**
1474 * Order list download.
1475 */
1476 public function download_order_list() {
1477 global $wpdb, $usces, $usces_settings;
1478
1479 if ( ! current_user_can( 'wel_manage_order' ) ) {
1480 wp_die( __( 'You do not have sufficient privileges to perform this operation.', 'usces' ) );
1481 }
1482 check_admin_referer( 'order_list', 'wc_nonce' );
1483
1484 require_once USCES_PLUGIN_DIR . '/classes/orderList2.class.php';
1485
1486 $all_column = true;
1487 $orderlist = new WlcOrderList( $all_column );
1488 $orderlist->pageLimit = 'off';
1489 $arr_column = $orderlist->get_column();
1490 $res = $orderlist->MakeTable();
1491 $arr_search = $orderlist->GetSearchs();
1492 $rows = $orderlist->rows;
1493
1494 if ( ! empty( $_REQUEST['listcheck'] ) ) {
1495 $listcheck = ( is_array( $_REQUEST['listcheck'] ) ) ? $_REQUEST['listcheck'] : explode( ',', $_REQUEST['listcheck'] );
1496 $rows = array_filter( $rows, function( $row ) use ( $listcheck ) {
1497 return in_array( (int)$row['ID'], array_map( 'intval', $listcheck ), true );
1498 } );
1499 }
1500
1501 $ext = wp_unslash( $_REQUEST['ftype'] );
1502 if ( 'csv' === $ext ) {
1503 $table_h = '';
1504 $table_f = '';
1505 $tr_h = '';
1506 $tr_f = '';
1507 $th_h1 = '"';
1508 $th_h = ',"';
1509 $th_f = '"';
1510 $td_h1 = '"';
1511 $td_h = ',"';
1512 $td_f = '"';
1513 $sp = ':';
1514 $lf = "\n";
1515 } else {
1516 exit();
1517 }
1518
1519 $csod_meta = usces_has_custom_field_meta( 'order' );
1520 $cscs_meta = usces_has_custom_field_meta( 'customer' );
1521 $csde_meta = usces_has_custom_field_meta( 'delivery' );
1522 $applyform = usces_get_apply_addressform( $usces->options['system']['addressform'] );
1523 $usces_tax = Welcart_Tax::get_instance();
1524
1525 // ==========================================================================
1526
1527 $usces_opt_order = get_option( 'usces_opt_order' );
1528 if ( ! is_array( $usces_opt_order ) ) {
1529 $usces_opt_order = array();
1530 }
1531 $usces_opt_order['ftype_ord'] = $ext;
1532 $chk_ord = array();
1533 $chk_ord['ID'] = ( isset( $_REQUEST['check']['ID'] ) ) ? 1 : 0;
1534 $chk_ord['deco_id'] = ( isset( $_REQUEST['check']['deco_id'] ) ) ? 1 : 0;
1535 $chk_ord['date'] = ( isset( $_REQUEST['check']['date'] ) ) ? 1 : 0;
1536 $chk_ord['mem_id'] = ( isset( $_REQUEST['check']['mem_id'] ) ) ? 1 : 0;
1537 $chk_ord['email'] = ( isset( $_REQUEST['check']['email'] ) ) ? 1 : 0;
1538 if ( ! empty( $cscs_meta ) ) {
1539 foreach ( $cscs_meta as $key => $entry ) {
1540 if ( 'name_pre' === $entry['position'] ) {
1541 $name = $entry['name'];
1542 $cscs_key = 'cscs_' . $key;
1543 $chk_ord[ $cscs_key ] = ( isset( $_REQUEST['check'][ $cscs_key ] ) ) ? 1 : 0;
1544 }
1545 }
1546 }
1547 $chk_ord['name'] = ( isset( $_REQUEST['check']['name'] ) ) ? 1 : 0;
1548 if ( 'JP' === $applyform ) {
1549 $chk_ord['kana'] = ( isset( $_REQUEST['check']['kana'] ) ) ? 1 : 0;
1550 }
1551 if ( ! empty( $cscs_meta ) ) {
1552 foreach ( $cscs_meta as $key => $entry ) {
1553 if ( 'name_after' === $entry['position'] ) {
1554 $name = $entry['name'];
1555 $cscs_key = 'cscs_' . $key;
1556 $chk_ord[ $cscs_key ] = ( isset( $_REQUEST['check'][ $cscs_key ] ) ) ? 1 : 0;
1557 }
1558 }
1559 }
1560 $chk_ord['zip'] = ( isset( $_REQUEST['check']['zip'] ) ) ? 1 : 0;
1561 $chk_ord['country'] = ( isset( $_REQUEST['check']['country'] ) ) ? 1 : 0;
1562 $chk_ord['pref'] = ( isset( $_REQUEST['check']['pref'] ) ) ? 1 : 0;
1563 $chk_ord['address1'] = ( isset( $_REQUEST['check']['address1'] ) ) ? 1 : 0;
1564 $chk_ord['address2'] = ( isset( $_REQUEST['check']['address2'] ) ) ? 1 : 0;
1565 $chk_ord['address3'] = ( isset( $_REQUEST['check']['address3'] ) ) ? 1 : 0;
1566 $chk_ord['tel'] = ( isset( $_REQUEST['check']['tel'] ) ) ? 1 : 0;
1567 $chk_ord['fax'] = ( isset( $_REQUEST['check']['fax'] ) ) ? 1 : 0;
1568 if ( ! empty( $cscs_meta ) ) {
1569 foreach ( $cscs_meta as $key => $entry ) {
1570 if ( 'fax_after' === $entry['position'] ) {
1571 $name = $entry['name'];
1572 $cscs_key = 'cscs_' . $key;
1573 $chk_ord[ $cscs_key ] = ( isset( $_REQUEST['check'][ $cscs_key ] ) ) ? 1 : 0;
1574 }
1575 }
1576 }
1577 // --------------------------------------------------------------------------
1578 if ( ! empty( $csde_meta ) ) {
1579 foreach ( $csde_meta as $key => $entry ) {
1580 if ( 'name_pre' === $entry['position'] ) {
1581 $name = $entry['name'];
1582 $csde_key = 'csde_' . $key;
1583 $chk_ord[ $csde_key ] = ( isset( $_REQUEST['check'][ $csde_key ] ) ) ? 1 : 0;
1584 }
1585 }
1586 }
1587 $chk_ord['delivery_name'] = ( isset( $_REQUEST['check']['delivery_name'] ) ) ? 1 : 0;
1588 if ( 'JP' === $applyform ) {
1589 $chk_ord['delivery_kana'] = ( isset( $_REQUEST['check']['delivery_kana'] ) ) ? 1 : 0;
1590 }
1591 if ( ! empty( $csde_meta ) ) {
1592 foreach ( $csde_meta as $key => $entry ) {
1593 if ( 'name_after' === $entry['position'] ) {
1594 $name = $entry['name'];
1595 $csde_key = 'csde_' . $key;
1596 $chk_ord[ $csde_key ] = ( isset( $_REQUEST['check'][ $csde_key ] ) ) ? 1 : 0;
1597 }
1598 }
1599 }
1600 $chk_ord['delivery_zip'] = ( isset( $_REQUEST['check']['delivery_zip'] ) ) ? 1 : 0;
1601 $chk_ord['delivery_country'] = ( isset( $_REQUEST['check']['delivery_country'] ) ) ? 1 : 0;
1602 $chk_ord['delivery_pref'] = ( isset( $_REQUEST['check']['delivery_pref'] ) ) ? 1 : 0;
1603 $chk_ord['delivery_address1'] = ( isset( $_REQUEST['check']['delivery_address1'] ) ) ? 1 : 0;
1604 $chk_ord['delivery_address2'] = ( isset( $_REQUEST['check']['delivery_address2'] ) ) ? 1 : 0;
1605 $chk_ord['delivery_address3'] = ( isset( $_REQUEST['check']['delivery_address3'] ) ) ? 1 : 0;
1606 $chk_ord['delivery_tel'] = ( isset( $_REQUEST['check']['delivery_tel'] ) ) ? 1 : 0;
1607 $chk_ord['delivery_fax'] = ( isset( $_REQUEST['check']['delivery_fax'] ) ) ? 1 : 0;
1608 if ( ! empty( $csde_meta ) ) {
1609 foreach ( $csde_meta as $key => $entry ) {
1610 if ( 'fax_after' === $entry['position'] ) {
1611 $name = $entry['name'];
1612 $csde_key = 'csde_' . $key;
1613 $chk_ord[ $csde_key ] = ( isset( $_REQUEST['check'][ $csde_key ] ) ) ? 1 : 0;
1614 }
1615 }
1616 }
1617 // --------------------------------------------------------------------------
1618 $chk_ord['shipping_date'] = ( isset( $_REQUEST['check']['shipping_date'] ) ) ? 1 : 0;
1619 $chk_ord['peyment_method'] = ( isset( $_REQUEST['check']['peyment_method'] ) ) ? 1 : 0;
1620 $chk_ord['wc_trans_id'] = ( isset( $_REQUEST['check']['wc_trans_id'] ) ) ? 1 : 0;
1621 $chk_ord['delivery_method'] = ( isset( $_REQUEST['check']['delivery_method'] ) ) ? 1 : 0;
1622 $chk_ord['delivery_date'] = ( isset( $_REQUEST['check']['delivery_date'] ) ) ? 1 : 0;
1623 $chk_ord['delivery_time'] = ( isset( $_REQUEST['check']['delivery_time'] ) ) ? 1 : 0;
1624 $chk_ord['delidue_date'] = ( isset( $_REQUEST['check']['delidue_date'] ) ) ? 1 : 0;
1625 $chk_ord['status'] = ( isset( $_REQUEST['check']['status'] ) ) ? 1 : 0;
1626 $chk_ord['tracking_number'] = ( isset( $_REQUEST['check']['tracking_number'] ) ) ? 1 : 0;
1627 $chk_ord['total_amount'] = ( isset( $_REQUEST['check']['total_amount'] ) ) ? 1 : 0;
1628 $chk_ord['item_total_amount'] = ( isset( $_REQUEST['check']['item_total_amount'] ) ) ? 1 : 0;
1629 if ( usces_is_member_system() && usces_is_member_system_point() ) {
1630 $chk_ord['getpoint'] = ( isset( $_REQUEST['check']['getpoint'] ) ) ? 1 : 0;
1631 $chk_ord['usedpoint'] = ( isset( $_REQUEST['check']['usedpoint'] ) ) ? 1 : 0;
1632 }
1633 $chk_ord['discount'] = ( isset( $_REQUEST['check']['discount'] ) ) ? 1 : 0;
1634 $chk_ord['shipping_charge'] = ( isset( $_REQUEST['check']['shipping_charge'] ) ) ? 1 : 0;
1635 $chk_ord['cod_fee'] = ( isset( $_REQUEST['check']['cod_fee'] ) ) ? 1 : 0;
1636 if ( usces_is_tax_display() ) {
1637 $chk_ord['tax'] = ( isset( $_REQUEST['check']['tax'] ) ) ? 1 : 0;
1638 if ( usces_is_reduced_taxrate() ) {
1639 $chk_ord['subtotal_standard'] = ( isset( $_REQUEST['check']['subtotal_standard'] ) ) ? 1 : 0;
1640 $chk_ord['tax_standard'] = ( isset( $_REQUEST['check']['tax_standard'] ) ) ? 1 : 0;
1641 $chk_ord['subtotal_reduced'] = ( isset( $_REQUEST['check']['subtotal_reduced'] ) ) ? 1 : 0;
1642 $chk_ord['tax_reduced'] = ( isset( $_REQUEST['check']['tax_reduced'] ) ) ? 1 : 0;
1643 }
1644 }
1645 $chk_ord['note'] = ( isset( $_REQUEST['check']['note'] ) ) ? 1 : 0;
1646 if ( ! empty( $csod_meta ) ) {
1647 foreach ( $csod_meta as $key => $entry ) {
1648 $name = $entry['name'];
1649 $csod_key = 'csod_' . $key;
1650 $chk_ord[ $csod_key ] = ( isset( $_REQUEST['check'][ $csod_key ] ) ) ? 1 : 0;
1651 }
1652 }
1653 $chk_ord['admin_memo'] = ( isset( $_REQUEST['check']['admin_memo'] ) ) ? 1 : 0;
1654 $usces_opt_order['chk_ord'] = apply_filters( 'usces_filter_chk_ord', $chk_ord );
1655 update_option( 'usces_opt_order', $usces_opt_order );
1656
1657 // ==========================================================================
1658
1659 if ( isset( $_REQUEST['check']['status'] ) ) {
1660 $usces_management_status = apply_filters( 'usces_filter_management_status', get_option( 'usces_management_status' ) );
1661 $usces_management_status['new'] = __( 'new order', 'usces' );
1662 }
1663
1664 // ==========================================================================
1665
1666 $line = $table_h;
1667 $line .= $tr_h;
1668 $line_col = '';
1669 if ( isset( $_REQUEST['check']['ID'] ) ) {
1670 $line_col .= $th_h1 . __( 'ID', 'usces' ) . $th_f;
1671 }
1672 if ( isset( $_REQUEST['check']['deco_id'] ) ) {
1673 $line_col .= $th_h . __( 'Order number', 'usces' ) . $th_f;
1674 }
1675 if ( isset( $_REQUEST['check']['date'] ) ) {
1676 $line_col .= $th_h . __( 'order date', 'usces' ) . $th_f;
1677 }
1678 if ( isset( $_REQUEST['check']['mem_id'] ) ) {
1679 $line_col .= $th_h . __( 'membership number', 'usces' ) . $th_f;
1680 }
1681 if ( isset( $_REQUEST['check']['email'] ) ) {
1682 $line_col .= $th_h . __( 'e-mail', 'usces' ) . $th_f;
1683 }
1684 if ( ! empty( $cscs_meta ) ) {
1685 foreach ( $cscs_meta as $key => $entry ) {
1686 if ( 'name_pre' === $entry['position'] ) {
1687 $name = $entry['name'];
1688 $cscs_key = 'cscs_' . $key;
1689 if ( isset( $_REQUEST['check'][ $cscs_key ] ) ) {
1690 $line_col .= $th_h . usces_entity_decode( $name, $ext ) . $th_f;
1691 }
1692 }
1693 }
1694 }
1695 if ( isset( $_REQUEST['check']['name'] ) ) {
1696 $line_col .= $th_h . __( 'name', 'usces' ) . $th_f;
1697 }
1698 if ( 'JP' === $applyform ) {
1699 if ( isset( $_REQUEST['check']['kana'] ) ) {
1700 $line_col .= $th_h . __( 'furigana', 'usces' ) . $th_f;
1701 }
1702 }
1703 if ( ! empty( $cscs_meta ) ) {
1704 foreach ( $cscs_meta as $key => $entry ) {
1705 if ( 'name_after' === $entry['position'] ) {
1706 $name = $entry['name'];
1707 $cscs_key = 'cscs_' . $key;
1708 if ( isset( $_REQUEST['check'][ $cscs_key ] ) ) {
1709 $line_col .= $th_h . usces_entity_decode( $name, $ext ) . $th_f;
1710 }
1711 }
1712 }
1713 }
1714
1715 switch ( $applyform ) {
1716 case 'JP':
1717 if ( isset( $_REQUEST['check']['zip'] ) ) {
1718 $line_col .= $th_h . __( 'Zip/Postal Code', 'usces' ) . $th_f;
1719 }
1720 if ( isset( $_REQUEST['check']['country'] ) ) {
1721 $line_col .= $th_h . __( 'Country', 'usces' ) . $th_f;
1722 }
1723 if ( isset( $_REQUEST['check']['pref'] ) ) {
1724 $line_col .= $th_h . __( 'Province', 'usces' ) . $th_f;
1725 }
1726 if ( isset( $_REQUEST['check']['address1'] ) ) {
1727 $line_col .= $th_h . __( 'city', 'usces' ) . $th_f;
1728 }
1729 if ( isset( $_REQUEST['check']['address2'] ) ) {
1730 $line_col .= $th_h . __( 'numbers', 'usces' ) . $th_f;
1731 }
1732 if ( isset( $_REQUEST['check']['address3'] ) ) {
1733 $line_col .= $th_h . __( 'building name', 'usces' ) . $th_f;
1734 }
1735 if ( isset( $_REQUEST['check']['tel'] ) ) {
1736 $line_col .= $th_h . __( 'Phone number', 'usces' ) . $th_f;
1737 }
1738 if ( isset( $_REQUEST['check']['fax'] ) ) {
1739 $line_col .= $th_h . __( 'FAX number', 'usces' ) . $th_f;
1740 }
1741 break;
1742 case 'US':
1743 default:
1744 if ( isset( $_REQUEST['check']['address2'] ) ) {
1745 $line_col .= $th_h . __( 'Address Line1', 'usces' ) . $th_f;
1746 }
1747 if ( isset( $_REQUEST['check']['address3'] ) ) {
1748 $line_col .= $th_h . __( 'Address Line2', 'usces' ) . $th_f;
1749 }
1750 if ( isset( $_REQUEST['check']['address1'] ) ) {
1751 $line_col .= $th_h . __( 'city', 'usces' ) . $th_f;
1752 }
1753 if ( isset( $_REQUEST['check']['pref'] ) ) {
1754 $line_col .= $th_h . __( 'State', 'usces' ) . $th_f;
1755 }
1756 if ( isset( $_REQUEST['check']['country'] ) ) {
1757 $line_col .= $th_h . __( 'Country', 'usces' ) . $th_f;
1758 }
1759 if ( isset( $_REQUEST['check']['zip'] ) ) {
1760 $line_col .= $th_h . __( 'Zip', 'usces' ) . $th_f;
1761 }
1762 if ( isset( $_REQUEST['check']['tel'] ) ) {
1763 $line_col .= $th_h . __( 'Phone number', 'usces' ) . $th_f;
1764 }
1765 if ( isset( $_REQUEST['check']['fax'] ) ) {
1766 $line_col .= $th_h . __( 'FAX number', 'usces' ) . $th_f;
1767 }
1768 break;
1769 }
1770
1771 if ( ! empty( $cscs_meta ) ) {
1772 foreach ( $cscs_meta as $key => $entry ) {
1773 if ( 'fax_after' === $entry['position'] ) {
1774 $name = $entry['name'];
1775 $cscs_key = 'cscs_' . $key;
1776 if ( isset( $_REQUEST['check'][ $cscs_key ] ) ) {
1777 $line_col .= $th_h . usces_entity_decode( $name, $ext ) . $th_f;
1778 }
1779 }
1780 }
1781 }
1782 $line_col .= apply_filters( 'usces_filter_chk_ord_label_customer', null, $usces_opt_order, $rows );
1783 // --------------------------------------------------------------------------
1784 if ( ! empty( $csde_meta ) ) {
1785 foreach ( $csde_meta as $key => $entry ) {
1786 if ( 'name_pre' === $entry['position'] ) {
1787 $name = $entry['name'];
1788 $csde_key = 'csde_' . $key;
1789 if ( isset( $_REQUEST['check'][ $csde_key ] ) ) {
1790 $line_col .= $th_h . usces_entity_decode( $name, $ext ) . $th_f;
1791 }
1792 }
1793 }
1794 }
1795 if ( isset( $_REQUEST['check']['delivery_name'] ) ) {
1796 $line_col .= $th_h . __( 'Shipping Name', 'usces' ) . $th_f;
1797 }
1798 if ( 'JP' === $applyform ) {
1799 if ( isset( $_REQUEST['check']['delivery_kana'] ) ) {
1800 $line_col .= $th_h . __( 'Shipping Furigana', 'usces' ) . $th_f;
1801 }
1802 }
1803 if ( ! empty( $csde_meta ) ) {
1804 foreach ( $csde_meta as $key => $entry ) {
1805 if ( 'name_after' === $entry['position'] ) {
1806 $name = $entry['name'];
1807 $csde_key = 'csde_' . $key;
1808 if ( isset( $_REQUEST['check'][ $csde_key ] ) ) {
1809 $line_col .= $th_h . usces_entity_decode( $name, $ext ) . $th_f;
1810 }
1811 }
1812 }
1813 }
1814
1815 switch ( $applyform ) {
1816 case 'JP':
1817 if ( isset( $_REQUEST['check']['delivery_zip'] ) ) {
1818 $line_col .= $th_h . __( 'Shipping Zip', 'usces' ) . $th_f;
1819 }
1820 if ( isset( $_REQUEST['check']['delivery_country'] ) ) {
1821 $line_col .= $th_h . __( 'Shipping Country', 'usces' ) . $th_f;
1822 }
1823 if ( isset( $_REQUEST['check']['delivery_pref'] ) ) {
1824 $line_col .= $th_h . __( 'Shipping State', 'usces' ) . $th_f;
1825 }
1826 if ( isset( $_REQUEST['check']['delivery_address1'] ) ) {
1827 $line_col .= $th_h . __( 'Shipping City', 'usces' ) . $th_f;
1828 }
1829 if ( isset( $_REQUEST['check']['delivery_address2'] ) ) {
1830 $line_col .= $th_h . __( 'Shipping Address1', 'usces' ) . $th_f;
1831 }
1832 if ( isset( $_REQUEST['check']['delivery_address3'] ) ) {
1833 $line_col .= $th_h . __( 'Shipping Address2', 'usces' ) . $th_f;
1834 }
1835 if ( isset( $_REQUEST['check']['delivery_tel'] ) ) {
1836 $line_col .= $th_h . __( 'Shipping Phone', 'usces' ) . $th_f;
1837 }
1838 if ( isset( $_REQUEST['check']['delivery_fax'] ) ) {
1839 $line_col .= $th_h . __( 'Shipping FAX', 'usces' ) . $th_f;
1840 }
1841 break;
1842 case 'US':
1843 default:
1844 if ( isset( $_REQUEST['check']['delivery_address2'] ) ) {
1845 $line_col .= $th_h . __( 'Shipping Address1', 'usces' ) . $th_f;
1846 }
1847 if ( isset( $_REQUEST['check']['delivery_address3'] ) ) {
1848 $line_col .= $th_h . __( 'Shipping Address2', 'usces' ) . $th_f;
1849 }
1850 if ( isset( $_REQUEST['check']['delivery_address1'] ) ) {
1851 $line_col .= $th_h . __( 'Shipping City', 'usces' ) . $th_f;
1852 }
1853 if ( isset( $_REQUEST['check']['delivery_pref'] ) ) {
1854 $line_col .= $th_h . __( 'Shipping State', 'usces' ) . $th_f;
1855 }
1856 if ( isset( $_REQUEST['check']['delivery_country'] ) ) {
1857 $line_col .= $th_h . __( 'Shipping Country', 'usces' ) . $th_f;
1858 }
1859 if ( isset( $_REQUEST['check']['delivery_zip'] ) ) {
1860 $line_col .= $th_h . __( 'Shipping Zip', 'usces' ) . $th_f;
1861 }
1862 if ( isset( $_REQUEST['check']['delivery_tel'] ) ) {
1863 $line_col .= $th_h . __( 'Shipping Phone', 'usces' ) . $th_f;
1864 }
1865 if ( isset( $_REQUEST['check']['delivery_fax'] ) ) {
1866 $line_col .= $th_h . __( 'Shipping FAX', 'usces' ) . $th_f;
1867 }
1868 break;
1869 }
1870
1871 if ( ! empty( $csde_meta ) ) {
1872 foreach ( $csde_meta as $key => $entry ) {
1873 if ( 'fax_after' === $entry['position'] ) {
1874 $name = $entry['name'];
1875 $csde_key = 'csde_' . $key;
1876 if ( isset( $_REQUEST['check'][ $csde_key ] ) ) {
1877 $line_col .= $th_h . usces_entity_decode( $name, $ext ) . $th_f;
1878 }
1879 }
1880 }
1881 }
1882 $line_col .= apply_filters( 'usces_filter_chk_ord_label_delivery', null, $usces_opt_order, $rows );
1883 // --------------------------------------------------------------------------
1884 if ( isset( $_REQUEST['check']['shipping_date'] ) ) {
1885 $line_col .= $th_h . __( 'shpping date', 'usces' ) . $th_f;
1886 }
1887 if ( isset( $_REQUEST['check']['peyment_method'] ) ) {
1888 $line_col .= $th_h . __( 'payment method', 'usces' ) . $th_f;
1889 }
1890 if ( isset( $_REQUEST['check']['wc_trans_id'] ) ) {
1891 $line_col .= $th_h . __( 'Transaction ID', 'usces' ) . $th_f;
1892 }
1893 if ( isset( $_REQUEST['check']['delivery_method'] ) ) {
1894 $line_col .= $th_h . __( 'shipping option', 'usces' ) . $th_f;
1895 }
1896 if ( isset( $_REQUEST['check']['delivery_date'] ) ) {
1897 $line_col .= $th_h . __( 'Delivery date', 'usces' ) . $th_f;
1898 }
1899 if ( isset( $_REQUEST['check']['delivery_time'] ) ) {
1900 $line_col .= $th_h . __( 'delivery time', 'usces' ) . $th_f;
1901 }
1902 if ( isset( $_REQUEST['check']['delidue_date'] ) ) {
1903 $line_col .= $th_h . __( 'Shipping date', 'usces' ) . $th_f;
1904 }
1905 if ( isset( $_REQUEST['check']['status'] ) ) {
1906 $line_col .= $th_h . __( 'Status', 'usces' ) . $th_f;
1907 }
1908 if ( isset( $_REQUEST['check']['tracking_number'] ) ) {
1909 $line_col .= $th_h . __( 'Tracking number', 'usces' ) . $th_f;
1910 }
1911 if ( isset( $_REQUEST['check']['total_amount'] ) ) {
1912 $line_col .= $th_h . __( 'Total Amount', 'usces' ) . $th_f;
1913 }
1914 if ( isset( $_REQUEST['check']['item_total_amount'] ) ) {
1915 $line_col .= $th_h . __( 'total items', 'usces' ) . $th_f;
1916 }
1917 if ( usces_is_member_system() && usces_is_member_system_point() ) {
1918 if ( isset( $_REQUEST['check']['getpoint'] ) ) {
1919 $line_col .= $th_h . __( 'granted points', 'usces' ) . $th_f;
1920 }
1921 if ( isset( $_REQUEST['check']['usedpoint'] ) ) {
1922 $line_col .= $th_h . __( 'Used points', 'usces' ) . $th_f;
1923 }
1924 }
1925 if ( isset( $_REQUEST['check']['discount'] ) ) {
1926 $line_col .= $th_h . __( 'Discount', 'usces' ) . $th_f;
1927 }
1928 if ( usces_is_tax_display() && 'products' === usces_get_tax_target() ) {
1929 if ( isset( $_REQUEST['check']['tax'] ) ) {
1930 $line_col .= $th_h . usces_tax_label( array(), 'return' ) . $th_f;
1931 }
1932 if ( usces_is_reduced_taxrate() ) {
1933 if ( isset( $_REQUEST['check']['subtotal_standard'] ) ) {
1934 $line_col .= $th_h . sprintf( __( 'Applies to %s%%', 'usces' ), $usces_tax->tax_rate_standard ) . $th_f;
1935 }
1936 if ( isset( $_REQUEST['check']['tax_standard'] ) ) {
1937 $line_col .= $th_h . sprintf( __( '%s%% consumption tax', 'usces' ), $usces_tax->tax_rate_standard ) . $th_f;
1938 }
1939 if ( isset( $_REQUEST['check']['subtotal_reduced'] ) ) {
1940 $line_col .= $th_h . sprintf( __( 'Applies to %s%%', 'usces' ), $usces_tax->tax_rate_reduced ) . $th_f;
1941 }
1942 if ( isset( $_REQUEST['check']['tax_reduced'] ) ) {
1943 $line_col .= $th_h . sprintf( __( '%s%% consumption tax', 'usces' ), $usces_tax->tax_rate_reduced ) . $th_f;
1944 }
1945 }
1946 }
1947 if ( isset( $_REQUEST['check']['shipping_charge'] ) ) {
1948 $line_col .= $th_h . __( 'Shipping', 'usces' ) . $th_f;
1949 }
1950 if ( isset( $_REQUEST['check']['cod_fee'] ) ) {
1951 $line_col .= $th_h . apply_filters( 'usces_filter_cod_label', __( 'COD fee', 'usces' ) ) . $th_f;
1952 }
1953 if ( usces_is_tax_display() && 'products' !== usces_get_tax_target() ) {
1954 if ( isset( $_REQUEST['check']['tax'] ) ) {
1955 $line_col .= $th_h . usces_tax_label( array(), 'return' ) . $th_f;
1956 }
1957 if ( usces_is_reduced_taxrate() ) {
1958 if ( isset( $_REQUEST['check']['subtotal_standard'] ) ) {
1959 $line_col .= $th_h . sprintf( __( 'Applies to %s%%', 'usces' ), $usces_tax->tax_rate_standard ) . $th_f;
1960 }
1961 if ( isset( $_REQUEST['check']['tax_standard'] ) ) {
1962 $line_col .= $th_h . sprintf( __( '%s%% consumption tax', 'usces' ), $usces_tax->tax_rate_standard ) . $th_f;
1963 }
1964 if ( isset( $_REQUEST['check']['subtotal_reduced'] ) ) {
1965 $line_col .= $th_h . sprintf( __( 'Applies to %s%%', 'usces' ), $usces_tax->tax_rate_reduced ) . $th_f;
1966 }
1967 if ( isset( $_REQUEST['check']['tax_reduced'] ) ) {
1968 $line_col .= $th_h . sprintf( __( '%s%% consumption tax', 'usces' ), $usces_tax->tax_rate_reduced ) . $th_f;
1969 }
1970 }
1971 }
1972 if ( isset( $_REQUEST['check']['note'] ) ) {
1973 $line_col .= $th_h . __( 'Notes', 'usces' ) . $th_f;
1974 }
1975 if ( ! empty( $csod_meta ) ) {
1976 foreach ( $csod_meta as $key => $entry ) {
1977 $name = $entry['name'];
1978 $csod_key = 'csod_' . $key;
1979 if ( isset( $_REQUEST['check'][ $csod_key ] ) ) {
1980 $line_col .= $th_h . usces_entity_decode( $name, $ext ) . $th_f;
1981 }
1982 }
1983 }
1984 if ( isset( $_REQUEST['check']['admin_memo'] ) ) {
1985 $line_col .= $th_h . __( 'Administrator Note', 'usces' ) . $th_f;
1986 }
1987 $line_col = ltrim( $line_col, ',' );
1988 $line_col = apply_filters( 'usces_filter_chk_ord_label_line_col', $line_col, $usces_opt_order );
1989 $line .= $line_col;
1990 $line .= apply_filters( 'usces_filter_chk_ord_label_order', null, $usces_opt_order, $rows, $line_col );
1991 $line .= $tr_f . $lf;
1992
1993 // ==========================================================================
1994
1995 foreach ( (array) $rows as $data ) {
1996
1997 $data = apply_filters( 'usces_filter_order_csv_data', $data );
1998
1999 $order_id = $data['ID'];
2000 $deli = unserialize( $data['deli_name'] );
2001 $reduced_taxrate = usces_is_reduced_taxrate( $order_id );
2002
2003 if ( usces_is_tax_display() && $reduced_taxrate ) {
2004 $cart = usces_get_ordercartdata( $order_id );
2005 $condition = usces_get_order_condition( $order_id );
2006 $materials = array(
2007 'total_items_price' => $data['item_total_price'],
2008 'discount' => $data['discount'],
2009 'shipping_charge' => $data['shipping_charge'],
2010 'cod_fee' => $data['cod_fee'],
2011 'use_point' => $data['usedpoint'],
2012 'carts' => $cart,
2013 'condition' => $condition,
2014 'order_id' => $order_id,
2015 );
2016 $usces_tax->get_order_tax( $materials );
2017 }
2018
2019 $line .= $tr_h;
2020 $line_row = '';
2021 if ( isset( $_REQUEST['check']['ID'] ) ) {
2022 $line_row .= $td_h1 . $order_id . $td_f;
2023 }
2024 if ( isset( $_REQUEST['check']['deco_id'] ) ) {
2025 $line_row .= $td_h . usces_get_deco_order_id( $order_id ) . $td_f;
2026 }
2027 if ( isset( $_REQUEST['check']['date'] ) ) {
2028 $line_row .= $td_h . $data['order_date'] . $td_f;
2029 }
2030 if ( isset( $_REQUEST['check']['mem_id'] ) ) {
2031 $line_row .= $td_h . $data['mem_id'] . $td_f;
2032 }
2033 if ( isset( $_REQUEST['check']['email'] ) ) {
2034 $line_row .= $td_h . usces_entity_decode( $data['email'], $ext ) . $td_f;
2035 }
2036 if ( ! empty( $cscs_meta ) ) {
2037 foreach ( $cscs_meta as $key => $entry ) {
2038 if ( 'name_pre' === $entry['position'] ) {
2039 $name = $entry['name'];
2040 $cscs_key = 'cscs_' . $key;
2041 if ( isset( $_REQUEST['check'][ $cscs_key ] ) ) {
2042 $value = maybe_unserialize( $usces->get_order_meta_value( $cscs_key, $order_id ) );
2043 $value = apply_filters( 'usces_filter_csv_cscs_meta_value', $value, $key, $order_id );
2044 if ( empty( $value ) ) {
2045 $value = '';
2046 } elseif ( is_array( $value ) ) {
2047 $concatval = '';
2048 $c = '';
2049 foreach ( $value as $v ) {
2050 $concatval .= $c . $v;
2051 $c = ' ';
2052 }
2053 $value = $concatval;
2054 }
2055 $line_row .= $td_h . usces_entity_decode( $value, $ext ) . $td_f;
2056 }
2057 }
2058 }
2059 }
2060
2061 switch ( $applyform ) {
2062 case 'JP':
2063 if ( isset( $_REQUEST['check']['name'] ) ) {
2064 $line_row .= $td_h . usces_entity_decode( $data['name1'] . ' ' . $data['name2'], $ext ) . $td_f;
2065 }
2066 if ( isset( $_REQUEST['check']['kana'] ) ) {
2067 $line_row .= $td_h . usces_entity_decode( $data['name3'] . ' ' . $data['name4'], $ext ) . $td_f;
2068 }
2069 break;
2070 case 'US':
2071 default:
2072 if ( isset( $_REQUEST['check']['name'] ) ) {
2073 $line_row .= $td_h . usces_entity_decode( $data['name2'] . ' ' . $data['name1'], $ext ) . $td_f;
2074 }
2075 break;
2076 }
2077
2078 if ( ! empty( $cscs_meta ) ) {
2079 foreach ( $cscs_meta as $key => $entry ) {
2080 if ( 'name_after' === $entry['position'] ) {
2081 $name = $entry['name'];
2082 $cscs_key = 'cscs_' . $key;
2083 if ( isset( $_REQUEST['check'][ $cscs_key ] ) ) {
2084 $value = maybe_unserialize( $usces->get_order_meta_value( $cscs_key, $order_id ) );
2085 $value = apply_filters( 'usces_filter_csv_cscs_meta_value', $value, $key, $order_id );
2086 if ( empty( $value ) ) {
2087 $value = '';
2088 } elseif ( is_array( $value ) ) {
2089 $concatval = '';
2090 $c = '';
2091 foreach ( $value as $v ) {
2092 $concatval .= $c . $v;
2093 $c = ' ';
2094 }
2095 $value = $concatval;
2096 }
2097 $line_row .= $td_h . usces_entity_decode( $value, $ext ) . $td_f;
2098 }
2099 }
2100 }
2101 }
2102
2103 $address_info = '';
2104 switch ( $applyform ) {
2105 case 'JP':
2106 if ( isset( $_REQUEST['check']['zip'] ) ) {
2107 $address_info .= $td_h . usces_entity_decode( $data['zipcode'], $ext ) . $td_f;
2108 }
2109 if ( isset( $_REQUEST['check']['country'] ) ) {
2110 $address_info .= $td_h . ( isset( $usces_settings['country'][ $data['country'] ] ) ? $usces_settings['country'][ $data['country'] ] : '' ) . $td_f;
2111 }
2112 if ( isset( $_REQUEST['check']['pref'] ) ) {
2113 $address_info .= $td_h . usces_entity_decode( $data['pref'], $ext ) . $td_f;
2114 }
2115 if ( isset( $_REQUEST['check']['address1'] ) ) {
2116 $address_info .= $td_h . usces_entity_decode( $data['address1'], $ext ) . $td_f;
2117 }
2118 if ( isset( $_REQUEST['check']['address2'] ) ) {
2119 $address_info .= $td_h . usces_entity_decode( $data['address2'], $ext ) . $td_f;
2120 }
2121 if ( isset( $_REQUEST['check']['address3'] ) ) {
2122 $address_info .= $td_h . usces_entity_decode( $data['address3'], $ext ) . $td_f;
2123 }
2124 if ( isset( $_REQUEST['check']['tel'] ) ) {
2125 $address_info .= $td_h . usces_entity_decode( $data['tel'], $ext ) . $td_f;
2126 }
2127 if ( isset( $_REQUEST['check']['fax'] ) ) {
2128 $address_info .= $td_h . usces_entity_decode( $data['fax'], $ext ) . $td_f;
2129 }
2130 break;
2131 case 'US':
2132 default:
2133 if ( isset( $_REQUEST['check']['address2'] ) ) {
2134 $address_info .= $td_h . usces_entity_decode( $data['address2'], $ext ) . $td_f;
2135 }
2136 if ( isset( $_REQUEST['check']['address3'] ) ) {
2137 $address_info .= $td_h . usces_entity_decode( $data['address3'], $ext ) . $td_f;
2138 }
2139 if ( isset( $_REQUEST['check']['address1'] ) ) {
2140 $address_info .= $td_h . usces_entity_decode( $data['address1'], $ext ) . $td_f;
2141 }
2142 if ( isset( $_REQUEST['check']['pref'] ) ) {
2143 $address_info .= $td_h . usces_entity_decode( $data['pref'], $ext ) . $td_f;
2144 }
2145 if ( isset( $_REQUEST['check']['country'] ) ) {
2146 $address_info .= $td_h . ( isset( $usces_settings['country'][ $data['country'] ] ) ? $usces_settings['country'][ $data['country'] ] : '' ) . $td_f;
2147 }
2148 if ( isset( $_REQUEST['check']['zip'] ) ) {
2149 $address_info .= $td_h . usces_entity_decode( $data['zipcode'], $ext ) . $td_f;
2150 }
2151 if ( isset( $_REQUEST['check']['tel'] ) ) {
2152 $address_info .= $td_h . usces_entity_decode( $data['tel'], $ext ) . $td_f;
2153 }
2154 if ( isset( $_REQUEST['check']['fax'] ) ) {
2155 $address_info .= $td_h . usces_entity_decode( $data['fax'], $ext ) . $td_f;
2156 }
2157 break;
2158 }
2159 $address_info_args = compact( 'td_h', 'td_f', 'ext', 'order_id', 'applyform' );
2160 $line_row .= apply_filters( 'usces_filter_ord_csv_address_info', $address_info, $data, $address_info_args );
2161
2162 if ( ! empty( $cscs_meta ) ) {
2163 foreach ( $cscs_meta as $key => $entry ) {
2164 if ( 'fax_after' === $entry['position'] ) {
2165 $name = $entry['name'];
2166 $cscs_key = 'cscs_' . $key;
2167 if ( isset( $_REQUEST['check'][ $cscs_key ] ) ) {
2168 $value = maybe_unserialize( $usces->get_order_meta_value( $cscs_key, $order_id ) );
2169 $value = apply_filters( 'usces_filter_csv_cscs_meta_value', $value, $key, $order_id );
2170 if ( empty( $value ) ) {
2171 $value = '';
2172 } elseif ( is_array( $value ) ) {
2173 $concatval = '';
2174 $c = '';
2175 foreach ( $value as $v ) {
2176 $concatval .= $c . $v;
2177 $c = ' ';
2178 }
2179 $value = $concatval;
2180 }
2181 $line_row .= $td_h . usces_entity_decode( $value, $ext ) . $td_f;
2182 }
2183 }
2184 }
2185 }
2186 $line_row .= apply_filters( 'usces_filter_chk_ord_data_customer', null, $usces_opt_order, $order_id, $data );
2187 // ----------------------------------------------------------------------
2188 if ( ! empty( $csde_meta ) ) {
2189 foreach ( $csde_meta as $key => $entry ) {
2190 if ( 'name_pre' === $entry['position'] ) {
2191 $name = $entry['name'];
2192 $csde_key = 'csde_' . $key;
2193 if ( isset( $_REQUEST['check'][ $csde_key ] ) ) {
2194 $value = maybe_unserialize( $usces->get_order_meta_value( $csde_key, $order_id ) );
2195 $value = apply_filters( 'usces_filter_csv_csde_meta_value', $value, $key, $order_id );
2196 if ( empty( $value ) ) {
2197 $value = '';
2198 } elseif ( is_array( $value ) ) {
2199 $concatval = '';
2200 $c = '';
2201 foreach ( $value as $v ) {
2202 $concatval .= $c . $v;
2203 $c = ' ';
2204 }
2205 $value = $concatval;
2206 }
2207 $line_row .= $td_h . usces_entity_decode( $value, $ext ) . $td_f;
2208 }
2209 }
2210 }
2211 }
2212
2213 switch ( $applyform ) {
2214 case 'JP':
2215 if ( isset( $_REQUEST['check']['delivery_name'] ) ) {
2216 $line_row .= $td_h . usces_entity_decode( $deli['name1'] . ' ' . $deli['name2'], $ext ) . $td_f;
2217 }
2218 if ( isset( $_REQUEST['check']['delivery_kana'] ) ) {
2219 $line_row .= $td_h . usces_entity_decode( $deli['name3'] . ' ' . $deli['name4'], $ext ) . $td_f;
2220 }
2221 break;
2222 case 'US':
2223 default:
2224 if ( isset( $_REQUEST['check']['delivery_name'] ) ) {
2225 $line_row .= $td_h . usces_entity_decode( $deli['name2'] . ' ' . $deli['name1'], $ext ) . $td_f;
2226 }
2227 break;
2228 }
2229
2230 if ( ! empty( $csde_meta ) ) {
2231 foreach ( $csde_meta as $key => $entry ) {
2232 if ( 'name_after' === $entry['position'] ) {
2233 $name = $entry['name'] . '</td>';
2234 $csde_key = 'csde_' . $key;
2235 if ( isset( $_REQUEST['check'][ $csde_key ] ) ) {
2236 $value = maybe_unserialize( $usces->get_order_meta_value( $csde_key, $order_id ) );
2237 $value = apply_filters( 'usces_filter_csv_csde_meta_value', $value, $key, $order_id );
2238 if ( empty( $value ) ) {
2239 $value = '';
2240 } elseif ( is_array( $value ) ) {
2241 $concatval = '';
2242 $c = '';
2243 foreach ( $value as $v ) {
2244 $concatval .= $c . $v;
2245 $c = ' ';
2246 }
2247 $value = $concatval;
2248 }
2249 $line_row .= $td_h . usces_entity_decode( $value, $ext ) . $td_f;
2250 }
2251 }
2252 }
2253 }
2254
2255 $address_info = '';
2256 switch ( $applyform ) {
2257 case 'JP':
2258 if ( isset( $_REQUEST['check']['delivery_zip'] ) ) {
2259 $address_info .= $td_h . usces_entity_decode( $deli['zipcode'], $ext ) . $td_f;
2260 }
2261 if ( isset( $_REQUEST['check']['delivery_country'] ) ) {
2262 $address_info .= $td_h . ( isset( $usces_settings['country'][ $deli['country'] ] ) ? $usces_settings['country'][ $deli['country'] ] : '' ) . $td_f;
2263 }
2264 if ( isset( $_REQUEST['check']['delivery_pref'] ) ) {
2265 $address_info .= $td_h . usces_entity_decode( $deli['pref'], $ext ) . $td_f;
2266 }
2267 if ( isset( $_REQUEST['check']['delivery_address1'] ) ) {
2268 $address_info .= $td_h . usces_entity_decode( $deli['address1'], $ext ) . $td_f;
2269 }
2270 if ( isset( $_REQUEST['check']['delivery_address2'] ) ) {
2271 $address_info .= $td_h . usces_entity_decode( $deli['address2'], $ext ) . $td_f;
2272 }
2273 if ( isset( $_REQUEST['check']['delivery_address3'] ) ) {
2274 $address_info .= $td_h . usces_entity_decode( $deli['address3'], $ext ) . $td_f;
2275 }
2276 if ( isset( $_REQUEST['check']['delivery_tel'] ) ) {
2277 $address_info .= $td_h . usces_entity_decode( $deli['tel'], $ext ) . $td_f;
2278 }
2279 if ( isset( $_REQUEST['check']['delivery_fax'] ) ) {
2280 $address_info .= $td_h . usces_entity_decode( $deli['fax'], $ext ) . $td_f;
2281 }
2282 break;
2283 case 'US':
2284 default:
2285 if ( isset( $_REQUEST['check']['delivery_address2'] ) ) {
2286 $address_info .= $td_h . usces_entity_decode( $deli['address2'], $ext ) . $td_f;
2287 }
2288 if ( isset( $_REQUEST['check']['delivery_address3'] ) ) {
2289 $address_info .= $td_h . usces_entity_decode( $deli['address3'], $ext ) . $td_f;
2290 }
2291 if ( isset( $_REQUEST['check']['delivery_address1'] ) ) {
2292 $address_info .= $td_h . usces_entity_decode( $deli['address1'], $ext ) . $td_f;
2293 }
2294 if ( isset( $_REQUEST['check']['delivery_pref'] ) ) {
2295 $address_info .= $td_h . usces_entity_decode( $deli['pref'], $ext ) . $td_f;
2296 }
2297 if ( isset( $_REQUEST['check']['delivery_country'] ) ) {
2298 $address_info .= $td_h . ( isset( $usces_settings['country'][ $deli['country'] ] ) ? $usces_settings['country'][ $deli['country'] ] : '' ) . $td_f;
2299 }
2300 if ( isset( $_REQUEST['check']['delivery_zip'] ) ) {
2301 $address_info .= $td_h . usces_entity_decode( $deli['zipcode'], $ext ) . $td_f;
2302 }
2303 if ( isset( $_REQUEST['check']['delivery_tel'] ) ) {
2304 $address_info .= $td_h . usces_entity_decode( $deli['tel'], $ext ) . $td_f;
2305 }
2306 if ( isset( $_REQUEST['check']['delivery_fax'] ) ) {
2307 $address_info .= $td_h . usces_entity_decode( $deli['fax'], $ext ) . $td_f;
2308 }
2309 break;
2310 }
2311 $line_row .= apply_filters( 'usces_filter_ord_csv_delivery_address_info', $address_info, $deli, $address_info_args );
2312
2313 if ( ! empty( $csde_meta ) ) {
2314 foreach ( $csde_meta as $key => $entry ) {
2315 if ( 'fax_after' === $entry['position'] ) {
2316 $name = $entry['name'];
2317 $csde_key = 'csde_' . $key;
2318 if ( isset( $_REQUEST['check'][ $csde_key ] ) ) {
2319 $value = maybe_unserialize( $usces->get_order_meta_value( $csde_key, $order_id ) );
2320 $value = apply_filters( 'usces_filter_csv_csde_meta_value', $value, $key, $order_id );
2321 if ( empty( $value ) ) {
2322 $value = '';
2323 } elseif ( is_array( $value ) ) {
2324 $concatval = '';
2325 $c = '';
2326 foreach ( $value as $v ) {
2327 $concatval .= $c . $v;
2328 $c = ' ';
2329 }
2330 $value = $concatval;
2331 }
2332 $line_row .= $td_h . usces_entity_decode( $value, $ext ) . $td_f;
2333 }
2334 }
2335 }
2336 }
2337 $line_row .= apply_filters( 'usces_filter_chk_ord_data_delivery', null, $usces_opt_order, $order_id, $deli );
2338 // ----------------------------------------------------------------------
2339 if ( isset( $_REQUEST['check']['shipping_date'] ) ) {
2340 $line_row .= $td_h . $data['order_modified'] . $td_f;
2341 }
2342 if ( isset( $_REQUEST['check']['peyment_method'] ) ) {
2343 $line_row .= $td_h . $data['payment_name'] . $td_f;
2344 }
2345 if ( isset( $_REQUEST['check']['wc_trans_id'] ) ) {
2346 $line_row .= $td_h . $data['wc_trans_id'] . $td_f;
2347 }
2348 if ( isset( $_REQUEST['check']['delivery_method'] ) ) {
2349 $delivery_method = '';
2350 if ( '#NONE#' === strtoupper( $data['deli_method'] ) ) {
2351 $delivery_method = __( 'No preference', 'usces' );
2352 } else {
2353 foreach ( (array) $usces->options['delivery_method'] as $dkey => $delivery ) {
2354 if ( $delivery['id'] == $data['deli_method'] ) {
2355 $delivery_method = $delivery['name'];
2356 break;
2357 }
2358 }
2359 }
2360 $line_row .= $td_h . $delivery_method . $td_f;
2361 }
2362 if ( isset( $_REQUEST['check']['delivery_date'] ) ) {
2363 $line_row .= $td_h . $data['deli_date'] . $td_f;
2364 }
2365 if ( isset( $_REQUEST['check']['delivery_time'] ) ) {
2366 $line_row .= $td_h . $data['deli_time'] . $td_f;
2367 }
2368 if ( isset( $_REQUEST['check']['delidue_date'] ) ) {
2369 $order_delidue_date = ( '#NONE#' === strtoupper( $data['delidue_date'] ) ) ? '' : $data['delidue_date'];
2370 $line_row .= $td_h . $order_delidue_date . $td_f;
2371 }
2372 if ( isset( $_REQUEST['check']['status'] ) ) {
2373 $order_status = explode( ',', $data['process_status'] );
2374 $status = '';
2375 foreach ( (array) $order_status as $os ) {
2376 if ( isset( $usces_management_status[ $os ] ) ) {
2377 $status .= $usces_management_status[ $os ] . $sp;
2378 }
2379 }
2380 $line_row .= $td_h . trim( $status, $sp ) . $td_f;
2381 }
2382 if ( isset( $_REQUEST['check']['tracking_number'] ) ) {
2383 $line_row .= $td_h . $data['tracking_number'] . $td_f;
2384 }
2385 if ( isset( $_REQUEST['check']['total_amount'] ) ) {
2386 $line_row .= $td_h . usces_crform( $data['total_price'], false, false, 'return', false ) . $td_f;
2387 }
2388 if ( isset( $_REQUEST['check']['item_total_amount'] ) ) {
2389 $line_row .= $td_h . usces_crform( $data['item_total_price'], false, false, 'return', false ) . $td_f;
2390 }
2391 if ( usces_is_member_system() && usces_is_member_system_point() ) {
2392 if ( isset( $_REQUEST['check']['getpoint'] ) ) {
2393 $line_row .= $td_h . $data['getpoint'] . $td_f;
2394 }
2395 if ( isset( $_REQUEST['check']['usedpoint'] ) ) {
2396 $line_row .= $td_h . $data['usedpoint'] . $td_f;
2397 }
2398 }
2399 if ( isset( $_REQUEST['check']['discount'] ) ) {
2400 $line_row .= $td_h . usces_crform( $data['discount'], false, false, 'return', false ) . $td_f;
2401 }
2402 if ( usces_is_tax_display() && 'products' === usces_get_tax_target() ) {
2403 if ( $reduced_taxrate ) {
2404 if ( isset( $_REQUEST['check']['tax'] ) ) {
2405 if ( 'include' === usces_get_tax_mode() ) {
2406 $tax = $usces_tax->tax;
2407 } else {
2408 $tax = $data['tax'];
2409 }
2410 $line_row .= $td_h . usces_crform( $tax, false, false, 'return', false ) . $td_f;
2411 }
2412 if ( isset( $_REQUEST['check']['subtotal_standard'] ) ) {
2413 $line_row .= $td_h . usces_crform( $usces_tax->subtotal_standard, false, false, 'return', false ) . $td_f;
2414 }
2415 if ( isset( $_REQUEST['check']['tax_standard'] ) ) {
2416 $line_row .= $td_h . usces_crform( $usces_tax->tax_standard, false, false, 'return', false ) . $td_f;
2417 }
2418 if ( isset( $_REQUEST['check']['subtotal_reduced'] ) ) {
2419 $line_row .= $td_h . usces_crform( $usces_tax->subtotal_reduced, false, false, 'return', false ) . $td_f;
2420 }
2421 if ( isset( $_REQUEST['check']['tax_reduced'] ) ) {
2422 $line_row .= $td_h . usces_crform( $usces_tax->tax_reduced, false, false, 'return', false ) . $td_f;
2423 }
2424 } else {
2425 if ( isset( $_REQUEST['check']['tax'] ) ) {
2426 if ( 'include' === usces_get_tax_mode() ) {
2427 $materials = array(
2428 'total_items_price' => $data['item_total_price'],
2429 'discount' => $data['discount'],
2430 'shipping_charge' => $data['shipping_charge'],
2431 'cod_fee' => $data['cod_fee'],
2432 'use_point' => $data['usedpoint'],
2433 'order_id' => $data['ID'],
2434 );
2435 $tax = usces_internal_tax( $materials, 'return' );
2436 } else {
2437 $tax = $data['tax'];
2438 }
2439 $line_row .= $td_h . usces_crform( $tax, false, false, 'return', false ) . $td_f;
2440 }
2441 if ( isset( $_REQUEST['check']['subtotal_standard'] ) ) {
2442 $line_row .= $td_h . '' . $td_f;
2443 }
2444 if ( isset( $_REQUEST['check']['tax_standard'] ) ) {
2445 $line_row .= $td_h . '' . $td_f;
2446 }
2447 if ( isset( $_REQUEST['check']['subtotal_reduced'] ) ) {
2448 $line_row .= $td_h . '' . $td_f;
2449 }
2450 if ( isset( $_REQUEST['check']['tax_reduced'] ) ) {
2451 $line_row .= $td_h . '' . $td_f;
2452 }
2453 }
2454 }
2455 if ( isset( $_REQUEST['check']['shipping_charge'] ) ) {
2456 $line_row .= $td_h . usces_crform( $data['shipping_charge'], false, false, 'return', false ) . $td_f;
2457 }
2458 if ( isset( $_REQUEST['check']['cod_fee'] ) ) {
2459 $line_row .= $td_h . usces_crform( $data['cod_fee'], false, false, 'return', false ) . $td_f;
2460 }
2461 if ( usces_is_tax_display() && 'products' !== usces_get_tax_target() ) {
2462 if ( $reduced_taxrate ) {
2463 if ( isset( $_REQUEST['check']['tax'] ) ) {
2464 if ( 'include' === usces_get_tax_mode() ) {
2465 $tax = $usces_tax->tax;
2466 } else {
2467 $tax = $data['tax'];
2468 }
2469 $line_row .= $td_h . usces_crform( $tax, false, false, 'return', false ) . $td_f;
2470 }
2471 if ( isset( $_REQUEST['check']['subtotal_standard'] ) ) {
2472 $line_row .= $td_h . usces_crform( $usces_tax->subtotal_standard, false, false, 'return', false ) . $td_f;
2473 }
2474 if ( isset( $_REQUEST['check']['tax_standard'] ) ) {
2475 $line_row .= $td_h . usces_crform( $usces_tax->tax_standard, false, false, 'return', false ) . $td_f;
2476 }
2477 if ( isset( $_REQUEST['check']['subtotal_reduced'] ) ) {
2478 $line_row .= $td_h . usces_crform( $usces_tax->subtotal_reduced, false, false, 'return', false ) . $td_f;
2479 }
2480 if ( isset( $_REQUEST['check']['tax_reduced'] ) ) {
2481 $line_row .= $td_h . usces_crform( $usces_tax->tax_reduced, false, false, 'return', false ) . $td_f;
2482 }
2483 } else {
2484 if ( isset( $_REQUEST['check']['tax'] ) ) {
2485 if ( 'include' === usces_get_tax_mode() ) {
2486 $materials = array(
2487 'total_items_price' => $data['item_total_price'],
2488 'discount' => $data['discount'],
2489 'shipping_charge' => $data['shipping_charge'],
2490 'cod_fee' => $data['cod_fee'],
2491 'use_point' => $data['usedpoint'],
2492 'order_id' => $data['ID'],
2493 );
2494 $tax = usces_internal_tax( $materials, 'return' );
2495 } else {
2496 $tax = $data['tax'];
2497 }
2498 $line_row .= $td_h . usces_crform( $tax, false, false, 'return', false ) . $td_f;
2499 }
2500 if ( isset( $_REQUEST['check']['subtotal_standard'] ) ) {
2501 $line_row .= $td_h . '' . $td_f;
2502 }
2503 if ( isset( $_REQUEST['check']['tax_standard'] ) ) {
2504 $line_row .= $td_h . '' . $td_f;
2505 }
2506 if ( isset( $_REQUEST['check']['subtotal_reduced'] ) ) {
2507 $line_row .= $td_h . '' . $td_f;
2508 }
2509 if ( isset( $_REQUEST['check']['tax_reduced'] ) ) {
2510 $line_row .= $td_h . '' . $td_f;
2511 }
2512 }
2513 }
2514 if ( isset( $_REQUEST['check']['note'] ) ) {
2515 $note = apply_filters( 'usces_filter_newordercsv_note_value', $data['note'], $data );
2516 $line_row .= $td_h . usces_entity_decode( $note, $ext ) . $td_f;
2517 }
2518 if ( ! empty( $csod_meta ) ) {
2519 foreach ( $csod_meta as $key => $entry ) {
2520 $name = $entry['name'];
2521 $csod_key = 'csod_' . $key;
2522 if ( isset( $_REQUEST['check'][ $csod_key ] ) ) {
2523 $value = maybe_unserialize( $usces->get_order_meta_value( $csod_key, $order_id ) );
2524 $value = apply_filters( 'usces_filter_csv_csod_meta_value', $value, $key, $order_id );
2525 if ( empty( $value ) ) {
2526 $value = '';
2527 } elseif ( is_array( $value ) ) {
2528 $concatval = '';
2529 $c = '';
2530 foreach ( $value as $v ) {
2531 $concatval .= $c . $v;
2532 $c = ' ';
2533 }
2534 $value = $concatval;
2535 }
2536 $line_row .= $td_h . usces_entity_decode( $value, $ext ) . $td_f;
2537 }
2538 }
2539 }
2540 if ( isset( $_REQUEST['check']['admin_memo'] ) ) {
2541 $line_row .= $td_h . usces_entity_decode( $data['admin_memo'], $ext ) . $td_f;
2542 }
2543 $line_row = preg_replace( "/\n,/", "\n", ltrim( $line_row, ',' ) );
2544 $line_row = apply_filters( 'usces_filter_chk_ord_data_detail_line_row', $line_row, $usces_opt_order, $data );
2545 $line .= $line_row;
2546 $line .= apply_filters( 'usces_filter_chk_ord_data_order', null, $usces_opt_order, $order_id, $data, $line_row );
2547 $line .= $tr_f . $lf;
2548 }
2549 $line .= $table_f;
2550 $line = apply_filters( 'wc_filter_chk_ord_data_order', $line );
2551
2552 // ==========================================================================
2553
2554 header( 'Content-Type: application/octet-stream' );
2555 header( 'Content-Disposition: attachment; filename=usces_order_list.' . $ext );
2556 mb_http_output( 'pass' );
2557 print( mb_convert_encoding( $line, apply_filters( 'usces_filter_output_csv_encode', 'SJIS-win' ), 'UTF-8' ) );
2558 exit();
2559 }
2560
2561 /**
2562 * Action view checkbox product order.
2563 *
2564 * @param array $chk_pro Output check.
2565 */
2566 public function self_action_chk_pro_order( $chk_pro ) {
2567 $arr_mail_print_fields = get_option( 'usces_order_mail_print_fields' );
2568 foreach ( $arr_mail_print_fields as $key => $value ) {
2569 $checked = usces_checked( $chk_pro, $key, 'return' );
2570 echo '<label for="chk_pro[' . $key . ']"><input type="checkbox" class="check_pro" id="chk_pro[' . $key . ']" value="' . $key . '"' . $checked . ' />' . esc_attr( $value['label'] ) . '</label>' . "\n";
2571 }
2572 }
2573
2574 /**
2575 * Action view checkbox order.
2576 *
2577 * @param array $chk_ord Output check.
2578 */
2579 public function self_action_chk_ord_order( $chk_ord ) {
2580 $arr_mail_print_fields = get_option( 'usces_order_mail_print_fields' );
2581 foreach ( $arr_mail_print_fields as $key => $value ) {
2582 $checked = usces_checked( $chk_ord, $key, 'return' );
2583 echo '<label for="chk_ord[' . $key . ']"><input type="checkbox" class="check_order" id="chk_ord[' . $key . ']" value="' . $key . '"' . $checked . ' />' . esc_attr( $value['label'] ) . '</label>' . "\n";
2584 }
2585 }
2586
2587 /**
2588 * Filter checkbox product order.
2589 *
2590 * @param array $chk_pro Output check.
2591 * @return array
2592 */
2593 public function self_filter_chk_pro( $chk_pro ) {
2594 $arr_mail_print_fields = get_option( 'usces_order_mail_print_fields' );
2595 foreach ( $arr_mail_print_fields as $key => $value ) {
2596 $chk_pro[ $key ] = ( isset( $_REQUEST['check'][ $key ] ) ) ? 1 : 0;
2597 }
2598 return $chk_pro;
2599 }
2600
2601 /**
2602 * Filter checkbox product label order.
2603 *
2604 * @param string $other Unused.
2605 * @param array $usces_opt_order Output check.
2606 * @param array $rows Order data.
2607 * @return string
2608 */
2609 public function self_filter_chk_pro_label_order( $other, $usces_opt_order, $rows ) {
2610 $th_h = ',"';
2611 $th_f = '"';
2612 $line_col = $other;
2613 $arr_mail_print_fields = get_option( 'usces_order_mail_print_fields' );
2614 foreach ( $arr_mail_print_fields as $key => $value ) {
2615 if ( isset( $_REQUEST['check'][ $key ] ) ) {
2616 $line_col .= $th_h . $value['label'] . $th_f;
2617 }
2618 }
2619 return $line_col;
2620 }
2621
2622 /**
2623 * Filter checkbox product data order.
2624 *
2625 * @param string $other Unused.
2626 * @param array $usces_opt_order Output check.
2627 * @param int $order_id Order ID.
2628 * @param array $data Order data.
2629 * @param array $cart_row Cart data.
2630 * @return string
2631 */
2632 public function self_filter_chk_pro_data_order( $other, $usces_opt_order, $order_id, $data, $cart_row ) {
2633 $td_h = ',"';
2634 $td_f = '"';
2635 $line_row = $other;
2636 $arr_mail_print_status = self::get_value_print_mail();
2637 $arr_mail_print_fields = get_option( 'usces_order_mail_print_fields' );
2638 $a_order_check = maybe_unserialize( $data['order_check'] );
2639 if ( ! is_array( $a_order_check ) ) {
2640 $a_order_check = array();
2641 }
2642 foreach ( $arr_mail_print_fields as $key => $value ) {
2643 if ( isset( $_REQUEST['check'][ $key ] ) && isset( $arr_mail_print_status[ $value['type'] ] ) ) {
2644 $type_mps = $arr_mail_print_status[ $value['type'] ];
2645 if ( in_array( $key, $a_order_check ) ) {
2646 $line_row .= $td_h . $type_mps[1]['alias'] . $td_f;
2647 } else {
2648 $line_row .= $td_h . $type_mps[0]['alias'] . $td_f;
2649 }
2650 }
2651 }
2652 return $line_row;
2653 }
2654
2655 /**
2656 * Filter checkbox order.
2657 *
2658 * @param array $chk_ord Output check.
2659 * @return array
2660 */
2661 public function self_filter_chk_ord( $chk_ord ) {
2662 $arr_mail_print_fields = get_option( 'usces_order_mail_print_fields' );
2663 foreach ( $arr_mail_print_fields as $key => $value ) {
2664 $chk_ord[ $key ] = ( isset( $_REQUEST['check'][ $key ] ) ) ? 1 : 0;
2665 }
2666 return $chk_ord;
2667 }
2668
2669 /**
2670 * Filter checkbox label order.
2671 *
2672 * @param string $other Unused.
2673 * @param array $usces_opt_order Output check.
2674 * @param array $rows Order data.
2675 * @param string $line_col Line.
2676 * @return string
2677 */
2678 public function self_filter_chk_ord_label_order( $other, $usces_opt_order, $rows, $line_col ) {
2679 $th_h = ',"';
2680 $th_f = '"';
2681 $line_col = $other;
2682 $arr_mail_print_fields = get_option( 'usces_order_mail_print_fields' );
2683 foreach ( $arr_mail_print_fields as $key => $value ) {
2684 if ( isset( $_REQUEST['check'][ $key ] ) ) {
2685 $line_col .= $th_h . $value['label'] . $th_f;
2686 }
2687 }
2688 return $line_col;
2689 }
2690
2691 /**
2692 * Filter checkbox data order.
2693 *
2694 * @param string $other Unused.
2695 * @param array $usces_opt_order Output check.
2696 * @param int $order_id Order ID.
2697 * @param array $data Order data.
2698 * @param string $cart_row Cart data.
2699 * @return string
2700 */
2701 public function self_filter_chk_ord_data_order( $other, $usces_opt_order, $order_id, $data, $cart_row ) {
2702 $td_h = ',"';
2703 $td_f = '"';
2704 $line_row = $other;
2705 $arr_mail_print_status = self::get_value_print_mail();
2706 $arr_mail_print_fields = get_option( 'usces_order_mail_print_fields' );
2707 $a_order_check = maybe_unserialize( $data['order_check'] );
2708 if ( ! is_array( $a_order_check ) ) {
2709 $a_order_check = array();
2710 }
2711 if ( !empty( $arr_mail_print_fields ) ) {
2712 foreach ( $arr_mail_print_fields as $key => $value ) {
2713 if ( isset( $_REQUEST['check'][ $key ] ) && isset( $arr_mail_print_status[ $value['type'] ] ) ) {
2714 $type_mps = $arr_mail_print_status[ $value['type'] ];
2715 if ( in_array( $key, $a_order_check ) ) {
2716 $line_row .= $td_h . $type_mps[1]['alias'] . $td_f;
2717 } else {
2718 $line_row .= $td_h . $type_mps[0]['alias'] . $td_f;
2719 }
2720 }
2721 }
2722 }
2723 return $line_row;
2724 }
2725 }
2726