Version Description
- 2018-08-30 =
- Added filter by user custom fields
- Added order fields "Count of exported items", "User Website"
- Added product fields "Product Id", "Variation Id", "Order Line Subtotal Tax"
- Multiple custom fields with same title are exported as list (for order)
- Format Shipping/Billing fields as string (Excel only)
- Fixed compatibility issue with WP Redis cache
- Fixed bug - "Progressbar" shows error message correctly
- Fixed bug - "Progressbar" doesn't miss orders if both "Mark exported" and "Export unmarked only" are ON
- Reduced memory footprint (options are not autoloaded)
Download this release
Release Info
Developer | algol.plus |
Plugin | ![]() |
Version | 1.5.6 |
Comparing to | |
See all releases |
Code changes from version 1.5.5 to 1.5.6
- assets/css/export.css +58 -0
- assets/js/export.js +167 -2
- assets/js/settings-form.js +7 -2
- classes/admin/class-wc-order-export-ajax.php +137 -86
- classes/admin/class-wc-order-export-manage.php +119 -94
- classes/class-wc-order-export-admin.php +302 -238
- classes/core/class-wc-order-export-data-extractor-ui.php +665 -184
- classes/core/class-wc-order-export-data-extractor.php +837 -585
- classes/core/class-wc-order-export-engine.php +348 -269
- classes/formats/abstract-class-woe-formatter-sv.php +19 -14
- classes/formats/abstract-class-woe-formatter.php +30 -26
- classes/formats/class-woe-formatter-csv.php +4 -2
- classes/formats/class-woe-formatter-json.php +11 -8
- classes/formats/class-woe-formatter-tsv.php +1 -0
- classes/formats/class-woe-formatter-xls.php +74 -58
- classes/formats/class-woe-formatter-xml.php +47 -38
- i18n/languages/woo-order-export-lite.pot +267 -240
- readme.txt +12 -1
- view/settings-form.php +50 -10
- woo-order-export-lite.php +2 -2
assets/css/export.css
CHANGED
@@ -636,4 +636,62 @@ input.date{
|
|
636 |
height: 28px;
|
637 |
vertical-align: middle;
|
638 |
background: url("../img/calendar.png") 98px 5px no-repeat;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
639 |
}
|
636 |
height: 28px;
|
637 |
vertical-align: middle;
|
638 |
background: url("../img/calendar.png") 98px 5px no-repeat;
|
639 |
+
}
|
640 |
+
|
641 |
+
.woe-row-sort-handle {
|
642 |
+
width: 20px;
|
643 |
+
height: 20px;
|
644 |
+
color: black;
|
645 |
+
cursor: move;
|
646 |
+
}
|
647 |
+
|
648 |
+
#reorder_section {
|
649 |
+
display: inline-block;
|
650 |
+
margin-top: 10px;
|
651 |
+
}
|
652 |
+
|
653 |
+
#reorder_section #apply_reorder, #reorder_section #cancel_reorder {
|
654 |
+
display: none;
|
655 |
+
}
|
656 |
+
|
657 |
+
.wp-wrap .column-order {
|
658 |
+
width: 2.2em;
|
659 |
+
}
|
660 |
+
|
661 |
+
.wp-wrap .pipe {
|
662 |
+
font-size: x-large;
|
663 |
+
vertical-align: middle;
|
664 |
+
}
|
665 |
+
|
666 |
+
.section_choice {
|
667 |
+
cursor: pointer;
|
668 |
+
}
|
669 |
+
|
670 |
+
.section_choice.active {
|
671 |
+
font-weight: bold;
|
672 |
+
color: #000;
|
673 |
+
}
|
674 |
+
|
675 |
+
.section:not(.active) {
|
676 |
+
display: none;
|
677 |
+
}
|
678 |
+
|
679 |
+
.license_paragraph {
|
680 |
+
margin : 15px 0 15px 0;
|
681 |
+
}
|
682 |
+
|
683 |
+
#license_help_text {
|
684 |
+
background-color: white;
|
685 |
+
border: 1px #b2b2b2 solid;
|
686 |
+
border-radius: 5px;
|
687 |
+
padding:10px;
|
688 |
+
margin: 15px 0 15px 0;
|
689 |
+
}
|
690 |
+
|
691 |
+
#my-shedule-days .wc_oe-select-interval {
|
692 |
+
width: 55%;
|
693 |
+
}
|
694 |
+
|
695 |
+
#my-shedule-days .input-mins-custom-interval {
|
696 |
+
max-width: 100px;
|
697 |
}
|
assets/js/export.js
CHANGED
@@ -130,6 +130,9 @@ function bind_events() {
|
|
130 |
});
|
131 |
//end of change
|
132 |
|
|
|
|
|
|
|
133 |
//PRODUCT ATTRIBUTES BEGIN
|
134 |
jQuery( '#attributes' ).change( function() {
|
135 |
|
@@ -855,6 +858,101 @@ function bind_events() {
|
|
855 |
}
|
856 |
}
|
857 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
858 |
function add_bind_for_custom_fields( prefix, output_format, $to ) {
|
859 |
jQuery( '#button_custom_field_' + prefix + '' ).off();
|
860 |
jQuery( '#button_custom_field_' + prefix + '' ).click( function() {
|
@@ -1030,7 +1128,10 @@ function select2_inits()
|
|
1030 |
} );
|
1031 |
jQuery( "#product_custom_fields_check" ).select2(select2WODropdownOpts);
|
1032 |
|
1033 |
-
|
|
|
|
|
|
|
1034 |
|
1035 |
jQuery( "#taxonomies" ).select2( {
|
1036 |
width: 150
|
@@ -1250,4 +1351,68 @@ function try_color_date_filter() {
|
|
1250 |
if( jQuery( "#from_date" ).val() || jQuery( "#to_date" ).val() )
|
1251 |
color = 'red';
|
1252 |
jQuery( "#my-date-filter" ).css('color', color);
|
1253 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
});
|
131 |
//end of change
|
132 |
|
133 |
+
// for filter by USER custom fields
|
134 |
+
bind_events_users();
|
135 |
+
|
136 |
//PRODUCT ATTRIBUTES BEGIN
|
137 |
jQuery( '#attributes' ).change( function() {
|
138 |
|
858 |
}
|
859 |
}
|
860 |
|
861 |
+
function bind_events_users() {
|
862 |
+
// for filter by ORDER custom fields
|
863 |
+
jQuery( '#user_custom_fields' ).change( function () {
|
864 |
+
|
865 |
+
jQuery( '#select_user_custom_fields' ).attr( 'disabled', 'disabled' );
|
866 |
+
var data = {
|
867 |
+
'cf_name': jQuery( this ).val(),
|
868 |
+
method: "get_user_custom_fields_values",
|
869 |
+
action: "order_exporter"
|
870 |
+
};
|
871 |
+
var val_op = jQuery( '#select_user_custom_fields' ).val();
|
872 |
+
jQuery( '#text_user_custom_fields' ).val( '' );
|
873 |
+
jQuery.post( ajaxurl, data, function ( response ) {
|
874 |
+
jQuery( '#select_user_custom_fields' ).remove();
|
875 |
+
jQuery( '#select_user_custom_fields--select2 select' ).select2( 'destroy' );
|
876 |
+
jQuery( '#select_user_custom_fields, #select_user_custom_fields--select2' ).remove();
|
877 |
+
if ( response ) {
|
878 |
+
var options = '<option>' + export_messages.empty + '</option>';
|
879 |
+
jQuery.each( response, function ( index, value ) {
|
880 |
+
options += '<option>' + value + '</option>';
|
881 |
+
} );
|
882 |
+
var $select = jQuery( '<div id="select_user_custom_fields--select2" style="margin-top: 0px;margin-right: 6px; vertical-align: top;'
|
883 |
+
+ 'display: ' + (
|
884 |
+
(
|
885 |
+
'LIKE' === val_op || 'NOT SET' === val_op || 'IS SET' === val_op
|
886 |
+
) ? 'none' : 'inline-block'
|
887 |
+
) + ';">'
|
888 |
+
+ '<select id="select_user_custom_fields">' + options + '</select></div>' );
|
889 |
+
$select.insertBefore( jQuery( '#add_user_custom_fields' ) )
|
890 |
+
$select.find( 'select' ).select2( {tags: true} );
|
891 |
+
}
|
892 |
+
else {
|
893 |
+
jQuery( '<input type="text" id="select_user_custom_fields" style="margin-right: 8px;">' ).insertBefore(
|
894 |
+
jQuery( '#add_user_custom_fields' ) );
|
895 |
+
}
|
896 |
+
}, 'json' );
|
897 |
+
} );
|
898 |
+
jQuery( '#add_user_custom_fields' ).click( function () {
|
899 |
+
|
900 |
+
var val = ! jQuery( "#select_user_custom_fields" ).is( ':disabled' ) ? jQuery(
|
901 |
+
"#select_user_custom_fields" ).val() : jQuery( "#text_user_custom_fields" ).val();
|
902 |
+
var val2 = jQuery( '#user_custom_fields' ).val();
|
903 |
+
var val_op = jQuery( '#user_custom_fields_compare' ).val();
|
904 |
+
if ( val != null && val2 != null && val.length && val2.length ) {
|
905 |
+
var result = val2 + ' ' + val_op + ' ' + val;
|
906 |
+
|
907 |
+
var f = true;
|
908 |
+
jQuery( '#user_custom_fields_check' ).next().find( 'ul li' ).each( function () {
|
909 |
+
if ( jQuery( this ).attr( 'title' ) == val ) {
|
910 |
+
f = false;
|
911 |
+
}
|
912 |
+
} );
|
913 |
+
|
914 |
+
if ( f ) {
|
915 |
+
if ( export_messages.empty === val ) {
|
916 |
+
result = val2 + ' ' + val_op + ' empty';
|
917 |
+
jQuery(
|
918 |
+
'#user_custom_fields_check' ).append( '<option selected="selected" value="' + result + '">' + result + '</option>' );
|
919 |
+
} else {
|
920 |
+
jQuery(
|
921 |
+
'#user_custom_fields_check' ).append( '<option selected="selected" value="' + result + '">' + result + '</option>' );
|
922 |
+
}
|
923 |
+
|
924 |
+
jQuery( '#user_custom_fields_check' ).select2();
|
925 |
+
|
926 |
+
jQuery( '#user_custom_fields_check option' ).each( function () {
|
927 |
+
jQuery( '#user_custom_fields_check option[value=\"' + jQuery( this ).val() + '\"]:not(:last)' ).remove();
|
928 |
+
} );
|
929 |
+
|
930 |
+
jQuery( "input#select_user_custom_fields" ).val( '' );
|
931 |
+
}
|
932 |
+
}
|
933 |
+
return false;
|
934 |
+
} );
|
935 |
+
|
936 |
+
jQuery( '#user_custom_fields_compare').change(function() {
|
937 |
+
var val_op = jQuery( '#user_custom_fields_compare' ).val();
|
938 |
+
if ( 'LIKE' === val_op ) {
|
939 |
+
jQuery( "#select_user_custom_fields" ).css( 'display', 'none' ).attr( 'disabled', 'disabled' );
|
940 |
+
jQuery( "#select_user_custom_fields--select2" ).hide();
|
941 |
+
jQuery( "#text_user_custom_fields" ).css('display', 'inline' ).attr( 'disabled', false );
|
942 |
+
}
|
943 |
+
else if ( 'NOT SET' === val_op || 'IS SET' === val_op ) {
|
944 |
+
jQuery( "#select_user_custom_fields" ).css( 'display', 'none' ).attr( 'disabled', 'disabled' ) . val(' ');
|
945 |
+
jQuery( "#select_user_custom_fields--select2" ).hide();
|
946 |
+
jQuery( "#text_user_custom_fields" ).css('display', 'none' ).attr( 'disabled', false ). val(' ');
|
947 |
+
}
|
948 |
+
else {
|
949 |
+
jQuery( "#select_user_custom_fields" ).css( 'display', 'inline-block' ).attr( 'disabled', false );
|
950 |
+
jQuery( '#select_user_custom_fields--select2' ).css('display', 'inline' );
|
951 |
+
jQuery( "#text_user_custom_fields" ).css( 'display', 'none' ).attr( 'disabled', 'disabled' );
|
952 |
+
}
|
953 |
+
});
|
954 |
+
}
|
955 |
+
|
956 |
function add_bind_for_custom_fields( prefix, output_format, $to ) {
|
957 |
jQuery( '#button_custom_field_' + prefix + '' ).off();
|
958 |
jQuery( '#button_custom_field_' + prefix + '' ).click( function() {
|
1128 |
} );
|
1129 |
jQuery( "#product_custom_fields_check" ).select2(select2WODropdownOpts);
|
1130 |
|
1131 |
+
jQuery( "#user_custom_fields" ).select2( {
|
1132 |
+
width: 150
|
1133 |
+
} );
|
1134 |
+
jQuery( "#user_custom_fields_check" ).select2();
|
1135 |
|
1136 |
jQuery( "#taxonomies" ).select2( {
|
1137 |
width: 150
|
1351 |
if( jQuery( "#from_date" ).val() || jQuery( "#to_date" ).val() )
|
1352 |
color = 'red';
|
1353 |
jQuery( "#my-date-filter" ).css('color', color);
|
1354 |
+
}
|
1355 |
+
|
1356 |
+
jQuery( document ).ready( function ($) {
|
1357 |
+
|
1358 |
+
$( "#the-list" ).sortable( { handle: '.woe-row-sort-handle' } );
|
1359 |
+
|
1360 |
+
$( '.wp-wrap .column-order' ).hide();
|
1361 |
+
|
1362 |
+
$start_reorder_button = $( '#start_reorder' );
|
1363 |
+
$apply_reorder_button = $( '#apply_reorder' );
|
1364 |
+
$cancel_reorder_button = $( '#cancel_reorder' );
|
1365 |
+
$start_reorder_button.click( function ( e ) {
|
1366 |
+
$order_ids = $( "#the-list" ).sortable( "toArray", {attribute: 'data-job_id'} );
|
1367 |
+
|
1368 |
+
$start_reorder_button.hide();
|
1369 |
+
$apply_reorder_button.show();
|
1370 |
+
$cancel_reorder_button.show();
|
1371 |
+
|
1372 |
+
$( '.wp-wrap .check-column' ).hide();
|
1373 |
+
$( '.wp-wrap .column-order' ).show();
|
1374 |
+
} );
|
1375 |
+
|
1376 |
+
$apply_reorder_button.click( function ( e ) {
|
1377 |
+
$start_reorder_button.show();
|
1378 |
+
$apply_reorder_button.hide();
|
1379 |
+
$cancel_reorder_button.hide();
|
1380 |
+
|
1381 |
+
$( '.wp-wrap .check-column' ).show();
|
1382 |
+
$( '.wp-wrap .column-order' ).hide();
|
1383 |
+
|
1384 |
+
jQuery.ajax({
|
1385 |
+
url: ajaxurl,
|
1386 |
+
data: {
|
1387 |
+
'action': "order_exporter",
|
1388 |
+
'method': 'reorder_jobs',
|
1389 |
+
'new_jobs_order': $( "#the-list" ).sortable( "toArray", {attribute: 'data-job_id'} ),
|
1390 |
+
'tab_name': $tab_name,
|
1391 |
+
},
|
1392 |
+
error: function ( response ) {},
|
1393 |
+
dataType: 'json',
|
1394 |
+
type: 'POST',
|
1395 |
+
success: function() {
|
1396 |
+
|
1397 |
+
}
|
1398 |
+
});
|
1399 |
+
|
1400 |
+
} );
|
1401 |
+
|
1402 |
+
$cancel_reorder_button.click( function ( e ) {
|
1403 |
+
$start_reorder_button.show();
|
1404 |
+
$apply_reorder_button.hide();
|
1405 |
+
$cancel_reorder_button.hide();
|
1406 |
+
|
1407 |
+
$( '.wp-wrap .check-column' ).show();
|
1408 |
+
$( '.wp-wrap .column-order' ).hide();
|
1409 |
+
|
1410 |
+
$( $order_ids ).each( function ( $key, $job_id ) {
|
1411 |
+
$element = $( '[data-job_id="' + $job_id + '"' ).detach();
|
1412 |
+
$( "#the-list" ).append( $element );
|
1413 |
+
} );
|
1414 |
+
} );
|
1415 |
+
|
1416 |
+
|
1417 |
+
|
1418 |
+
} );
|
assets/js/settings-form.js
CHANGED
@@ -503,6 +503,7 @@ jQuery( document ).ready( function( $ ) {
|
|
503 |
jQuery( '#itemmeta' ).change();
|
504 |
jQuery( '#custom_fields' ).change();
|
505 |
jQuery( '#product_custom_fields' ).change();
|
|
|
506 |
jQuery( '#shipping_locations' ).change();
|
507 |
jQuery( '#billing_locations' ).change();
|
508 |
jQuery( '#item_names' ).change();
|
@@ -601,7 +602,7 @@ jQuery( document ).ready( function( $ ) {
|
|
601 |
} );
|
602 |
|
603 |
$( 'input[type="checkbox"][name="settings[custom_php]"]' ).change( function() {
|
604 |
-
$( '
|
605 |
} );
|
606 |
|
607 |
$( '#order_fields input[type=checkbox]' ).change( function() {
|
@@ -727,7 +728,11 @@ jQuery( document ).ready( function( $ ) {
|
|
727 |
progress( 100, jQuery( '#progressBar' ) );
|
728 |
},
|
729 |
success: function( response ) {
|
730 |
-
|
|
|
|
|
|
|
|
|
731 |
}
|
732 |
} );
|
733 |
}
|
503 |
jQuery( '#itemmeta' ).change();
|
504 |
jQuery( '#custom_fields' ).change();
|
505 |
jQuery( '#product_custom_fields' ).change();
|
506 |
+
jQuery( '#user_custom_fields' ).change();
|
507 |
jQuery( '#shipping_locations' ).change();
|
508 |
jQuery( '#billing_locations' ).change();
|
509 |
jQuery( '#item_names' ).change();
|
602 |
} );
|
603 |
|
604 |
$( 'input[type="checkbox"][name="settings[custom_php]"]' ).change( function() {
|
605 |
+
$( 'div#custom_php_code_textarea' ).toggle( $( this ).is( ':checked' ) );
|
606 |
} );
|
607 |
|
608 |
$( '#order_fields input[type=checkbox]' ).change( function() {
|
728 |
progress( 100, jQuery( '#progressBar' ) );
|
729 |
},
|
730 |
success: function( response ) {
|
731 |
+
if ( typeof response.error !== 'undefined') {
|
732 |
+
alert( response.error );
|
733 |
+
} else {
|
734 |
+
get_all( response.start, ( response.start / window.count ) * 100, method )
|
735 |
+
}
|
736 |
}
|
737 |
} );
|
738 |
}
|
classes/admin/class-wc-order-export-ajax.php
CHANGED
@@ -10,82 +10,86 @@ class WC_Order_Export_Ajax {
|
|
10 |
|
11 |
public function save_settings() {
|
12 |
$settings = WC_Order_Export_Manage::make_new_settings( $_POST );
|
13 |
-
$id
|
14 |
echo json_encode( array( 'id' => $id ) );
|
15 |
}
|
16 |
-
|
17 |
public function validate_url_key() {
|
18 |
$main_settings = WC_Order_Export_Admin::load_main_settings();
|
19 |
-
if( !isset( $_REQUEST['key'] ) OR $_REQUEST['key'] != $main_settings['cron_key'] ) {
|
20 |
-
_e( 'Wrong key for cron url!', 'woo-order-export-lite' )
|
21 |
die();
|
22 |
}
|
23 |
-
}
|
24 |
|
25 |
//called from UI
|
26 |
public function run_one_job() {
|
27 |
-
if( !empty( $_REQUEST[
|
28 |
-
$settings = WC_Order_Export_Manage::get( WC_Order_Export_Manage::EXPORT_SCHEDULE, $_REQUEST[
|
29 |
-
elseif($_REQUEST[
|
30 |
$settings = WC_Order_Export_Manage::get( WC_Order_Export_Manage::EXPORT_NOW );
|
31 |
-
else
|
32 |
-
$settings = WC_Order_Export_Manage::get( WC_Order_Export_Manage::EXPORT_PROFILE, $_REQUEST[
|
|
|
33 |
$filename = WC_Order_Export_Engine::build_file_full( $settings );
|
34 |
WC_Order_Export_Manage::set_correct_file_ext( $settings );
|
35 |
-
$this->send_headers( $settings[
|
36 |
-
|
|
|
37 |
}
|
38 |
|
39 |
public function run_one_scheduled_job() {
|
40 |
WC_Order_Export_Cron::run_one_scheduled_job();
|
41 |
}
|
42 |
-
|
43 |
public function run_cron_jobs() {
|
44 |
WC_Order_Export_Cron::wc_export_cron_global_f();
|
45 |
}
|
46 |
-
|
47 |
-
|
48 |
-
$data = json_decode($_POST['tools-import'], true);
|
49 |
-
|
50 |
WC_Order_Export_Manage::import_settings( $data );
|
|
|
51 |
}
|
52 |
|
53 |
-
|
54 |
WC_Order_Export_Admin::save_main_settings();
|
55 |
}
|
56 |
|
57 |
public function get_products() {
|
58 |
-
|
|
|
59 |
}
|
60 |
|
61 |
public function get_users() {
|
62 |
-
echo json_encode( WC_Order_Export_Data_Extractor_UI::get_users_like($_REQUEST['q']) );
|
63 |
}
|
64 |
|
65 |
public function get_coupons() {
|
66 |
-
echo json_encode( WC_Order_Export_Data_Extractor_UI::get_coupons_like($_REQUEST['q']) );
|
67 |
}
|
68 |
|
69 |
public function get_used_custom_order_meta() {
|
70 |
$settings = WC_Order_Export_Manage::make_new_settings( $_POST );
|
71 |
-
$sql
|
72 |
-
$ret
|
73 |
echo json_encode( $ret );
|
74 |
}
|
75 |
|
76 |
public function get_used_custom_products_meta() {
|
77 |
$settings = WC_Order_Export_Manage::make_new_settings( $_POST );
|
78 |
-
$sql
|
79 |
-
$ret
|
80 |
-
sort($ret);
|
81 |
echo json_encode( $ret );
|
82 |
}
|
83 |
|
84 |
public function get_used_custom_order_items_meta() {
|
85 |
$settings = WC_Order_Export_Manage::make_new_settings( $_POST );
|
86 |
-
$sql
|
87 |
-
$ret
|
88 |
-
sort($ret);
|
89 |
echo json_encode( $ret );
|
90 |
}
|
91 |
|
@@ -95,7 +99,7 @@ class WC_Order_Export_Ajax {
|
|
95 |
}
|
96 |
|
97 |
public function get_categories() {
|
98 |
-
echo json_encode( WC_Order_Export_Data_Extractor_UI::get_categories_like($_REQUEST['q']) );
|
99 |
}
|
100 |
|
101 |
public function get_vendors() {
|
@@ -105,8 +109,8 @@ class WC_Order_Export_Ajax {
|
|
105 |
public function test_destination() {
|
106 |
$settings = WC_Order_Export_Manage::make_new_settings( $_POST );
|
107 |
|
108 |
-
unset( $settings[
|
109 |
-
$settings[
|
110 |
|
111 |
// use unsaved settings
|
112 |
|
@@ -115,7 +119,7 @@ class WC_Order_Export_Ajax {
|
|
115 |
$main_settings = WC_Order_Export_Admin::load_main_settings();
|
116 |
|
117 |
$result = WC_Order_Export_Engine::build_files_and_export( $settings, '', $main_settings['limit_button_test'] );
|
118 |
-
echo str_replace("<br>", "\r\n", $result);
|
119 |
}
|
120 |
|
121 |
public function preview() {
|
@@ -137,84 +141,94 @@ class WC_Order_Export_Ajax {
|
|
137 |
}
|
138 |
|
139 |
public function get_order_custom_fields_values() {
|
140 |
-
echo json_encode( WC_Order_Export_Data_Extractor_UI::get_order_custom_fields_values($_POST['cf_name']) );
|
|
|
|
|
|
|
|
|
141 |
}
|
142 |
|
143 |
public function get_product_custom_fields_values() {
|
144 |
-
echo json_encode( WC_Order_Export_Data_Extractor_UI::get_product_custom_fields_values($_POST['cf_name']) );
|
145 |
}
|
146 |
|
147 |
public function get_products_taxonomies_values() {
|
148 |
-
echo json_encode( WC_Order_Export_Data_Extractor_UI::get_products_taxonomies_values($_POST['tax']) );
|
149 |
}
|
150 |
|
151 |
public function get_products_attributes_values() {
|
152 |
-
echo json_encode( WC_Order_Export_Data_Extractor_UI::get_products_attributes_values($_POST['attr']) );
|
153 |
}
|
154 |
|
155 |
-
|
156 |
-
echo json_encode( WC_Order_Export_Data_Extractor_UI::get_products_itemmeta_values($_POST['item']) );
|
157 |
}
|
158 |
|
159 |
public function get_order_shipping_values() {
|
160 |
-
echo json_encode( WC_Order_Export_Data_Extractor_UI::get_order_meta_values('_shipping_', $_POST['item']) );
|
|
|
|
|
|
|
|
|
161 |
}
|
162 |
|
163 |
-
public function get_order_billing_values() {
|
164 |
-
echo json_encode( WC_Order_Export_Data_Extractor_UI::get_order_meta_values('_billing_', $_POST['item']) );
|
165 |
-
}
|
166 |
-
|
167 |
public function get_order_item_names() {
|
168 |
-
echo json_encode( WC_Order_Export_Data_Extractor_UI::get_order_item_names($_POST['item_type']) );
|
169 |
}
|
|
|
170 |
public function get_order_item_meta_key_values() {
|
171 |
-
echo json_encode( WC_Order_Export_Data_Extractor_UI::get_order_item_meta_key_values($_POST['meta_key']) );
|
172 |
}
|
173 |
-
|
174 |
-
|
175 |
|
176 |
-
|
|
|
177 |
WC_Order_Export_Engine::kill_buffers();
|
178 |
switch ( $format ) {
|
179 |
case 'XLSX':
|
180 |
-
if( empty( $download_name ) )
|
181 |
-
|
|
|
182 |
header( 'Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' );
|
183 |
break;
|
184 |
case 'XLS':
|
185 |
-
if( empty( $download_name ) )
|
186 |
-
|
|
|
187 |
header( 'Content-type: application/vnd.ms-excel; charset=utf-8' );
|
188 |
break;
|
189 |
case 'CSV':
|
190 |
-
if( empty( $download_name ) )
|
191 |
-
|
|
|
192 |
header( 'Content-type: text/csv' );
|
193 |
break;
|
194 |
case 'TSV':
|
195 |
-
if( empty( $download_name ) )
|
196 |
$download_name = "orders.tsv";
|
|
|
197 |
header( 'Content-type: text/csv' );
|
198 |
break;
|
199 |
case 'JSON':
|
200 |
-
if( empty( $download_name ) )
|
201 |
-
|
|
|
202 |
header( 'Content-type: application/json' );
|
203 |
break;
|
204 |
case 'XML':
|
205 |
-
if( empty( $download_name ) )
|
206 |
-
|
|
|
207 |
header( 'Content-type: text/xml' );
|
208 |
break;
|
209 |
}
|
210 |
-
header( 'Content-Disposition: attachment; filename="' . $download_name
|
211 |
}
|
212 |
|
213 |
public function start_prevent_object_cache() {
|
214 |
global $_wp_using_ext_object_cache;
|
215 |
|
216 |
-
$this->_wp_using_ext_object_cache_previous
|
217 |
-
$_wp_using_ext_object_cache
|
218 |
}
|
219 |
|
220 |
public function stop_prevent_object_cache() {
|
@@ -228,16 +242,16 @@ class WC_Order_Export_Ajax {
|
|
228 |
$settings = WC_Order_Export_Manage::make_new_settings( $_POST );
|
229 |
|
230 |
$filename = WC_Order_Export_Engine::tempnam( sys_get_temp_dir(), "orders" );
|
231 |
-
if(
|
232 |
-
die( __( 'Can\'t create temporary file', 'woo-order-export-lite' ) )
|
233 |
}
|
234 |
-
|
235 |
//no free space or other file system errors?
|
236 |
-
try {
|
237 |
file_put_contents( $filename, '' );
|
238 |
do_action( 'woe_start_export_job', $_POST['id'], $settings );
|
239 |
$total = WC_Order_Export_Engine::build_file( $settings, 'start_estimate', 'file', 0, 0, $filename );
|
240 |
-
} catch (Exception $e) {
|
241 |
die( $e->getMessage() );
|
242 |
}
|
243 |
// file created
|
@@ -256,6 +270,7 @@ class WC_Order_Export_Ajax {
|
|
256 |
}
|
257 |
set_transient( $this->tempfile_prefix . $_REQUEST['file_id'], $filename, 60 );
|
258 |
$this->stop_prevent_object_cache();
|
|
|
259 |
return $filename;
|
260 |
}
|
261 |
|
@@ -264,7 +279,7 @@ class WC_Order_Export_Ajax {
|
|
264 |
$filename = get_transient( $this->tempfile_prefix . $_REQUEST['file_id'] );
|
265 |
if ( $filename !== false ) {
|
266 |
delete_transient( $this->tempfile_prefix . $_REQUEST['file_id'] );
|
267 |
-
unlink($filename);
|
268 |
}
|
269 |
$this->stop_prevent_object_cache();
|
270 |
}
|
@@ -276,10 +291,11 @@ class WC_Order_Export_Ajax {
|
|
276 |
}
|
277 |
|
278 |
public function export_part() {
|
279 |
-
$settings
|
280 |
$main_settings = WC_Order_Export_Admin::load_main_settings();
|
281 |
|
282 |
-
WC_Order_Export_Engine::build_file( $settings, 'partial', 'file', intval( $_POST['start'] ),
|
|
|
283 |
$this->get_temp_file_name() );
|
284 |
echo json_encode( array( 'start' => $_POST['start'] + $main_settings['ajax_orders_per_step'] ) );
|
285 |
}
|
@@ -289,7 +305,9 @@ class WC_Order_Export_Ajax {
|
|
289 |
WC_Order_Export_Engine::build_file( $settings, 'finish', 'file', 0, 0, $this->get_temp_file_name() );
|
290 |
|
291 |
$filename = WC_Order_Export_Engine::make_filename( $settings['export_filename'] );
|
|
|
292 |
set_transient( $this->tempfile_prefix . 'download_filename', $filename, 60 );
|
|
|
293 |
echo json_encode( array( 'done' => true ) );
|
294 |
}
|
295 |
|
@@ -298,9 +316,9 @@ class WC_Order_Export_Ajax {
|
|
298 |
$format = basename( $_GET['format'] );
|
299 |
$filename = $this->get_temp_file_name();
|
300 |
delete_transient( $this->tempfile_prefix . $_GET['file_id'] );
|
301 |
-
|
302 |
-
$download_name = get_transient( $this->tempfile_prefix . 'download_filename');
|
303 |
-
$this->send_headers( $format
|
304 |
$this->send_contents_delete_file( $filename );
|
305 |
$this->stop_prevent_object_cache();
|
306 |
}
|
@@ -311,8 +329,9 @@ class WC_Order_Export_Ajax {
|
|
311 |
do_action( 'woe_start_export_job', $_POST['id'], $settings );
|
312 |
|
313 |
// custom export worked for plain
|
314 |
-
if( apply_filters( 'woe_plain_export_custom_func', false, $_POST['id'], $settings ) )
|
315 |
-
return
|
|
|
316 |
|
317 |
$file = WC_Order_Export_Engine::build_file_full( $settings );
|
318 |
|
@@ -324,11 +343,13 @@ class WC_Order_Export_Ajax {
|
|
324 |
|
325 |
WC_Order_Export_Manage::set_correct_file_ext( $settings );
|
326 |
|
327 |
-
$_GET['format'] = $settings[
|
328 |
$_GET['file_id'] = $_REQUEST['file_id'] = $file_id;
|
329 |
|
330 |
$filename = WC_Order_Export_Engine::make_filename( $settings['export_filename'] );
|
|
|
331 |
set_transient( $this->tempfile_prefix . 'download_filename', $filename, 60 );
|
|
|
332 |
|
333 |
$this->export_download();
|
334 |
} else {
|
@@ -337,21 +358,51 @@ class WC_Order_Export_Ajax {
|
|
337 |
}
|
338 |
|
339 |
function export_download_bulk_file() {
|
340 |
-
if($_REQUEST[
|
341 |
-
$settings
|
342 |
-
else
|
343 |
-
$settings = WC_Order_Export_Manage::get( WC_Order_Export_Manage::EXPORT_PROFILE,
|
344 |
-
|
|
|
|
|
345 |
WC_Order_Export_Manage::set_correct_file_ext( $settings );
|
346 |
-
$this->send_headers( $settings[
|
|
|
347 |
$this->send_contents_delete_file( $filename );
|
348 |
}
|
349 |
-
|
350 |
private function send_contents_delete_file( $filename ) {
|
351 |
-
if( !empty($filename) ) {
|
352 |
readfile( $filename );
|
353 |
unlink( $filename );
|
354 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
355 |
}
|
356 |
}
|
|
|
357 |
?>
|
10 |
|
11 |
public function save_settings() {
|
12 |
$settings = WC_Order_Export_Manage::make_new_settings( $_POST );
|
13 |
+
$id = WC_Order_Export_Manage::save_export_settings( $_POST['mode'], $_POST['id'], $settings );
|
14 |
echo json_encode( array( 'id' => $id ) );
|
15 |
}
|
16 |
+
|
17 |
public function validate_url_key() {
|
18 |
$main_settings = WC_Order_Export_Admin::load_main_settings();
|
19 |
+
if ( ! isset( $_REQUEST['key'] ) OR $_REQUEST['key'] != $main_settings['cron_key'] ) {
|
20 |
+
_e( 'Wrong key for cron url!', 'woo-order-export-lite' );
|
21 |
die();
|
22 |
}
|
23 |
+
}
|
24 |
|
25 |
//called from UI
|
26 |
public function run_one_job() {
|
27 |
+
if ( ! empty( $_REQUEST['schedule'] ) ) {
|
28 |
+
$settings = WC_Order_Export_Manage::get( WC_Order_Export_Manage::EXPORT_SCHEDULE, $_REQUEST['schedule'] );
|
29 |
+
} elseif ( $_REQUEST['profile'] == 'now' ) {
|
30 |
$settings = WC_Order_Export_Manage::get( WC_Order_Export_Manage::EXPORT_NOW );
|
31 |
+
} else {
|
32 |
+
$settings = WC_Order_Export_Manage::get( WC_Order_Export_Manage::EXPORT_PROFILE, $_REQUEST['profile'] );
|
33 |
+
}
|
34 |
$filename = WC_Order_Export_Engine::build_file_full( $settings );
|
35 |
WC_Order_Export_Manage::set_correct_file_ext( $settings );
|
36 |
+
$this->send_headers( $settings['format'],
|
37 |
+
WC_Order_Export_Engine::make_filename( $settings['export_filename'] ) );
|
38 |
+
$this->send_contents_delete_file( $filename );
|
39 |
}
|
40 |
|
41 |
public function run_one_scheduled_job() {
|
42 |
WC_Order_Export_Cron::run_one_scheduled_job();
|
43 |
}
|
44 |
+
|
45 |
public function run_cron_jobs() {
|
46 |
WC_Order_Export_Cron::wc_export_cron_global_f();
|
47 |
}
|
48 |
+
|
49 |
+
public function save_tools() {
|
50 |
+
$data = json_decode( $_POST['tools-import'], true );
|
51 |
+
if ( $data ) {
|
52 |
WC_Order_Export_Manage::import_settings( $data );
|
53 |
+
}
|
54 |
}
|
55 |
|
56 |
+
public function save_settings_tab() {
|
57 |
WC_Order_Export_Admin::save_main_settings();
|
58 |
}
|
59 |
|
60 |
public function get_products() {
|
61 |
+
$main_settings = WC_Order_Export_Admin::load_main_settings();
|
62 |
+
echo json_encode( WC_Order_Export_Data_Extractor_UI::get_products_like( $_REQUEST['q'], $main_settings['autocomplete_products_max'] ) );
|
63 |
}
|
64 |
|
65 |
public function get_users() {
|
66 |
+
echo json_encode( WC_Order_Export_Data_Extractor_UI::get_users_like( $_REQUEST['q'] ) );
|
67 |
}
|
68 |
|
69 |
public function get_coupons() {
|
70 |
+
echo json_encode( WC_Order_Export_Data_Extractor_UI::get_coupons_like( $_REQUEST['q'] ) );
|
71 |
}
|
72 |
|
73 |
public function get_used_custom_order_meta() {
|
74 |
$settings = WC_Order_Export_Manage::make_new_settings( $_POST );
|
75 |
+
$sql = WC_Order_Export_Data_Extractor::sql_get_order_ids( $settings );
|
76 |
+
$ret = WC_Order_Export_Data_Extractor_UI::get_all_order_custom_meta_fields( $sql );
|
77 |
echo json_encode( $ret );
|
78 |
}
|
79 |
|
80 |
public function get_used_custom_products_meta() {
|
81 |
$settings = WC_Order_Export_Manage::make_new_settings( $_POST );
|
82 |
+
$sql = WC_Order_Export_Data_Extractor::sql_get_order_ids( $settings );
|
83 |
+
$ret = WC_Order_Export_Data_Extractor_UI::get_product_custom_meta_fields_for_orders( $sql );
|
84 |
+
sort( $ret );
|
85 |
echo json_encode( $ret );
|
86 |
}
|
87 |
|
88 |
public function get_used_custom_order_items_meta() {
|
89 |
$settings = WC_Order_Export_Manage::make_new_settings( $_POST );
|
90 |
+
$sql = WC_Order_Export_Data_Extractor::sql_get_order_ids( $settings );
|
91 |
+
$ret = WC_Order_Export_Data_Extractor_UI::get_order_item_custom_meta_fields_for_orders( $sql );
|
92 |
+
sort( $ret );
|
93 |
echo json_encode( $ret );
|
94 |
}
|
95 |
|
99 |
}
|
100 |
|
101 |
public function get_categories() {
|
102 |
+
echo json_encode( WC_Order_Export_Data_Extractor_UI::get_categories_like( $_REQUEST['q'] ) );
|
103 |
}
|
104 |
|
105 |
public function get_vendors() {
|
109 |
public function test_destination() {
|
110 |
$settings = WC_Order_Export_Manage::make_new_settings( $_POST );
|
111 |
|
112 |
+
unset( $settings['destination']['type'] );
|
113 |
+
$settings['destination']['type'][] = $_POST['destination'];
|
114 |
|
115 |
// use unsaved settings
|
116 |
|
119 |
$main_settings = WC_Order_Export_Admin::load_main_settings();
|
120 |
|
121 |
$result = WC_Order_Export_Engine::build_files_and_export( $settings, '', $main_settings['limit_button_test'] );
|
122 |
+
echo str_replace( "<br>", "\r\n", $result );
|
123 |
}
|
124 |
|
125 |
public function preview() {
|
141 |
}
|
142 |
|
143 |
public function get_order_custom_fields_values() {
|
144 |
+
echo json_encode( WC_Order_Export_Data_Extractor_UI::get_order_custom_fields_values( $_POST['cf_name'] ) );
|
145 |
+
}
|
146 |
+
|
147 |
+
public function get_user_custom_fields_values() {
|
148 |
+
echo json_encode( WC_Order_Export_Data_Extractor_UI::get_user_custom_fields_values( $_POST['cf_name'] ) );
|
149 |
}
|
150 |
|
151 |
public function get_product_custom_fields_values() {
|
152 |
+
echo json_encode( WC_Order_Export_Data_Extractor_UI::get_product_custom_fields_values( $_POST['cf_name'] ) );
|
153 |
}
|
154 |
|
155 |
public function get_products_taxonomies_values() {
|
156 |
+
echo json_encode( WC_Order_Export_Data_Extractor_UI::get_products_taxonomies_values( $_POST['tax'] ) );
|
157 |
}
|
158 |
|
159 |
public function get_products_attributes_values() {
|
160 |
+
echo json_encode( WC_Order_Export_Data_Extractor_UI::get_products_attributes_values( $_POST['attr'] ) );
|
161 |
}
|
162 |
|
163 |
+
public function get_products_itemmeta_values() {
|
164 |
+
echo json_encode( WC_Order_Export_Data_Extractor_UI::get_products_itemmeta_values( $_POST['item'] ) );
|
165 |
}
|
166 |
|
167 |
public function get_order_shipping_values() {
|
168 |
+
echo json_encode( WC_Order_Export_Data_Extractor_UI::get_order_meta_values( '_shipping_', $_POST['item'] ) );
|
169 |
+
}
|
170 |
+
|
171 |
+
public function get_order_billing_values() {
|
172 |
+
echo json_encode( WC_Order_Export_Data_Extractor_UI::get_order_meta_values( '_billing_', $_POST['item'] ) );
|
173 |
}
|
174 |
|
|
|
|
|
|
|
|
|
175 |
public function get_order_item_names() {
|
176 |
+
echo json_encode( WC_Order_Export_Data_Extractor_UI::get_order_item_names( $_POST['item_type'] ) );
|
177 |
}
|
178 |
+
|
179 |
public function get_order_item_meta_key_values() {
|
180 |
+
echo json_encode( WC_Order_Export_Data_Extractor_UI::get_order_item_meta_key_values( $_POST['meta_key'] ) );
|
181 |
}
|
|
|
|
|
182 |
|
183 |
+
|
184 |
+
public function send_headers( $format, $download_name = '' ) {
|
185 |
WC_Order_Export_Engine::kill_buffers();
|
186 |
switch ( $format ) {
|
187 |
case 'XLSX':
|
188 |
+
if ( empty( $download_name ) ) {
|
189 |
+
$download_name = "orders.xlsx";
|
190 |
+
}
|
191 |
header( 'Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' );
|
192 |
break;
|
193 |
case 'XLS':
|
194 |
+
if ( empty( $download_name ) ) {
|
195 |
+
$download_name = "orders.xls";
|
196 |
+
}
|
197 |
header( 'Content-type: application/vnd.ms-excel; charset=utf-8' );
|
198 |
break;
|
199 |
case 'CSV':
|
200 |
+
if ( empty( $download_name ) ) {
|
201 |
+
$download_name = "orders.csv";
|
202 |
+
}
|
203 |
header( 'Content-type: text/csv' );
|
204 |
break;
|
205 |
case 'TSV':
|
206 |
+
if ( empty( $download_name ) ) {
|
207 |
$download_name = "orders.tsv";
|
208 |
+
}
|
209 |
header( 'Content-type: text/csv' );
|
210 |
break;
|
211 |
case 'JSON':
|
212 |
+
if ( empty( $download_name ) ) {
|
213 |
+
$download_name = "orders.json";
|
214 |
+
}
|
215 |
header( 'Content-type: application/json' );
|
216 |
break;
|
217 |
case 'XML':
|
218 |
+
if ( empty( $download_name ) ) {
|
219 |
+
$download_name = "orders.xml";
|
220 |
+
}
|
221 |
header( 'Content-type: text/xml' );
|
222 |
break;
|
223 |
}
|
224 |
+
header( 'Content-Disposition: attachment; filename="' . $download_name . '"' );
|
225 |
}
|
226 |
|
227 |
public function start_prevent_object_cache() {
|
228 |
global $_wp_using_ext_object_cache;
|
229 |
|
230 |
+
$this->_wp_using_ext_object_cache_previous = $_wp_using_ext_object_cache;
|
231 |
+
$_wp_using_ext_object_cache = false;
|
232 |
}
|
233 |
|
234 |
public function stop_prevent_object_cache() {
|
242 |
$settings = WC_Order_Export_Manage::make_new_settings( $_POST );
|
243 |
|
244 |
$filename = WC_Order_Export_Engine::tempnam( sys_get_temp_dir(), "orders" );
|
245 |
+
if ( ! $filename ) {
|
246 |
+
die( __( 'Can\'t create temporary file', 'woo-order-export-lite' ) );
|
247 |
}
|
248 |
+
|
249 |
//no free space or other file system errors?
|
250 |
+
try {
|
251 |
file_put_contents( $filename, '' );
|
252 |
do_action( 'woe_start_export_job', $_POST['id'], $settings );
|
253 |
$total = WC_Order_Export_Engine::build_file( $settings, 'start_estimate', 'file', 0, 0, $filename );
|
254 |
+
} catch ( Exception $e ) {
|
255 |
die( $e->getMessage() );
|
256 |
}
|
257 |
// file created
|
270 |
}
|
271 |
set_transient( $this->tempfile_prefix . $_REQUEST['file_id'], $filename, 60 );
|
272 |
$this->stop_prevent_object_cache();
|
273 |
+
|
274 |
return $filename;
|
275 |
}
|
276 |
|
279 |
$filename = get_transient( $this->tempfile_prefix . $_REQUEST['file_id'] );
|
280 |
if ( $filename !== false ) {
|
281 |
delete_transient( $this->tempfile_prefix . $_REQUEST['file_id'] );
|
282 |
+
unlink( $filename );
|
283 |
}
|
284 |
$this->stop_prevent_object_cache();
|
285 |
}
|
291 |
}
|
292 |
|
293 |
public function export_part() {
|
294 |
+
$settings = WC_Order_Export_Manage::make_new_settings( $_POST );
|
295 |
$main_settings = WC_Order_Export_Admin::load_main_settings();
|
296 |
|
297 |
+
WC_Order_Export_Engine::build_file( $settings, 'partial', 'file', intval( $_POST['start'] ),
|
298 |
+
$main_settings['ajax_orders_per_step'],
|
299 |
$this->get_temp_file_name() );
|
300 |
echo json_encode( array( 'start' => $_POST['start'] + $main_settings['ajax_orders_per_step'] ) );
|
301 |
}
|
305 |
WC_Order_Export_Engine::build_file( $settings, 'finish', 'file', 0, 0, $this->get_temp_file_name() );
|
306 |
|
307 |
$filename = WC_Order_Export_Engine::make_filename( $settings['export_filename'] );
|
308 |
+
$this->start_prevent_object_cache();
|
309 |
set_transient( $this->tempfile_prefix . 'download_filename', $filename, 60 );
|
310 |
+
$this->stop_prevent_object_cache();
|
311 |
echo json_encode( array( 'done' => true ) );
|
312 |
}
|
313 |
|
316 |
$format = basename( $_GET['format'] );
|
317 |
$filename = $this->get_temp_file_name();
|
318 |
delete_transient( $this->tempfile_prefix . $_GET['file_id'] );
|
319 |
+
|
320 |
+
$download_name = get_transient( $this->tempfile_prefix . 'download_filename' );
|
321 |
+
$this->send_headers( $format, $download_name );
|
322 |
$this->send_contents_delete_file( $filename );
|
323 |
$this->stop_prevent_object_cache();
|
324 |
}
|
329 |
do_action( 'woe_start_export_job', $_POST['id'], $settings );
|
330 |
|
331 |
// custom export worked for plain
|
332 |
+
if ( apply_filters( 'woe_plain_export_custom_func', false, $_POST['id'], $settings ) ) {
|
333 |
+
return;
|
334 |
+
}
|
335 |
|
336 |
$file = WC_Order_Export_Engine::build_file_full( $settings );
|
337 |
|
343 |
|
344 |
WC_Order_Export_Manage::set_correct_file_ext( $settings );
|
345 |
|
346 |
+
$_GET['format'] = $settings['format'];
|
347 |
$_GET['file_id'] = $_REQUEST['file_id'] = $file_id;
|
348 |
|
349 |
$filename = WC_Order_Export_Engine::make_filename( $settings['export_filename'] );
|
350 |
+
$this->start_prevent_object_cache();
|
351 |
set_transient( $this->tempfile_prefix . 'download_filename', $filename, 60 );
|
352 |
+
$this->stop_prevent_object_cache();
|
353 |
|
354 |
$this->export_download();
|
355 |
} else {
|
358 |
}
|
359 |
|
360 |
function export_download_bulk_file() {
|
361 |
+
if ( $_REQUEST['export_bulk_profile'] == 'now' ) {
|
362 |
+
$settings = WC_Order_Export_Manage::get( WC_Order_Export_Manage::EXPORT_NOW );
|
363 |
+
} else {
|
364 |
+
$settings = WC_Order_Export_Manage::get( WC_Order_Export_Manage::EXPORT_PROFILE,
|
365 |
+
$_REQUEST['export_bulk_profile'] );
|
366 |
+
}
|
367 |
+
$filename = WC_Order_Export_Engine::build_file_full( $settings, '', 0, explode( ",", $_REQUEST['ids'] ) );
|
368 |
WC_Order_Export_Manage::set_correct_file_ext( $settings );
|
369 |
+
$this->send_headers( $settings['format'],
|
370 |
+
WC_Order_Export_Engine::make_filename( $settings['export_filename'] ) );
|
371 |
$this->send_contents_delete_file( $filename );
|
372 |
}
|
373 |
+
|
374 |
private function send_contents_delete_file( $filename ) {
|
375 |
+
if ( ! empty( $filename ) ) {
|
376 |
readfile( $filename );
|
377 |
unlink( $filename );
|
378 |
+
}
|
379 |
+
}
|
380 |
+
|
381 |
+
public function reorder_jobs() {
|
382 |
+
if ( ! empty( $_REQUEST['new_jobs_order'] ) AND ! empty( $_REQUEST['tab_name'] ) ) {
|
383 |
+
|
384 |
+
if ( $_REQUEST['tab_name'] == 'schedule' ) {
|
385 |
+
$mode = WC_Order_Export_Manage::EXPORT_SCHEDULE;
|
386 |
+
} elseif ( $_REQUEST['tab_name'] == 'profile' ) {
|
387 |
+
$mode = WC_Order_Export_Manage::EXPORT_PROFILE;
|
388 |
+
} elseif ( $_REQUEST['tab_name'] == 'order_action' ) {
|
389 |
+
$mode = WC_Order_Export_Manage::EXPORT_ORDER_ACTION;
|
390 |
+
} else {
|
391 |
+
echo json_encode( array( 'result' => false ) );
|
392 |
+
die();
|
393 |
+
}
|
394 |
+
|
395 |
+
//skip zero ids
|
396 |
+
foreach ( array_filter( $_REQUEST['new_jobs_order'] ) as $index => $job_id ) {
|
397 |
+
$job = WC_Order_Export_Manage::get( $mode, $job_id );
|
398 |
+
$job['priority'] = $index + 1;
|
399 |
+
WC_Order_Export_Manage::save_export_settings( $mode, $job_id, $job );
|
400 |
+
}
|
401 |
+
echo json_encode( array( 'result' => true ) );
|
402 |
+
} else {
|
403 |
+
echo json_encode( array( 'result' => false ) );
|
404 |
+
}
|
405 |
}
|
406 |
}
|
407 |
+
|
408 |
?>
|
classes/admin/class-wc-order-export-manage.php
CHANGED
@@ -13,18 +13,18 @@ class WC_Order_Export_Manage {
|
|
13 |
const EXPORT_PROFILE = 'profiles';
|
14 |
const EXPORT_SCHEDULE = 'cron';
|
15 |
const EXPORT_ORDER_ACTION = 'order-action';
|
16 |
-
|
17 |
public static $edit_existing_job = false;
|
18 |
-
|
19 |
static function get_days() {
|
20 |
return array(
|
21 |
-
'Sun'=>__( 'Sun', 'woo-order-export-lite' ),
|
22 |
-
'Mon'=>__( 'Mon', 'woo-order-export-lite' ),
|
23 |
-
'Tue'=>__( 'Tue', 'woo-order-export-lite' ),
|
24 |
-
'Wed'=>__( 'Wed', 'woo-order-export-lite' ),
|
25 |
-
'Thu'=>__( 'Thu', 'woo-order-export-lite' ),
|
26 |
-
'Fri'=>__( 'Fri', 'woo-order-export-lite' ),
|
27 |
-
'Sat'=>__( 'Sat', 'woo-order-export-lite' ),
|
28 |
);
|
29 |
}
|
30 |
|
@@ -39,37 +39,42 @@ class WC_Order_Export_Manage {
|
|
39 |
} elseif ( $mode == self::EXPORT_ORDER_ACTION ) {
|
40 |
$name = self::settings_name_actions;
|
41 |
}
|
|
|
42 |
return $name;
|
43 |
}
|
44 |
-
|
45 |
static function remove_settings() {
|
46 |
$options = array(
|
47 |
self::settings_name_now,
|
48 |
self::settings_name_cron,
|
49 |
self::settings_name_profiles,
|
50 |
self::settings_name_actions,
|
51 |
-
);
|
52 |
-
|
53 |
-
foreach($options as $option)
|
54 |
delete_option( $option );
|
|
|
55 |
}
|
56 |
|
57 |
// arrays
|
58 |
static function get_export_settings_collection( $mode ) {
|
59 |
$name = self::get_settings_name_for_mode( $mode );
|
|
|
60 |
return get_option( $name, array() );
|
61 |
}
|
|
|
62 |
static function save_export_settings_collection( $mode, $jobs ) {
|
63 |
$name = self::get_settings_name_for_mode( $mode );
|
64 |
-
|
|
|
65 |
}
|
66 |
|
67 |
static function make_new_settings( $in ) {
|
68 |
$new_settings = $in['settings'];
|
69 |
-
|
70 |
// use old PHP code if no permissions, just to stop trcky persons ;)
|
71 |
-
if( !WC_Order_Export_Admin::user_can_add_custom_php() ) {
|
72 |
-
|
73 |
}
|
74 |
|
75 |
// UI don't pass empty multiselects
|
@@ -86,11 +91,12 @@ class WC_Order_Export_Manage {
|
|
86 |
'shipping_methods',
|
87 |
'user_roles',
|
88 |
'user_names',
|
|
|
89 |
'coupons',
|
90 |
-
|
91 |
'payment_methods',
|
92 |
'product_attributes',
|
93 |
-
|
94 |
'product_taxonomies',
|
95 |
'item_names',
|
96 |
'item_metadata',
|
@@ -101,8 +107,8 @@ class WC_Order_Export_Manage {
|
|
101 |
}
|
102 |
}
|
103 |
|
104 |
-
$settings
|
105 |
-
|
106 |
// setup new values for same keys
|
107 |
foreach ( $new_settings as $key => $val ) {
|
108 |
$settings[ $key ] = $val;
|
@@ -111,7 +117,7 @@ class WC_Order_Export_Manage {
|
|
111 |
$sections = array(
|
112 |
'orders' => 'order_fields',
|
113 |
'products' => 'order_product_fields',
|
114 |
-
'coupons' => 'order_coupon_fields'
|
115 |
);
|
116 |
foreach ( $sections as $section => $fieldset ) {
|
117 |
$new_order_fields = array();
|
@@ -122,7 +128,7 @@ class WC_Order_Export_Manage {
|
|
122 |
$opts = array(
|
123 |
"checked" => $in_sec['exported'][ $field ],
|
124 |
"colname" => $colname,
|
125 |
-
"label" => $in_sec['label'][ $field ]
|
126 |
);
|
127 |
// for products & coupons
|
128 |
if ( isset( $in_sec['repeat'][ $field ] ) ) {
|
@@ -152,24 +158,27 @@ class WC_Order_Export_Manage {
|
|
152 |
static function get( $mode, $id = false ) {
|
153 |
$all_jobs = self::get_export_settings_collection( $mode );
|
154 |
|
155 |
-
if ( $mode == self::EXPORT_NOW) { // one job
|
156 |
return self::apply_defaults( $mode, $all_jobs );
|
157 |
} elseif ( $id === false ) {
|
158 |
-
if ( empty( $all_jobs ) OR !is_array($all_jobs) )
|
159 |
return array();
|
160 |
-
|
|
|
|
|
161 |
return WC_Order_Export_Manage::apply_defaults( $mode, $item );
|
162 |
}, $all_jobs );
|
163 |
}
|
164 |
|
165 |
$settings = isset( $all_jobs[ $id ] ) ? $all_jobs[ $id ] : array();
|
|
|
166 |
return self::apply_defaults( $mode, $settings );
|
167 |
}
|
168 |
|
169 |
static function apply_defaults( $mode, $settings ) {
|
170 |
-
|
171 |
-
$settings = apply_filters( "woe_before_apply_default_settings", $settings
|
172 |
-
|
173 |
$defaults = array(
|
174 |
'mode' => $mode,
|
175 |
'title' => '',
|
@@ -187,7 +196,8 @@ class WC_Order_Export_Manage {
|
|
187 |
'item_metadata' => array(),
|
188 |
'user_roles' => array(),
|
189 |
'user_names' => array(),
|
190 |
-
|
|
|
191 |
'payment_methods' => array(),
|
192 |
'any_coupon_used' => 0,
|
193 |
'coupons' => array(),
|
@@ -198,14 +208,14 @@ class WC_Order_Export_Manage {
|
|
198 |
'product_taxonomies' => array(),
|
199 |
'product_custom_fields' => array(),
|
200 |
'product_attributes' => array(),
|
201 |
-
|
202 |
'format' => 'XLS',
|
203 |
-
'format_xls_use_xls_format'
|
204 |
-
'format_xls_sheet_name'
|
205 |
'format_xls_display_column_names' => 1,
|
206 |
-
'format_xls_auto_width'
|
207 |
'format_xls_populate_other_columns_product_rows' => 1,
|
208 |
-
'format_xls_direction_rtl'
|
209 |
'format_csv_enclosure' => '"',
|
210 |
'format_csv_delimiter' => ',',
|
211 |
'format_csv_linebreak' => '\r\n',
|
@@ -229,10 +239,10 @@ class WC_Order_Export_Manage {
|
|
229 |
'format_xml_self_closing_tags' => 1,
|
230 |
'all_products_from_order' => 1,
|
231 |
'skip_refunded_items' => 1,
|
232 |
-
'skip_suborders'
|
233 |
-
'export_refunds'
|
234 |
-
'date_format'
|
235 |
-
'time_format'
|
236 |
'sort_direction' => 'DESC',
|
237 |
'sort' => 'order_id',
|
238 |
'format_number_fields' => 0,
|
@@ -241,14 +251,14 @@ class WC_Order_Export_Manage {
|
|
241 |
'strip_tags_product_fields' => 0,
|
242 |
'cleanup_phone' => 0,
|
243 |
'enable_debug' => 0,
|
244 |
-
'format_json_start_tag'
|
245 |
-
'format_json_end_tag'
|
246 |
'custom_php' => 0,
|
247 |
'custom_php_code' => '',
|
248 |
'mark_exported_orders' => 0,
|
249 |
'export_unmarked_orders' => 0,
|
250 |
-
|
251 |
-
'summary_report_by_products'
|
252 |
);
|
253 |
|
254 |
if ( ! isset( $settings['format'] ) ) {
|
@@ -262,54 +272,63 @@ class WC_Order_Export_Manage {
|
|
262 |
if ( ! isset( $settings['order_fields'] ) ) {
|
263 |
$settings['order_fields'] = array();
|
264 |
}
|
265 |
-
self::merge_settings_and_default( $settings['order_fields'],
|
|
|
266 |
|
267 |
if ( ! isset( $settings['order_product_fields'] ) ) {
|
268 |
$settings['order_product_fields'] = array();
|
269 |
}
|
270 |
-
self::merge_settings_and_default( $settings['order_product_fields'],
|
|
|
271 |
|
272 |
if ( ! isset( $settings['order_coupon_fields'] ) ) {
|
273 |
$settings['order_coupon_fields'] = array();
|
274 |
}
|
275 |
-
self::merge_settings_and_default( $settings['order_coupon_fields'],
|
|
|
|
|
276 |
return array_merge( $defaults, $settings );
|
277 |
}
|
278 |
|
279 |
-
static function merge_settings_and_default(&$opt, $defaults) {
|
280 |
-
foreach( $defaults as $k
|
281 |
-
if( isset($opt[$k]) ) {
|
282 |
//set default attribute OR add to option
|
283 |
-
if( isset($v['default']) )
|
284 |
-
$opt[$k]['default'] = $v['default'];
|
|
|
285 |
//set default format OR add to option
|
286 |
-
if( isset($v['format']) )
|
287 |
-
$opt[$k]['format'] = $v['format'];
|
|
|
288 |
// overwrite labels for localization
|
289 |
-
$opt[$k]['label'] = $v['label'];
|
290 |
} else {
|
291 |
-
if( self::$edit_existing_job AND $v['checked']=="1" )
|
292 |
$v['checked'] = "0";
|
293 |
-
|
294 |
-
|
|
|
295 |
}
|
296 |
}
|
297 |
|
298 |
static function save_export_settings( $mode, $id, $options ) {
|
299 |
-
$all_jobs = self::get_export_settings_collection( $mode);
|
300 |
if ( $mode == self::EXPORT_NOW ) {
|
301 |
$all_jobs = $options;// just replace
|
302 |
} elseif ( $mode == self::EXPORT_SCHEDULE ) {
|
303 |
if ( $id ) {
|
304 |
-
$options['schedule']['last_run'] = isset($all_jobs[ $id ]) ? $all_jobs[ $id ]['schedule']['last_run'] : current_time("timestamp",
|
305 |
-
|
|
|
|
|
306 |
$all_jobs[ $id ] = $options;
|
307 |
} else {
|
308 |
-
$options['schedule']['last_run'] = current_time("timestamp",0);
|
309 |
$options['schedule']['next_run'] = WC_Order_Export_Cron::next_event_timestamp_for_schedule( $options['schedule'] );
|
310 |
$all_jobs[] = $options; // new job
|
311 |
-
|
312 |
-
|
313 |
}
|
314 |
} elseif ( $mode == self::EXPORT_PROFILE OR $mode == self::EXPORT_ORDER_ACTION ) {
|
315 |
if ( $id ) {
|
@@ -321,10 +340,12 @@ class WC_Order_Export_Manage {
|
|
321 |
}
|
322 |
}
|
323 |
|
324 |
-
self::save_export_settings_collection( $mode, $all_jobs);
|
325 |
|
326 |
-
if( $mode == self::EXPORT_SCHEDULE )
|
327 |
WC_Order_Export_Cron::install_job();
|
|
|
|
|
328 |
return $id;
|
329 |
}
|
330 |
|
@@ -332,22 +353,25 @@ class WC_Order_Export_Manage {
|
|
332 |
return self::advanced_clone_export_settings( $id, $mode, $mode );
|
333 |
}
|
334 |
|
335 |
-
static function advanced_clone_export_settings(
|
|
|
|
|
|
|
|
|
336 |
$all_jobs_in = self::get_export_settings_collection( $mode_in );
|
337 |
//new settings
|
338 |
-
$settings
|
339 |
-
$settings['mode']
|
340 |
|
341 |
if ( $mode_in !== $mode_out ) {
|
342 |
$all_jobs_out = self::get_export_settings_collection( $mode_out );
|
343 |
-
}
|
344 |
-
|
345 |
-
$
|
346 |
-
$all_jobs_out = $all_jobs_in;
|
347 |
$settings['title'] .= " [cloned]"; //add note
|
348 |
}
|
349 |
|
350 |
-
if ( $mode_in === self::EXPORT_PROFILE && $mode_out === self::EXPORT_SCHEDULE) {
|
351 |
if ( ! isset( $settings['destination'] ) ) {
|
352 |
$settings['destination'] = array(
|
353 |
'type' => 'folder',
|
@@ -365,8 +389,8 @@ class WC_Order_Export_Manage {
|
|
365 |
|
366 |
if ( ! isset( $settings['schedule'] ) ) {
|
367 |
$settings['schedule'] = array(
|
368 |
-
|
369 |
-
|
370 |
);
|
371 |
}
|
372 |
|
@@ -374,10 +398,11 @@ class WC_Order_Export_Manage {
|
|
374 |
}
|
375 |
|
376 |
end( $all_jobs_out );
|
377 |
-
$next_id
|
378 |
$all_jobs_out[ $next_id ] = $settings;
|
379 |
|
380 |
-
self::save_export_settings_collection( $mode_out, $all_jobs_out
|
|
|
381 |
return $next_id;
|
382 |
}
|
383 |
|
@@ -395,7 +420,7 @@ class WC_Order_Export_Manage {
|
|
395 |
self::EXPORT_PROFILE,
|
396 |
self::EXPORT_ORDER_ACTION,
|
397 |
);
|
398 |
-
if( isset( $data[ self::EXPORT_NOW ] ) ) { // import ALL
|
399 |
foreach ( $allowed_options as $key ) {
|
400 |
if ( isset( $data[ $key ] ) ) {
|
401 |
$setting_name = self::get_settings_name_for_mode( $key );
|
@@ -404,28 +429,28 @@ class WC_Order_Export_Manage {
|
|
404 |
$data[ $key ] = self::edit_import_data( $data[ $key ] );
|
405 |
} else {
|
406 |
foreach ( $data[ $key ] as $index => $import_single_data ) {
|
407 |
-
$data[$key][$index] = self::edit_import_data( $import_single_data );
|
408 |
}
|
409 |
}
|
410 |
|
411 |
-
update_option( $setting_name, $data[ $key ] );
|
412 |
}
|
413 |
}
|
414 |
-
}
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
$items[] = self::edit_import_data( $data );
|
426 |
-
|
427 |
-
update_option( $setting_name, $items );
|
428 |
}
|
|
|
|
|
|
|
429 |
}// if modes
|
430 |
}
|
431 |
|
13 |
const EXPORT_PROFILE = 'profiles';
|
14 |
const EXPORT_SCHEDULE = 'cron';
|
15 |
const EXPORT_ORDER_ACTION = 'order-action';
|
16 |
+
|
17 |
public static $edit_existing_job = false;
|
18 |
+
|
19 |
static function get_days() {
|
20 |
return array(
|
21 |
+
'Sun' => __( 'Sun', 'woo-order-export-lite' ),
|
22 |
+
'Mon' => __( 'Mon', 'woo-order-export-lite' ),
|
23 |
+
'Tue' => __( 'Tue', 'woo-order-export-lite' ),
|
24 |
+
'Wed' => __( 'Wed', 'woo-order-export-lite' ),
|
25 |
+
'Thu' => __( 'Thu', 'woo-order-export-lite' ),
|
26 |
+
'Fri' => __( 'Fri', 'woo-order-export-lite' ),
|
27 |
+
'Sat' => __( 'Sat', 'woo-order-export-lite' ),
|
28 |
);
|
29 |
}
|
30 |
|
39 |
} elseif ( $mode == self::EXPORT_ORDER_ACTION ) {
|
40 |
$name = self::settings_name_actions;
|
41 |
}
|
42 |
+
|
43 |
return $name;
|
44 |
}
|
45 |
+
|
46 |
static function remove_settings() {
|
47 |
$options = array(
|
48 |
self::settings_name_now,
|
49 |
self::settings_name_cron,
|
50 |
self::settings_name_profiles,
|
51 |
self::settings_name_actions,
|
52 |
+
);
|
53 |
+
|
54 |
+
foreach ( $options as $option ) {
|
55 |
delete_option( $option );
|
56 |
+
}
|
57 |
}
|
58 |
|
59 |
// arrays
|
60 |
static function get_export_settings_collection( $mode ) {
|
61 |
$name = self::get_settings_name_for_mode( $mode );
|
62 |
+
|
63 |
return get_option( $name, array() );
|
64 |
}
|
65 |
+
|
66 |
static function save_export_settings_collection( $mode, $jobs ) {
|
67 |
$name = self::get_settings_name_for_mode( $mode );
|
68 |
+
|
69 |
+
return update_option( $name, $jobs, false );
|
70 |
}
|
71 |
|
72 |
static function make_new_settings( $in ) {
|
73 |
$new_settings = $in['settings'];
|
74 |
+
|
75 |
// use old PHP code if no permissions, just to stop trcky persons ;)
|
76 |
+
if ( ! WC_Order_Export_Admin::user_can_add_custom_php() ) {
|
77 |
+
unset( $new_settings['custom_php_code'] );
|
78 |
}
|
79 |
|
80 |
// UI don't pass empty multiselects
|
91 |
'shipping_methods',
|
92 |
'user_roles',
|
93 |
'user_names',
|
94 |
+
'user_custom_fields',
|
95 |
'coupons',
|
96 |
+
'billing_locations',
|
97 |
'payment_methods',
|
98 |
'product_attributes',
|
99 |
+
'product_itemmeta',
|
100 |
'product_taxonomies',
|
101 |
'item_names',
|
102 |
'item_metadata',
|
107 |
}
|
108 |
}
|
109 |
|
110 |
+
$settings = self::get( $in['mode'], $in['id'] );
|
111 |
+
$settings['id'] = $in['id'];
|
112 |
// setup new values for same keys
|
113 |
foreach ( $new_settings as $key => $val ) {
|
114 |
$settings[ $key ] = $val;
|
117 |
$sections = array(
|
118 |
'orders' => 'order_fields',
|
119 |
'products' => 'order_product_fields',
|
120 |
+
'coupons' => 'order_coupon_fields',
|
121 |
);
|
122 |
foreach ( $sections as $section => $fieldset ) {
|
123 |
$new_order_fields = array();
|
128 |
$opts = array(
|
129 |
"checked" => $in_sec['exported'][ $field ],
|
130 |
"colname" => $colname,
|
131 |
+
"label" => $in_sec['label'][ $field ],
|
132 |
);
|
133 |
// for products & coupons
|
134 |
if ( isset( $in_sec['repeat'][ $field ] ) ) {
|
158 |
static function get( $mode, $id = false ) {
|
159 |
$all_jobs = self::get_export_settings_collection( $mode );
|
160 |
|
161 |
+
if ( $mode == self::EXPORT_NOW ) { // one job
|
162 |
return self::apply_defaults( $mode, $all_jobs );
|
163 |
} elseif ( $id === false ) {
|
164 |
+
if ( empty( $all_jobs ) OR ! is_array( $all_jobs ) ) {
|
165 |
return array();
|
166 |
+
}
|
167 |
+
|
168 |
+
return array_map( function ( $item ) use ( $mode ) {
|
169 |
return WC_Order_Export_Manage::apply_defaults( $mode, $item );
|
170 |
}, $all_jobs );
|
171 |
}
|
172 |
|
173 |
$settings = isset( $all_jobs[ $id ] ) ? $all_jobs[ $id ] : array();
|
174 |
+
|
175 |
return self::apply_defaults( $mode, $settings );
|
176 |
}
|
177 |
|
178 |
static function apply_defaults( $mode, $settings ) {
|
179 |
+
|
180 |
+
$settings = apply_filters( "woe_before_apply_default_settings", $settings, $mode );
|
181 |
+
|
182 |
$defaults = array(
|
183 |
'mode' => $mode,
|
184 |
'title' => '',
|
196 |
'item_metadata' => array(),
|
197 |
'user_roles' => array(),
|
198 |
'user_names' => array(),
|
199 |
+
'user_custom_fields' => array(),
|
200 |
+
'billing_locations' => array(),
|
201 |
'payment_methods' => array(),
|
202 |
'any_coupon_used' => 0,
|
203 |
'coupons' => array(),
|
208 |
'product_taxonomies' => array(),
|
209 |
'product_custom_fields' => array(),
|
210 |
'product_attributes' => array(),
|
211 |
+
'product_itemmeta' => array(),
|
212 |
'format' => 'XLS',
|
213 |
+
'format_xls_use_xls_format' => 0,
|
214 |
+
'format_xls_sheet_name' => __( 'Orders', 'woo-order-export-lite' ),
|
215 |
'format_xls_display_column_names' => 1,
|
216 |
+
'format_xls_auto_width' => 1,
|
217 |
'format_xls_populate_other_columns_product_rows' => 1,
|
218 |
+
'format_xls_direction_rtl' => 0,
|
219 |
'format_csv_enclosure' => '"',
|
220 |
'format_csv_delimiter' => ',',
|
221 |
'format_csv_linebreak' => '\r\n',
|
239 |
'format_xml_self_closing_tags' => 1,
|
240 |
'all_products_from_order' => 1,
|
241 |
'skip_refunded_items' => 1,
|
242 |
+
'skip_suborders' => 0,
|
243 |
+
'export_refunds' => 0,
|
244 |
+
'date_format' => 'Y-m-d',
|
245 |
+
'time_format' => 'H:i',
|
246 |
'sort_direction' => 'DESC',
|
247 |
'sort' => 'order_id',
|
248 |
'format_number_fields' => 0,
|
251 |
'strip_tags_product_fields' => 0,
|
252 |
'cleanup_phone' => 0,
|
253 |
'enable_debug' => 0,
|
254 |
+
'format_json_start_tag' => '[',
|
255 |
+
'format_json_end_tag' => ']',
|
256 |
'custom_php' => 0,
|
257 |
'custom_php_code' => '',
|
258 |
'mark_exported_orders' => 0,
|
259 |
'export_unmarked_orders' => 0,
|
260 |
+
|
261 |
+
'summary_report_by_products' => 0,
|
262 |
);
|
263 |
|
264 |
if ( ! isset( $settings['format'] ) ) {
|
272 |
if ( ! isset( $settings['order_fields'] ) ) {
|
273 |
$settings['order_fields'] = array();
|
274 |
}
|
275 |
+
self::merge_settings_and_default( $settings['order_fields'],
|
276 |
+
WC_Order_Export_Data_Extractor_UI::get_order_fields( $settings['format'] ) );
|
277 |
|
278 |
if ( ! isset( $settings['order_product_fields'] ) ) {
|
279 |
$settings['order_product_fields'] = array();
|
280 |
}
|
281 |
+
self::merge_settings_and_default( $settings['order_product_fields'],
|
282 |
+
WC_Order_Export_Data_Extractor_UI::get_order_product_fields( $settings['format'] ) );
|
283 |
|
284 |
if ( ! isset( $settings['order_coupon_fields'] ) ) {
|
285 |
$settings['order_coupon_fields'] = array();
|
286 |
}
|
287 |
+
self::merge_settings_and_default( $settings['order_coupon_fields'],
|
288 |
+
WC_Order_Export_Data_Extractor_UI::get_order_coupon_fields( $settings['format'] ) );
|
289 |
+
|
290 |
return array_merge( $defaults, $settings );
|
291 |
}
|
292 |
|
293 |
+
static function merge_settings_and_default( &$opt, $defaults ) {
|
294 |
+
foreach ( $defaults as $k => $v ) {
|
295 |
+
if ( isset( $opt[ $k ] ) ) {
|
296 |
//set default attribute OR add to option
|
297 |
+
if ( isset( $v['default'] ) ) {
|
298 |
+
$opt[ $k ]['default'] = $v['default'];
|
299 |
+
}
|
300 |
//set default format OR add to option
|
301 |
+
if ( isset( $v['format'] ) ) {
|
302 |
+
$opt[ $k ]['format'] = $v['format'];
|
303 |
+
}
|
304 |
// overwrite labels for localization
|
305 |
+
$opt[ $k ]['label'] = $v['label'];
|
306 |
} else {
|
307 |
+
if ( self::$edit_existing_job AND $v['checked'] == "1" ) {
|
308 |
$v['checked'] = "0";
|
309 |
+
}
|
310 |
+
$opt[ $k ] = $v;
|
311 |
+
}
|
312 |
}
|
313 |
}
|
314 |
|
315 |
static function save_export_settings( $mode, $id, $options ) {
|
316 |
+
$all_jobs = self::get_export_settings_collection( $mode );
|
317 |
if ( $mode == self::EXPORT_NOW ) {
|
318 |
$all_jobs = $options;// just replace
|
319 |
} elseif ( $mode == self::EXPORT_SCHEDULE ) {
|
320 |
if ( $id ) {
|
321 |
+
$options['schedule']['last_run'] = isset( $all_jobs[ $id ] ) ? $all_jobs[ $id ]['schedule']['last_run'] : current_time( "timestamp",
|
322 |
+
0 );
|
323 |
+
$options['schedule']['next_run'] = WC_Order_Export_Cron::next_event_timestamp_for_schedule( $options['schedule'],
|
324 |
+
$id );
|
325 |
$all_jobs[ $id ] = $options;
|
326 |
} else {
|
327 |
+
$options['schedule']['last_run'] = current_time( "timestamp", 0 );
|
328 |
$options['schedule']['next_run'] = WC_Order_Export_Cron::next_event_timestamp_for_schedule( $options['schedule'] );
|
329 |
$all_jobs[] = $options; // new job
|
330 |
+
end( $all_jobs );
|
331 |
+
$id = key( $all_jobs );
|
332 |
}
|
333 |
} elseif ( $mode == self::EXPORT_PROFILE OR $mode == self::EXPORT_ORDER_ACTION ) {
|
334 |
if ( $id ) {
|
340 |
}
|
341 |
}
|
342 |
|
343 |
+
self::save_export_settings_collection( $mode, $all_jobs );
|
344 |
|
345 |
+
if ( $mode == self::EXPORT_SCHEDULE ) {
|
346 |
WC_Order_Export_Cron::install_job();
|
347 |
+
}
|
348 |
+
|
349 |
return $id;
|
350 |
}
|
351 |
|
353 |
return self::advanced_clone_export_settings( $id, $mode, $mode );
|
354 |
}
|
355 |
|
356 |
+
static function advanced_clone_export_settings(
|
357 |
+
$id,
|
358 |
+
$mode_in = self::EXPORT_SCHEDULE,
|
359 |
+
$mode_out = self::EXPORT_SCHEDULE
|
360 |
+
) {
|
361 |
$all_jobs_in = self::get_export_settings_collection( $mode_in );
|
362 |
//new settings
|
363 |
+
$settings = $all_jobs_in[ $id ];
|
364 |
+
$settings['mode'] = $mode_out;
|
365 |
|
366 |
if ( $mode_in !== $mode_out ) {
|
367 |
$all_jobs_out = self::get_export_settings_collection( $mode_out );
|
368 |
+
} else {
|
369 |
+
$mode_out = $mode_in;
|
370 |
+
$all_jobs_out = $all_jobs_in;
|
|
|
371 |
$settings['title'] .= " [cloned]"; //add note
|
372 |
}
|
373 |
|
374 |
+
if ( $mode_in === self::EXPORT_PROFILE && $mode_out === self::EXPORT_SCHEDULE ) {
|
375 |
if ( ! isset( $settings['destination'] ) ) {
|
376 |
$settings['destination'] = array(
|
377 |
'type' => 'folder',
|
389 |
|
390 |
if ( ! isset( $settings['schedule'] ) ) {
|
391 |
$settings['schedule'] = array(
|
392 |
+
'type' => 'schedule-1',
|
393 |
+
'run_at' => '00:00',
|
394 |
);
|
395 |
}
|
396 |
|
398 |
}
|
399 |
|
400 |
end( $all_jobs_out );
|
401 |
+
$next_id = key( $all_jobs_out ) + 1;
|
402 |
$all_jobs_out[ $next_id ] = $settings;
|
403 |
|
404 |
+
self::save_export_settings_collection( $mode_out, $all_jobs_out );
|
405 |
+
|
406 |
return $next_id;
|
407 |
}
|
408 |
|
420 |
self::EXPORT_PROFILE,
|
421 |
self::EXPORT_ORDER_ACTION,
|
422 |
);
|
423 |
+
if ( isset( $data[ self::EXPORT_NOW ] ) ) { // import ALL
|
424 |
foreach ( $allowed_options as $key ) {
|
425 |
if ( isset( $data[ $key ] ) ) {
|
426 |
$setting_name = self::get_settings_name_for_mode( $key );
|
429 |
$data[ $key ] = self::edit_import_data( $data[ $key ] );
|
430 |
} else {
|
431 |
foreach ( $data[ $key ] as $index => $import_single_data ) {
|
432 |
+
$data[ $key ][ $index ] = self::edit_import_data( $import_single_data );
|
433 |
}
|
434 |
}
|
435 |
|
436 |
+
update_option( $setting_name, $data[ $key ], false );
|
437 |
}
|
438 |
}
|
439 |
+
} elseif ( isset( $data["mode"] ) AND in_array( $data["mode"], $allowed_options ) ) { // OR import single ?
|
440 |
+
$setting_name = self::get_settings_name_for_mode( $data["mode"] );
|
441 |
+
if ( $setting_name == self::settings_name_now ) {
|
442 |
+
update_option( $setting_name, self::edit_import_data( $data ), false ); // rewrite
|
443 |
+
} else { // append!
|
444 |
+
$items = get_option( $setting_name, array() );
|
445 |
+
|
446 |
+
if ( empty( $items ) ) {
|
447 |
+
$items[1] = self::edit_import_data( $data );
|
448 |
+
} else {
|
449 |
+
$items[] = self::edit_import_data( $data );
|
|
|
|
|
|
|
450 |
}
|
451 |
+
|
452 |
+
update_option( $setting_name, $items, false );
|
453 |
+
}
|
454 |
}// if modes
|
455 |
}
|
456 |
|
classes/class-wc-order-export-admin.php
CHANGED
@@ -30,65 +30,70 @@ class WC_Order_Export_Admin {
|
|
30 |
|
31 |
//Add custom bulk export action in Woocomerce orders Table, modified for WP 4.7
|
32 |
add_filter( 'bulk_actions-edit-shop_order', array( $this, 'export_orders_bulk_action' ) );
|
33 |
-
add_filter( 'handle_bulk_actions-edit-shop_order', array( $this, 'export_orders_bulk_action_process' ), 10,
|
34 |
-
|
|
|
35 |
//do once
|
36 |
-
if( !get_option( $this->activation_notice_option ) )
|
37 |
-
add_action('admin_notices', array( $this,'display_plugin_activated_message'));
|
38 |
-
|
|
|
39 |
//extra links in >Plugins
|
40 |
-
add_filter( 'plugin_action_links_' . WOE_PLUGIN_BASENAME, array($this,'add_action_links') );
|
41 |
-
|
42 |
// Add 'Export Status' orders page column header
|
43 |
add_filter( 'manage_edit-shop_order_columns', array( $this, 'add_order_status_column_header' ), 20 );
|
44 |
|
45 |
// Add 'Export Status' orders page column content
|
46 |
add_action( 'manage_shop_order_posts_custom_column', array( $this, 'add_order_status_column_content' ) );
|
47 |
|
48 |
-
if ( isset( $_GET[
|
49 |
add_action( 'admin_print_styles', array( $this, 'add_order_status_column_style' ) );
|
50 |
}
|
51 |
}
|
52 |
|
53 |
-
|
54 |
|
55 |
//Pro active ?
|
56 |
-
if( self::is_full_version() ) {
|
57 |
-
|
58 |
add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
|
59 |
-
add_filter( 'cron_schedules', array( 'WC_Order_Export_Cron', 'create_custom_schedules' ),
|
60 |
add_action( 'wc_export_cron_global', array( 'WC_Order_Export_Cron', 'wc_export_cron_global_f' ) );
|
61 |
|
62 |
//for direct calls
|
63 |
add_action( 'wp_ajax_order_exporter_run', array( $this, 'ajax_gate_guest' ) );
|
64 |
add_action( 'wp_ajax_nopriv_order_exporter_run', array( $this, 'ajax_gate_guest' ) );
|
65 |
-
$this->methods_allowed_for_guests = array('run_cron_jobs','run_one_job','run_one_scheduled_job');
|
66 |
|
67 |
// order actions
|
68 |
-
add_action( 'woocommerce_order_status_changed', array( $this, 'wc_order_status_changed' ), 10, 3);
|
69 |
// activate CRON hook if it was removed
|
70 |
-
add_action( 'wp_loaded', function() {
|
71 |
$all_jobs = WC_Order_Export_Manage::get_export_settings_collection( WC_Order_Export_Manage::EXPORT_SCHEDULE );
|
72 |
-
if ( $all_jobs )
|
73 |
WC_Order_Export_Cron::install_job();
|
|
|
74 |
} );
|
75 |
}
|
76 |
|
77 |
}
|
78 |
|
79 |
public function add_order_status_column_header( $columns ) {
|
80 |
-
|
81 |
-
if( ! $this->settings['show_export_status_column'] )
|
82 |
return $columns;
|
83 |
-
|
|
|
84 |
$new_columns = array();
|
85 |
foreach ( $columns as $column_name => $column_info ) {
|
86 |
-
if ( 'order_actions' === $column_name OR 'wc_actions' === $column_name) { // Woocommerce uses wc_actions since 3.3.0
|
87 |
-
$label
|
88 |
$new_columns['woe_export_status'] = $label;
|
89 |
}
|
90 |
$new_columns[ $column_name ] = $column_info;
|
91 |
}
|
|
|
92 |
return $new_columns;
|
93 |
}
|
94 |
|
@@ -102,7 +107,7 @@ class WC_Order_Export_Admin {
|
|
102 |
$is_exported = true;
|
103 |
}
|
104 |
|
105 |
-
if( $is_exported ) {
|
106 |
echo '<span class="dashicons dashicons-yes" style="color: #2ea2cc"></span>';
|
107 |
} else {
|
108 |
echo '<span class="dashicons dashicons-minus"></span>';
|
@@ -117,37 +122,43 @@ class WC_Order_Export_Admin {
|
|
117 |
|
118 |
public function install() {
|
119 |
//wp_clear_scheduled_hook( "wc_export_cron_global" ); //debug
|
120 |
-
if( self::is_full_version() )
|
121 |
WC_Order_Export_Cron::install_job();
|
|
|
122 |
}
|
123 |
|
124 |
public function display_plugin_activated_message() {
|
125 |
?>
|
126 |
-
|
127 |
-
|
128 |
-
|
|
|
129 |
<?php
|
130 |
-
update_option( $this->activation_notice_option, true );
|
131 |
}
|
132 |
|
133 |
public function add_action_links( $links ) {
|
134 |
-
$mylinks
|
135 |
-
'<a href="admin.php?page=wc-order-export">'. __('Settings', 'woo-order-export-lite'). '</a>',
|
136 |
-
'<a href="https://algolplus.com/plugins/documentation-order-export-woocommerce/" target="_blank">'. __('Docs',
|
137 |
-
|
|
|
|
|
138 |
);
|
139 |
-
|
|
|
140 |
}
|
141 |
|
142 |
public function deactivate() {
|
143 |
wp_clear_scheduled_hook( "wc_export_cron_global" );
|
144 |
delete_option( $this->activation_notice_option );
|
145 |
|
146 |
-
if( self::is_full_version() ) {
|
147 |
//don't do it! updater call this function!
|
148 |
// WC_Order_Export_EDD::getInstance()->edd_woe_force_deactivate_license();
|
149 |
}
|
150 |
}
|
|
|
151 |
public static function uninstall() {
|
152 |
//delete_option( self::settings_name_common );
|
153 |
//WC_Order_Export_Manage::remove_settings();
|
@@ -156,62 +167,74 @@ class WC_Order_Export_Admin {
|
|
156 |
static function load_main_settings() {
|
157 |
return array_merge(
|
158 |
array(
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
|
|
|
|
169 |
),
|
170 |
get_option( self::settings_name_common, array() )
|
171 |
);
|
172 |
}
|
|
|
173 |
static function save_main_settings() {
|
174 |
// update main settings here!
|
175 |
-
$settings = filter_input_array(INPUT_POST, array(
|
176 |
-
'
|
177 |
-
'
|
178 |
-
'
|
|
|
179 |
'show_export_in_status_change_job' => FILTER_VALIDATE_BOOLEAN,
|
180 |
-
'
|
181 |
-
'
|
182 |
-
'
|
183 |
-
'
|
184 |
-
'
|
185 |
-
'
|
|
|
186 |
) );
|
187 |
-
update_option( self::settings_name_common, $settings );
|
188 |
|
189 |
if ( isset( $settings['ipn_url'] ) ) {
|
190 |
-
update_option( WOE_IPN_URL_OPTION_KEY, $settings['ipn_url'] );
|
191 |
}
|
192 |
}
|
193 |
|
194 |
|
195 |
function load_textdomain() {
|
196 |
$locale = apply_filters( 'plugin_locale', get_locale(), 'woo-order-export-lite' );
|
197 |
-
load_textdomain( 'woo-order-export-lite',
|
|
|
198 |
|
199 |
load_plugin_textdomain( 'woo-order-export-lite', false,
|
200 |
plugin_basename( dirname( dirname( __FILE__ ) ) ) . '/i18n/languages' );
|
201 |
}
|
202 |
|
203 |
public function add_menu() {
|
204 |
-
if( apply_filters('woe_current_user_can_export', true) ) {
|
205 |
-
if ( current_user_can( 'manage_woocommerce' ) )
|
206 |
-
add_submenu_page( 'woocommerce', __( 'Export Orders', 'woo-order-export-lite' ),
|
207 |
-
|
208 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
}
|
210 |
}
|
211 |
|
212 |
public function render_menu() {
|
213 |
$this->render( 'main', array( 'WC_Order_Export' => $this, 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
|
214 |
-
$active_tab = isset( $_REQUEST['tab'] ) ? $_REQUEST['tab'] : '
|
215 |
if ( method_exists( $this, 'render_tab_' . $active_tab ) ) {
|
216 |
$this->{'render_tab_' . $active_tab}();
|
217 |
}
|
@@ -221,40 +244,41 @@ class WC_Order_Export_Admin {
|
|
221 |
$this->render( 'tab/export', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'WC_Order_Export' => $this ) );
|
222 |
}
|
223 |
|
224 |
-
|
225 |
$this->render( 'tab/tools', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'WC_Order_Export' => $this ) );
|
226 |
}
|
227 |
|
228 |
-
|
229 |
-
$this->render( 'tab/settings',
|
|
|
230 |
}
|
231 |
|
232 |
public function render_tab_license() {
|
233 |
$this->render( 'tab/license', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'WC_Order_Export' => $this ) );
|
234 |
}
|
235 |
|
236 |
-
|
237 |
$this->render( 'tab/help', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'WC_Order_Export' => $this ) );
|
238 |
}
|
239 |
|
240 |
public function render_tab_order_actions() {
|
241 |
$wc_oe = isset( $_REQUEST['wc_oe'] ) ? $_REQUEST['wc_oe'] : '';
|
242 |
$ajaxurl = admin_url( 'admin-ajax.php' );
|
243 |
-
$mode
|
244 |
$all_items = WC_Order_Export_Manage::get_export_settings_collection( $mode );
|
245 |
$show = array(
|
246 |
-
'date_filter'
|
247 |
-
'export_button'
|
248 |
'export_button_plain' => $this->settings['show_export_in_status_change_job'],
|
249 |
-
'preview_actions'
|
250 |
-
'destinations'
|
251 |
-
'schedule'
|
252 |
-
'sort_orders'
|
253 |
-
'order_filters'
|
254 |
-
'product_filters'
|
255 |
-
'customer_filters'
|
256 |
-
'billing_filters'
|
257 |
-
'shipping_filters'
|
258 |
);
|
259 |
switch ( $wc_oe ) {
|
260 |
case 'add_action':
|
@@ -265,15 +289,17 @@ class WC_Order_Export_Admin {
|
|
265 |
'id' => $next_id,
|
266 |
'WC_Order_Export' => $this,
|
267 |
'ajaxurl' => $ajaxurl,
|
268 |
-
'show' => $show
|
269 |
) );
|
|
|
270 |
return;
|
271 |
case 'edit_action':
|
272 |
-
if( !isset( $_REQUEST[
|
273 |
break;
|
274 |
-
|
|
|
275 |
WC_Order_Export_Manage::$edit_existing_job = true;
|
276 |
-
$clone
|
277 |
if ( $clone ) {
|
278 |
$item_id = WC_Order_Export_Manage::clone_export_settings( $mode, $item_id );
|
279 |
}
|
@@ -282,30 +308,34 @@ class WC_Order_Export_Admin {
|
|
282 |
'id' => $item_id,
|
283 |
'WC_Order_Export' => $this,
|
284 |
'ajaxurl' => $ajaxurl,
|
285 |
-
'show' => $show
|
286 |
) );
|
|
|
287 |
return;
|
288 |
case 'delete':
|
289 |
-
if( !isset( $_REQUEST[
|
290 |
break;
|
291 |
-
|
|
|
292 |
unset( $all_items[ $item_id ] );
|
293 |
WC_Order_Export_Manage::save_export_settings_collection( $mode, $all_items );
|
294 |
break;
|
295 |
case 'change_status':
|
296 |
-
if( !isset( $_REQUEST[
|
297 |
break;
|
298 |
-
|
|
|
299 |
$all_items[ $item_id ]['active'] = $_REQUEST['status'];
|
300 |
WC_Order_Export_Manage::save_export_settings_collection( $mode, $all_items );
|
301 |
$url = remove_query_arg( array( 'wc_oe', 'action_id', 'status' ) );
|
302 |
wp_redirect( $url );
|
303 |
break;
|
304 |
case 'change_statuses':
|
305 |
-
if( !isset( $_REQUEST['chosen_order_actions'] ) AND !isset( $_REQUEST['doaction'] ) AND -1 == $_REQUEST['doaction'] )
|
306 |
break;
|
307 |
-
|
308 |
-
$
|
|
|
309 |
|
310 |
foreach ( $chosen_order_actions as $order_action_id ) {
|
311 |
if ( 'activate' == $doaction ) {
|
@@ -321,20 +351,21 @@ class WC_Order_Export_Admin {
|
|
321 |
wp_redirect( $url );
|
322 |
break;
|
323 |
}
|
324 |
-
$this->render( 'tab/order-actions',
|
|
|
325 |
}
|
326 |
|
327 |
public function render_tab_schedules() {
|
328 |
$wc_oe = isset( $_REQUEST['wc_oe'] ) ? $_REQUEST['wc_oe'] : '';
|
329 |
$ajaxurl = admin_url( 'admin-ajax.php' );
|
330 |
-
$mode
|
331 |
$all_jobs = WC_Order_Export_Manage::get_export_settings_collection( $mode );
|
332 |
-
$show
|
333 |
-
'date_filter'
|
334 |
-
'export_button'
|
335 |
'export_button_plain' => true,
|
336 |
-
'destinations'
|
337 |
-
'schedule'
|
338 |
);
|
339 |
switch ( $wc_oe ) {
|
340 |
case 'add_schedule':
|
@@ -345,15 +376,17 @@ class WC_Order_Export_Admin {
|
|
345 |
'id' => $next_id,
|
346 |
'WC_Order_Export' => $this,
|
347 |
'ajaxurl' => $ajaxurl,
|
348 |
-
'show' => $show
|
349 |
) );
|
|
|
350 |
return;
|
351 |
case 'edit_schedule':
|
352 |
-
if( !isset( $_REQUEST[
|
353 |
break;
|
354 |
-
|
|
|
355 |
WC_Order_Export_Manage::$edit_existing_job = true;
|
356 |
-
$clone
|
357 |
if ( $clone ) {
|
358 |
$schedule_id = WC_Order_Export_Manage::clone_export_settings( $mode, $schedule_id );
|
359 |
}
|
@@ -362,40 +395,44 @@ class WC_Order_Export_Admin {
|
|
362 |
'id' => $schedule_id,
|
363 |
'WC_Order_Export' => $this,
|
364 |
'ajaxurl' => $ajaxurl,
|
365 |
-
'show' => $show
|
366 |
) );
|
|
|
367 |
return;
|
368 |
case 'delete_schedule':
|
369 |
-
if( !isset( $_REQUEST[
|
370 |
break;
|
371 |
-
|
|
|
372 |
unset( $all_jobs[ $schedule_id ] );
|
373 |
WC_Order_Export_Manage::save_export_settings_collection( $mode, $all_jobs );
|
374 |
break;
|
375 |
case 'change_status_schedule':
|
376 |
-
if( !isset( $_REQUEST[
|
377 |
break;
|
378 |
-
|
|
|
379 |
$all_jobs[ $schedule_id ]['active'] = $_REQUEST['status'];
|
380 |
WC_Order_Export_Manage::save_export_settings_collection( $mode, $all_jobs );
|
381 |
$url = remove_query_arg( array( 'wc_oe', 'schedule_id', 'status' ) );
|
382 |
wp_redirect( $url );
|
383 |
break;
|
384 |
case 'change_status_schedules':
|
385 |
-
if( !isset( $_REQUEST['chosen_schedules'] ) AND !isset( $_REQUEST['doaction'] ) AND -1 == $_REQUEST['doaction'] )
|
386 |
break;
|
387 |
-
|
388 |
-
$
|
|
|
389 |
|
390 |
foreach ( $chosen_schedules as $schedule_id ) {
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
WC_Order_Export_Manage::save_export_settings_collection( $mode, $all_jobs );
|
400 |
$url = remove_query_arg( array( 'wc_oe', 'chosen_schedules', 'doaction' ) );
|
401 |
wp_redirect( $url );
|
@@ -405,16 +442,16 @@ class WC_Order_Export_Admin {
|
|
405 |
}
|
406 |
|
407 |
public function render_tab_profiles() {
|
408 |
-
$wc_oe
|
409 |
-
$ajaxurl
|
410 |
-
$mode
|
411 |
$all_items = WC_Order_Export_Manage::get_export_settings_collection( $mode );
|
412 |
-
$show
|
413 |
-
'date_filter'
|
414 |
-
'export_button'
|
415 |
'export_button_plain' => true,
|
416 |
-
'destinations'
|
417 |
-
'schedule'
|
418 |
);
|
419 |
switch ( $wc_oe ) {
|
420 |
case 'add_profile':
|
@@ -425,15 +462,17 @@ class WC_Order_Export_Admin {
|
|
425 |
'id' => $next_id,
|
426 |
'WC_Order_Export' => $this,
|
427 |
'ajaxurl' => $ajaxurl,
|
428 |
-
'show' => $show
|
429 |
) );
|
|
|
430 |
return;
|
431 |
case 'edit_profile':
|
432 |
-
if( !isset( $_REQUEST['profile_id'] ) )
|
433 |
break;
|
434 |
-
|
|
|
435 |
WC_Order_Export_Manage::$edit_existing_job = true;
|
436 |
-
$clone
|
437 |
if ( $clone ) {
|
438 |
$profile_id = WC_Order_Export_Manage::clone_export_settings( $mode, $profile_id );
|
439 |
}
|
@@ -442,49 +481,54 @@ class WC_Order_Export_Admin {
|
|
442 |
'id' => $profile_id,
|
443 |
'WC_Order_Export' => $this,
|
444 |
'ajaxurl' => $ajaxurl,
|
445 |
-
'show' => $show
|
446 |
) );
|
|
|
447 |
return;
|
448 |
case 'copy_profile_to_scheduled':
|
449 |
$profile_id = isset( $_REQUEST['profile_id'] ) ? $_REQUEST['profile_id'] : '';
|
450 |
-
$schedule_id = WC_Order_Export_Manage::advanced_clone_export_settings( $profile_id, $mode,
|
451 |
-
|
452 |
-
$url
|
453 |
-
$url
|
454 |
-
$url
|
|
|
455 |
wp_redirect( $url );
|
456 |
break;
|
457 |
case 'copy_profile_to_actions':
|
458 |
$profile_id = isset( $_REQUEST['profile_id'] ) ? $_REQUEST['profile_id'] : '';
|
459 |
-
$schedule_id = WC_Order_Export_Manage::advanced_clone_export_settings( $profile_id, $mode,
|
460 |
-
|
461 |
-
$url
|
462 |
-
$url
|
463 |
-
$url
|
|
|
464 |
wp_redirect( $url );
|
465 |
break;
|
466 |
case 'delete_profile':
|
467 |
-
if( !isset( $_REQUEST['profile_id'] ) )
|
468 |
break;
|
|
|
469 |
$profile_id = $_REQUEST['profile_id'];
|
470 |
unset( $all_items[ $profile_id ] );
|
471 |
WC_Order_Export_Manage::save_export_settings_collection( $mode, $all_items );
|
472 |
break;
|
473 |
case 'change_profile_statuses':
|
474 |
-
if( !isset( $_REQUEST['chosen_profiles'] ) AND !isset( $_REQUEST['doaction'] ) AND -1 == $_REQUEST['doaction'] )
|
475 |
break;
|
476 |
-
|
477 |
-
$
|
|
|
478 |
|
479 |
foreach ( $chosen_profiles as $profile_id ) {
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
WC_Order_Export_Manage::save_export_settings_collection( $mode, $all_items );
|
489 |
$url = remove_query_arg( array( 'wc_oe', 'chosen_profiles', 'doaction' ) );
|
490 |
wp_redirect( $url );
|
@@ -493,12 +537,12 @@ class WC_Order_Export_Admin {
|
|
493 |
|
494 |
//code to copy default settings as profile
|
495 |
$profiles = WC_Order_Export_Manage::get_export_settings_collection( $mode );
|
496 |
-
$free_job = WC_Order_Export_Manage::get_export_settings_collection( WC_Order_Export_Manage::EXPORT_NOW);
|
497 |
-
if(empty( $profiles )
|
498 |
-
$free_job['title'] = __('Copied from "Export now"', 'woo-order-export-lite' );
|
499 |
-
$free_job['mode']
|
500 |
-
$profiles[1]
|
501 |
-
update_option( WC_Order_Export_Manage::settings_name_profiles, $profiles);
|
502 |
}
|
503 |
|
504 |
$this->render( 'tab/profiles', array( 'ajaxurl' => $ajaxurl, 'WC_Order_Export' => $this ) );
|
@@ -511,20 +555,23 @@ class WC_Order_Export_Admin {
|
|
511 |
wp_enqueue_style( 'jquery-style',
|
512 |
'//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css' );
|
513 |
$this->enqueue_select2_scripts();
|
514 |
-
|
515 |
wp_enqueue_script( 'export', $this->url_plugin . 'assets/js/export.js', array(), WOE_VERSION );
|
516 |
-
wp_enqueue_script( 'serializejson', $this->url_plugin . 'assets/js/jquery.serializejson.js', array('jquery'),
|
|
|
517 |
wp_enqueue_style( 'export', $this->url_plugin . 'assets/css/export.css', array(), WOE_VERSION );
|
518 |
wp_enqueue_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array() );
|
519 |
|
520 |
-
$_REQUEST['tab'] = isset( $_REQUEST['tab'] ) ? $_REQUEST['tab'] : '
|
521 |
-
if ( isset( $_REQUEST['wc_oe'] ) AND ( strpos($_REQUEST['wc_oe'], 'add_') === 0 OR strpos($_REQUEST['wc_oe'],
|
522 |
-
|
|
|
|
|
523 |
|
524 |
$localize_settings_form = array(
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
wp_localize_script( 'settings-form', 'localize_settings_form', $localize_settings_form );
|
529 |
|
530 |
|
@@ -554,7 +601,7 @@ class WC_Order_Export_Admin {
|
|
554 |
'object_formats' => array( 'XML', 'JSON' ),
|
555 |
'xml_formats' => array( 'XML' ),
|
556 |
|
557 |
-
|
558 |
|
559 |
);
|
560 |
|
@@ -564,17 +611,19 @@ class WC_Order_Export_Admin {
|
|
564 |
|
565 |
// Localize the script with new data
|
566 |
$translation_array = array(
|
567 |
-
'empty_column_name'
|
568 |
-
'empty_meta_key'
|
569 |
-
'empty_meta_key_and_taxonomy' => __( 'select product field or item field or taxonomy',
|
570 |
-
|
571 |
-
'
|
572 |
-
'
|
573 |
-
'
|
574 |
-
'
|
575 |
-
'
|
|
|
|
|
576 |
);
|
577 |
-
wp_localize_script( 'export', 'export_messages', $translation_array );
|
578 |
}
|
579 |
|
580 |
private function enqueue_select2_scripts() {
|
@@ -600,10 +649,11 @@ class WC_Order_Export_Admin {
|
|
600 |
array(), WC_VERSION );
|
601 |
}
|
602 |
|
603 |
-
public function script_loader_src($src, $handle) {
|
604 |
// don't load ANY select2.js / select2.min.js and OUTDATED select2.full.js
|
605 |
-
if (!preg_match('/\/select2\.full\.js\?ver=[1-3]/', $src) && !preg_match('/\/select2\.min\.js/',
|
606 |
-
|
|
|
607 |
) {
|
608 |
return $src;
|
609 |
}
|
@@ -611,8 +661,8 @@ class WC_Order_Export_Admin {
|
|
611 |
|
612 |
public function render( $view, $params = array(), $path_views = null ) {
|
613 |
$params = apply_filters( 'woe_render_params', $params );
|
614 |
-
$params = apply_filters( 'woe_render_params_'
|
615 |
-
|
616 |
extract( $params );
|
617 |
if ( $path_views ) {
|
618 |
include $path_views . "$view.php";
|
@@ -627,6 +677,7 @@ class WC_Order_Export_Admin {
|
|
627 |
if ( substr( $name, 0, 1 ) == '[' ) {
|
628 |
$name = substr( $name, 1 );
|
629 |
}
|
|
|
630 |
return trim( $name );
|
631 |
}, $arr_name );
|
632 |
$arr_name = array_filter( $arr_name );
|
@@ -634,6 +685,7 @@ class WC_Order_Export_Admin {
|
|
634 |
foreach ( $arr_name as $value ) {
|
635 |
$arr = isset( $arr[ $value ] ) ? $arr[ $value ] : "";
|
636 |
}
|
|
|
637 |
return $arr;
|
638 |
}
|
639 |
|
@@ -647,36 +699,39 @@ class WC_Order_Export_Admin {
|
|
647 |
$new_status = is_string( $new_status ) && strpos( $new_status, 'wc-' ) !== 0 ? "wc-{$new_status}" : $new_status;
|
648 |
|
649 |
$this->changed_order_id = $order_id;
|
650 |
-
add_filter( 'woe_sql_get_order_ids_where', array($this, "filter_by_changed_order"), 10, 2 );
|
651 |
|
652 |
-
$logger
|
653 |
$logger_context = array( 'source' => 'woo-order-export-lite' );
|
654 |
|
655 |
-
foreach ( $all_items as $key
|
656 |
$item = WC_Order_Export_Manage::get( WC_Order_Export_Manage::EXPORT_ORDER_ACTION, $key );
|
657 |
if ( isset( $item['active'] ) && ! $item['active'] ) {
|
658 |
continue;
|
659 |
}
|
660 |
// use empty for ANY status
|
661 |
-
if ( ( empty( $item['from_status'] ) OR
|
662 |
AND
|
663 |
( empty( $item['to_status'] ) OR in_array( $new_status, $item['to_status'] ) )
|
664 |
-
|
665 |
-
do_action('woe_order_action_started', $order_id, $item );
|
666 |
$result = WC_Order_Export_Engine::build_files_and_export( $item );
|
667 |
-
$output = sprintf( __('Status change job #%s for order #%s. Result: %s', 'woo-order-export-lite' ),
|
|
|
668 |
// log if required
|
669 |
-
if( $logger AND !empty($item['log_results']) )
|
670 |
$logger->info( $output, $logger_context );
|
|
|
671 |
|
672 |
-
do_action('woe_order_action_completed', $order_id,
|
673 |
}
|
674 |
}
|
675 |
-
remove_filter( 'woe_sql_get_order_ids_where', array($this, "filter_by_changed_order"), 10 );
|
676 |
}
|
677 |
|
678 |
-
public function filter_by_changed_order
|
679 |
$where[] = "orders.ID = " . $this->changed_order_id;
|
|
|
680 |
return $where;
|
681 |
}
|
682 |
|
@@ -686,11 +741,11 @@ class WC_Order_Export_Admin {
|
|
686 |
if ( isset( $_REQUEST['method'] ) ) {
|
687 |
$method = $_REQUEST['method'];
|
688 |
if ( method_exists( 'WC_Order_Export_Ajax', $method ) ) {
|
689 |
-
$_POST = stripslashes_deep($_POST);
|
690 |
// parse json to arrays?
|
691 |
-
if ( !empty($_POST['json']) ) {
|
692 |
-
$json = json_decode( $_POST['json'], true );
|
693 |
-
if( is_array($json) ) {
|
694 |
// add $_POST['settings'],$_POST['orders'],$_POST['products'],$_POST['coupons']
|
695 |
$_POST = $_POST + $json;
|
696 |
unset( $_POST['json'] );
|
@@ -705,75 +760,81 @@ class WC_Order_Export_Admin {
|
|
705 |
|
706 |
//TODO: debug!
|
707 |
public function ajax_gate_guest() {
|
708 |
-
if ( isset( $_REQUEST['method'] )
|
709 |
$method = $_REQUEST['method'];
|
710 |
if ( method_exists( 'WC_Order_Export_Ajax', $method ) ) {
|
711 |
-
$_POST = array_map('stripslashes_deep', $_POST);
|
712 |
-
$ajax
|
713 |
$ajax->validate_url_key();
|
714 |
$ajax->$method();
|
715 |
}
|
716 |
}
|
717 |
die();
|
718 |
}
|
719 |
-
|
720 |
//Works since Wordpress 4.7
|
721 |
function export_orders_bulk_action( $actions ) {
|
722 |
$settings = WC_Order_Export_Manage::get( WC_Order_Export_Manage::EXPORT_NOW );
|
723 |
WC_Order_Export_Manage::set_correct_file_ext( $settings );
|
724 |
-
|
725 |
// default
|
726 |
-
if( ! empty($settings['format']) ) {
|
727 |
-
$actions['woe_export_selected_orders'] = sprintf( __( 'Export as %s', 'woo-order-export-lite' ),
|
|
|
728 |
}
|
729 |
-
|
730 |
// mark/unmark
|
731 |
-
if( $this->settings['show_export_actions_in_bulk'] ) {
|
732 |
-
$actions['woe_mark_exported']
|
733 |
$actions['woe_unmark_exported'] = __( 'Unmark exported', 'woo-order-export-lite' );
|
734 |
-
}
|
735 |
|
736 |
$all_items = WC_Order_Export_Manage::get_export_settings_collection( WC_Order_Export_Manage::EXPORT_PROFILE );
|
737 |
foreach ( $all_items as $job_id => $job ) {
|
738 |
-
if ( isset( $job['use_as_bulk'] ) )
|
739 |
-
$actions['woe_export_selected_orders_profile_' . $job_id] =
|
|
|
|
|
740 |
}
|
741 |
-
|
742 |
return $actions;
|
743 |
}
|
744 |
|
745 |
-
function export_orders_bulk_action_process($redirect_to, $action, $ids) {
|
746 |
switch ( $action ) {
|
747 |
case 'woe_export_selected_orders':
|
748 |
-
$redirect_to = add_query_arg( array( 'export_bulk_profile' => 'now', 'ids' => join( ',', $ids ) ),
|
|
|
749 |
break;
|
750 |
case 'woe_mark_exported':
|
751 |
-
foreach( $ids as $post_id ) {
|
752 |
update_post_meta( $post_id, 'woe_order_exported', 1 );
|
753 |
}
|
754 |
-
$redirect_to = add_query_arg( array(
|
755 |
'woe_bulk_mark_exported' => count( $ids ),
|
756 |
'woe_bulk_unmark_exported' => false,
|
757 |
), $redirect_to );
|
758 |
break;
|
759 |
case 'woe_unmark_exported':
|
760 |
-
foreach( $ids as $post_id ) {
|
761 |
-
delete_post_meta( $post_id, 'woe_order_exported');
|
762 |
}
|
763 |
$redirect_to = add_query_arg( array(
|
764 |
'woe_bulk_mark_exported' => false,
|
765 |
-
'woe_bulk_unmark_exported' => count( $ids )
|
766 |
), $redirect_to );
|
767 |
break;
|
768 |
default:
|
769 |
if ( preg_match( '/woe_export_selected_orders_profile_(\d+)/', $action, $matches ) ) {
|
770 |
if ( isset( $matches[1] ) ) {
|
771 |
-
$id
|
772 |
-
$redirect_to = add_query_arg( array( 'export_bulk_profile' => $id, 'ids' => join( ',', $ids ) ),
|
|
|
773 |
break;
|
774 |
-
}
|
775 |
}
|
776 |
-
|
|
|
777 |
return $redirect_to;
|
778 |
}
|
779 |
|
@@ -785,9 +846,9 @@ class WC_Order_Export_Admin {
|
|
785 |
|
786 |
global $post_type, $pagenow;
|
787 |
|
788 |
-
if ( $pagenow == 'edit.php' && $post_type == 'shop_order' && isset( $_REQUEST[
|
789 |
-
$url = admin_url( 'admin-ajax.php' ) . "?action=order_exporter&method=export_download_bulk_file&export_bulk_profile=" . $_REQUEST[
|
790 |
-
wp_redirect($url);
|
791 |
exit();
|
792 |
/* unused code
|
793 |
//$message = sprintf( __( 'Orders exported. <a href="%s">Download report.</a>' ,'woo-order-export-lite'), $url );
|
@@ -798,8 +859,8 @@ class WC_Order_Export_Admin {
|
|
798 |
// must remove this arg from pagination url
|
799 |
add_filter('removable_query_args', array($this, 'fix_table_links') );
|
800 |
*/
|
801 |
-
} else if ( $pagenow == 'edit.php' && $post_type == 'shop_order' && isset( $_REQUEST[
|
802 |
-
$count = intval( $_REQUEST[
|
803 |
printf(
|
804 |
'<div id="message" class="updated fade">' .
|
805 |
_n( '%s order marked.', '%s orders marked.', $count, 'woo-order-export-lite' )
|
@@ -807,8 +868,8 @@ class WC_Order_Export_Admin {
|
|
807 |
$count
|
808 |
);
|
809 |
|
810 |
-
} else if ( $pagenow == 'edit.php' && $post_type == 'shop_order' && isset( $_REQUEST[
|
811 |
-
$count = intval( $_REQUEST[
|
812 |
printf(
|
813 |
'<div id="message" class="updated fade">' .
|
814 |
_n( '%s order unmarked.', '%s orders unmarked.', $count, 'woo-order-export-lite' )
|
@@ -821,24 +882,27 @@ class WC_Order_Export_Admin {
|
|
821 |
function fix_table_links( $args ) {
|
822 |
$args[] = 'export_bulk_profile';
|
823 |
$args[] = 'ids';
|
|
|
824 |
return $args;
|
825 |
}
|
826 |
|
827 |
function must_run_ajax_methods() {
|
828 |
// wait admin ajax!
|
829 |
-
$script_name = !empty($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : $_SERVER['PHP_SELF'];
|
830 |
-
if ( basename( $script_name ) != "admin-ajax.php" )
|
831 |
-
|
|
|
|
|
832 |
// our method MUST BE called
|
833 |
-
return isset($_REQUEST['action'])
|
834 |
}
|
835 |
|
836 |
public static function is_full_version() {
|
837 |
return defined( 'WOE_STORE_URL' );
|
838 |
-
|
839 |
-
|
840 |
public static function user_can_add_custom_php() {
|
841 |
-
return apply_filters('woe_user_can_add_custom_php', current_user_can('edit_themes') );
|
842 |
-
|
843 |
-
|
844 |
}
|
30 |
|
31 |
//Add custom bulk export action in Woocomerce orders Table, modified for WP 4.7
|
32 |
add_filter( 'bulk_actions-edit-shop_order', array( $this, 'export_orders_bulk_action' ) );
|
33 |
+
add_filter( 'handle_bulk_actions-edit-shop_order', array( $this, 'export_orders_bulk_action_process' ), 10,
|
34 |
+
3 );
|
35 |
+
add_action( 'admin_notices', array( $this, 'export_orders_bulk_action_notices' ) );
|
36 |
//do once
|
37 |
+
if ( ! get_option( $this->activation_notice_option ) ) {
|
38 |
+
add_action( 'admin_notices', array( $this, 'display_plugin_activated_message' ) );
|
39 |
+
}
|
40 |
+
|
41 |
//extra links in >Plugins
|
42 |
+
add_filter( 'plugin_action_links_' . WOE_PLUGIN_BASENAME, array( $this, 'add_action_links' ) );
|
43 |
+
|
44 |
// Add 'Export Status' orders page column header
|
45 |
add_filter( 'manage_edit-shop_order_columns', array( $this, 'add_order_status_column_header' ), 20 );
|
46 |
|
47 |
// Add 'Export Status' orders page column content
|
48 |
add_action( 'manage_shop_order_posts_custom_column', array( $this, 'add_order_status_column_content' ) );
|
49 |
|
50 |
+
if ( isset( $_GET['post_type'] ) && $_GET['post_type'] == 'shop_order' ) {
|
51 |
add_action( 'admin_print_styles', array( $this, 'add_order_status_column_style' ) );
|
52 |
}
|
53 |
}
|
54 |
|
55 |
+
$this->settings = self::load_main_settings();
|
56 |
|
57 |
//Pro active ?
|
58 |
+
if ( self::is_full_version() ) {
|
59 |
+
new WC_Order_Export_Zapier_Engine( $this->settings );
|
60 |
add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
|
61 |
+
add_filter( 'cron_schedules', array( 'WC_Order_Export_Cron', 'create_custom_schedules' ), 999, 1 );
|
62 |
add_action( 'wc_export_cron_global', array( 'WC_Order_Export_Cron', 'wc_export_cron_global_f' ) );
|
63 |
|
64 |
//for direct calls
|
65 |
add_action( 'wp_ajax_order_exporter_run', array( $this, 'ajax_gate_guest' ) );
|
66 |
add_action( 'wp_ajax_nopriv_order_exporter_run', array( $this, 'ajax_gate_guest' ) );
|
67 |
+
$this->methods_allowed_for_guests = array( 'run_cron_jobs', 'run_one_job', 'run_one_scheduled_job' );
|
68 |
|
69 |
// order actions
|
70 |
+
add_action( 'woocommerce_order_status_changed', array( $this, 'wc_order_status_changed' ), 10, 3 );
|
71 |
// activate CRON hook if it was removed
|
72 |
+
add_action( 'wp_loaded', function () {
|
73 |
$all_jobs = WC_Order_Export_Manage::get_export_settings_collection( WC_Order_Export_Manage::EXPORT_SCHEDULE );
|
74 |
+
if ( $all_jobs ) {
|
75 |
WC_Order_Export_Cron::install_job();
|
76 |
+
}
|
77 |
} );
|
78 |
}
|
79 |
|
80 |
}
|
81 |
|
82 |
public function add_order_status_column_header( $columns ) {
|
83 |
+
|
84 |
+
if ( ! $this->settings['show_export_status_column'] ) {
|
85 |
return $columns;
|
86 |
+
}
|
87 |
+
|
88 |
$new_columns = array();
|
89 |
foreach ( $columns as $column_name => $column_info ) {
|
90 |
+
if ( 'order_actions' === $column_name OR 'wc_actions' === $column_name ) { // Woocommerce uses wc_actions since 3.3.0
|
91 |
+
$label = __( 'Export Status', 'woo-order-export-lite' );
|
92 |
$new_columns['woe_export_status'] = $label;
|
93 |
}
|
94 |
$new_columns[ $column_name ] = $column_info;
|
95 |
}
|
96 |
+
|
97 |
return $new_columns;
|
98 |
}
|
99 |
|
107 |
$is_exported = true;
|
108 |
}
|
109 |
|
110 |
+
if ( $is_exported ) {
|
111 |
echo '<span class="dashicons dashicons-yes" style="color: #2ea2cc"></span>';
|
112 |
} else {
|
113 |
echo '<span class="dashicons dashicons-minus"></span>';
|
122 |
|
123 |
public function install() {
|
124 |
//wp_clear_scheduled_hook( "wc_export_cron_global" ); //debug
|
125 |
+
if ( self::is_full_version() ) {
|
126 |
WC_Order_Export_Cron::install_job();
|
127 |
+
}
|
128 |
}
|
129 |
|
130 |
public function display_plugin_activated_message() {
|
131 |
?>
|
132 |
+
<div class="notice notice-success is-dismissible">
|
133 |
+
<p><?php _e( 'Advanced Order Export For WooCommerce is available <a href="admin.php?page=wc-order-export">on this page</a>.',
|
134 |
+
'woo-order-export-lite' ); ?></p>
|
135 |
+
</div>
|
136 |
<?php
|
137 |
+
update_option( $this->activation_notice_option, true, false);
|
138 |
}
|
139 |
|
140 |
public function add_action_links( $links ) {
|
141 |
+
$mylinks = array(
|
142 |
+
'<a href="admin.php?page=wc-order-export">' . __( 'Settings', 'woo-order-export-lite' ) . '</a>',
|
143 |
+
'<a href="https://algolplus.com/plugins/documentation-order-export-woocommerce/" target="_blank">' . __( 'Docs',
|
144 |
+
'woo-order-export-lite' ) . '</a>',
|
145 |
+
'<a href="https://algolplus.freshdesk.com" target="_blank">' . __( 'Support',
|
146 |
+
'woo-order-export-lite' ) . '</a>',
|
147 |
);
|
148 |
+
|
149 |
+
return array_merge( $mylinks, $links );
|
150 |
}
|
151 |
|
152 |
public function deactivate() {
|
153 |
wp_clear_scheduled_hook( "wc_export_cron_global" );
|
154 |
delete_option( $this->activation_notice_option );
|
155 |
|
156 |
+
if ( self::is_full_version() ) {
|
157 |
//don't do it! updater call this function!
|
158 |
// WC_Order_Export_EDD::getInstance()->edd_woe_force_deactivate_license();
|
159 |
}
|
160 |
}
|
161 |
+
|
162 |
public static function uninstall() {
|
163 |
//delete_option( self::settings_name_common );
|
164 |
//WC_Order_Export_Manage::remove_settings();
|
167 |
static function load_main_settings() {
|
168 |
return array_merge(
|
169 |
array(
|
170 |
+
'default_tab' => 'export',
|
171 |
+
'cron_tasks_active' => '1',
|
172 |
+
'show_export_status_column' => '1',
|
173 |
+
'show_export_actions_in_bulk' => '1',
|
174 |
+
'show_export_in_status_change_job' => '0',
|
175 |
+
'autocomplete_products_max' => '10',
|
176 |
+
'ajax_orders_per_step' => '30',
|
177 |
+
'limit_button_test' => '1',
|
178 |
+
'cron_key' => '1234',
|
179 |
+
'ipn_url' => '',
|
180 |
+
'zapier_api_key' => '12345678',
|
181 |
+
'zapier_file_timeout' => 60,
|
182 |
),
|
183 |
get_option( self::settings_name_common, array() )
|
184 |
);
|
185 |
}
|
186 |
+
|
187 |
static function save_main_settings() {
|
188 |
// update main settings here!
|
189 |
+
$settings = filter_input_array( INPUT_POST, array(
|
190 |
+
'default_tab' => FILTER_SANITIZE_STRING,
|
191 |
+
'cron_tasks_active' => FILTER_VALIDATE_BOOLEAN,
|
192 |
+
'show_export_status_column' => FILTER_VALIDATE_BOOLEAN,
|
193 |
+
'show_export_actions_in_bulk' => FILTER_VALIDATE_BOOLEAN,
|
194 |
'show_export_in_status_change_job' => FILTER_VALIDATE_BOOLEAN,
|
195 |
+
'autocomplete_products_max' => FILTER_VALIDATE_INT,
|
196 |
+
'ajax_orders_per_step' => FILTER_VALIDATE_INT,
|
197 |
+
'limit_button_test' => FILTER_SANITIZE_STRING,
|
198 |
+
'cron_key' => FILTER_SANITIZE_STRING,
|
199 |
+
'ipn_url' => FILTER_SANITIZE_STRING,
|
200 |
+
'zapier_api_key' => FILTER_SANITIZE_STRING,
|
201 |
+
'zapier_file_timeout' => FILTER_SANITIZE_NUMBER_INT,
|
202 |
) );
|
203 |
+
update_option( self::settings_name_common, $settings, false );
|
204 |
|
205 |
if ( isset( $settings['ipn_url'] ) ) {
|
206 |
+
update_option( WOE_IPN_URL_OPTION_KEY, $settings['ipn_url'], false );
|
207 |
}
|
208 |
}
|
209 |
|
210 |
|
211 |
function load_textdomain() {
|
212 |
$locale = apply_filters( 'plugin_locale', get_locale(), 'woo-order-export-lite' );
|
213 |
+
load_textdomain( 'woo-order-export-lite',
|
214 |
+
WP_LANG_DIR . '/woocommerce-order-export/woocommerce-order-export-' . $locale . '.mo' );
|
215 |
|
216 |
load_plugin_textdomain( 'woo-order-export-lite', false,
|
217 |
plugin_basename( dirname( dirname( __FILE__ ) ) ) . '/i18n/languages' );
|
218 |
}
|
219 |
|
220 |
public function add_menu() {
|
221 |
+
if ( apply_filters( 'woe_current_user_can_export', true ) ) {
|
222 |
+
if ( current_user_can( 'manage_woocommerce' ) ) {
|
223 |
+
add_submenu_page( 'woocommerce', __( 'Export Orders', 'woo-order-export-lite' ),
|
224 |
+
__( 'Export Orders', 'woo-order-export-lite' ), 'view_woocommerce_reports', 'wc-order-export',
|
225 |
+
array( $this, 'render_menu' ) );
|
226 |
+
} else // add after Sales Report!
|
227 |
+
{
|
228 |
+
add_menu_page( __( 'Export Orders', 'woo-order-export-lite' ),
|
229 |
+
__( 'Export Orders', 'woo-order-export-lite' ), 'view_woocommerce_reports', 'wc-order-export',
|
230 |
+
array( $this, 'render_menu' ), null, '55.7' );
|
231 |
+
}
|
232 |
}
|
233 |
}
|
234 |
|
235 |
public function render_menu() {
|
236 |
$this->render( 'main', array( 'WC_Order_Export' => $this, 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
|
237 |
+
$active_tab = isset( $_REQUEST['tab'] ) ? $_REQUEST['tab'] : $this->settings['default_tab'];
|
238 |
if ( method_exists( $this, 'render_tab_' . $active_tab ) ) {
|
239 |
$this->{'render_tab_' . $active_tab}();
|
240 |
}
|
244 |
$this->render( 'tab/export', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'WC_Order_Export' => $this ) );
|
245 |
}
|
246 |
|
247 |
+
public function render_tab_tools() {
|
248 |
$this->render( 'tab/tools', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'WC_Order_Export' => $this ) );
< |