-
Notifications
You must be signed in to change notification settings - Fork 8
/
orders.php
executable file
·705 lines (591 loc) · 39.1 KB
/
orders.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
<?php
//Exit if not called in proper context
if (!defined('ABSPATH')) exit();
if (isset($_GET['action-top']) && isset($_GET['action-bottom'])) add_action('admin_init', 'foxyshop_multi_api_edit');
function foxyshop_multi_api_edit() {
if (!isset($_GET['post'])) return;
if ($_GET['action-top'] == -1) $act = sanitize_text_field($_GET['action-bottom']);
if ($_GET['action-bottom'] == -1) $act = sanitize_text_field($_GET['action-top']);
if ($act == -1) return;
$posts = sanitize_text_field($_GET['post']);
if (!is_array($posts)) $posts = array(sanitize_text_field($_POST['post']));
if ($act == "archive" || $act == "unarchive") {
$hide_transaction = $act == "archive" ? 1 : 0;
foreach ($posts as $postid) {
$foxy_data = array("api_action" => "transaction_modify", "transaction_id" => $postid, "hide_transaction" => $hide_transaction);
foxyshop_get_foxycart_data($foxy_data); //Run the API Update Call
}
}
}
if (isset($_GET['foxyshop_print_invoice'])) add_action('admin_init', 'foxyshop_print_invoice');
if (isset($_GET['transaction_search_type'])) {
$transaction_search_type = sanitize_text_field($_GET['transaction_search_type']);
if ($transaction_search_type == "print_recipts") {
add_action('admin_init', 'foxyshop_print_invoice');
} elseif ($transaction_search_type == "export_csv" || $transaction_search_type == "export_tab") {
add_action('admin_init', 'foxyshop_transaction_export');
} elseif ($transaction_search_type == "export_ups") {
add_action('admin_init', 'foxyshop_ups_export');
}
}
function foxyshop_print_invoice() {
global $foxyshop_settings;
//Setup Fields and Defaults
$foxy_data_defaults = array(
"is_test_filter" => "0",
"hide_transaction_filter" => "0",
"data_is_fed_filter" => "",
"id_filter" => "",
"display_id_filter" => "",
"order_total_filter" => "",
"coupon_code_filter" => "",
"transaction_date_filter_begin" => date("Y-m-d", strtotime("-10 days")),
"transaction_date_filter_end" => date("Y-m-d"),
"customer_id_filter" => "",
"customer_email_filter" => "",
"customer_first_name_filter" => "",
"customer_last_name_filter" => "",
"customer_state_filter" => "",
"shipping_state_filter" => "",
"customer_ip_filter" => "",
"product_code_filter" => "",
"product_name_filter" => "",
"product_option_name_filter" => "",
"product_option_value_filter" => ""
);
if (version_compare($foxyshop_settings['version'], '2.0', ">=")) {
$foxy_data_defaults["status_filter"] = "all";
}
$foxy_data = wp_parse_args(array("api_action" => "transaction_list"), $foxy_data_defaults);
if (isset($_GET['foxyshop_search'])) {
$fields = array("is_test_filter", "hide_transaction_filter", "data_is_fed_filter", "id_filter", "display_id_filter", "order_total_filter", "coupon_code_filter", "transaction_date_filter_begin", "transaction_date_filter_end", "customer_id_filter", "customer_email_filter", "customer_first_name_filter", "customer_last_name_filter","customer_state_filter", "shipping_state_filter", "customer_ip_filter", "product_code_filter", "product_name_filter", "product_option_name_filter", "product_option_value_filter");
foreach ($fields as $field) {
if (isset($_GET[$field])) {
$foxy_data[$field] = sanitize_text_field($_GET[$field]);
}
}
$foxy_data['pagination_start'] = (isset($_GET['pagination_start']) ? sanitize_text_field($_GET['pagination_start']) : 0);
if (version_compare($foxyshop_settings['version'], '0.7.0', ">")) $foxy_data['entries_per_page'] = FOXYSHOP_API_ENTRIES_PER_PAGE;
}
$foxy_response = foxyshop_get_foxycart_data($foxy_data);
$xml = simplexml_load_string($foxy_response, NULL, LIBXML_NOCDATA);
if ($xml->result == "ERROR") {
echo '<h3>' . wp_kses_post($xml->messages->message) . '</h3>';
die;
}
include foxyshop_get_template_file('/foxyshop-receipt.php');
die;
}
//Shipping Integrations
include_once FOXYSHOP_PATH . '/shippingintegration.php';
//Order Management
add_action('admin_menu', 'foxyshop_order_management_menu');
function foxyshop_order_management_menu() {
add_submenu_page('edit.php?post_type=foxyshop_product', __('Order Management', 'foxyshop'), __('Orders', 'foxyshop'), apply_filters('foxyshop_order_perm', 'manage_options'), 'foxyshop_order_management', 'foxyshop_order_management');
}
function foxyshop_order_management() {
global $foxyshop_settings, $wp_version;
//Setup Fields and Defaults
$foxy_data_defaults = array(
"is_test_filter" => "0",
"hide_transaction_filter" => "0",
"data_is_fed_filter" => "",
"id_filter" => "",
"display_id_filter" => "",
"order_total_filter" => "",
"coupon_code_filter" => "",
"transaction_date_filter_begin" => date("Y-m-d", strtotime("-10 days")),
"transaction_date_filter_end" => date("Y-m-d"),
"customer_id_filter" => "",
"customer_email_filter" => "",
"customer_first_name_filter" => "",
"customer_last_name_filter" => "",
"customer_state_filter" => "",
"shipping_state_filter" => "",
"customer_ip_filter" => "",
"product_code_filter" => "",
"product_name_filter" => "",
"product_option_name_filter" => "",
"product_option_value_filter" => ""
);
if (version_compare($foxyshop_settings['version'], '0.7.2', ">=")) {
$foxy_data_defaults["custom_field_name_filter"] = "";
$foxy_data_defaults["custom_field_value_filter"] = "";
}
if (version_compare($foxyshop_settings['version'], '2.0', ">=")) {
$foxy_data_defaults["status_filter"] = "all";
}
$foxy_data = wp_parse_args(array("api_action" => "transaction_list"), apply_filters('foxyshop_transaction_filter_defaults',$foxy_data_defaults));
$foxyshop_querystring = "?post_type=foxyshop_product&page=foxyshop_order_management&foxyshop_search=1";
$foxyshop_hidden_input = "";
if (isset($_GET['foxyshop_search']) || !defined('FOXYSHOP_AUTO_API_DISABLED')) {
$fields = array("is_test_filter", "hide_transaction_filter", "data_is_fed_filter", "id_filter", "display_id_filter", "order_total_filter", "coupon_code_filter", "transaction_date_filter_begin", "transaction_date_filter_end", "customer_id_filter", "customer_email_filter", "customer_first_name_filter", "customer_last_name_filter","customer_state_filter", "shipping_state_filter", "customer_ip_filter", "product_code_filter", "product_name_filter", "product_option_name_filter", "product_option_value_filter", "custom_field_name_filter", "custom_field_value_filter");
foreach ($fields as $field) {
if (isset($_GET[$field])) {
$foxy_data[$field] = sanitize_text_field($_GET[$field]);
$foxyshop_querystring .= "&$field=" . urlencode($foxy_data[$field]);
$foxyshop_hidden_input .= '<input type="hidden" name="' . $field . '" value="' . htmlspecialchars($foxy_data[$field]) . '" />' . "\n";
}
}
$foxy_data['pagination_start'] = (isset($_GET['pagination_start']) ? sanitize_text_field($_GET['pagination_start']) : 0);
$p = (int)(version_compare($foxyshop_settings['version'], '0.7.1', "<") ? 50 : FOXYSHOP_API_ENTRIES_PER_PAGE);
if (version_compare($foxyshop_settings['version'], '0.7.0', ">")) $foxy_data['entries_per_page'] = $p;
$start_offset = (int)(version_compare($foxyshop_settings['version'], '0.7.1', "<=") ? -1 : 0);
if (isset($_GET['paged-top']) || isset($_GET['paged-bottom'])) {
if ($_GET['paged-top'] != $_GET['paged-top-original']) $foxy_data['pagination_start'] = $p * ((int)sanitize_text_field($_GET['paged-top']) - 1) + 1 + $start_offset;
if ($_GET['paged-bottom'] != $_GET['paged-bottom-original']) $foxy_data['pagination_start'] = $p * ((int)sanitize_text_field($_GET['paged-bottom']) - 1) + 1 + $start_offset;
}
}
$transaction_search_type = isset($_GET['transaction_search_type']) ? sanitize_text_field($_GET['transaction_search_type']) : '';
if ($foxyshop_settings["orderdesk_url"]) {
$orderdesk_link = ' <a class="' . (version_compare(get_bloginfo('version'), '3.2', "<") ? "button " : '') . 'add-new-h2" href="https://app.orderdesk.me/" target="_blank">' . __('Launch Order Desk', 'foxyshop') . '</a>';
} else {
$orderdesk_link = "";
}
?>
<div class="wrap">
<div class="icon32 icon32-posts-page" id="icon-edit-pages"><br></div>
<h2><?php _e('Manage Orders', 'foxyshop'); echo wp_kses_post($orderdesk_link); ?></h2>
<form action="edit.php" method="get" id="foxyshop_searchform" name="foxyshop_searchform" style="display: block; margin: 14px 0 20px 0;">
<input type="hidden" name="foxyshop_search" value="1" />
<input type="hidden" name="post_type" value="foxyshop_product" />
<input type="hidden" name="page" value="foxyshop_order_management" />
<table class="widefat">
<thead><tr><th colspan="2"><img src="<?php echo esc_url(FOXYSHOP_DIR); ?>/images/search-icon.png" alt="" /><?php _e('Search Options', 'foxyshop'); ?></th></tr></thead>
<tbody><tr><td>
<div class="foxyshop_field_control foxyshop_radio_label_container">
<label><?php _e('Transaction Status', 'foxyshop'); ?></label>
<input type="radio" id="hide_transaction_filter0" name="hide_transaction_filter" value="0" <?php echo $foxy_data['hide_transaction_filter'] == 0 ? ' checked="checked"' : ''; ?> />
<label for="hide_transaction_filter0"><?php _e('Visible', 'foxyshop'); ?></label>
<input type="radio" id="hide_transaction_filter1" name="hide_transaction_filter" value="1" <?php echo $foxy_data['hide_transaction_filter'] == 1 ? ' checked="checked"' : ''; ?> />
<label for="hide_transaction_filter1"><?php _e('Hidden', 'foxyshop'); ?></label>
<input type="radio" id="hide_transaction_filter" name="hide_transaction_filter" value="" <?php echo $foxy_data['hide_transaction_filter'] == '' ? ' checked="checked"' : ''; ?> />
<label for="hide_transaction_filter"><?php _e('Both', 'foxyshop'); ?></label>
</div>
<div class="foxyshop_field_control foxyshop_radio_label_container">
<label><?php _e('Datafeed Status', 'foxyshop'); ?></label>
<input type="radio" id="data_is_fed_filter0" name="data_is_fed_filter" value="0" <?php echo $foxy_data['data_is_fed_filter'] == 0 ? ' checked="checked"' : ''; ?> />
<label for="data_is_fed_filter0"><?php _e('Fed', 'foxyshop'); ?></label>
<input type="radio" id="data_is_fed_filter1" name="data_is_fed_filter" value="1" <?php echo $foxy_data['data_is_fed_filter'] == 1 ? ' checked="checked"' : ''; ?> />
<label for="data_is_fed_filter1"><?php _e('Unfed', 'foxyshop'); ?></label>
<input type="radio" id="data_is_fed_filter" name="data_is_fed_filter" value="" <?php echo $foxy_data['data_is_fed_filter'] == '' ? ' checked="checked"' : ''; ?> />
<label for="data_is_fed_filter"><?php _e('Both', 'foxyshop'); ?></label>
</div>
<div class="foxyshop_field_control foxyshop_radio_label_container">
<label><?php _e('Test Transactions', 'foxyshop'); ?></label>
<input type="radio" id="is_test_filter0" name="is_test_filter" value="0" <?php echo $foxy_data['is_test_filter'] == 0 ? ' checked="checked"' : ''; ?> />
<label for="is_test_filter0"><?php _e('Live', 'foxyshop'); ?></label>
<input type="radio" id="is_test_filter1" name="is_test_filter" value="1" <?php echo $foxy_data['is_test_filter'] == 1 ? ' checked="checked"' : ''; ?> />
<label for="is_test_filter1"><?php _e('Test', 'foxyshop'); ?></label>
<input type="radio" id="is_test_filter" name="is_test_filter" value="" <?php echo $foxy_data['is_test_filter'] == '' ? ' checked="checked"' : ''; ?> />
<label for="is_test_filter"><?php _e('Both', 'foxyshop'); ?></label>
</div>
<div class="foxyshop_field_control">
<label for="order_id_filter"><?php _e('Order ID', 'foxyshop'); ?></label><input type="text" name="id_filter" id="id_filter" value="<?php echo esc_attr($foxy_data['id_filter']); ?>" />
</div>
<div class="foxyshop_field_control">
<label for="display_id_filter"><?php _e('Display ID', 'foxyshop'); ?></label><input type="text" name="display_id_filter" id="display_id_filter" value="<?php echo esc_attr($foxy_data['display_id_filter']); ?>" />
</div>
<div class="foxyshop_field_control">
<label for="order_total_filter"><?php _e('Order Total', 'foxyshop'); ?></label><input type="text" name="order_total_filter" id="order_total_filter" value="<?php echo esc_attr($foxy_data['order_total_filter']); ?>" />
</div>
<div class="foxyshop_field_control">
<label for="coupon_code_filter"><?php _e('Coupon Code', 'foxyshop'); ?></label><input type="text" name="coupon_code_filter" id="coupon_code_filter" value="<?php echo esc_attr($foxy_data['coupon_code_filter']); ?>" />
</div>
<div class="foxyshop_field_control">
<label for="product_code_filter"><?php echo esc_html(FOXYSHOP_PRODUCT_NAME_SINGULAR) . ' ' . __('Code', 'foxyshop'); ?></label><input type="text" name="product_code_filter" id="product_code_filter" value="<?php echo esc_attr($foxy_data['product_code_filter']); ?>" />
</div>
<div class="foxyshop_field_control">
<label for="product_name_filter"><?php echo esc_html(FOXYSHOP_PRODUCT_NAME_SINGULAR) . ' ' . __('Name', 'foxyshop'); ?></label><input type="text" name="product_name_filter" id="product_name_filter" value="<?php echo esc_attr($foxy_data['product_name_filter']); ?>" />
</div>
<div class="foxyshop_field_control">
<label for="product_option_name_filter"><?php echo esc_html(FOXYSHOP_PRODUCT_NAME_SINGULAR) . ' ' . __('Option Name', 'foxyshop'); ?></label><input type="text" name="product_option_name_filter" id="product_option_name_filter" value="<?php echo esc_attr($foxy_data['product_option_name_filter']); ?>" />
<label for="product_option_value_filter" style="margin-left: 15px; margin-top: 4px; width: 34px;"><?php _e('Value', 'foxyshop'); ?></label><input type="text" name="product_option_value_filter" id="product_option_value_filter" value="<?php echo esc_attr($foxy_data['product_option_value_filter']); ?>" />
</div>
<?php if (version_compare($foxyshop_settings['version'], '0.7.2', ">=")) { ?>
<div class="foxyshop_field_control">
<label for="custom_field_name_filter"><?php _e('Custom Field Name', 'foxyshop'); ?></label><input type="text" name="custom_field_name_filter" id="custom_field_name_filter" value="<?php echo esc_attr($foxy_data['custom_field_name_filter']); ?>" />
<label for="custom_field_value_filter" style="margin-left: 15px; margin-top: 4px; width: 34px;"><?php _e('Value', 'foxyshop'); ?></label><input type="text" name="custom_field_value_filter" id="custom_field_value_filter" value="<?php echo esc_attr($foxy_data['custom_field_value_filter']); ?>" />
</div>
<?php } ?>
</td><td>
<div class="foxyshop_field_control">
<label for="transaction_date_filter_begin"><?php _e('Date Range', 'foxyshop'); ?></label><input type="text" name="transaction_date_filter_begin" id="transaction_date_filter_begin" value="<?php echo esc_attr($foxy_data['transaction_date_filter_begin']); ?>" class="foxyshop_date_field" />
<span><?php _e('to', 'foxyshop'); ?></span><input type="text" name="transaction_date_filter_end" id="transaction_date_filter_end" value="<?php echo esc_attr($foxy_data['transaction_date_filter_end']); ?>" class="foxyshop_date_field" />
</div>
<div class="foxyshop_field_control">
<label for="customer_id_filter"><?php _e('Customer ID', 'foxyshop'); ?></label><input type="text" name="customer_id_filter" id="customer_id_filter" value="<?php echo esc_attr($foxy_data['customer_id_filter']); ?>" />
</div>
<div class="foxyshop_field_control">
<label for="customer_email_filter"><?php _e('Customer Email', 'foxyshop'); ?></label><input type="text" name="customer_email_filter" id="customer_email_filter" value="<?php echo esc_attr($foxy_data['customer_email_filter']); ?>" />
</div>
<div class="foxyshop_field_control">
<label for="customer_first_name_filter"><?php _e('Customer First Name', 'foxyshop'); ?></label><input type="text" name="customer_first_name_filter" id="customer_first_name_filter" value="<?php echo esc_attr($foxy_data['customer_first_name_filter']); ?>" />
</div>
<div class="foxyshop_field_control">
<label for="customer_last_name_filter"><?php _e('Customer Last Name', 'foxyshop'); ?></label><input type="text" name="customer_last_name_filter" id="customer_last_name_filter" value="<?php echo esc_attr($foxy_data['customer_last_name_filter']); ?>" />
</div>
<div class="foxyshop_field_control">
<label for="customer_state_filter"><?php _e('Customer State', 'foxyshop'); ?></label><input type="text" name="customer_state_filter" id="customer_state_filter" value="<?php echo esc_attr($foxy_data['customer_state_filter']); ?>" />
</div>
<div class="foxyshop_field_control">
<label for="shipping_state_filter"><?php _e('Shipping State', 'foxyshop'); ?></label><input type="text" name="shipping_state_filter" id="shipping_state_filter" value="<?php echo esc_attr($foxy_data['shipping_state_filter']); ?>" />
</div>
<div class="foxyshop_field_control">
<label for="customer_ip_filter"><?php _e('Customer IP', 'foxyshop'); ?></label><input type="text" name="customer_ip_filter" id="customer_ip_filter" value="<?php echo esc_attr($foxy_data['customer_ip_filter']); ?>" />
</div>
<div style="clear: both;"></div>
<select name="transaction_search_type" id="transaction_search_type">
<option value="show_orders"<?php echo ($transaction_search_type == "show_orders" ? ' selected="selected"' : ''); ?>><?php _e('Show Orders', 'foxyshop'); ?></option>
<option value="print_recipts" target="_blank"><?php _e('Print Receipts', 'foxyshop'); ?></option>
<?php if (!$foxyshop_settings['enable_ship_to']) { ?>
<option value="export_csv"><?php _e('Export CSV', 'foxyshop'); ?></option>
<option value="export_tab"><?php _e('Export Tab Delimeted', 'foxyshop'); ?></option>
<option value="export_ups"><?php _e('Export to UPS', 'foxyshop'); ?></option>
<?php } ?>
<?php do_action("foxyshop_order_search_list"); ?>
</select>
<button type="submit" id="foxyshop_search_submit" name="foxyshop_search_submit" class="button-primary" style="clear: left; margin-top: 10px;"><?php _e('Submit', 'foxyshop'); ?></button>
<button type="button" class="button submitcancel" style="margin-top: 10px;" onclick="document.location.href = 'edit.php?post_type=foxyshop_product&page=foxyshop_order_management';"><?php _e('Reset', 'foxyshop'); ?></button>
<div style="clear: both;"></div>
<?php
if (has_action('foxyshop_order_search_buttons')) {
echo '<div id="foxyshop_order_search_buttons">';
do_action("foxyshop_order_search_buttons", $foxy_data);
echo '</div>';
}
?>
</td></tr></tbody></table>
</form>
<?php
if (!isset($_GET['foxyshop_search']) && defined('FOXYSHOP_AUTO_API_DISABLED')) return;
$foxy_response = foxyshop_get_foxycart_data($foxy_data);
$xml = simplexml_load_string($foxy_response, NULL, LIBXML_NOCDATA);
//var_dump($xml);
if ((string)$xml->result == __('ERROR', 'foxyshop')) {
echo '<h3>' . wp_kses_post((string)$xml->messages->message) . '</h3>';
return;
} else {
?>
<form action="edit.php" method="get">
<input type="hidden" name="foxyshop_search" value="1" />
<input type="hidden" name="post_type" value="foxyshop_product" />
<input type="hidden" name="page" value="foxyshop_order_management" />
<?php
echo foxy_wp_kses_html($foxyshop_hidden_input, ['input']);
foxyshop_api_paging_nav('transactions', 'top', $xml, $foxyshop_querystring);
?>
<table cellpadding="0" cellspacing="0" border="0" class="wp-list-table widefat foxyshop-list-table" id="transaction_table">
<thead>
<tr>
<th id="cb" class="manage-column column-cb check-column" scope="col"><input type="checkbox"></th>
<th><span><?php _e('Transaction ID', 'foxyshop'); ?></span><span class="sorting-indicator"></span></th>
<th><span><?php _e('Order Date', 'foxyshop'); ?></span><span class="sorting-indicator"></span></th>
<th><span><?php _e('Customer', 'foxyshop'); ?></span><span class="sorting-indicator"></span></th>
<th><span><?php _e('Total', 'foxyshop'); ?></span><span class="sorting-indicator"></span></th>
<?php do_action("foxyshop_order_table_head"); ?>
</tr>
</thead>
<tfoot>
<tr>
<th class="manage-column column-cb check-column" style="" scope="col"><input type="checkbox"></th>
<th><?php _e('Transaction ID', 'foxyshop'); ?></th>
<th><?php _e('OrderDate', 'foxyshop'); ?></th>
<th><?php _e('Customer', 'foxyshop'); ?></th>
<th><?php _e('Total', 'foxyshop'); ?></th>
<?php do_action("foxyshop_order_table_foot"); ?>
</tr>
</tfoot>
<tbody id="the-list">
<?php
$holder = "";
$hide_transaction_filter = isset($_REQUEST['hide_transaction_filter']) ? sanitize_text_field($_REQUEST['hide_transaction_filter']) : 0;
$transactions = $xml->transactions->transaction ? $xml->transactions->transaction : [];
if (!count($transactions)) {
echo '<tr><td colspan="5">'.__('No transaction found.').'</td></tr>';
}
foreach($transactions as $transaction) {
$transaction_id = (string)$transaction->id;
$customer_first_name = (string)$transaction->customer_first_name;
$customer_last_name = (string)$transaction->customer_last_name;
$is_anonymous = (int)$transaction->is_anonymous;
$customer_id = (string)$transaction->customer_id;
$minfraud_score = (int)$transaction->minfraud_score;
$transaction_date = (string)$transaction->transaction_date;
$transaction_date = date(apply_filters("foxyshop_date_time_format", "Y-m-d H:i"), strtotime($transaction_date));
$customer_name = $customer_last_name . ', ' . $customer_first_name;
if ($is_anonymous != 1 && $customer_id) $customer_name = '<a href="edit.php?post_type=foxyshop_product&page=foxyshop_customer_management&customer_id_filter=' . $customer_id . '&foxyshop_search=1" title="Customer ' . $customer_id . '">' . $customer_name . '</a>';
$print_receipt_link = "edit.php?foxyshop_search=1&post_type=foxyshop_product&page=foxyshop_order_management&id_filter=" . $transaction_id . "&foxyshop_print_invoice=1&is_test_filter=&skip_print=1&transaction_date_filter_begin=" . $foxy_data['transaction_date_filter_begin'] . "&transaction_date_filter_end=" . $foxy_data['transaction_date_filter_end'];
foreach($transaction->transaction_details->transaction_detail as $transaction_detail) {
$pickup_day = "";
$pickup_location = "";
foreach($transaction_detail->transaction_detail_options->transaction_detail_option as $transaction_detail_option) {
if ((string)$transaction_detail_option->product_option_name == "Pickup_Day") {
$pickup_day = (string)$transaction_detail_option->product_option_value;
} elseif ((string)$transaction_detail_option->product_option_name == "Pickup_Location") {
$pickup_location = (string)$transaction_detail_option->product_option_value;
}
$holder .= '<li>';
$holder .= str_replace("_", " ", (string)$transaction_detail_option->product_option_name) . ': ';
if (substr((string)$transaction_detail_option->product_option_value,0,5) == "file-") {
$upload_dir = wp_upload_dir();
$holder .= '<a href="' . $upload_dir['baseurl'] . '/customuploads/' . (string)$transaction_detail_option->product_option_value . '" target="_blank">' . (string)$transaction_detail_option->product_option_value . '</a>';
} else {
$holder .= $transaction_detail_option->product_option_value;
}
if ((string)$transaction_detail_option->price_mod != '0.000') $holder .= ' (' . (strpos("-",$transaction_detail_option->price_mod) !== false ? '-' : '+') . foxyshop_currency((double)$transaction_detail_option->price_mod) . ')';
$holder .= '</li>';
}
}
echo '<tr rel="' . esc_attr($transaction_id) . '">';
echo '<th class="check-column" scope="row"><input type="checkbox" value="' . esc_attr($transaction_id) . '" name="post[]"></th>'."\n";
echo '<td>';
echo '<a href="' . esc_url((string)$transaction->receipt_url) . '" title="' . __('FoxyCart Receipt', 'foxyshop') . '" target="_blank" style="float: left;"><img src="' . esc_url(FOXYSHOP_DIR) . '/images/foxycart-icon.png" alt="" align="top" /></a>';
echo '<strong><a href="#" class="view_detail" style="float: left; line-height: 18px; margin: 0 0 0 5px;">' . esc_html($transaction_id) . '</a></strong>';
echo '<div class="row-actions">';
echo '<span><a href="#" class="view_detail">' . __('View Order', 'foxyshop') . '</a> | </span>';
echo '<span><a href="' . esc_attr($print_receipt_link) . '" title="' . __('Printable Receipt', 'foxyshop') . '" target="_blank">' . __('Receipt', 'foxyshop') . '</a></span>';
if (!isset($transaction->is_hidden)) {
$is_hidden = $hide_transaction_filter;
} else {
$is_hidden = (string)$transaction->is_hidden;
}
if ($is_hidden == 1) {
echo '<span> | <a href="#" class="set_order_hidden_status" rel="0">' . __('Unhide Transaction', 'foxyshop') . '</a></span>';
} else {
echo '<span> | <a href="#" class="set_order_hidden_status" rel="1">' . __('Hide Transaction', 'foxyshop') . '</a></span>';
}
do_action("foxyshop_order_line_item", $transaction);
echo '</div>';
echo '</td>';
echo '<td>' . esc_html($transaction_date) . '</td>';
echo '<td>' . wp_kses_post($customer_name) . '</td>';
echo '<td>' . esc_html(foxyshop_currency((double)$transaction->order_total)) . '</td>';
do_action("foxyshop_order_line_end", $transaction);
echo '</tr>'."\n";
//Write Out Order Details Holder
$holder .= '<div class="detail_holder" id="holder_' . $transaction_id . '">'."\n";
$holder .= '<div class="foxyshop_list_col">';
$holder .= '<h4>' . __('Transaction Details', 'foxyshop') . '</h4>';
$holder .= '<ul>';
$holder .= '<li>' . __('Order ID', 'foxyshop') . ': ' . (string)$transaction->id . '</li>';
$holder .= '<li>' . __('Date', 'foxyshop') . ': ' . $transaction_date. '</li>';
$holder .= '<li>' . (string)$transaction->processor_response. '</li>';
if ((string)$transaction->cc_number_masked != "") $holder .= '<li>' . __('Card', 'foxyshop') . ': ' . (string)$transaction->cc_number_masked. ' (' . (string)$transaction->cc_type . ')</li>';
if ((string)$transaction->cc_exp_month != "") $holder .= '<li>' . __('Exp', 'foxyshop') . ': ' . (string)$transaction->cc_exp_month . '-' . (string)$transaction->cc_exp_year . '</li>';
if ($minfraud_score > 0) $holder .= '<li>' . __('MinFraud Score', 'foxyshop') . ': ' . $minfraud_score . '</li>';
if ((string)$transaction->shipto_shipping_service_description != "") $holder .= '<li>' . __('Shipping Type', 'foxyshop') . ': ' . (string)$transaction->shipto_shipping_service_description . '</li>';
if ((string)$transaction->processor_response == "Purchase Order") $holder .= '<li>PO #: ' . (string)$transaction->purchase_order . '</li>';
$holder .= '</ul>';
$holder .= '</div>';
$holder .= '<div class="foxyshop_list_col">';
$holder .= '<h4>' . __('Order Details', 'foxyshop') . '</h4>';
$holder .= '<ul>';
$holder .= '<li>' . __('Subtotal', 'foxyshop') . ': ' . foxyshop_currency((double)$transaction->product_total) . '</li>';
//Discounts
foreach($transaction->discounts->discount as $discount) {
$holder .= '<li>' . (string)$discount->name . ': ' . foxyshop_currency((double)$discount->amount) . '</li>';
}
//Taxes
foreach($transaction->taxes->tax as $tax) {
$holder .= '<li>' . (string)$tax->tax_name . ': ' . foxyshop_currency((double)$tax->tax_amount) . '</li>';
}
$holder .= '<li>' . __('Shipping', 'foxyshop') . ': ' . foxyshop_currency((double)$transaction->shipping_total) . '</li>';
$holder .= '<li><strong>' . __('Order Total', 'foxyshop') . ': ' . foxyshop_currency((double)$transaction->order_total) . '</strong></li>';
$holder .= '</ul>';
$holder .= '</div>';
$holder .= '<div class="foxyshop_list_col">';
$holder .= '<h4>' . __('Customer Address', 'foxyshop') . '</h4>';
$holder .= '<ul>';
$holder .= '<li>' . (string)$transaction->customer_first_name . ' ' . (string)$transaction->customer_last_name . '</li>';
if ((string)$transaction->customer_company != "") $holder .= '<li>' . (string)$transaction->customer_company . '</li>';
$holder .= '<li>' . (string)$transaction->customer_address1 . '</li>';
if ((string)$transaction->customer_address2 != "") $holder .= '<li>' . (string)$transaction->customer_address2 . '</li>';
$holder .= '<li>' . (string)$transaction->customer_city . ', ' . (string)$transaction->customer_state . ' ' . (string)$transaction->customer_postal_code . '</li>';
$holder .= '<li>' . (string)$transaction->customer_country . '</li>';
$holder .= '</ul>';
$holder .= '</div>';
//Shipping Addresses (if entered)
if ((string)$transaction->shipping_first_name != "" && !isset($transaction->shipto_addresses->shipto_address)) {
$holder .= '<div class="foxyshop_list_col">';
$holder .= '<h4>' . __('Shipping Details', 'foxyshop') . '</h4>';
$holder .= '<ul>';
$holder .= '<li>' . (string)$transaction->shipping_first_name . ' ' . (string)$transaction->shipping_last_name . '</li>';
if ((string)$transaction->shipping_company != "") $holder .= '<li>' . (string)$transaction->shipping_company . '</li>';
$holder .= '<li>' . (string)$transaction->shipping_address1 . '</li>';
if ((string)$transaction->shipping_address2 != "") $holder .= '<li>' . (string)$transaction->shipping_address2 . '</li>';
$holder .= '<li>' . (string)$transaction->shipping_city . ', ' . (string)$transaction->shipping_state . ' ' . (string)$transaction->shipping_postal_code . '</li>';
$holder .= '<li>' . (string)$transaction->shipping_country . '</li>';
if ((string)$transaction->shipping_phone != "") $holder .= '<li>' . (string)$transaction->shipping_phone . '</li>';
$holder .= '</ul>';
$holder .= '</div>';
}
//Multi-ship Addresses
foreach($transaction->shipto_addresses->shipto_address as $shipto_address) {
$holder .= '<div class="foxyshop_list_col">';
$holder .= '<h4>' . __('Shipping Details', 'foxyshop') . ': ' . $shipto_address->address_name . '</h4>';
$holder .= '<ul>';
$holder .= '<li>' . $shipto_address->shipto_first_name . ' ' . $shipto_address->shipto_last_name . '</li>';
if ((string)$shipto_address->shipto_company != "") $holder .= '<li>' . $shipto_address->shipto_company . '</li>';
$holder .= '<li>' . $shipto_address->shipto_address1 . '</li>';
if ((string)$shipto_address->shipto_address2 != "") $holder .= '<li>' . $shipto_address->shipto_address2 . '</li>';
$holder .= '<li>' . $shipto_address->shipto_city . ', ' . $shipto_address->shipto_state . ' ' . $shipto_address->shipto_postal_code . '</li>';
$holder .= '<li>' . $shipto_address->shipto_country . '</li>';
if ((string)$shipto_address->shipto_phone != "") $holder .= '<li>' . $shipto_address->shipto_phone . '</li>';
$holder .= '<li><br />' . __('Method', 'foxyshop') . ': ' . $shipto_address->shipto_shipping_service_description . '</li>';
$holder .= '<li>' . __('Shipping', 'foxyshop') . ': ' . foxyshop_currency((double)$shipto_address->shipto_shipping_total) . '</li>';
$holder .= '</ul>';
$holder .= '</div>';
}
//Customer Details
$holder .= '<div class="foxyshop_list_col">';
$holder .= '<h4>' . __('Customer Details', 'foxyshop') . '</h4>';
$holder .= '<ul>';
if ((string)$transaction->customer_phone != "") $holder .= '<li>' . (string)$transaction->customer_phone . '</li>';
$holder .= '<li><a href="mailto:' . (string)$transaction->customer_email . '">' . (string)$transaction->customer_email . '</a></li>';
$holder .= '<li>' . apply_filters('foxyshop_order_ip', '<a href="' . 'http://whatismyipaddress.com/ip/' . (string)$transaction->customer_ip . '" target="_blank">' . (string)$transaction->customer_ip . '</a>', (string)$transaction->customer_ip) . '</li>';
$holder .= '<li> </li>';
//Custom Fields
foreach($transaction->custom_fields->custom_field as $custom_field) {
if ($custom_field->custom_field_name != 'ga') {
$holder .= '<li><strong>' . str_replace("_"," ",(string)$custom_field->custom_field_name) . ':</strong> ' . nl2br((string)$custom_field->custom_field_value) . '</li>';
}
}
$holder .= '</ul>';
$holder .= '</div>';
//Custom Attributes
$holder .= foxyshop_manage_attributes($transaction->attributes, $transaction_id, "transaction");
$holder .= '<div style="clear: both; height: 20px;"></div>';
foreach($transaction->transaction_details->transaction_detail as $transaction_detail) {
$holder .= '<div class="product_listing">';
if ($transaction_detail->image != "") {
$holder .= '<div class="image_div">';
if ($transaction_detail->url != "") $holder .= '<a href="' . $transaction_detail->url . '" target="_blank">';
$holder .= '<img src="' . $transaction_detail->image . '" />';
if ($transaction_detail->url != "") $holder .= '</a>';
$holder .= '</div>';
}
$product_discount = 0;
$weight_discount = 0;
foreach($transaction_detail->transaction_detail_options->transaction_detail_option as $transaction_detail_option) {
$product_discount += (double)$transaction_detail_option->price_mod;
$weight_discount += (double)$transaction_detail_option->weight_mod;
}
$holder .= '<div class="details_div">';
$holder .= '<h4>' . $transaction_detail->product_name . '</h4>';
$holder .= '<ul>';
if ((string)$transaction_detail->shipto != "") $holder .= '<li>Ship To: ' . (string)$transaction_detail->shipto . '</li>';
$holder .= '<li>' . __('Code', 'foxyshop') . ': ' . (string)$transaction_detail->product_code . '</li>';
$holder .= '<li>' . __('Price', 'foxyshop') . ': ' . foxyshop_currency((double)$transaction_detail->product_price). '</li>';
if ($product_discount != 0) $holder .= '<li>Adjusted Price: ' . foxyshop_currency((double)$transaction_detail->product_price + $product_discount). '</li>';
$holder .= '<li>' . __('Qty', 'foxyshop') . ': ' . $transaction_detail->product_quantity . '</li>';
if ((string)$transaction_detail->product_weight != "0.000") $holder .= '<li>Weight: ' . (string)$transaction_detail->product_weight . '</li>';
if ($weight_discount != 0) $holder .= '<li>Adjusted Weight: ' . ((double)$transaction_detail->product_weight + $weight_discount). '</li>';
if ((string)$transaction_detail->category_code != "DEFAULT") $holder .= '<li>Category: ' . (string)$transaction_detail->category_description . '</li>';
if ((string)$transaction_detail->product_delivery_type != "shipped") $holder .= '<li>Delivery Type: ' . (string)$transaction_detail->product_delivery_type . '</li>';
if ((string)$transaction_detail->downloadable_url != "") $holder .= '<li>Downloadable URL: <a href="' . (string)$transaction_detail->downloadable_url . '" target="_blank">Click Here</a></li>';
if ($transaction_detail->subscription_frequency != "") {
$holder .= '<li>' . __('Subscription Frequency', 'foxyshop') . ': ' . (string)$transaction_detail->subscription_frequency . '</li>';
$holder .= '<li>' . __('Subscription Start Date', 'foxyshop') . ': ' . (string)$transaction_detail->subscription_startdate . '</li>';
$holder .= '<li>' . __('Subscription Next Date', 'foxyshop') . ': ' . (string)$transaction_detail->subscription_nextdate . '</li>';
if ((string)$transaction_detail->subscription_enddate != "0000-00-00") $holder .= '<li>Subscription End Date: ' . (string)$transaction_detail->subscription_enddate . '</li>';
}
foreach($transaction_detail->transaction_detail_options->transaction_detail_option as $transaction_detail_option) {
$holder .= '<li>';
$holder .= str_replace("_", " ", (string)$transaction_detail_option->product_option_name) . ': ';
if (substr((string)$transaction_detail_option->product_option_value,0,5) == "file-") {
$upload_dir = wp_upload_dir();
$holder .= '<a href="' . $upload_dir['baseurl'] . '/customuploads/' . (string)$transaction_detail_option->product_option_value . '" target="_blank">' . (string)$transaction_detail_option->product_option_value . '</a>';
} else {
$holder .= $transaction_detail_option->product_option_value;
}
if ((string)$transaction_detail_option->price_mod != '0.000') $holder .= ' (' . (strpos("-",$transaction_detail_option->price_mod) !== false ? '-' : '+') . foxyshop_currency((double)$transaction_detail_option->price_mod) . ')';
$holder .= '</li>';
}
$holder .= '</ul>';
$holder .= '</div>';
$holder .= '<div style="clear: both;"></div>';
$holder .= '</div>';
}
$holder .= '<div style="clear: both; height: 10px;"></div>';
$holder .= '</div>';
}
echo '</tbody></table>';
foxyshop_api_paging_nav('transactions', 'bottom', $xml, $foxyshop_querystring);
?>
</form>
<?php } ?>
<div id="details_holder"><?php echo foxy_wp_kses_html($holder); ?></div>
<?php
function foxyshop_inline_orders_js() {
$hide_transaction_filter = isset($_REQUEST['hide_transaction_filter']) ? sanitize_text_field($_REQUEST['hide_transaction_filter']) : 0;
echo "<script type='text/javascript'>
jQuery(document).ready(function($) {
$(\"#foxyshop_searchform\").on(\"click\", \"button\", function() {
if ($(\"#transaction_search_type option:selected\").attr(\"target\") == \"_blank\") {
$(\"#foxyshop_searchform\").attr(\"target\",\"_blank\");
} else {
$(\"#foxyshop_searchform\").attr(\"target\",\"_self\");
}
});
$(\".tablenav a.disabled\").click(function() {
return false;
});
});
jQuery(document).ready(function($){
$(\".foxyshop-list-table thead th\").click(function() {
$(\"#foxyshop-list-inline .detail_holder\").appendTo(\"#details_holder\");
$(\"#foxyshop-list-inline\").remove();
});
$(\".foxyshop-list-table\").tablesorter({
'cssDesc': 'asc sorted',
'cssAsc': 'desc sorted',
'headers': { 0: { sorter: false} }
});
$(\".view_detail\").click(function() {
var id = $(this).parents(\"tr\").attr(\"rel\");
if ($(\"#foxyshop-list-inline #holder_\" + id).length > 0) {
$(\"#foxyshop-list-inline .detail_holder\").appendTo(\"#details_holder\");
$(\"#foxyshop-list-inline\").remove();
} else {
$(\"#foxyshop-list-inline .detail_holder\").appendTo(\"#details_holder\");
$(\"#foxyshop-list-inline\").remove();
$(this).parents(\"tr\").after('<tr id=\"foxyshop-list-inline\"><td colspan=\"7\"></td></tr>');
$(\"#holder_\"+id).appendTo(\"#foxyshop-list-inline td\");
}
return false;
});
$(\".set_order_hidden_status\").click( function() {
var hide_transaction = $(this).attr(\"rel\");
var transaction_id = $(this).parents(\"tr\").attr(\"rel\");
var data = {
action: 'foxyshop_display_list_ajax_action',
security: '" . wp_create_nonce("foxyshop-display-list-function") . "',
hide_transaction: hide_transaction,
foxyshop_action: 'hide_transaction',
id: transaction_id
};
$.post(ajaxurl, data, function(response) {
";
if ($hide_transaction_filter == "0") {
echo "
$(\"tr[rel=\"+transaction_id+\"]\").remove();
$(\"#foxyshop-list-inline #holder_\" + transaction_id).remove();
";
} else {
echo "
alert(response);
";
}
echo "
});
return false;
});
";
echo esc_js(foxyshop_manage_attributes_jquery('transaction'));
echo "
});
</script>";
}
add_action( 'admin_print_footer_scripts', 'foxyshop_inline_orders_js' );
}