Advanced Order Export For WooCommerce - Version 3.1.2

Version Description

  • 2020-03-16 =
  • Added filter by order IDs (not order numbers!)
  • Added checkbox "Export only matched product items" to section "Filter by item and metadata"
  • Added checkbox "Shipping fields use billing details (if shipping address is empty)" to section "Misc Settings"
  • Added fields "Item Cost Before Discount", "Item Discount Tax" to section "Product order items"
  • Renamed field "Product Variation" to "Order Item Metadata"
  • Added some tooltips to sections inside "Set up fields"
  • Support tag {order_number} in filename
  • Fixed UI bugs for Firefox
  • Fixed bug - Preview was wrong if CSV format used non-UTF8 codepage
  • Fixed bug - some warnings in JS console
  • Fixed bug - Safari added .csv to any filename when we use TSV format
  • Fixed bug - wrong filters applied when user selected orders and exported them via bulk action
  • New hooks for product custom fields
Download this release

Release Info

Developer algol.plus
Plugin Icon 128x128 Advanced Order Export For WooCommerce
Version 3.1.2
Comparing to
See all releases

Code changes from version 3.1.1 to 3.1.2

Files changed (29) hide show
  1. assets/css/export.css +136 -15
  2. assets/css/orders_style.css +19 -0
  3. assets/js/buttons.js +7 -4
  4. assets/js/export-fields.js +18 -15
  5. assets/js/settings-form.js +20 -1
  6. classes/FPDF/class-woe-pdf-mc-table.php +51 -7
  7. classes/admin/class-wc-order-export-manage.php +29 -21
  8. classes/admin/class-wc-order-export-settings.php +2 -0
  9. classes/admin/tabs/ajax/class-wc-order-export-ajax.php +27 -3
  10. classes/admin/tabs/ajax/trait-wc-order-export-admin-tab-abstract-ajax-export.php +10 -6
  11. classes/admin/tabs/ajax/trait-wc-order-export-ajax-helpers.php +12 -5
  12. classes/admin/tabs/class-wc-order-export-admin-tab-abstract.php +9 -0
  13. classes/admin/tabs/class-wc-order-export-admin-tab-profiles.php +2 -1
  14. classes/admin/tabs/class-wc-order-export-admin-tab-schedule-jobs.php +2 -1
  15. classes/admin/tabs/class-wc-order-export-admin-tab-status-change-jobs.php +1 -1
  16. classes/class-wc-order-export-admin.php +16 -3
  17. classes/core/class-wc-order-export-data-extractor-ui.php +45 -23
  18. classes/core/class-wc-order-export-data-extractor.php +76 -11
  19. classes/core/class-wc-order-export-engine.php +38 -21
  20. classes/core/class-wc-order-export-order-fields.php +54 -17
  21. classes/core/class-wc-order-export-order-product-fields.php +28 -6
  22. classes/formats/abstract-class-woe-formatter-plain-format.php +3 -1
  23. classes/formats/abstract-class-woe-formatter-sv.php +2 -2
  24. classes/formats/class-woe-formatter-html.php +0 -20
  25. classes/formats/class-woe-formatter-pdf.php +3 -4
  26. i18n/languages/woo-order-export-lite.pot +501 -459
  27. readme.txt +20 -5
  28. view/settings-form.php +444 -381
  29. woo-order-export-lite.php +3 -3
assets/css/export.css CHANGED
@@ -84,12 +84,8 @@ input.date {
84
list-style-type: none;
85
}
86
87
- .btn-edit {
88
- padding: 2px 3px !important;
89
- }
90
-
91
- .btn-trash {
92
- padding: 2px 3px !important;
93
}
94
95
.padding-10 {
@@ -148,7 +144,6 @@ input.date {
148
float: left;
149
width: 100%;
150
}
151
-
152
.all-input-100pr input[type="text"] {
153
width: 100%;
154
}
@@ -284,10 +279,12 @@ input.date {
284
width: 48%;
285
vertical-align: top;
286
}
287
-
288
#custom_date_format_block input, #custom_time_format_block input {
289
- width: 70%;
290
- margin-left: 41px;
291
}
292
293
#date_format_block select, #time_format_block select {
@@ -337,6 +334,7 @@ input.date {
337
338
#woe-admin .tools-textarea {
339
width: 66.66667%;
340
}
341
342
#woe-admin .woe-input-simple input, #woe-admin .woe-select input, #woe-admin .woe-input-simple textarea, #woe-admin .woe-select textarea, .woe-calendar-wrapper .woe-input-simple input, .woe-calendar-wrapper .woe-select input, .woe-calendar-wrapper .woe-input-simple textarea, .woe-calendar-wrapper .woe-select textarea, #woe-admin .woe-checkbox label, #woe-admin .woe-radiobox label, #woe-admin .woe-switch label, #woe-admin .woe-select.woe-select-info-label .woe-label-big label, .woe-calendar-wrapper .woe-select.woe-select-info-label #woe-admin .woe-label-big label, .woe-calendar-wrapper .woe-checkbox label, .woe-calendar-wrapper .woe-radiobox label, .woe-calendar-wrapper .woe-switch label, .woe-calendar-wrapper .woe-select.woe-select-info-label .woe-label-big label, #woe-admin .woe-checkbutton input + label, .woe-calendar-wrapper .woe-checkbutton input + label, #woe-admin .col-time, .woe-calendar-wrapper .col-time, #woe-admin .woe-box-title, .woe-calendar-wrapper .woe-box-title, .select2-container.select2-container-woe .select2-selection-single, .select2-container.select2-container-woe .select2-selection-multiple {
@@ -421,7 +419,7 @@ input.date {
421
font-weight: normal;
422
}
423
424
- #my-sort {
425
font-weight: bold;
426
}
427
@@ -485,7 +483,17 @@ input.date {
485
font-weight: bold;
486
color: #000;
487
}
488
-
489
.settings-segment:not(.active) {
490
display: none;
491
}
@@ -632,7 +640,13 @@ input.date {
632
margin-bottom: 5px;
633
display: inline-block;
634
}
635
-
636
.fields-control-block .segment-header select {
637
width: auto;
638
}
@@ -653,7 +667,7 @@ input.date {
653
654
#manage_fields.summary-products-report #unselected_fields .subsubsub .block-segment-choice[data-segment="products"] {
655
display: inline;
656
- }
657
658
#manage_fields.summary-products-report #unselected_fields .tab-actions-buttons {
659
margin-top: 0;
@@ -724,6 +738,7 @@ input.date {
724
{
725
display: inline-block;
726
max-width: 45px;
727
}
728
729
.datetime-picker-control .delimiter {
@@ -771,4 +786,110 @@ input.date {
771
#manage_fields.summary-customers-report #unselected_fields .subsubsub .block-segment-choice[data-segment="billing"],
772
#manage_fields.summary-customers-report #unselected_fields .subsubsub .block-segment-choice[data-segment="shipping"] {
773
display: inline;
774
- }
84
list-style-type: none;
85
}
86
87
+ .btn-edit, .btn-trash {
88
+ padding: 0 3px !important;
89
}
90
91
.padding-10 {
144
float: left;
145
width: 100%;
146
}
147
.all-input-100pr input[type="text"] {
148
width: 100%;
149
}
279
width: 48%;
280
vertical-align: top;
281
}
282
+ #custom_date_format_block {
283
+ margin-top: .3rem;
284
+ }
285
#custom_date_format_block input, #custom_time_format_block input {
286
+ width: 70.5%;
287
+ margin-left: 38px;
288
}
289
290
#date_format_block select, #time_format_block select {
334
335
#woe-admin .tools-textarea {
336
width: 66.66667%;
337
+ margin-top: 1rem;
338
}
339
340
#woe-admin .woe-input-simple input, #woe-admin .woe-select input, #woe-admin .woe-input-simple textarea, #woe-admin .woe-select textarea, .woe-calendar-wrapper .woe-input-simple input, .woe-calendar-wrapper .woe-select input, .woe-calendar-wrapper .woe-input-simple textarea, .woe-calendar-wrapper .woe-select textarea, #woe-admin .woe-checkbox label, #woe-admin .woe-radiobox label, #woe-admin .woe-switch label, #woe-admin .woe-select.woe-select-info-label .woe-label-big label, .woe-calendar-wrapper .woe-select.woe-select-info-label #woe-admin .woe-label-big label, .woe-calendar-wrapper .woe-checkbox label, .woe-calendar-wrapper .woe-radiobox label, .woe-calendar-wrapper .woe-switch label, .woe-calendar-wrapper .woe-select.woe-select-info-label .woe-label-big label, #woe-admin .woe-checkbutton input + label, .woe-calendar-wrapper .woe-checkbutton input + label, #woe-admin .col-time, .woe-calendar-wrapper .col-time, #woe-admin .woe-box-title, .woe-calendar-wrapper .woe-box-title, .select2-container.select2-container-woe .select2-selection-single, .select2-container.select2-container-woe .select2-selection-multiple {
419
font-weight: normal;
420
}
421
422
+ #my-sort,#my-change-status {
423
font-weight: bold;
424
}
425
483
font-weight: bold;
484
color: #000;
485
}
486
+ #woe_hints_block {
487
+ margin-top: 10px;
488
+ }
489
+ .woe_segment_tips {
490
+ display: none;
491
+ }
492
+ .woe_segment_tips.active {
493
+ color: #5b841b;
494
+ font-size: .85rem;
495
+ display: block;
496
+ }
497
.settings-segment:not(.active) {
498
display: none;
499
}
640
margin-bottom: 5px;
641
display: inline-block;
642
}
643
+ .fields-control-block .segment-header_flex-styles {
644
+ display: inline-flex;
645
+ justify-content: space-around;
646
+ align-items: center;
647
+ max-width: 185px;
648
+ width: 100%;
649
+ }
650
.fields-control-block .segment-header select {
651
width: auto;
652
}
667
668
#manage_fields.summary-products-report #unselected_fields .subsubsub .block-segment-choice[data-segment="products"] {
669
display: inline;
670
+ }
671
672
#manage_fields.summary-products-report #unselected_fields .tab-actions-buttons {
673
margin-top: 0;
738
{
739
display: inline-block;
740
max-width: 45px;
741
+ padding: 0 .4rem;
742
}
743
744
.datetime-picker-control .delimiter {
786
#manage_fields.summary-customers-report #unselected_fields .subsubsub .block-segment-choice[data-segment="billing"],
787
#manage_fields.summary-customers-report #unselected_fields .subsubsub .block-segment-choice[data-segment="shipping"] {
788
display: inline;
789
+ }
790
+ .mb-0 {
791
+ margin-bottom: 0;
792
+ }
793
+ .mb-2 {
794
+ margin-bottom: 2rem;
795
+ }
796
+ .mt-sm {
797
+ margin-top: .5rem;
798
+ }
799
+ .line-height__3 {
800
+ line-height: 3;
801
+ }
802
+ .line-height__2 {
803
+ line-height: 2;
804
+ }
805
+ .output_destination__position {
806
+ margin: 0 .2rem .3rem 0 !important;
807
+ }
808
+ .custom-fields__condotion-wrapper {
809
+ display: flex;
810
+ flex-wrap: wrap;
811
+ justify-content: space-between;
812
+ width: 85%;
813
+ }
814
+ .custom-fields__condotion-wrapper_position {
815
+ margin-bottom: .5rem;
816
+ }
817
+ .custom-fields__condotion-wrapper > * {
818
+ height: 30px !important;
819
+ max-width: 170px !important;
820
+ margin: 0 !important;
821
+ }
822
+ input[type=number] {
823
+ min-height: 35px;
824
+ }
825
+ #d-schedule-1 {
826
+ margin: 15px 0;
827
+ }
828
+ .weekday {
829
+ margin-top: -5px;
830
+ }
831
+
832
+ .custom-fields__condotion-wrapper > .select2.select2-container {
833
+ height: 30px !important;
834
+ }
835
+ .select2-container .select2-selection--single {
836
+ height: 100%!important;
837
+ }
838
+ .select2-container .select2-selection--single .select2-selection__rendered {
839
+ height: 100%;
840
+ line-height: initial !important;
841
+ }
842
+ .select2-container,
843
+ .select2-container .select2-selection--single .select2-selection__arrow {
844
+ height: 100%!important;
845
+ }
846
+ .custom-fields__condotion-wrapper .selection .select2-selection__rendered,
847
+ .custom-fields__condotion-wrapper .selection .select2-selection__arrow {
848
+ display: flex !important ;
849
+ align-items: center;
850
+ }
851
+ .select2-container .select2-search__field {
852
+ min-width: initial !important;
853
+ }
854
+ @media( max-width: 1024px ) {
855
+ .custom-fields__condotion-wrapper {
856
+ justify-content: start;
857
+ }
858
+ .custom-fields__condotion-wrapper > * {
859
+ margin: 0 .3rem 0 0 !important;
860
+ }
861
+ }
862
+ .tab-actions-forms .segment-form .set-up__selects {
863
+ width: 54%;
864
+ max-width: 100%;
865
+ }
866
+ .tab-actions-forms .segment-form .set-up__selects_sm {
867
+ width: 221px;
868
+ max-width: 100%;
869
+ }
870
+ .div_custom.segment-form.all-segments > div,
871
+ .div_custom.products-segment > div,
872
+ .div_custom.product_items-segment > div,
873
+ .div_custom.coupons-segment > div {
874
+ margin-top: .2rem;
875
+ }
876
+ #my-export-date-field input[type="radio"] {
877
+ margin-right: 0;
878
+ }
879
+ #my-export-date-field label {
880
+ padding-right: .5rem;
881
+ }
882
+ .wp-core-ui .button, .wp-core-ui .button-secondary {
883
+ margin-right: .2rem;
884
+ margin-bottom: .2rem;
885
+ }
886
+ @media( max-width: 1440px ) {
887
+ .widefat .column-from_date,
888
+ .widefat .column-to_date {
889
+ width: 4.5rem;
890
+ }
891
+ .widefat .column-actions .button-secondary {
892
+ padding: 0 3px !important;
893
+ }
894
+ }
895
+
assets/css/orders_style.css ADDED
@@ -0,0 +1,19 @@
1
+ @media (min-width: 576px) and (max-width: 782px) {
2
+ th#woe_export_status {
3
+ display: table-cell !important;
4
+ }
5
+ th.manage-column.column-woe_export_status {
6
+ display: table-cell !important;
7
+ }
8
+ td.woe_export_status.column-woe_export_status {
9
+ display: table-cell !important;
10
+ padding: 1em;
11
+ line-height: 26px;
12
+ }
13
+ .wp-list-table tr:not(.inline-edit-row):not(.no-items) td:not(.column-primary)::before {
14
+ content: none;
15
+ }
16
+ .post-type-shop_order .wp-list-table tbody td {
17
+ padding: 1em !important;
18
+ }
19
+ }
assets/js/buttons.js CHANGED
@@ -72,11 +72,14 @@ function woe_get_data() {
72
}
73
74
function woe_validate_export() {
75
-
76
if ( (
77
- mode == settings_form.EXPORT_PROFILE
78
) && (
79
- ! jQuery( "[name='settings[title]']" ).val()
80
) ) {
81
alert( export_messages.empty_title );
82
jQuery( "[name='settings[title]']" ).focus();
@@ -232,7 +235,7 @@ function woe_get_all( start, percent, method ) {
232
233
if ( woe_is_ipad_or_iphone() || ( output_format == 'HTML' && settings_form.settings.display_html_report_in_browser ) ) {
234
235
- $( '#progress_div .title-download a' ).attr( 'href', ajaxurl + (
236
ajaxurl.indexOf( '?' ) === - 1 ? '?' : '&'
237
) + 'action=order_exporter&method=export_download&format=' + download_format + '&file_id=' + window.file_id + '&tab=' + settings_form.woe_active_tab );
238
jQuery( '#progress_div .title-download' ).show();
72
}
73
74
function woe_validate_export() {
75
if ( (
76
+ mode == settings_form.EXPORT_PROFILE
77
+ ||
78
+ mode == settings_form.EXPORT_ORDER_ACTION
79
+ ||
80
+ mode == settings_form.EXPORT_SCHEDULE
81
) && (
82
+ ! jQuery( "[name='settings[title]']" ).val().trim()
83
) ) {
84
alert( export_messages.empty_title );
85
jQuery( "[name='settings[title]']" ).focus();
235
236
if ( woe_is_ipad_or_iphone() || ( output_format == 'HTML' && settings_form.settings.display_html_report_in_browser ) ) {
237
238
+ jQuery( '#progress_div .title-download a' ).attr( 'href', ajaxurl + (
239
ajaxurl.indexOf( '?' ) === - 1 ? '?' : '&'
240
) + 'action=order_exporter&method=export_download&format=' + download_format + '&file_id=' + window.file_id + '&tab=' + settings_form.woe_active_tab );
241
jQuery( '#progress_div .title-download' ).show();
assets/js/export-fields.js CHANGED
@@ -350,22 +350,22 @@ function woe_create_unselected_fields( old_output_format, format, format_changed
350
}
351
352
jQuery.each( window['all_fields'], function ( segment, fields ) {
353
354
- fields.forEach( function ( value ) {
355
356
- var $unselected_field_segment = jQuery( '#' + woe_sprintf( $unselected_segment_id, segment ) );
357
- var index = value.key;
358
359
- $unselected_field_segment.append(
360
- woe_make_unselected_field( index, value, format, format_changed, segment )
361
- );
362
-
363
- woe_activate_draggable_field(
364
- $unselected_field_segment.find( '.segment_field' ),
365
- segment,
366
- format
367
- );
368
- } )
369
370
} );
371
}
@@ -664,7 +664,7 @@ function woe_make_repeat_options( index ) {
664
repeat_options_html['inside_one_cell'].push( line_delimiter_html );
665
666
var popup_options = jQuery( '<div class=""></div>' );
667
- popup_options.append( jQuery( '<div class="segment-header">' + '<label>' + localize_settings_form.js_tpl_popup.add + ' ' + index + ' ' + localize_settings_form.js_tpl_popup.as + '</label>' + '</div>' ).append( repeat_select ) );
668
669
jQuery.each( repeat_options_html, function ( key, currentValue ) {
670
popup_options.append( jQuery( '<div class="display_as duplicate_' + key + '_options"></div>' ).append( currentValue ) );
@@ -1023,7 +1023,7 @@ jQuery( document ).ready( function ( $ ) {
1023
$( '.segment_choice' ).click( function () {
1024
1025
var segment = $( this ).data( 'segment' );
1026
-
1027
$('.tab-actions-buttons').hide();
1028
1029
if ($('.tab-actions-buttons.' + segment + '-actions-buttons').length) {
@@ -1038,6 +1038,9 @@ jQuery( document ).ready( function ( $ ) {
1038
$( '.settings-segment' ).removeClass( 'active' );
1039
$( '#' + $( this ).data( 'segment' ) + '_unselected_segment' ).addClass( 'active' );
1040
1041
window.location.href = $( this ).attr( 'href' );
1042
1043
woe_reset_field_contorls();
350
}
351
352
jQuery.each( window['all_fields'], function ( segment, fields ) {
353
+
354
+ fields.forEach( function ( value ) {
355
356
+ var $unselected_field_segment = jQuery( '#' + woe_sprintf( $unselected_segment_id, segment ) );
357
+ var index = value.key;
358
359
+ $unselected_field_segment.append(
360
+ woe_make_unselected_field( index, value, format, format_changed, segment )
361
+ );
362
363
+ woe_activate_draggable_field(
364
+ $unselected_field_segment.find( '.segment_field' ),
365
+ segment,
366
+ format
367
+ );
368
+ } )
369
370
} );
371
}
664
repeat_options_html['inside_one_cell'].push( line_delimiter_html );
665
666
var popup_options = jQuery( '<div class=""></div>' );
667
+ popup_options.append( jQuery( '<div class="segment-header segment-header_flex-styles">' + '<label>' + localize_settings_form.js_tpl_popup.add + ' ' + index + ' ' + localize_settings_form.js_tpl_popup.as + '</label>' + '</div>' ).append( repeat_select ) );
668
669
jQuery.each( repeat_options_html, function ( key, currentValue ) {
670
popup_options.append( jQuery( '<div class="display_as duplicate_' + key + '_options"></div>' ).append( currentValue ) );
1023
$( '.segment_choice' ).click( function () {
1024
1025
var segment = $( this ).data( 'segment' );
1026
+
1027
$('.tab-actions-buttons').hide();
1028
1029
if ($('.tab-actions-buttons.' + segment + '-actions-buttons').length) {
1038
$( '.settings-segment' ).removeClass( 'active' );
1039
$( '#' + $( this ).data( 'segment' ) + '_unselected_segment' ).addClass( 'active' );
1040
1041
+ $( '.woe_segment_tips' ).removeClass( 'active' );
1042
+ $( '#woe_tips_' + $( this ).data( 'segment' ) ).addClass( 'active' );
1043
+
1044
window.location.href = $( this ).attr( 'href' );
1045
1046
woe_reset_field_contorls();
assets/js/settings-form.js CHANGED
@@ -143,7 +143,6 @@ var woe_form_submitting = false;
143
function woe_set_form_submitting() {
144
woe_form_submitting = true;
145
}
146
-
147
window.onload = function () {
148
149
var form = jQuery( '#export_job_settings' );
@@ -158,7 +157,12 @@ window.onload = function () {
158
};
159
160
window.addEventListener( "beforeunload", function ( e ) {
161
162
if ( woe_is_dirty( on_load_form_data ) && ! woe_form_submitting ) {
163
(
164
e || window.event
@@ -172,6 +176,13 @@ window.onload = function () {
172
173
jQuery( document ).ready( function ( $ ) {
174
175
$( '.my-hide-next' ).click( function () {
176
177
$( this ).next().toggle();
@@ -207,6 +218,14 @@ jQuery( document ).ready( function ( $ ) {
207
$( 'div#custom_php_code_textarea' ).toggle( $( this ).is( ':checked' ) );
208
} );
209
210
if (typeof settings_form.settings.show_date_time_picker_for_date_range !== 'undefined' && settings_form.settings.show_date_time_picker_for_date_range) {
211
if ( typeof woe_init_datetime_picker !== 'undefined' ) {
212
woe_init_datetime_picker($("#from_date"), {'hours': "00", 'minutes': "00", 'seconds': "00"});
143
function woe_set_form_submitting() {
144
woe_form_submitting = true;
145
}
146
window.onload = function () {
147
148
var form = jQuery( '#export_job_settings' );
157
};
158
159
window.addEventListener( "beforeunload", function ( e ) {
160
+ var clicked_el = e.target.activeElement;
161
162
+ if ( clicked_el.id === 'copy-to-profiles' ) {
163
+ woe_set_form_submitting();
164
+ }
165
+
166
if ( woe_is_dirty( on_load_form_data ) && ! woe_form_submitting ) {
167
(
168
e || window.event
176
177
jQuery( document ).ready( function ( $ ) {
178
179
+ function woe_disable_input_by_id( current_elem, element_id ) {
180
+ var $disabled = $( '#' + element_id );
181
+ ( current_elem.checked === true )
182
+ ? $disabled.attr( 'disabled', true )
183
+ : $disabled.removeAttr( 'disabled' );
184
+ }
185
+
186
$( '.my-hide-next' ).click( function () {
187
188
$( this ).next().toggle();
218
$( 'div#custom_php_code_textarea' ).toggle( $( this ).is( ':checked' ) );
219
} );
220
221
+ $( '#woe_format_disabler' ).on( 'change', function() {
222
+ woe_disable_input_by_id( this, 'woe_format_disabled' );
223
+ } ).trigger( 'change' );
224
+
225
+ $( '#woe_format_tsv_disabler').on( 'change', function() {
226
+ woe_disable_input_by_id( this, 'woe_format_tsv_disabled' );
227
+ } ).trigger( 'change' );
228
+
229
if (typeof settings_form.settings.show_date_time_picker_for_date_range !== 'undefined' && settings_form.settings.show_date_time_picker_for_date_range) {
230
if ( typeof woe_init_datetime_picker !== 'undefined' ) {
231
woe_init_datetime_picker($("#from_date"), {'hours': "00", 'minutes': "00", 'seconds': "00"});
classes/FPDF/class-woe-pdf-mc-table.php CHANGED
@@ -50,6 +50,7 @@ class WOE_PDF_MC_Table extends WOE_FPDF {
50
'size' => 5,
51
'text_color' => array( 0, 0, 0 ),
52
'background_color' => array( 255, 255, 255 ),
53
),
54
'footer' => array(
55
'title' => '',
@@ -180,8 +181,21 @@ class WOE_PDF_MC_Table extends WOE_FPDF {
180
if ( ! $data ) {
181
return;
182
}
183
$widths = ! $widths ? $this->getRowWidths( $data ) : $widths;
184
$h = ! $h ? $this->getRowHeight( $widths, $data ) : $h;
185
//Issue a page break first if needed
186
$this->CheckPageBreak( $h );
187
@@ -195,11 +209,7 @@ class WOE_PDF_MC_Table extends WOE_FPDF {
195
);
196
}
197
$data = array_slice( $data, 0, $columns_count );
198
- if( $style ) {
199
- $this->SetFillColor($style['background_color'][0], $style['background_color'][1], $style['background_color'][2]);
200
- $this->SetTextColor($style['text_color'][0], $style['text_color'][1], $style['text_color'][2]);
201
- $this->SetFontSize($style['size']);
202
- }
203
//Draw the cells of the row
204
for ( $i = 0; $i < count( $data ); $i ++ ) {
205
$w = $widths[ $i ];
@@ -211,10 +221,20 @@ class WOE_PDF_MC_Table extends WOE_FPDF {
211
//Draw the border
212
$this->Rect( $x, $y, $w, $h, $this->table_props['border_style'] );
213
214
- if ( isset( $data[ $i ]['type'], $data[ $i ]['value'] ) && 'image' === $data[ $i ]['type'] && file_exists( $data[ $i ]['value'] ) ) {
215
$source = $data[ $i ]['value'];
216
$type = strtoupper( pathinfo( $source, PATHINFO_EXTENSION ) );
217
- $this->Image( $source, $x + 1 / 2, $y + 1 / 2, $w - 1, $h - 1, $type );
218
} elseif ( ! is_array( $data[ $i ] ) ) {
219
//Print the text
220
$this->MultiCell( $w, $h, $data[ $i ], 0, $horizontal_align, $vertical_align );
@@ -227,6 +247,30 @@ class WOE_PDF_MC_Table extends WOE_FPDF {
227
$this->Ln( $h );
228
}
229
230
protected function getColumnCountInPage( $widths ) {
231
$count = count( $widths );
232
if ( $this->table_props['stretch'] ) {
50
'size' => 5,
51
'text_color' => array( 0, 0, 0 ),
52
'background_color' => array( 255, 255, 255 ),
53
+ 'image_height' => null,
54
),
55
'footer' => array(
56
'title' => '',
181
if ( ! $data ) {
182
return;
183
}
184
+
185
+ if ( $style ) {
186
+ $this->SetFillColor( $style['background_color'][0], $style['background_color'][1], $style['background_color'][2] );
187
+ $this->SetTextColor( $style['text_color'][0], $style['text_color'][1], $style['text_color'][2] );
188
+ $this->SetFontSize( $style['size'] );
189
+ }
190
+
191
$widths = ! $widths ? $this->getRowWidths( $data ) : $widths;
192
$h = ! $h ? $this->getRowHeight( $widths, $data ) : $h;
193
+
194
+ $image_height = floatval( $this->table_row_props['image_height'] );
195
+ if ( $image_height && $this->isRowWithImage( $data ) && $h < $image_height ) {
196
+ $h = $image_height;
197
+ }
198
+
199
//Issue a page break first if needed
200
$this->CheckPageBreak( $h );
201
209
);
210
}
211
$data = array_slice( $data, 0, $columns_count );
212
+
213
//Draw the cells of the row
214
for ( $i = 0; $i < count( $data ); $i ++ ) {
215
$w = $widths[ $i ];
221
//Draw the border
222
$this->Rect( $x, $y, $w, $h, $this->table_props['border_style'] );
223
224
+ if ( $this->isImageCell($data[ $i ]) ) {
225
+ $margin = 1 / 2;
226
+
227
+ /** move image to center if cell height larger than image height */
228
+ $y_offset = floatval( 0 );
229
+ if ( $image_height && $image_height < $h ) {
230
+ $y_offset += ( $h - $image_height ) / 2;
231
+ } else {
232
+ $image_height = $h;
233
+ }
234
+
235
$source = $data[ $i ]['value'];
236
$type = strtoupper( pathinfo( $source, PATHINFO_EXTENSION ) );
237
+ $this->Image( $source, $x + $margin, $y + $margin + $y_offset, $w - 2 * $margin, $image_height - 2 * $margin, $type );
238
} elseif ( ! is_array( $data[ $i ] ) ) {
239
//Print the text
240
$this->MultiCell( $w, $h, $data[ $i ], 0, $horizontal_align, $vertical_align );
247
$this->Ln( $h );
248
}
249
250
+ /**
251
+ * @param array $data
252
+ *
253
+ * @return bool
254
+ */
255
+ protected function isRowWithImage( $data ) {
256
+ foreach ( $data as $value ) {
257
+ if ( $this->isImageCell( $value ) ) {
258
+ return true;
259
+ }
260
+ }
261
+
262
+ return false;
263
+ }
264
+
265
+ /**
266
+ * @param mixed $value
267
+ *
268
+ * @return bool
269
+ */
270
+ protected function isImageCell( $value ) {
271
+ return isset( $value['type'], $value['value'] ) && 'image' === $value['type'] && file_exists( $value['value'] );
272
+ }
273
+
274
protected function getColumnCountInPage( $widths ) {
275
$count = count( $widths );
276
if ( $this->table_props['stretch'] ) {
classes/admin/class-wc-order-export-manage.php CHANGED
@@ -46,7 +46,7 @@ class WC_Order_Export_Manage {
46
// arrays
47
static function get_export_settings_collection( $mode ) {
48
$name = self::get_settings_name_for_mode( $mode );
49
-
50
return get_option( $name, array() );
51
}
52
@@ -165,7 +165,7 @@ class WC_Order_Export_Manage {
165
if ( ! isset( $settings['version'] ) ) {
166
$settings = self::convert_settings_to_version_2( $mode, $settings );
167
}
168
-
169
return self::apply_defaults( $mode, $settings );
170
}
171
@@ -176,6 +176,8 @@ class WC_Order_Export_Manage {
176
'statuses' => array(),
177
'from_date' => '',
178
'to_date' => '',
179
'shipping_locations' => array(),
180
'shipping_methods' => array(),
181
'item_names' => array(),
@@ -213,6 +215,8 @@ class WC_Order_Export_Manage {
213
'statuses' => ($mode == "now" OR $mode == "profiles") ? array("wc-pending","wc-processing","wc-on-hold","wc-completed") : array(),
214
'from_date' => '',
215
'to_date' => '',
216
'shipping_locations' => array(),
217
'shipping_methods' => array(),
218
'item_names' => array(),
@@ -228,6 +232,7 @@ class WC_Order_Export_Manage {
228
'product_categories' => array(),
229
'product_vendors' => array(),
230
'products' => array(),
231
'exclude_products' => array(),
232
'product_taxonomies' => array(),
233
'product_custom_fields' => array(),
@@ -314,24 +319,26 @@ class WC_Order_Export_Manage {
314
'format_html_row_images_height' => 100,
315
'format_html_custom_css' => $settings['default_html_css'],
316
317
- 'all_products_from_order' => 1,
318
- 'skip_refunded_items' => 1,
319
- 'skip_suborders' => 0,
320
- 'export_refunds' => 0,
321
- 'date_format' => 'Y-m-d',
322
- 'time_format' => 'H:i',
323
- 'sort_direction' => 'DESC',
324
- 'sort' => 'order_id',
325
- 'format_number_fields' => 0,
326
- 'export_all_comments' => 0,
327
- 'export_refund_notes' => 0,
328
- 'strip_tags_product_fields' => 0,
329
- 'cleanup_phone' => 0,
330
- 'enable_debug' => 0,
331
- 'custom_php' => 0,
332
- 'custom_php_code' => '',
333
- 'mark_exported_orders' => 0,
334
- 'export_unmarked_orders' => 0,
335
336
'summary_report_by_products' => 0,
337
'duplicated_fields_settings' => array(
@@ -367,6 +374,7 @@ class WC_Order_Export_Manage {
367
if ( ! isset( $settings['export_rule_field'] ) AND $mode == WC_Order_Export_Manage::EXPORT_SCHEDULE ) {
368
$settings['export_rule_field'] = 'modified';
369
}
370
371
foreach ( array( 'order_fields', 'order_product_fields', 'order_coupon_fields' ) as $index ) {
372
if ( ! isset( $settings[ $index ] ) ) {
@@ -378,7 +386,6 @@ class WC_Order_Export_Manage {
378
'order_product_fields' => 'products',
379
'order_coupon_fields' => 'coupons',
380
);
381
-
382
$settings['order_fields'] = array_merge(
383
$settings['order_fields'],
384
array_map( function ( $value ) use ( $map_segment, $index ) {
@@ -394,6 +401,7 @@ class WC_Order_Export_Manage {
394
395
// add parent fields if not exists
396
foreach ( array( 'products', 'coupons' ) as $main_field ) {
397
if ( in_array( $main_field, wp_list_pluck( $settings['order_fields'], 'key' ) ) ) {
398
continue;
399
}
46
// arrays
47
static function get_export_settings_collection( $mode ) {
48
$name = self::get_settings_name_for_mode( $mode );
49
+
50
return get_option( $name, array() );
51
}
52
165
if ( ! isset( $settings['version'] ) ) {
166
$settings = self::convert_settings_to_version_2( $mode, $settings );
167
}
168
+
169
return self::apply_defaults( $mode, $settings );
170
}
171
176
'statuses' => array(),
177
'from_date' => '',
178
'to_date' => '',
179
+ 'from_order_id' => '',
180
+ 'to_order_id' => '',
181
'shipping_locations' => array(),
182
'shipping_methods' => array(),
183
'item_names' => array(),
215
'statuses' => ($mode == "now" OR $mode == "profiles") ? array("wc-pending","wc-processing","wc-on-hold","wc-completed") : array(),
216
'from_date' => '',
217
'to_date' => '',
218
+ 'from_order_id' => '',
219
+ 'to_order_id' => '',
220
'shipping_locations' => array(),
221
'shipping_methods' => array(),
222
'item_names' => array(),
232
'product_categories' => array(),
233
'product_vendors' => array(),
234
'products' => array(),
235
+ 'product_sku' => '',
236
'exclude_products' => array(),
237
'product_taxonomies' => array(),
238
'product_custom_fields' => array(),
319
'format_html_row_images_height' => 100,
320
'format_html_custom_css' => $settings['default_html_css'],
321
322
+ 'all_products_from_order' => 1,
323
+ 'skip_refunded_items' => 1,
324
+ 'skip_suborders' => 0,
325
+ 'export_refunds' => 0,
326
+ 'export_matched_items' => 0,
327
+ 'date_format' => 'Y-m-d',
328
+ 'time_format' => 'H:i',
329
+ 'sort_direction' => 'DESC',
330
+ 'sort' => 'order_id',
331
+ 'format_number_fields' => 0,
332
+ 'export_all_comments' => 0,
333
+ 'export_refund_notes' => 0,
334
+ 'strip_tags_product_fields' => 0,
335
+ 'cleanup_phone' => 0,
336
+ 'enable_debug' => 0,
337
+ 'billing_details_for_shipping' => 0,
338
+ 'custom_php' => 0,
339
+ 'custom_php_code' => '',
340
+ 'mark_exported_orders' => 0,
341
+ 'export_unmarked_orders' => 0,
342
343
'summary_report_by_products' => 0,
344
'duplicated_fields_settings' => array(
374
if ( ! isset( $settings['export_rule_field'] ) AND $mode == WC_Order_Export_Manage::EXPORT_SCHEDULE ) {
375
$settings['export_rule_field'] = 'modified';
376
}
377
+
378
379
foreach ( array( 'order_fields', 'order_product_fields', 'order_coupon_fields' ) as $index ) {
380
if ( ! isset( $settings[ $index ] ) ) {
386
'order_product_fields' => 'products',
387
'order_coupon_fields' => 'coupons',
388
);
389
$settings['order_fields'] = array_merge(
390
$settings['order_fields'],
391
array_map( function ( $value ) use ( $map_segment, $index ) {
401
402
// add parent fields if not exists
403
foreach ( array( 'products', 'coupons' ) as $main_field ) {
404
+
405
if ( in_array( $main_field, wp_list_pluck( $settings['order_fields'], 'key' ) ) ) {
406
continue;
407
}
classes/admin/class-wc-order-export-settings.php CHANGED
@@ -26,6 +26,8 @@ class WC_Order_Export_Main_Settings {
26
'zapier_api_key' => '12345678',
27
'zapier_file_timeout' => 60,
28
'show_date_time_picker_for_date_range' => false,
29
'display_html_report_in_browser' => false,
30
'default_date_range_for_export_now' => '',
31
'default_html_css' => '',
26
'zapier_api_key' => '12345678',
27
'zapier_file_timeout' => 60,
28
'show_date_time_picker_for_date_range' => false,
29
+ 'display_profiles_export_date_range' => false,
30
+ 'show_destination_in_profile' => false,
31
'display_html_report_in_browser' => false,
32
'default_date_range_for_export_now' => '',
33
'default_html_css' => '',
classes/admin/tabs/ajax/class-wc-order-export-ajax.php CHANGED
@@ -29,10 +29,33 @@ class WC_Order_Export_Ajax {
29
30
31
public function ajax_export_download_bulk_file() {
32
33
- $settings = array_merge($this->get_settings_from_bulk_request(), WC_Order_Export_Manage::get_defaults_filters());
34
-
35
- $this->build_and_send_file( $settings );
36
}
37
38
protected function get_settings_from_bulk_request() {
@@ -43,4 +66,5 @@ class WC_Order_Export_Ajax {
43
44
return $settings;
45
}
46
}
29
30
31
public function ajax_export_download_bulk_file() {
32
+
33
+ $main_settings = WC_Order_Export_Main_Settings::get_settings();
34
+ $destination_flag = $main_settings['show_destination_in_profile'];
35
+ $settings = array_merge( WC_Order_Export_Manage::get_defaults_filters(), $this->get_settings_from_bulk_request() );
36
+ $browser_output = empty($settings['destination']['not_download_browser']);
37
+ $result = $this->build_and_send_file( $settings, $destination_flag, $browser_output );
38
+
39
+ $output = sprintf( __( 'Export as profile "%s".', 'woo-order-export-lite' ) . "<br>\n" . __( 'Result: %s', 'woo-order-export-lite' ),
40
+ $settings['title'], implode("<br>\n\r", array_map(function ($v) { return $v['text']; }, $result)) );
41
+
42
+ $logger = function_exists( "wc_get_logger" ) ? wc_get_logger() : false; //new logger in 3.0+
43
+ $logger_context = array( 'source' => 'woo-order-export-lite' );
44
+ if ( $logger && ! empty( $result ) ) {
45
+ $logger->info( $output, $logger_context );
46
+ }
47
48
+ //admin will see this message in any case , later
49
+ if ( !empty( $result ) AND $settings['title'] )
50
+ set_transient( WC_Order_Export_Admin::last_bulk_export_results, $output );
51
+ if ( !$browser_output ) { // we don't send file to user, so we must redirect to previous page!
52
+ if( isset( $_SERVER['HTTP_REFERER'] ) ) {
53
+ wp_redirect( $_SERVER['HTTP_REFERER'] );
54
+ exit();
55
+ } else { // if we don't know the referer - just show the message
56
+ die($output);
57
+ }
58
+ }
59
}
60
61
protected function get_settings_from_bulk_request() {
66
67
return $settings;
68
}
69
+
70
}
classes/admin/tabs/ajax/trait-wc-order-export-admin-tab-abstract-ajax-export.php CHANGED
@@ -7,18 +7,26 @@ trait WC_Order_Export_Admin_Tab_Abstract_Ajax_Export {
7
use WC_Order_Export_Ajax_Helpers;
8
9
public function ajax_preview() {
10
-
11
$settings = WC_Order_Export_Manage::make_new_settings( $_POST );
12
// use unsaved settings
13
14
do_action( 'woe_start_preview_job', $_POST['id'], $settings );
15
16
WC_Order_Export_Engine::kill_buffers();
17
ob_start(); // we need html for preview , even empty!
18
$total = WC_Order_Export_Engine::build_file( $settings, 'estimate_preview', 'file', 0, 0, 'test');
19
WC_Order_Export_Engine::build_file( $settings, 'preview', 'browser', 0, $_POST['limit'] );
20
$html = ob_get_contents();
21
ob_end_clean();
22
echo json_encode( array( 'total' => $total, 'html' => $html ) );
23
}
24
@@ -33,7 +41,6 @@ trait WC_Order_Export_Admin_Tab_Abstract_Ajax_Export {
33
}
34
35
public function ajax_export_start() {
36
-
37
$this->start_prevent_object_cache();
38
$settings = WC_Order_Export_Manage::make_new_settings( $_POST );
39
@@ -41,7 +48,6 @@ trait WC_Order_Export_Admin_Tab_Abstract_Ajax_Export {
41
if ( ! $filename ) {
42
die( __( 'Can\'t create temporary file', 'woo-order-export-lite' ) );
43
}
44
-
45
//no free space or other file system errors?
46
try {
47
file_put_contents( $filename, '' );
@@ -82,7 +88,7 @@ trait WC_Order_Export_Admin_Tab_Abstract_Ajax_Export {
82
}
83
84
$file = WC_Order_Export_Engine::build_file_full( $settings );
85
-
86
if ( $file !== false ) {
87
$file_id = current_time( 'timestamp' );
88
$this->start_prevent_object_cache();
@@ -93,7 +99,6 @@ trait WC_Order_Export_Admin_Tab_Abstract_Ajax_Export {
93
94
$_GET['format'] = $settings['format'];
95
$_GET['file_id'] = $_REQUEST['file_id'] = $file_id;
96
-
97
$filename = WC_Order_Export_Engine::make_filename( $settings['export_filename'] );
98
$this->start_prevent_object_cache();
99
set_transient( $this->tempfile_prefix . 'download_filename', $filename, 60 );
@@ -120,7 +125,6 @@ trait WC_Order_Export_Admin_Tab_Abstract_Ajax_Export {
120
}
121
122
public function ajax_export_finish() {
123
-
124
$settings = WC_Order_Export_Manage::make_new_settings( $_POST );
125
WC_Order_Export_Engine::build_file( $settings, 'finish', 'file', 0, 0, $this->get_temp_file_name() );
126
7
use WC_Order_Export_Ajax_Helpers;
8
9
public function ajax_preview() {
10
+ global $wp_filter;
11
+
12
$settings = WC_Order_Export_Manage::make_new_settings( $_POST );
13
// use unsaved settings
14
15
do_action( 'woe_start_preview_job', $_POST['id'], $settings );
16
17
WC_Order_Export_Engine::kill_buffers();
18
+
19
ob_start(); // we need html for preview , even empty!
20
+
21
+ $currrent_wp_filter = $wp_filter;
22
$total = WC_Order_Export_Engine::build_file( $settings, 'estimate_preview', 'file', 0, 0, 'test');
23
+ $wp_filter = $currrent_wp_filter;//revert all hooks/fiilters added by build_file
24
+
25
WC_Order_Export_Engine::build_file( $settings, 'preview', 'browser', 0, $_POST['limit'] );
26
+
27
$html = ob_get_contents();
28
ob_end_clean();
29
+
30
echo json_encode( array( 'total' => $total, 'html' => $html ) );
31
}
32
41
}
42
43
public function ajax_export_start() {
44
$this->start_prevent_object_cache();
45
$settings = WC_Order_Export_Manage::make_new_settings( $_POST );
46
48
if ( ! $filename ) {
49
die( __( 'Can\'t create temporary file', 'woo-order-export-lite' ) );
50
}
51
//no free space or other file system errors?
52
try {
53
file_put_contents( $filename, '' );
88
}
89
90
$file = WC_Order_Export_Engine::build_file_full( $settings );
91
+ //$order_id = WC_Order_Export_Engine::$orders_for_export;
92
if ( $file !== false ) {
93
$file_id = current_time( 'timestamp' );
94
$this->start_prevent_object_cache();
99
100
$_GET['format'] = $settings['format'];
101
$_GET['file_id'] = $_REQUEST['file_id'] = $file_id;
102
$filename = WC_Order_Export_Engine::make_filename( $settings['export_filename'] );
103
$this->start_prevent_object_cache();
104
set_transient( $this->tempfile_prefix . 'download_filename', $filename, 60 );
125
}
126
127
public function ajax_export_finish() {
128
$settings = WC_Order_Export_Manage::make_new_settings( $_POST );
129
WC_Order_Export_Engine::build_file( $settings, 'finish', 'file', 0, 0, $this->get_temp_file_name() );
130
classes/admin/tabs/ajax/trait-wc-order-export-ajax-helpers.php CHANGED
@@ -35,7 +35,7 @@ trait WC_Order_Export_Ajax_Helpers {
35
if ( empty( $download_name ) ) {
36
$download_name = "orders.tsv";
37
}
38
- header( 'Content-type: text/csv' );
39
break;
40
case 'JSON':
41
if ( empty( $download_name ) ) {
@@ -135,12 +135,19 @@ trait WC_Order_Export_Ajax_Helpers {
135
$this->stop_prevent_object_cache();
136
}
137
138
- protected function build_and_send_file( $settings ) {
139
$filename = WC_Order_Export_Engine::build_file_full( $settings, '', 0, explode( ",", $_REQUEST['ids'] ) );
140
WC_Order_Export_Manage::set_correct_file_ext( $settings );
141
-
142
- $this->send_headers( $settings['format'], WC_Order_Export_Engine::make_filename( $settings['export_filename'] ) );
143
- $this->send_contents_delete_file( $filename );
144
}
145
146
}
35
if ( empty( $download_name ) ) {
36
$download_name = "orders.tsv";
37
}
38
+ header( 'Content-type: text/tsv' );
39
break;
40
case 'JSON':
41
if ( empty( $download_name ) ) {
135
$this->stop_prevent_object_cache();
136
}
137
138
+ protected function build_and_send_file( $settings, $export = false, $browser_output = true ) {
139
+ $result = [];
140
$filename = WC_Order_Export_Engine::build_file_full( $settings, '', 0, explode( ",", $_REQUEST['ids'] ) );
141
+ $download_name = WC_Order_Export_Engine::make_filename( $settings['export_filename'] );
142
WC_Order_Export_Manage::set_correct_file_ext( $settings );
143
+ if ( $export ) {
144
+ $result = WC_Order_Export_Pro_Engine::export( $settings, $filename );
145
+ }
146
+ if ( $browser_output ) {
147
+ $this->send_headers( $settings['format'], $download_name );
148
+ $this->send_contents_delete_file( $filename );
149
+ }
150
+ return $result;
151
}
152
153
}
classes/admin/tabs/class-wc-order-export-admin-tab-abstract.php CHANGED
@@ -10,6 +10,12 @@ class WC_Order_Export_Admin_Tab_Abstract {
10
11
protected $title;
12
13
public static function get_key() {
14
return static::KEY;
15
}
@@ -18,6 +24,9 @@ class WC_Order_Export_Admin_Tab_Abstract {
18
return $this->title;
19
}
20
21
public function process() {
22
}
23
10
11
protected $title;
12
13
+ protected $settings;
14
+
15
+ public function __construct() {
16
+ $this->settings = WC_Order_Export_Main_Settings::get_settings();
17
+ }
18
+
19
public static function get_key() {
20
return static::KEY;
21
}
24
return $this->title;
25
}
26
27
+ public function get_settings() {
28
+ return $this->settings;
29
+ }
30
public function process() {
31
}
32
classes/admin/tabs/class-wc-order-export-admin-tab-profiles.php CHANGED
@@ -7,7 +7,8 @@ class WC_Order_Export_Admin_Tab_Profiles extends WC_Order_Export_Admin_Tab_Abstr
7
const KEY = 'profiles';
8
9
public function __construct() {
10
- $this->title = __( 'Profiles', 'woo-order-export-lite' );
11
}
12
13
public function render() {
7
const KEY = 'profiles';
8
9
public function __construct() {
10
+ $this->title = "&#x1f512; &nbsp;" . __( 'Profiles', 'woo-order-export-lite' ) ;
11
+ parent::__construct();
12
}
13
14
public function render() {
classes/admin/tabs/class-wc-order-export-admin-tab-schedule-jobs.php CHANGED
@@ -7,7 +7,8 @@ class WC_Order_Export_Admin_Tab_Schedule_Jobs extends WC_Order_Export_Admin_Tab_
7
const KEY = 'schedules';
8
9
public function __construct() {
10
- $this->title = __( 'Scheduled jobs', 'woo-order-export-lite' );
11
}
12
13
public function render() {
7
const KEY = 'schedules';
8
9
public function __construct() {
10
+ parent::__construct();
11
+ $this->title = "&#x1f512; &nbsp;" . __( 'Scheduled jobs', 'woo-order-export-lite' );
12
}
13
14
public function render() {
classes/admin/tabs/class-wc-order-export-admin-tab-status-change-jobs.php CHANGED
@@ -7,7 +7,7 @@ class WC_Order_Export_Admin_Tab_Status_Change_Jobs extends WC_Order_Export_Admin
7
const KEY = 'order_actions';
8
9
public function __construct() {
10
- $this->title = __( 'Status change jobs', 'woo-order-export-lite' );
11
}
12
13
public function render() {
7
const KEY = 'order_actions';
8
9
public function __construct() {
10
+ $this->title = "&#x1f512; &nbsp;" . __( 'Status change jobs', 'woo-order-export-lite' );
11
}
12
13
public function render() {
classes/class-wc-order-export-admin.php CHANGED
@@ -13,6 +13,8 @@ class WC_Order_Export_Admin {
13
public $path_plugin;
14
15
protected $tabs;
16
17
public function __construct() {
18
$this->url_plugin = dirname( plugin_dir_url( __FILE__ ) ) . '/';
@@ -31,6 +33,7 @@ class WC_Order_Export_Admin {
31
add_action( 'wp_loaded' , function() { //init tabs after loading text domains!
32
$this->tabs = $this->get_tabs();
33
});
34
35
add_action( 'wp_ajax_order_exporter', array( $this, 'ajax_gate' ) );
36
@@ -59,6 +62,7 @@ class WC_Order_Export_Admin {
59
// Style for 'Export Status' column
60
if ( isset( $_GET['post_type'] ) && $_GET['post_type'] == 'shop_order' ) {
61
add_action( 'admin_print_styles', array( $this, 'add_order_status_column_style' ) );
62
}
63
}
64
@@ -121,6 +125,9 @@ class WC_Order_Export_Admin {
121
$css = '.widefat .column-woe_export_status { width: 45px; text-align: center; }';
122
wp_add_inline_style( 'woocommerce_admin_styles', $css );
123
}
124
125
public function display_plugin_activated_message() {
126
?>
@@ -167,7 +174,6 @@ class WC_Order_Export_Admin {
167
public function render_menu() {
168
169
$active_tab = isset( $_REQUEST['tab'] ) ? $_REQUEST['tab'] : $this->settings['default_tab'];
170
-
171
$this->render( 'main', array(
172
'WC_Order_Export' => $this,
173
'ajaxurl' => admin_url( 'admin-ajax.php' ),
@@ -202,7 +208,7 @@ class WC_Order_Export_Admin {
202
add_action( 'learn-press/admin/after-enqueue-scripts', function () {
203
wp_scripts()->dequeue( array('learn-press-utils', 'lp-admin-learnpress', 'lp-admin') );
204
},PHP_INT_MAX );
205
-
206
wp_enqueue_style( 'export', $this->url_plugin . 'assets/css/export.css', array(), WOE_VERSION );
207
208
wp_enqueue_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array() );
@@ -292,7 +298,7 @@ class WC_Order_Export_Admin {
292
'woo-order-export-lite' ),
293
'empty_item_field' => __( 'select item field', 'woo-order-export-lite' ),
294
'empty_value' => __( 'empty value', 'woo-order-export-lite' ),
295
- 'empty_title' => __( 'title is empty', 'woo-order-export-lite' ),
296
'wrong_date_range' => __( 'Date From is greater than Date To', 'woo-order-export-lite' ),
297
'no_fields' => __( 'Please, set up fields to export', 'woo-order-export-lite' ),
298
'no_results' => __( 'Nothing to export. Please, adjust your filters',
@@ -515,7 +521,14 @@ class WC_Order_Export_Admin {
515
. '</div>',
516
$count
517
);
518
}
519
}
520
521
function must_run_ajax_methods() {
13
public $path_plugin;
14
15
protected $tabs;
16
+
17
+ const last_bulk_export_results = 'woe-last-bulk-export-results';
18
19
public function __construct() {
20
$this->url_plugin = dirname( plugin_dir_url( __FILE__ ) ) . '/';
33
add_action( 'wp_loaded' , function() { //init tabs after loading text domains!
34
$this->tabs = $this->get_tabs();
35
});
36
+
37
38
add_action( 'wp_ajax_order_exporter', array( $this, 'ajax_gate' ) );
39
62
// Style for 'Export Status' column
63
if ( isset( $_GET['post_type'] ) && $_GET['post_type'] == 'shop_order' ) {
64
add_action( 'admin_print_styles', array( $this, 'add_order_status_column_style' ) );
65
+ add_action( 'admin_enqueue_scripts', array( $this, 'woe_add_orders_style' ) );
66
}
67
}
68
125
$css = '.widefat .column-woe_export_status { width: 45px; text-align: center; }';
126
wp_add_inline_style( 'woocommerce_admin_styles', $css );
127
}
128
+ function woe_add_orders_style() {
129
+ wp_enqueue_style( 'woe_orders_style', $this->url_plugin . 'assets/css/orders_style.css', array(), WOE_VERSION );
130
+ }
131
132
public function display_plugin_activated_message() {
133
?>
174
public function render_menu() {
175
176
$active_tab = isset( $_REQUEST['tab'] ) ? $_REQUEST['tab'] : $this->settings['default_tab'];
177
$this->render( 'main', array(
178
'WC_Order_Export' => $this,
179
'ajaxurl' => admin_url( 'admin-ajax.php' ),
208
add_action( 'learn-press/admin/after-enqueue-scripts', function () {
209
wp_scripts()->dequeue( array('learn-press-utils', 'lp-admin-learnpress', 'lp-admin') );
210
},PHP_INT_MAX );
211
+
212
wp_enqueue_style( 'export', $this->url_plugin . 'assets/css/export.css', array(), WOE_VERSION );
213
214
wp_enqueue_style( 'woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css', array() );
298
'woo-order-export-lite' ),
299
'empty_item_field' => __( 'select item field', 'woo-order-export-lite' ),
300
'empty_value' => __( 'empty value', 'woo-order-export-lite' ),
301
+ 'empty_title' => __( 'Title is empty', 'woo-order-export-lite' ),
302
'wrong_date_range' => __( 'Date From is greater than Date To', 'woo-order-export-lite' ),
303
'no_fields' => __( 'Please, set up fields to export', 'woo-order-export-lite' ),
304
'no_results' => __( 'Nothing to export. Please, adjust your filters',
521
. '</div>',
522
$count
523
);
524
+ } else {
525
+ $logs = get_transient( WC_Order_Export_Admin::last_bulk_export_results );
526
+ if ( $logs ) {
527
+ delete_transient( WC_Order_Export_Admin::last_bulk_export_results );
528
+ echo "<div id=\"notice-orders\" class=\"notice notice-info is-dismissible\" style=\"padding: 15px\">{$logs}</div>";
529
+ }
530
}
531
+
532
}
533
534
function must_run_ajax_methods() {
classes/core/class-wc-order-export-data-extractor-ui.php CHANGED
@@ -5,7 +5,6 @@ if ( ! defined( 'ABSPATH' ) ) {
5
6
class WC_Order_Export_Data_Extractor_UI extends WC_Order_Export_Data_Extractor {
7
static $object_type = 'shop_order';
8
- const HUGE_SHOP_CUSTOMERS = 1000;// more than 1000 customers
9
10
// ADD custom fields for export
11
public static function get_all_order_custom_meta_fields( $sql_order_ids = '' ) {
@@ -81,7 +80,7 @@ class WC_Order_Export_Data_Extractor_UI extends WC_Order_Export_Data_Extractor {
81
$sql_products = "SELECT DISTINCT meta_value FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE meta_key ='_product_id' AND order_item_id IN
82
(SELECT DISTINCT order_item_id FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_type = 'line_item' AND order_id IN ($sql_order_ids))";
83
84
- $product_ids = $wpdb->get_col( "SELECT DISTINCT ID FROM {$wpdb->posts} WHERE post_type IN ('product','product_variation') AND ID IN ($sql_products) ORDER BY ID DESC LIMIT 1000" );
85
86
$wp_fields = array();
87
if($product_ids ) {
@@ -199,16 +198,16 @@ class WC_Order_Export_Data_Extractor_UI extends WC_Order_Export_Data_Extractor {
199
200
public static function get_order_custom_fields_values( $key ) {
201
global $wpdb;
202
-
203
- $order_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = '" . self::$object_type . "' ORDER BY ID DESC LIMIT 1000" );
204
if( empty($order_ids) )
205
return array();
206
-
207
$order_ids = join( ",", $order_ids );
208
$values = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT meta_value FROM {$wpdb->postmeta} WHERE meta_key = %s AND post_id IN ($order_ids)", $key ) );
209
sort( $values );
210
211
- return $values;
212
}
213
214
public static function get_user_custom_fields_values( $key ) {
@@ -222,14 +221,14 @@ class WC_Order_Export_Data_Extractor_UI extends WC_Order_Export_Data_Extractor {
222
223
public static function get_product_custom_fields_values( $key ) {
224
global $wpdb;
225
-
226
- $product_ids = $wpdb->get_col( "SELECT DISTINCT ID FROM {$wpdb->posts} WHERE post_type = 'product_variation' OR post_type = 'product' ORDER BY ID DESC LIMIT 1000" );
227
if( empty($product_ids) )
228
return array();
229
-
230
$product_ids = join( ",", $product_ids );
231
232
-
233
$values = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT meta_value FROM {$wpdb->postmeta} WHERE meta_key = %s AND post_id IN ($product_ids)",
234
$key ) );
235
sort( $values );
@@ -286,13 +285,13 @@ class WC_Order_Export_Data_Extractor_UI extends WC_Order_Export_Data_Extractor {
286
287
public static function get_order_meta_values( $type, $key ) {
288
global $wpdb;
289
-
290
- $order_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = '" . self::$object_type . "' ORDER BY ID DESC LIMIT 1000" );
291
if( empty($order_ids) )
292
return array();
293
-
294
$order_ids = join( ",", $order_ids );
295
-
296
$query = $wpdb->prepare( 'SELECT DISTINCT meta_value FROM ' . $wpdb->postmeta . " WHERE meta_key = %s AND post_id IN($order_ids)",
297
array( $type . strtolower( $key ) ) );
298
$results = $wpdb->get_col( $query );
@@ -316,7 +315,7 @@ class WC_Order_Export_Data_Extractor_UI extends WC_Order_Export_Data_Extractor {
316
global $wpdb;
317
318
$names = $wpdb->get_results( "SELECT distinct order_item_type,meta_key FROM {$wpdb->prefix}woocommerce_order_items AS items
319
- INNER JOIN (SELECT ID AS order_id FROM {$wpdb->prefix}posts WHERE post_type='shop_order' ORDER BY ID DESC LIMIT 1000) AS orders ON orders.order_id = items.order_id
320
JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS meta ON meta.order_item_id = items.order_item_id
321
ORDER BY order_item_type,meta_key" );
322
@@ -376,11 +375,6 @@ class WC_Order_Export_Data_Extractor_UI extends WC_Order_Export_Data_Extractor {
376
'checked' => 0,
377
'format' => 'number',
378
),
379
- 'product_variation' => array(
380
- 'label' => __( 'Product Variation', 'woo-order-export-lite' ),
381
- 'checked' => 0,
382
- 'format' => 'string',
383
- ),
384
'seller' => array(
385
'label' => __( 'Product Seller', 'woo-order-export-lite' ),
386
'checked' => 0,
@@ -954,6 +948,11 @@ class WC_Order_Export_Data_Extractor_UI extends WC_Order_Export_Data_Extractor {
954
'checked' => 1,
955
'format' => 'money',
956
),
957
'line_no_tax' => array(
958
'label' => __( 'Order Line (w/o tax)', 'woo-order-export-lite' ),
959
'checked' => 0,
@@ -1014,11 +1013,26 @@ class WC_Order_Export_Data_Extractor_UI extends WC_Order_Export_Data_Extractor {
1014
'checked' => 0,
1015
'format' => 'number',
1016
),
1017
- 'item_download_url' => array(
1018
'label' => __( 'Item download URL', 'woo-order-export-lite' ),
1019
'checked' => 0,
1020
'format' => 'string',
1021
),
1022
);
1023
1024
foreach ( $map as $key => &$value ) {
@@ -1258,6 +1272,7 @@ class WC_Order_Export_Data_Extractor_UI extends WC_Order_Export_Data_Extractor {
1258
));
1259
}
1260
1261
/**
1262
* Same as get_order_segments() but with "product_items"
1263
*
@@ -1271,7 +1286,7 @@ class WC_Order_Export_Data_Extractor_UI extends WC_Order_Export_Data_Extractor {
1271
'billing' => __( 'Billing Address', 'woo-order-export-lite' ),
1272
'shipping' => __( 'Shipping Address', 'woo-order-export-lite' ),
1273
'products' => __( 'Products', 'woo-order-export-lite' ),
1274
- 'product_items' => __( 'Product items', 'woo-order-export-lite' ),
1275
'product_totals' => __( 'Product totals', 'woo-order-export-lite' ),
1276
'coupons' => __( 'Coupons', 'woo-order-export-lite' ),
1277
'other_items' => __( 'Other items', 'woo-order-export-lite' ),
@@ -1281,6 +1296,13 @@ class WC_Order_Export_Data_Extractor_UI extends WC_Order_Export_Data_Extractor {
1281
'misc' => __( 'Others', 'woo-order-export-lite' ),
1282
);
1283
}
1284
1285
public static function get_format_fields() {
1286
return array(
@@ -1293,4 +1315,4 @@ class WC_Order_Export_Data_Extractor_UI extends WC_Order_Export_Data_Extractor {
1293
}
1294
1295
1296
- }
5
6
class WC_Order_Export_Data_Extractor_UI extends WC_Order_Export_Data_Extractor {
7
static $object_type = 'shop_order';
8
9
// ADD custom fields for export
10
public static function get_all_order_custom_meta_fields( $sql_order_ids = '' ) {
80
$sql_products = "SELECT DISTINCT meta_value FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE meta_key ='_product_id' AND order_item_id IN
81
(SELECT DISTINCT order_item_id FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_type = 'line_item' AND order_id IN ($sql_order_ids))";
82
83
+ $product_ids = $wpdb->get_col( "SELECT DISTINCT ID FROM {$wpdb->posts} WHERE post_type IN ('product','product_variation') AND ID IN ($sql_products) ORDER BY ID DESC LIMIT " . self::HUGE_SHOP_PRODUCTS );
84
85
$wp_fields = array();
86
if($product_ids ) {
198
199
public static function get_order_custom_fields_values( $key ) {
200
global $wpdb;
201
+
202
+ $order_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = '" . self::$object_type . "' ORDER BY ID DESC LIMIT " . self::HUGE_SHOP_ORDERS );
203
if( empty($order_ids) )
204
return array();
205
+
206
$order_ids = join( ",", $order_ids );
207
$values = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT meta_value FROM {$wpdb->postmeta} WHERE meta_key = %s AND post_id IN ($order_ids)", $key ) );
208
sort( $values );
209
210
+ return apply_filters( 'woe_get_order_custom_fields_values', $values, $key);
211
}
212
213
public static function get_user_custom_fields_values( $key ) {
221
222
public static function get_product_custom_fields_values( $key ) {
223
global $wpdb;
224
+
225
+ $product_ids = $wpdb->get_col( "SELECT DISTINCT ID FROM {$wpdb->posts} WHERE post_type = 'product_variation' OR post_type = 'product' ORDER BY ID DESC LIMIT " . self::HUGE_SHOP_PRODUCTS );
226
if( empty($product_ids) )
227
return array();
228
+
229
$product_ids = join( ",", $product_ids );
230
231
+
232
$values = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT meta_value FROM {$wpdb->postmeta} WHERE meta_key = %s AND post_id IN ($product_ids)",
233
$key ) );
234
sort( $values );
285
286
public static function get_order_meta_values( $type, $key ) {
287
global $wpdb;
288
+
289
+ $order_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = '" . self::$object_type . "' ORDER BY ID DESC LIMIT " . self::HUGE_SHOP_ORDERS );
290
if( empty($order_ids) )
291
return array();
292
+
293
$order_ids = join( ",", $order_ids );
294
+
295
$query = $wpdb->prepare( 'SELECT DISTINCT meta_value FROM ' . $wpdb->postmeta . " WHERE meta_key = %s AND post_id IN($order_ids)",
296
array( $type . strtolower( $key ) ) );
297
$results = $wpdb->get_col( $query );
315
global $wpdb;
316
317
$names = $wpdb->get_results( "SELECT distinct order_item_type,meta_key FROM {$wpdb->prefix}woocommerce_order_items AS items
318
+ INNER JOIN (SELECT ID AS order_id FROM {$wpdb->prefix}posts WHERE post_type='shop_order' ORDER BY ID DESC LIMIT " . self::HUGE_SHOP_ORDERS . " ) AS orders ON orders.order_id = items.order_id
319
JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS meta ON meta.order_item_id = items.order_item_id
320
ORDER BY order_item_type,meta_key" );
321
375
'checked' => 0,
376
'format' => 'number',
377
),
378
'seller' => array(
379
'label' => __( 'Product Seller', 'woo-order-export-lite' ),
380
'checked' => 0,
948
'checked' => 1,
949
'format' => 'money',
950
),
951
+ 'item_price_before_discount' => array(
952
+ 'label' => __( 'Item Cost Before Discount', 'woo-order-export-lite' ),
953
+ 'checked' => 0,
954
+ 'format' => 'money',
955
+ ),
956
'line_no_tax' => array(
957
'label' => __( 'Order Line (w/o tax)', 'woo-order-export-lite' ),
958
'checked' => 0,
1013
'checked' => 0,
1014
'format' => 'number',
1015
),
1016
+ 'item_download_url' => array(
1017
'label' => __( 'Item download URL', 'woo-order-export-lite' ),
1018
'checked' => 0,
1019
'format' => 'string',
1020
),
1021
+ 'product_variation' => array(
1022
+ 'label' => __( 'Order Item Metadata', 'woo-order-export-lite' ),
1023
+ 'checked' => 0,
1024
+ 'format' => 'string',
1025
+ ),
1026
+ 'item_discount_tax' => array(
1027
+ 'label' => __( 'Item Discount Tax', 'woo-order-export-lite' ),
1028
+ 'checked' => 0,
1029
+ 'format' => 'number',
1030
+ ),
1031
+ 'item_discount_amount_and_tax'=> array(
1032
+ 'label' => __( 'Item Discount Amount + Tax', 'woo-order-export-lite' ),
1033
+ 'checked' => 0,
1034
+ 'format' => 'number',
1035
+ ),
1036
);
1037
1038
foreach ( $map as $key => &$value ) {
1272
));
1273
}
1274
1275
+
1276
/**
1277
* Same as get_order_segments() but with "product_items"
1278
*
1286
'billing' => __( 'Billing Address', 'woo-order-export-lite' ),
1287
'shipping' => __( 'Shipping Address', 'woo-order-export-lite' ),
1288
'products' => __( 'Products', 'woo-order-export-lite' ),
1289
+ 'product_items' => __( 'Product order items', 'woo-order-export-lite' ),
1290
'product_totals' => __( 'Product totals', 'woo-order-export-lite' ),
1291
'coupons' => __( 'Coupons', 'woo-order-export-lite' ),
1292
'other_items' => __( 'Other items', 'woo-order-export-lite' ),
1296
'misc' => __( 'Others', 'woo-order-export-lite' ),
1297
);
1298
}
1299
+
1300
+ public static function get_segment_hints() {
1301
+ return array(
1302
+ 'products' => __( 'Use section "Product order items" to add attributes', 'woo-order-export-lite' ),
1303
+ 'product_items' => __( 'Use "Add field" to export specific product attribute', 'woo-order-export-lite' ),
1304
+ );
1305
+ }
1306
1307
public static function get_format_fields() {
1308
return array(
1315
}
1316
1317
1318
+ }
classes/core/class-wc-order-export-data-extractor.php CHANGED
@@ -45,7 +45,8 @@ class WC_Order_Export_Data_Extractor {
45
if ( $total_orders < self::HUGE_SHOP_ORDERS ) {
46
$fields = $wpdb->get_col( "SELECT DISTINCT meta_key FROM {$wpdb->posts} INNER JOIN {$wpdb->postmeta} ON {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id WHERE post_type = '" . self::$object_type . "'" );
47
} else { // we have a lot of orders, take last good orders, upto 1000
48
- $order_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = '" . self::$object_type . "' AND post_status IN('wc-on-hold','wc-processing','wc-completed') ORDER BY post_date DESC LIMIT 1000" );
49
$order_ids[] = 0; // add fake zero
50
$order_ids = join( ",", $order_ids );
51
$fields = $wpdb->get_col( "SELECT DISTINCT meta_key FROM {$wpdb->postmeta} WHERE post_id IN ($order_ids)" );
@@ -122,7 +123,7 @@ class WC_Order_Export_Data_Extractor {
122
set_transient( $transient_key, $metas, 60 ); //valid for a minute
123
} else {
124
$limit = self::HUGE_SHOP_ORDERS;
125
- $order_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = '" . self::$object_type . "' AND post_status IN('wc-on-hold','wc-processing','wc-completed') ORDER BY post_date DESC LIMIT {$limit}" );
126
$order_ids = join( ",", $order_ids );
127
$metas = $wpdb->get_col( "SELECT DISTINCT meta.meta_key FROM {$wpdb->prefix}woocommerce_order_itemmeta meta inner join {$wpdb->prefix}woocommerce_order_items item on item.order_item_id=meta.order_item_id and item.order_item_type = 'line_item' WHERE item.order_id IN ($order_ids)" );
128
sort( $metas );
@@ -148,7 +149,7 @@ class WC_Order_Export_Data_Extractor {
148
149
} else {
150
$limit = self::HUGE_SHOP_ORDERS;
151
- $order_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = '" . self::$object_type . "' AND post_status IN('wc-on-hold','wc-processing','wc-completed') ORDER BY post_date DESC LIMIT {$limit}" );
152
$order_ids = join( ",", $order_ids );
153
$metas = $wpdb->get_col( "SELECT DISTINCT order_item_name FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_type = 'shipping' AND order_id IN ($order_ids) AND order_item_name <> '' " );
154
sort( $metas );
@@ -173,7 +174,7 @@ class WC_Order_Export_Data_Extractor {
173
set_transient( $transient_key, $metas, 60 ); //valid for a minute
174
} else {
175
$limit = self::HUGE_SHOP_ORDERS;
176
- $order_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = '" . self::$object_type . "' AND post_status IN('wc-on-hold','wc-processing','wc-completed') ORDER BY post_date DESC LIMIT {$limit}" );
177
$order_ids = join( ",", $order_ids );
178
$metas = $wpdb->get_col( "SELECT DISTINCT order_item_name FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_type = 'fee' AND order_id IN ($order_ids) AND order_item_name <> '' " );
179
sort( $metas );
@@ -198,7 +199,7 @@ class WC_Order_Export_Data_Extractor {
198
set_transient( $transient_key, $metas, 60 ); //valid for a minute
199
} else {
200
$limit = self::HUGE_SHOP_ORDERS;
201
- $order_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = '" . self::$object_type . "' AND post_status IN('wc-on-hold','wc-processing','wc-completed') ORDER BY post_date DESC LIMIT {$limit}" );
202
$order_ids = join( ",", $order_ids );
203
$metas = $wpdb->get_col( "SELECT DISTINCT order_item_name FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_type = 'tax' AND order_id IN ($order_ids) AND order_item_name <> '' " );
204
sort( $metas );
@@ -277,7 +278,7 @@ class WC_Order_Export_Data_Extractor {
277
return $pair_types;
278
}
279
280
- private static function parse_complex_pairs( $pairs, $valid_types = false, $mode = '' ) {
281
$pair_types = array();
282
$delimiters = array(
283
'NOT SET' => 'NOT SET',
@@ -1093,9 +1094,16 @@ class WC_Order_Export_Data_Extractor {
1093
if ( is_array( $settings['order_ids'] ) && count( array_filter( array_map( 'is_numeric', $order_ids ) ) ) === count( $order_ids ) ) {
1094
$order_ids_str = self::sql_subset( $order_ids );
1095
if ( $order_ids_str ) {
1096
- $where[] = "orders.id IN ($order_ids_str)";
1097
}
1098
}
1099
}
1100
1101
//default filter by date
@@ -1134,7 +1142,7 @@ class WC_Order_Export_Data_Extractor {
1134
//for date_paid or date_completed
1135
if ( $where_meta ) {
1136
$where_meta = join( " AND ", $where_meta );
1137
- $where[] = "orders.id IN ( SELECT post_id FROM {$wpdb->postmeta} AS order_$date_field WHERE order_$date_field.meta_key ='_$date_field' AND $where_meta)";
1138
}
1139
1140
// skip child orders?
@@ -1415,6 +1423,7 @@ class WC_Order_Export_Data_Extractor {
1415
$woe_order
1416
) {
1417
$export_only_products = $options['include_products'];
1418
$products = array();
1419
$i = 0;
1420
@@ -1432,6 +1441,62 @@ class WC_Order_Export_Data_Extractor {
1432
) {
1433
continue;
1434
}
1435
1436
$product = $item->get_product();
1437
$product = apply_filters( "woe_get_order_product", $product );
@@ -1587,8 +1652,8 @@ class WC_Order_Export_Data_Extractor {
1587
$woe_order->set_data($data);
1588
// fill as it must
1589
foreach ( $labels['order']->get_fetch_fields() as $field ) {
1590
- $row = $woe_order->get($row, $field);
1591
- //use empty value for missed field
1592
if ( $field != 'products' AND $field != 'coupons' ) {
1593
if ( ! isset( $row[ $field ] ) ) {
1594
$row[ $field ] = '';
@@ -1801,4 +1866,4 @@ class WC_Order_Export_Data_Extractor {
1801
return wc_get_order( absint( $order ) );
1802
}
1803
1804
- }
45
if ( $total_orders < self::HUGE_SHOP_ORDERS ) {
46
$fields = $wpdb->get_col( "SELECT DISTINCT meta_key FROM {$wpdb->posts} INNER JOIN {$wpdb->postmeta} ON {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id WHERE post_type = '" . self::$object_type . "'" );
47
} else { // we have a lot of orders, take last good orders, upto 1000
48
+ $limit = self::HUGE_SHOP_ORDERS;
49
+ $order_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = '" . self::$object_type . "' ORDER BY post_date DESC LIMIT {$limit}" );
50
$order_ids[] = 0; // add fake zero
51
$order_ids = join( ",", $order_ids );
52
$fields = $wpdb->get_col( "SELECT DISTINCT meta_key FROM {$wpdb->postmeta} WHERE post_id IN ($order_ids)" );
123
set_transient( $transient_key, $metas, 60 ); //valid for a minute
124
} else {
125
$limit = self::HUGE_SHOP_ORDERS;
126
+ $order_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = '" . self::$object_type . "' ORDER BY post_date DESC LIMIT {$limit}" );
127
$order_ids = join( ",", $order_ids );
128
$metas = $wpdb->get_col( "SELECT DISTINCT meta.meta_key FROM {$wpdb->prefix}woocommerce_order_itemmeta meta inner join {$wpdb->prefix}woocommerce_order_items item on item.order_item_id=meta.order_item_id and item.order_item_type = 'line_item' WHERE item.order_id IN ($order_ids)" );
129
sort( $metas );
149
150
} else {
151
$limit = self::HUGE_SHOP_ORDERS;
152
+ $order_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = '" . self::$object_type . "' ORDER BY post_date DESC LIMIT {$limit}" );
153
$order_ids = join( ",", $order_ids );
154
$metas = $wpdb->get_col( "SELECT DISTINCT order_item_name FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_type = 'shipping' AND order_id IN ($order_ids) AND order_item_name <> '' " );
155
sort( $metas );
174
set_transient( $transient_key, $metas, 60 ); //valid for a minute
175
} else {
176
$limit = self::HUGE_SHOP_ORDERS;
177
+ $order_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = '" . self::$object_type . "' ORDER BY post_date DESC LIMIT {$limit}" );
178
$order_ids = join( ",", $order_ids );
179
$metas = $wpdb->get_col( "SELECT DISTINCT order_item_name FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_type = 'fee' AND order_id IN ($order_ids) AND order_item_name <> '' " );
180
sort( $metas );
199
set_transient( $transient_key, $metas, 60 ); //valid for a minute
200
} else {
201
$limit = self::HUGE_SHOP_ORDERS;
202
+ $order_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} WHERE post_type = '" . self::$object_type . "' ORDER BY post_date DESC LIMIT {$limit}" );
203
$order_ids = join( ",", $order_ids );
204
$metas = $wpdb->get_col( "SELECT DISTINCT order_item_name FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_type = 'tax' AND order_id IN ($order_ids) AND order_item_name <> '' " );
205
sort( $metas );
278
return $pair_types;
279
}
280
281
+ public static function parse_complex_pairs( $pairs, $valid_types = false, $mode = '' ) {
282
$pair_types = array();
283
$delimiters = array(
284
'NOT SET' => 'NOT SET',
1094
if ( is_array( $settings['order_ids'] ) && count( array_filter( array_map( 'is_numeric', $order_ids ) ) ) === count( $order_ids ) ) {
1095
$order_ids_str = self::sql_subset( $order_ids );
1096
if ( $order_ids_str ) {
1097
+ $where[] = "orders.ID IN ($order_ids_str)";
1098
}
1099
}
1100
+ } else {
1101
+ if ( ! empty( $settings['from_order_id'] ) ) {
1102
+ $where[] = "orders.ID >= " . intval($settings['from_order_id']);
1103
+ }
1104
+ if ( ! empty( $settings['to_order_id'] ) ) {
1105
+ $where[] = "orders.ID <= " . intval($settings['to_order_id']);
1106
+ }
1107
}
1108
1109
//default filter by date
1142
//for date_paid or date_completed
1143
if ( $where_meta ) {
1144
$where_meta = join( " AND ", $where_meta );
1145
+ $where[] = "orders.ID IN ( SELECT post_id FROM {$wpdb->postmeta} AS order_$date_field WHERE order_$date_field.meta_key ='_$date_field' AND $where_meta)";
1146
}
1147
1148
// skip child orders?
1423
$woe_order
1424
) {
1425
$export_only_products = $options['include_products'];
1426
+ $export_matched_products = $options['export_matched_items'];
1427
$products = array();
1428
$i = 0;
1429
1441
) {
1442
continue;
1443
}
1444
+
1445
+ if( $export_matched_products ) {
1446
+ foreach ( $export_matched_products['item_metadata'] as $operator => $fields ) {
1447
+ foreach ( $fields as $field => $values ) {
1448
+ if ( $values ) {
1449
+ self::extract_item_type_and_key( $field, $type, $key );
1450
+ if($type != 'line_item') {
1451
+ continue;
1452
+ }
1453
+ $meta = wc_get_order_item_meta( $item_id, $key );
1454
+ if(($operator == 'IN' AND !in_array($meta, $values)) OR
1455
+ ($operator == 'NOT IN' AND in_array($meta, $values))) {
1456
+ continue 3;
1457
+ }
1458
+ else if($operator == 'LIKE') {
1459
+ $matched_like = false;
1460
+ foreach ($values as $value) {
1461
+ if(strpos($meta, $value) !== false) {
1462
+ $matched_like = true;
1463
+ continue;
1464
+ }
1465
+ }
1466
+ if(!$matched_like) {
1467
+ continue 3;
1468
+ }
1469
+ }
1470
+ }
1471
+ }
1472
+ }
1473
+ foreach ( $export_matched_products['item_names'] as $operator => $fields ) {
1474
+ foreach ( $fields as $field => $values ) {
1475
+ if ( $values ) {
1476
+ if($field != 'line_item') {
1477
+ continue;
1478
+ }
1479
+ $item_name = $item->get_name();
1480
+ if(($operator == 'IN' AND !in_array($item_name, $values)) OR
1481
+ ($operator == 'NOT IN' AND in_array($item_name, $values))) {
1482
+ continue 3;
1483
+ }
1484
+ else if($operator == 'LIKE') {
1485
+ $matched_like = false;
1486
+ foreach ($values as $value) {
1487
+ if(strpos($item_name, $value) !== false) {
1488
+ $matched_like = true;
1489
+ continue;
1490
+ }
1491
+ }
1492
+ if(!$matched_like) {
1493
+ continue 3;
1494
+ }
1495
+ }
1496
+ }
1497
+ }
1498
+ }
1499
+ }
1500
1501
$product = $item->get_product();
1502
$product = apply_filters( "woe_get_order_product", $product );
1652
$woe_order->set_data($data);
1653
// fill as it must
1654
foreach ( $labels['order']->get_fetch_fields() as $field ) {
1655
+ $row = $woe_order->get($row, $field);
1656
+ //use empty value for missed field
1657
if ( $field != 'products' AND $field != 'coupons' ) {
1658
if ( ! isset( $row[ $field ] ) ) {
1659
$row[ $field ] = '';
1866
return wc_get_order( absint( $order ) );
1867
}
1868
1869
+ }
classes/core/class-wc-order-export-engine.php CHANGED
@@ -15,29 +15,36 @@ class WC_Order_Export_Engine {
15
public static $make_separate_orders = false;
16
17
public static function make_filename( $mask ) {
18
if ( self::$make_separate_orders && strpos( $mask, '%order_id' ) === false ) {
19
$mask_parts = explode( '.', $mask );
20
$before_prefix = count( $mask_parts ) > 1 ? 2 : 1;
21
$mask_parts[ count( $mask_parts ) - $before_prefix ] .= '-%order_id';
22
$mask = implode( '.', $mask_parts );
23
}
24
- $time = apply_filters( 'woe_make_filename_current_time', current_time( 'timestamp' ) );
25
26
- $date = WC_Order_Export_Data_Extractor::get_date_range( self::$current_job_settings, false );
27
28
- $subst = apply_filters( 'woe_make_filename_replacements', array(
29
- '%d' => date( 'd', $time ),
30
- '%m' => date( 'm', $time ),
31
- '%y' => date( 'Y', $time ),
32
- '%h' => date( 'H', $time ),
33
- '%i' => date( 'i', $time ),
34
- '%s' => date( 's', $time ),
35
- '%order_id' => self::$order_id,
36
- '%orderid' => self::$order_id,
37
- '%id' => self::$order_id,
38
- '{from_date}' => isset( $date['from_date'] ) ? date( "Y-m-d", strtotime( $date['from_date'] ) ) : '',
39
- '{to_date}' => isset( $date['to_date'] ) ? date( "Y-m-d", strtotime( $date['to_date'] ) ) : '',
40
- ) );
41
42
return apply_filters( 'woe_make_filename', strtr( $mask, $subst ) );
43
}
@@ -257,13 +264,20 @@ class WC_Order_Export_Engine {
257
$options['item_rows_start_from_new_line'] = ( $format == 'csv' AND @$settings['format_csv_item_rows_start_from_new_line'] OR $format == 'tsv' AND @$settings['format_tsv_item_rows_start_from_new_line'] ) ;
258
$options['products_mode'] = isset( $settings['duplicated_fields_settings']['products']['repeat'] ) ? $settings['duplicated_fields_settings']['products']['repeat'] : "";
259
$options['coupons_mode'] = isset( $settings['duplicated_fields_settings']['coupons']['repeat'] ) ? $settings['duplicated_fields_settings']['coupons']['repeat'] : "";
260
-
261
if ( ! empty( $settings['all_products_from_order'] ) ) {
262
$options['include_products'] = false;
263
} else {
264
$options['include_products'] = $wpdb->get_col( WC_Order_Export_Data_Extractor::sql_get_product_ids( $settings ) );
265
}
266
267
if ( isset( $settings['date_format'] ) ) {
268
$options['date_format'] = $settings['date_format'];
269
} else {
@@ -317,8 +331,8 @@ class WC_Order_Export_Engine {
317
if ( ! isset( $settings['skip_empty_file'] ) ) {
318
$settings['skip_empty_file'] = true;
319
}
320
- // "preview" runs after "estimate, so we already activated code
321
- if ( self::$current_job_build_mode!=='preview' AND $settings['custom_php'] ) {
322
ob_start( array( 'WC_Order_Export_Engine', 'code_error_callback' ) );
323
$result = eval( $settings['custom_php_code'] );
324
ob_end_clean();
@@ -410,7 +424,7 @@ class WC_Order_Export_Engine {
410
411
412
//get IDs
413
- $sql = WC_Order_Export_Data_Extractor::sql_get_order_ids( $settings );
414
$settings = self::replace_sort_field( $settings );
415
if ( $make_mode == 'estimate' OR $make_mode =='estimate_preview' ) { //if estimate return total count
416
return $wpdb->get_var( str_replace( 'ID AS order_id', 'COUNT(ID) AS order_count', $sql ) );
@@ -486,7 +500,8 @@ class WC_Order_Export_Engine {
486
echo join( "\n\n", $s );
487
echo '</textarea>';
488
}
489
- $formater->finish();
490
}
491
492
// no action woe_export_finished here!
@@ -524,7 +539,9 @@ class WC_Order_Export_Engine {
524
$sql .= " LIMIT " . intval( $limit );
525
}
526
527
- $order_ids = apply_filters( "woe_get_order_ids", $wpdb->get_col( $sql ) );
528
self::$orders_for_export = $order_ids;
529
530
if ( empty( $order_ids ) AND apply_filters( 'woe_schedule_job_skip_empty_file',
15
public static $make_separate_orders = false;
16
17
public static function make_filename( $mask ) {
18
+ $time = apply_filters( 'woe_make_filename_current_time', current_time( 'timestamp' ) );
19
+ $date = WC_Order_Export_Data_Extractor::get_date_range( self::$current_job_settings, false );
20
+ $args = array(
21
+ '%d' => date( 'd', $time ),
22
+ '%m' => date( 'm', $time ),
23
+ '%y' => date( 'Y', $time ),
24
+ '%h' => date( 'H', $time ),
25
+ '%i' => date( 'i', $time ),
26
+ '%s' => date( 's', $time ),
27
+ '%order_id' => self::$order_id,
28
+ '%orderid' => self::$order_id,
29
+ '%id' => self::$order_id,
30
+ '{from_date}' => isset( $date['from_date'] ) ? date( "Y-m-d", strtotime( $date['from_date'] ) ) : '',
31
+ '{to_date}' => isset( $date['to_date'] ) ? date( "Y-m-d", strtotime( $date['to_date'] ) ) : '',
32
+ );
33
+
34
if ( self::$make_separate_orders && strpos( $mask, '%order_id' ) === false ) {
35
$mask_parts = explode( '.', $mask );
36
$before_prefix = count( $mask_parts ) > 1 ? 2 : 1;
37
$mask_parts[ count( $mask_parts ) - $before_prefix ] .= '-%order_id';
38
$mask = implode( '.', $mask_parts );
39
}
40
41
+ if ( strpos( $mask, '{order_number}' ) !== false && ( self::$current_job_build_mode === 'full' ) ) {
42
+ $wc_order = new WC_Order( self::$order_id );
43
+ $order_number = $wc_order->get_order_number();
44
+ $args['{order_number}'] = $order_number;
45
+ }
46
47
+ $subst = apply_filters( 'woe_make_filename_replacements', $args );
48
49
return apply_filters( 'woe_make_filename', strtr( $mask, $subst ) );
50
}
264
$options['item_rows_start_from_new_line'] = ( $format == 'csv' AND @$settings['format_csv_item_rows_start_from_new_line'] OR $format == 'tsv' AND @$settings['format_tsv_item_rows_start_from_new_line'] ) ;
265
$options['products_mode'] = isset( $settings['duplicated_fields_settings']['products']['repeat'] ) ? $settings['duplicated_fields_settings']['products']['repeat'] : "";
266
$options['coupons_mode'] = isset( $settings['duplicated_fields_settings']['coupons']['repeat'] ) ? $settings['duplicated_fields_settings']['coupons']['repeat'] : "";
267
+ $options['billing_details_for_shipping'] = '1' === $settings['billing_details_for_shipping'];
268
if ( ! empty( $settings['all_products_from_order'] ) ) {
269
$options['include_products'] = false;
270
} else {
271
$options['include_products'] = $wpdb->get_col( WC_Order_Export_Data_Extractor::sql_get_product_ids( $settings ) );
272
}
273
274
+ if ( empty( $settings['export_matched_items'] ) ) {
275
+ $options['export_matched_items'] = false;
276
+ } else {
277
+ $options['export_matched_items']['item_metadata'] = WC_Order_Export_Data_Extractor::parse_complex_pairs($settings['item_metadata']);
278
+ $options['export_matched_items']['item_names'] = WC_Order_Export_Data_Extractor::parse_complex_pairs($settings['item_names']);
279
+ }
280
+
281
if ( isset( $settings['date_format'] ) ) {
282
$options['date_format'] = $settings['date_format'];
283
} else {
331
if ( ! isset( $settings['skip_empty_file'] ) ) {
332
$settings['skip_empty_file'] = true;
333
}
334
+ //
335
+ if ( $settings['custom_php'] ) {
336
ob_start( array( 'WC_Order_Export_Engine', 'code_error_callback' ) );
337
$result = eval( $settings['custom_php_code'] );
338
ob_end_clean();
424
425
426
//get IDs
427
+ $sql = WC_Order_Export_Data_Extractor::sql_get_order_ids( $settings );//backtrace
428
$settings = self::replace_sort_field( $settings );
429
if ( $make_mode == 'estimate' OR $make_mode =='estimate_preview' ) { //if estimate return total count
430
return $wpdb->get_var( str_replace( 'ID AS order_id', 'COUNT(ID) AS order_count', $sql ) );
500
echo join( "\n\n", $s );
501
echo '</textarea>';
502
}
503
+
504
+ $formater->finish(); //backtrace
505
}
506
507
// no action woe_export_finished here!
539
$sql .= " LIMIT " . intval( $limit );
540
}
541
542
+ if ( !$order_ids OR apply_filters("woe_filter_bulk_action_export",false) ) {
543
+ $order_ids = apply_filters( "woe_get_order_ids", $wpdb->get_col( $sql ) );
544
+ }
545
self::$orders_for_export = $order_ids;
546
547
if ( empty( $order_ids ) AND apply_filters( 'woe_schedule_job_skip_empty_file',
classes/core/class-wc-order-export-order-fields.php CHANGED
@@ -22,23 +22,30 @@ class WC_Order_Export_Order_Fields {
22
$this->options = $options;
23
$this->export = $export;
24
$this->order = $order;
25
- $this->order_id = $order->get_id();
26
-
27
28
// get order meta
29
$this->order_meta = array();
30
if ( $order_post_meta = get_post_meta( $this->order_id ) ) {
31
foreach ( $order_post_meta as $meta_key => $meta_values ) {
32
- $this->order_meta[ $meta_key ] = join( WC_Order_Export_Data_Extractor::$export_custom_fields_separator, $meta_values );
33
}
34
}
35
36
37
38
// add fields for WC 3.0
39
- foreach ( array( "billing_country", "billing_state", "shipping_country", "shipping_state" ) as $field_30 ) {
40
$this->$field_30 = method_exists( $this->order,
41
'get_' . $field_30 ) ? $this->order->{'get_' . $field_30}() : $this->order->$field_30;
42
}
43
44
$parent_order_id = method_exists( $this->order,
@@ -62,14 +69,7 @@ class WC_Order_Export_Order_Fields {
62
63
//refund rewrites it
64
if ( $overwrite_child_order_meta ) {
65
- foreach (
66
- array(
67
- "billing_country",
68
- "billing_state",
69
- "shipping_country",
70
- "shipping_state",
71
- ) as $field_30
72
- ) {
73
$this->$field_30 = method_exists( $this->parent_order,
74
'get_' . $field_30 ) ? $this->parent_order->{'get_' . $field_30}() : $this->parent_order->$field_30;
75
}
@@ -83,14 +83,51 @@ class WC_Order_Export_Order_Fields {
83
// extra WP_User
84
$this->user = ! empty( $this->order_meta['_customer_user'] ) ? get_userdata( $this->order_meta['_customer_user'] ) : false;
85
// setup missed fields for full addresses
86
- $optional_fields = array( '_billing_address_1', '_billing_address_2', '_billing_first_name', '_billing_last_name', '_shipping_address_1', '_shipping_address_2', '_shipping_first_name', '_shipping_last_name' );
87
- foreach ($optional_fields as $optional_field ) {
88
if ( ! isset( $this->order_meta[ $optional_field ] ) ) {
89
$this->order_meta[ $optional_field ] = '';
90
}
91
}
92
93
$this->order_meta = apply_filters( 'woe_fetch_order_meta', $this->order_meta, $this->order_id );
94
}
95
96
public function set_data($data) {
@@ -378,9 +415,9 @@ class WC_Order_Export_Order_Fields {
378
} elseif ( isset( $this->order_meta[ "_" . $field ] ) ) { // or hidden field
379
$row[$field] = $this->order_meta[ "_" . $field ];
380
} else { // order_date...
381
- $row[$field] = method_exists( $this->order,
382
- 'get_' . $field ) ? $this->order->{'get_' . $field}() : get_post_meta( $this->order_id, '_' . $field, true );
383
- //print_r($field."=".$label); echo "debug static!\n\n";
384
}
385
return $row;
386
22
$this->options = $options;
23
$this->export = $export;
24
$this->order = $order;
25
+ $this->order_id = method_exists( $this->order, 'get_id' ) ? $order->get_id() : $order->id;
26
+
27
28
// get order meta
29
$this->order_meta = array();
30
if ( $order_post_meta = get_post_meta( $this->order_id ) ) {
31
foreach ( $order_post_meta as $meta_key => $meta_values ) {
32
+ if( apply_filters('woe_use_first_order_meta', false) )
33
+ $this->order_meta[ $meta_key ] = array_shift( $meta_values );
34
+ else
35
+ $this->order_meta[ $meta_key ] = join( WC_Order_Export_Data_Extractor::$export_custom_fields_separator, $meta_values );
36
}
37
}
38
39
40
41
// add fields for WC 3.0
42
+ $billing_fields = array( "billing_country", "billing_state" );
43
+ $shipping_fields = array( "shipping_country", "shipping_state" );
44
+ $fields_30 = array_merge( $billing_fields, $shipping_fields );
45
+ foreach ( $fields_30 as $field_30 ) {
46
$this->$field_30 = method_exists( $this->order,
47
'get_' . $field_30 ) ? $this->order->{'get_' . $field_30}() : $this->order->$field_30;
48
+
49
}
50
51
$parent_order_id = method_exists( $this->order,
69
70
//refund rewrites it
71
if ( $overwrite_child_order_meta ) {
72
+ foreach ( $fields_30 as $field_30 ) {
73
$this->$field_30 = method_exists( $this->parent_order,
74
'get_' . $field_30 ) ? $this->parent_order->{'get_' . $field_30}() : $this->parent_order->$field_30;
75
}
83
// extra WP_User
84
$this->user = ! empty( $this->order_meta['_customer_user'] ) ? get_userdata( $this->order_meta['_customer_user'] ) : false;
85
// setup missed fields for full addresses
86
+ $optional_billing_fields = array( '_billing_address_1', '_billing_address_2', '_billing_first_name', '_billing_last_name', '_billing_city', '_billing_postcode', '_billing_country', '_billing_state' );
87
+ $optional_shipping_fields = array( '_shipping_address_1', '_shipping_address_2', '_shipping_first_name', '_shipping_last_name', '_shipping_city', '_shipping_postcode', '_shipping_country', '_shipping_state' );
88
+ $optional_fields = array_merge( $optional_billing_fields, $optional_shipping_fields );
89
+ foreach ( $optional_fields as $optional_field ) {
90
+
91
if ( ! isset( $this->order_meta[ $optional_field ] ) ) {
92
$this->order_meta[ $optional_field ] = '';
93
}
94
}
95
+
96
+ //method WC_Order::has_shipping_address checks only these 2 fields, so we have to add filter
97
+ $has_shipping_address = false;
98
+ $has_shipping_validate_keys = apply_filters( "woe_has_shipping_validate_keys", array( "_shipping_address_1", "_shipping_address_2" ) );
99
+ foreach($has_shipping_validate_keys as $shippping_key ) {
100
+ if( !empty($this->order_meta[$shippping_key]) )
101
+ $has_shipping_address = true;
102
+ }
103
+
104
+ if ( $this->options['billing_details_for_shipping'] && !$has_shipping_address ) {
105
+ $this->set_shipping_fields( $optional_shipping_fields );
106
+ }
107
108
$this->order_meta = apply_filters( 'woe_fetch_order_meta', $this->order_meta, $this->order_id );
109
+ //$optional_billing_fields = array( 'billing_country', 'billing_state', '_billing_address_1', '_billing_address_2', '_billing_first_name', '_billing_last_name', '_billing_city', '_billing_postcode', '_billing_country', '_billing_state' );
110
+ }
111
+
112
+ public function set_shipping_fields( $shippings_fields ) {
113
+
114
+ foreach ( $shippings_fields as $shipping_field ) {
115
+
116
+ $billing_field = str_replace( "shipping_", "billing_", $shipping_field );
117
+
118
+ $this->order_meta[ $shipping_field ] = $this->order_meta[ $billing_field ];
119
+
120
+ $_shipping_field = substr($shipping_field, 1);
121
+
122
+ if (method_exists( $this->order, 'set_' . $_shipping_field )) {
123
+ $this->order->{ 'set_' . $_shipping_field }( $this->order_meta[ $billing_field ] );
124
+ } else {
125
+ $this->order->$_shipping_field = $this->order_meta[ $billing_field ];
126
+ }
127
+ }
128
+
129
+ $this->shipping_country = $this->billing_country;
130
+ $this->shipping_state = $this->billing_state;
131
}
132
133
public function set_data($data) {
415
} elseif ( isset( $this->order_meta[ "_" . $field ] ) ) { // or hidden field
416
$row[$field] = $this->order_meta[ "_" . $field ];
417
} else { // order_date...
418
+ $row[$field] = method_exists( $this->order,
419
+ 'get_' . $field ) ? $this->order->{'get_' . $field}() : get_post_meta( $this->order_id, '_' . $field, true );
420
+ //print_r($field."=".$label); echo "debug static!\n\n";
421
}
422
return $row;
423
classes/core/class-wc-order-export-order-product-fields.php CHANGED
@@ -159,13 +159,10 @@ class WC_Order_Export_Order_Product_Fields {
159
$field_value = $this->item_id;
160
} elseif ( $field == 'item_price' ) {
161
$field_value = $this->order->get_item_total( $this->item, false, true ); // YES we have to calc item price
162
} elseif ( $field == 'discount_amount' ) {
163
- if ( method_exists( $this->item, "get_subtotal" ) ) {
164
- $field_value = $this->item->get_subtotal() - $this->item->get_total();
165
- } else //2.6
166
- {
167
- $field_value = $this->item['line_subtotal'] - $this->item['line_total'];
168
- }
169
} elseif ( $field == 'tax_rate' ) {
170
if ( method_exists( $this->item, "get_subtotal" ) ) {
171
$subtotal_amount = $this->item->get_subtotal();
@@ -204,6 +201,12 @@ class WC_Order_Export_Order_Product_Fields {
204
}
205
$field_value = implode( "\n", $links );
206
}
207
} elseif ( $field == 'item_download_url' ) {
208
$field_value = '';
209
if ( $this->product AND $this->product->is_downloadable() ) {
@@ -268,4 +271,23 @@ class WC_Order_Export_Order_Product_Fields {
268
}
269
return $field_value;
270
}
271
}
159
$field_value = $this->item_id;
160
} elseif ( $field == 'item_price' ) {
161
$field_value = $this->order->get_item_total( $this->item, false, true ); // YES we have to calc item price
162
+ } elseif ( $field == 'item_price_before_discount' ) {
163
+ $field_value = $this->order->get_item_subtotal( $this->item );
164
} elseif ( $field == 'discount_amount' ) {
165
+ $field_value = $this->get_item_discount();
166
} elseif ( $field == 'tax_rate' ) {
167
if ( method_exists( $this->item, "get_subtotal" ) ) {
168
$subtotal_amount = $this->item->get_subtotal();
201
}
202
$field_value = implode( "\n", $links );
203
}
204
+ } elseif ( $field == 'item_discount_tax' ) {
205
+ $field_value = $this->get_item_discount() * $this->get_item_tax_rate()/100;
206
+ } elseif ( $field == 'item_discount_amount_and_tax' ) {
207
+ $item_discount = $this->get_item_discount();
208
+ $item_tax_rate = $this->get_item_tax_rate();
209
+ $field_value = $item_discount * ( 1 + $item_tax_rate / 100 );
210
} elseif ( $field == 'item_download_url' ) {
211
$field_value = '';
212
if ( $this->product AND $this->product->is_downloadable() ) {
271
}
272
return $field_value;
273
}
274
+
275
+ private function get_item_discount() {
276
+ if ( method_exists( $this->item, "get_subtotal" ) ) {
277
+ $item_discount = wc_format_decimal( $this->item->get_subtotal() - $this->item->get_total(), '');
278
+ } else {
279
+ $item_discount = $this->item['line_subtotal'] - $this->item['line_total'];
280
+ }
281
+ return $item_discount;
282
+ }
283
+ private function get_item_tax_rate() {
284
+ if ( method_exists( $this->item, "get_subtotal" ) ) {
285
+ $subtotal_amount = $this->item->get_subtotal();
286
+ $subtotal_tax = $this->item->get_subtotal_tax();
287
+ } else {
288
+ $subtotal_amount = $this->item['line_subtotal'];
289
+ $subtotal_tax = $this->item['line_subtotal_tax'];
290
+ }
291
+ return ( $subtotal_amount <> 0 ) ? round( 100 * $subtotal_tax / $subtotal_amount, apply_filters('woe_tax_rate_rounding_precision', 2) ) : 0;
292
+ }
293
}
classes/formats/abstract-class-woe-formatter-plain-format.php CHANGED
@@ -39,8 +39,10 @@ abstract class WOE_Formatter_Plain_Format extends WOE_Formatter {
39
}
40
41
$this->summary_processing = false; //true only when we finish order scan
42
-
43
$this->encoding = isset( $this->settings['encoding'] ) ? $this->settings['encoding'] : '';
44
}
45
46
// calculate max columns based on order items
39
}
40
41
$this->summary_processing = false; //true only when we finish order scan
42
$this->encoding = isset( $this->settings['encoding'] ) ? $this->settings['encoding'] : '';
43
+ if ( isset( $this->settings['add_utf8_bom'] ) && $this->settings['add_utf8_bom'] ) {
44
+ $this->encoding = "UTF-8";
45
+ }
46
}
47
48
// calculate max columns based on order items
classes/formats/abstract-class-woe-formatter-sv.php CHANGED
@@ -41,7 +41,7 @@ abstract class WOE_Formatter_sv extends WOE_Formatter_Plain_Format {
41
$data = apply_filters( "woe_{$this->format}_header_filter", $data );
42
$this->prepare_array( $data );
43
parent::start( $data );
44
-
45
if ( ! empty( $this->settings['add_utf8_bom'] ) ) {
46
fwrite( $this->handle, chr( 239 ) . chr( 187 ) . chr( 191 ) );
47
}
@@ -121,7 +121,7 @@ abstract class WOE_Formatter_sv extends WOE_Formatter_Plain_Format {
121
$arr = array_map( array( $this, 'stop_csv_injection' ), $arr );
122
}
123
124
- if ( ! in_array( $this->encoding, array( '', 'utf-8', 'UTF-8' ) ) ) {
125
$arr = array_map( array( $this, 'encode_value' ), $arr );
126
}
127
}
41
$data = apply_filters( "woe_{$this->format}_header_filter", $data );
42
$this->prepare_array( $data );
43
parent::start( $data );
44
+
45
if ( ! empty( $this->settings['add_utf8_bom'] ) ) {
46
fwrite( $this->handle, chr( 239 ) . chr( 187 ) . chr( 191 ) );
47
}
121
$arr = array_map( array( $this, 'stop_csv_injection' ), $arr );
122
}
123
124
+ if ( $this->mode !== 'preview' AND ! in_array( $this->encoding, array( '', 'utf-8', 'UTF-8' ) ) ) {
125
$arr = array_map( array( $this, 'encode_value' ), $arr );
126
}
127
}
classes/formats/class-woe-formatter-html.php CHANGED
@@ -180,26 +180,6 @@ class WOE_Formatter_Html extends WOE_Formatter_Plain_Format {
180
}
181
182
protected function prepare_array( &$arr ) {
183
- if ( apply_filters( "woe_stop_csv_injection", true ) ) {
184
- $arr = array_map( array( $this, 'stop_csv_injection' ), $arr );
185
- }
186
-
187
- if ( ! in_array( $this->encoding, array( '', 'utf-8', 'UTF-8' ) ) ) {
188
- $arr = array_map( array( $this, 'encode_value' ), $arr );
189
- }
190
- }
191
-
192
- protected function stop_csv_injection( $value ) {
193
- $formula_chars = array( "=", "+", "-", "@" );
194
- if ( in_array( substr( $value, 0, 1 ), $formula_chars ) ) {
195
- $value = " " . $value;
196
- }
197
-
198
- return $value;
199
- }
200
-
201
- protected function encode_value( $value ) {
202
- return iconv( 'UTF-8', $this->encoding, $value );
203
}
204
205
protected function get_prepared_css() {
180
}
181
182
protected function prepare_array( &$arr ) {
183
}
184
185
protected function get_prepared_css() {
classes/formats/class-woe-formatter-pdf.php CHANGED
@@ -173,6 +173,7 @@ class WOE_Formatter_PDF extends WOE_Formatter_Csv {
173
'size' => $this->font_size,
174
'text_color' => $this->hex2RGB( $this->settings['table_row_text_color'] ),
175
'background_color' => $this->hex2RGB( $this->settings['table_row_background_color'] ),
176
),
177
'footer' => array(
178
'title' => $this->settings['footer_text'],
@@ -210,13 +211,11 @@ class WOE_Formatter_PDF extends WOE_Formatter_Csv {
210
'value' => $source,
211
);
212
}
213
- $row_height = $this->settings['row_images_height'] ? $this->settings['row_images_height']: null;
214
- } else {
215
- $row_height = null;
216
}
217
$row = apply_filters( 'woe_pdf_prepare_row', $row );
218
$row_style = apply_filters("woe_pdf_before_print_row", null, $row, $this->pdf, $this);
219
- $this->pdf->addRow( $row, null, $row_height, $row_style );
220
$row = fgetcsv( $this->handle, 0, $this->delimiter, $this->enclosure );
221
}
222
173
'size' => $this->font_size,
174
'text_color' => $this->hex2RGB( $this->settings['table_row_text_color'] ),
175
'background_color' => $this->hex2RGB( $this->settings['table_row_background_color'] ),
176
+ 'image_height' => $this->settings['row_images_height'],
177
),
178
'footer' => array(
179
'title' => $this->settings['footer_text'],
211
'value' => $source,
212
);
213
}
214
}
215
+
216
$row = apply_filters( 'woe_pdf_prepare_row', $row );
217
$row_style = apply_filters("woe_pdf_before_print_row", null, $row, $this->pdf, $this);
218
+ $this->pdf->addRow( $row, null, null, $row_style );
219
$row = fgetcsv( $this->handle, 0, $this->delimiter, $this->enclosure );
220
}
221
i18n/languages/woo-order-export-lite.pot CHANGED
@@ -3,7 +3,7 @@ msgid ""
3
msgstr ""
4
"Project-Id-Version: Advanced Order Export For WooCommerce\n"
5
"Report-Msgid-Bugs-To: \n"
6
- "POT-Creation-Date: 2019-11-18 07:34+0000\n"
7
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
8
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
9
"Language-Team: \n"
@@ -13,97 +13,97 @@ msgstr ""
13
"Content-Type: text/plain; charset=UTF-8\n"
14
"Content-Transfer-Encoding: 8bit\n"
15
"X-Generator: Loco https://localise.biz/\n"
16
- "X-Loco-Version: 2.3.1; wp-5.3"
17
18
- #: classes/class-wc-order-export-admin.php:505
19
#, php-format
20
msgid "%s order marked."
21
msgid_plural "%s orders marked."
22
msgstr[0] ""
23
msgstr[1] ""
24
25
- #: classes/class-wc-order-export-admin.php:514
26
#, php-format
27
msgid "%s order unmarked."
28
msgid_plural "%s orders unmarked."
29
msgstr[0] ""
30
msgstr[1] ""
31
32
- #: view/settings-form.php:46 view/settings-form.php:690
33
- #: view/settings-form.php:716
34
msgid "-"
35
msgstr ""
36
37
- #: view/settings-form.php:776
38
msgid "- don't modify -"
39
msgstr ""
40
41
- #: view/settings-form.php:556
42
msgid "0 - auto scale"
43
msgstr ""
44
45
- #: classes/class-wc-order-export-admin.php:228
46
msgid "1st row only"
47
msgstr ""
48
49
- #: classes/core/class-wc-order-export-data-extractor.php:1755
50
msgid "[Rest of the World]"
51
msgstr ""
52
53
- #: view/settings-form.php:1471 view/settings-form.php:1482
54
msgid "Actions"
55
msgstr ""
56
57
- #: classes/class-wc-order-export-admin.php:223
58
msgid "Add"
59
msgstr ""
60
61
- #: classes/class-wc-order-export-admin.php:216
62
#, php-format
63
msgid "Add %s fields"
64
msgstr ""
65
66
- #: view/settings-form.php:1485
67
msgid "Add fee"
68
msgstr ""
69
70
- #: view/settings-form.php:1474
71
msgid "Add field"
72
msgstr ""
73
74
- #: view/settings-form.php:1488
75
msgid "Add shipping"
76
msgstr ""
77
78
- #: view/settings-form.php:1477
79
msgid "Add static field"
80
msgstr ""
81
82
- #: view/settings-form.php:1491
83
msgid "Add tax"
84
msgstr ""
85
86
- #: classes/core/class-wc-order-export-data-extractor-ui.php:771
87
msgid "Address 1 (Billing)"
88
msgstr ""
89
90
- #: classes/core/class-wc-order-export-data-extractor-ui.php:861
91
msgid "Address 1 (Shipping)"
92
msgstr ""
93
94
- #: classes/core/class-wc-order-export-data-extractor-ui.php:766
95
msgid "Address 1&2 (Billing)"
96
msgstr ""
97
98
- #: classes/core/class-wc-order-export-data-extractor-ui.php:856
99
msgid "Address 1&2 (Shipping)"
100
msgstr ""
101
102
- #: classes/core/class-wc-order-export-data-extractor-ui.php:776
103
msgid "Address 2 (Billing)"
104
msgstr ""
105
106
- #: classes/core/class-wc-order-export-data-extractor-ui.php:866
107
msgid "Address 2 (Shipping)"
108
msgstr ""
109
@@ -111,7 +111,7 @@ msgstr ""
111
msgid "Advanced Order Export For WooCommerce"
112
msgstr ""
113
114
- #: classes/class-wc-order-export-admin.php:128
115
msgid ""
116
"Advanced Order Export For WooCommerce is available <a href=\"admin.php?"
117
"page=wc-order-export\">on this page</a>."
@@ -125,15 +125,15 @@ msgstr ""
125
msgid "All"
126
msgstr ""
127
128
- #: classes/class-wc-order-export-admin.php:227
129
msgid "all rows"
130
msgstr ""
131
132
- #: view/settings-form.php:1231
133
msgid "Any coupon used"
134
msgstr ""
135
136
- #: view/settings-form.php:343
137
msgid "Append XML"
138
msgstr ""
139
@@ -141,24 +141,24 @@ msgstr ""
141
msgid "Are you sure to continue?"
142
msgstr ""
143
144
- #: classes/class-wc-order-export-admin.php:224
145
msgid "as"
146
msgstr ""
147
148
- #: view/settings-form.php:760
149
msgid "Ascending"
150
msgstr ""
151
152
- #: view/settings-form.php:257
153
msgid "Auto column width"
154
msgstr ""
155
156
- #: classes/core/class-wc-order-export-data-extractor-ui.php:1248
157
- #: classes/core/class-wc-order-export-data-extractor-ui.php:1271
158
msgid "Billing Address"
159
msgstr ""
160
161
- #: view/settings-form.php:1255
162
msgid "Billing locations"
163
msgstr ""
164
@@ -181,7 +181,7 @@ msgstr ""
181
msgid "can not open for output"
182
msgstr ""
183
184
- #: classes/admin/tabs/ajax/trait-wc-order-export-admin-tab-abstract-ajax-export.php:42
185
msgid "Can't create temporary file"
186
msgstr ""
187
@@ -189,73 +189,73 @@ msgstr ""
189
msgid "Can't find exported file"
190
msgstr ""
191
192
- #: view/settings-form.php:1528 view/settings-form.php:1549
193
- #: view/settings-form.php:1585 view/settings-form.php:1624
194
- #: view/settings-form.php:1646 view/settings-form.php:1676
195
- #: view/settings-form.php:1698 view/settings-form.php:1724
196
- #: view/settings-form.php:1747 view/settings-form.php:1769
197
- #: view/settings-form.php:1791 view/settings-form.php:1813
198
msgid "Cancel"
199
msgstr ""
200
201
- #: classes/core/class-wc-order-export-data-extractor-ui.php:1254
202
- #: classes/core/class-wc-order-export-data-extractor-ui.php:1278
203
msgid "Cart"
204
msgstr ""
205
206
- #: classes/core/class-wc-order-export-data-extractor-ui.php:1087
207
msgid "Cart Discount Amount"
208
msgstr ""
209
210
- #: classes/core/class-wc-order-export-data-extractor-ui.php:1092
211
msgid "Cart Discount Amount Tax"
212
msgstr ""
213
214
- #: classes/core/class-wc-order-export-data-extractor-ui.php:400
215
msgid "Category"
216
msgstr ""
217
218
- #: view/settings-form.php:443
219
msgid "Center align"
220
msgstr ""
221
222
- #: view/settings-form.php:771
223
msgid "Change order status to"
224
msgstr ""
225
226
- #: view/settings-form.php:316 view/settings-form.php:391
227
msgid "Character encoding"
228
msgstr ""
229
230
- #: classes/core/class-wc-order-export-data-extractor-ui.php:781
231
msgid "City (Billing)"
232
msgstr ""
233
234
- #: classes/core/class-wc-order-export-data-extractor-ui.php:871
235
msgid "City (Shipping)"
236
msgstr ""
237
238
- #: classes/core/class-wc-order-export-data-extractor-ui.php:796
239
msgid "City, State Zip (Billing)"
240
msgstr ""
241
242
- #: classes/core/class-wc-order-export-data-extractor-ui.php:886
243
msgid "City, State Zip (Shipping)"
244
msgstr ""
245
246
- #: classes/core/class-wc-order-export-data-extractor-ui.php:791
247
msgid "City, State, Zip (Billing)"
248
msgstr ""
249
250
- #: classes/core/class-wc-order-export-data-extractor-ui.php:881
251
msgid "City, State, Zip (Shipping)"
252
msgstr ""
253
254
- #: view/settings-form.php:818
255
msgid "Cleanup phone (export only digits)"
256
msgstr ""
257
258
- #: view/settings-form.php:1892
259
msgid "Click here to download"
260
msgstr ""
261
@@ -263,67 +263,67 @@ msgstr ""
263
msgid "code snippets"
264
msgstr ""
265
266
- #: view/settings-form.php:1518 view/settings-form.php:1534
267
- #: view/settings-form.php:1575 view/settings-form.php:1616
268
- #: view/settings-form.php:1630 view/settings-form.php:1668
269
- #: view/settings-form.php:1682 view/settings-form.php:1715
270
- #: view/settings-form.php:1730 view/settings-form.php:1759
271
- #: view/settings-form.php:1781 view/settings-form.php:1803
272
msgid "Column name"
273
msgstr ""
274
275
- #: classes/class-wc-order-export-admin.php:219
276
msgid "columns"
277
msgstr ""
278
279
- #: view/settings-form.php:600
280
msgid "Columns align"
281
msgstr ""
282
283
- #: view/settings-form.php:472
284
msgid "Columns horizontal align"
285
msgstr ""
286
287
- #: view/settings-form.php:483
288
msgid "Columns vertical align"
289
msgstr ""
290
291
- #: view/settings-form.php:462
292
msgid "Columns width"
293
msgstr ""
294
295
- #: view/settings-form.php:463 view/settings-form.php:601
296
msgid "comma separated list"
297
msgstr ""
298
299
- #: classes/core/class-wc-order-export-data-extractor-ui.php:1246
300
- #: classes/core/class-wc-order-export-data-extractor-ui.php:1269
301
msgid "Common"
302
msgstr ""
303
304
- #: classes/core/class-wc-order-export-data-extractor-ui.php:761
305
msgid "Company (Billing)"
306
msgstr ""
307
308
- #: classes/core/class-wc-order-export-data-extractor-ui.php:851
309
msgid "Company (Shipping)"
310
msgstr ""
311
312
#: view/settings-form.php:167
313
- #: classes/core/class-wc-order-export-data-extractor-ui.php:616
314
msgid "Completed Date"
315
msgstr ""
316
317
- #: view/settings-form.php:1526 view/settings-form.php:1547
318
- #: view/settings-form.php:1583 view/settings-form.php:1622
319
- #: view/settings-form.php:1644 view/settings-form.php:1674
320
- #: view/settings-form.php:1696 view/settings-form.php:1722
321
- #: view/settings-form.php:1744 view/settings-form.php:1766
322
- #: view/settings-form.php:1788 view/settings-form.php:1810
323
msgid "Confirm"
324
msgstr ""
325
326
- #: view/settings-form.php:298
327
msgid "Convert line breaks to literals"
328
msgstr ""
329
@@ -333,128 +333,128 @@ msgid ""
333
"install."
334
msgstr ""
335
336
- #: classes/core/class-wc-order-export-data-extractor-ui.php:811
337
msgid "Country Code (Billing)"
338
msgstr ""
339
340
- #: classes/core/class-wc-order-export-data-extractor-ui.php:901
341
msgid "Country Code (Shipping)"
342
msgstr ""
343
344
- #: classes/core/class-wc-order-export-data-extractor-ui.php:816
345
msgid "Country Name (Billing)"
346
msgstr ""
347
348
- #: classes/core/class-wc-order-export-data-extractor-ui.php:906
349
msgid "Country Name (Shipping)"
350
msgstr ""
351
352
- #: classes/core/class-wc-order-export-data-extractor-ui.php:536
353
msgid "Coupon Amount"
354
msgstr ""
355
356
- #: classes/core/class-wc-order-export-data-extractor-ui.php:507
357
msgid "Coupon Code"
358
msgstr ""
359
360
- #: classes/core/class-wc-order-export-data-extractor-ui.php:527
361
msgid "Coupon Description"
362
msgstr ""
363
364
- #: view/settings-form.php:340
365
msgid "Coupon tag"
366