Advanced Order Export For WooCommerce - Version 3.0.3

Version Description

  • 2019-08-29 =
  • Fixed CRITICAL bug - export wrong data if user added customer field "First Order Date" or "Last Order Date"
  • Fixed bug - customer fields "First Order Date" or "Last Order Date" were empty for guests
  • Fixed bug - wrong height for cells (PDF format only)
Download this release

Release Info

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

Code changes from version 3.0.2 to 3.0.3

classes/FPDF/class-woe-pdf-mc-table.php CHANGED
@@ -446,7 +446,7 @@ class WOE_PDF_MC_Table extends WOE_FPDF {
446
  if ( $w == 0 ) {
447
  $w = $this->GetPageWidth() - $this->getRightMargin() - $this->flt_position_x;
448
  }
449
- $wmax = ( $w - 2 * $this->int_cell_margin ) * 1000 / $this->int_font_size_user;
450
  $s = str_replace( "\r", '', $txt );
451
  $text_len = strlen( $s );
452
  if ( $text_len > 0 and $s[ $text_len - 1 ] == "\n" ) {
446
  if ( $w == 0 ) {
447
  $w = $this->GetPageWidth() - $this->getRightMargin() - $this->flt_position_x;
448
  }
449
+ $wmax = ( $w - 2 * $this->int_cell_margin ) * 1000;
450
  $s = str_replace( "\r", '', $txt );
451
  $text_len = strlen( $s );
452
  if ( $text_len > 0 and $s[ $text_len - 1 ] == "\n" ) {
classes/core/class-wc-order-export-data-extractor.php CHANGED
@@ -2033,13 +2033,13 @@ class WC_Order_Export_Data_Extractor {
2033
  } elseif ( $field == 'customer_total_orders' ) {
2034
  $row[ $field ] = ( isset( $user->ID ) ) ? wc_get_customer_order_count( $user->ID ) : 0;
2035
  } elseif ( $field == 'customer_first_order_date' ) {
2036
- $order = ( isset( $user->ID ) ) ? self::get_customer_order( $user->ID, 'first' ) : false;
2037
- $row[ $field ] = $order ? ( $order->get_date_created() ? gmdate( 'Y-m-d H:i:s',
2038
- $order->get_date_created()->getOffsetTimestamp() ) : '' ) : '';
2039
  } elseif ( $field == 'customer_last_order_date' ) {
2040
- $order = ( isset( $user->ID ) ) ? self::get_customer_order( $user->ID, 'last' ) : false;
2041
- $row[ $field ] = $order ? ( $order->get_date_created() ? gmdate( 'Y-m-d H:i:s',
2042
- $order->get_date_created()->getOffsetTimestamp() ) : '' ) : '';
2043
  } elseif ( $field == 'billing_address' ) {
2044
  $row[ $field ] = join( ", ",
2045
  array_filter( array( $order_meta["_billing_address_1"], $order_meta["_billing_address_2"] ) ) );
@@ -2332,9 +2332,19 @@ class WC_Order_Export_Data_Extractor {
2332
  return $shipping_methods;
2333
  }
2334
 
2335
- private static function get_customer_order( $customer_id, $first_or_last ) {
2336
  global $wpdb;
2337
 
 
 
 
 
 
 
 
 
 
 
2338
  if ( 'first' === $first_or_last ) {
2339
  $direction = 'ASC';
2340
  } else if ( 'last' === $first_or_last ) {
@@ -2342,14 +2352,15 @@ class WC_Order_Export_Data_Extractor {
2342
  } else {
2343
  return false;
2344
  }
 
2345
 
2346
  $order = $wpdb->get_var(
2347
  // phpcs:disable WordPress.DB.PreparedSQL.NotPrepared
2348
  "SELECT posts.ID
2349
  FROM $wpdb->posts AS posts
2350
  LEFT JOIN {$wpdb->postmeta} AS meta on posts.ID = meta.post_id
2351
- WHERE meta.meta_key = '_customer_user'
2352
- AND meta.meta_value = '" . esc_sql( $customer_id ) . "'
2353
  AND posts.post_type = 'shop_order'
2354
  AND posts.post_status IN ( '" . implode( "','", array_map( 'esc_sql', array_keys( wc_get_order_statuses() ) ) ) . "' )
2355
  ORDER BY posts.ID {$direction}"
2033
  } elseif ( $field == 'customer_total_orders' ) {
2034
  $row[ $field ] = ( isset( $user->ID ) ) ? wc_get_customer_order_count( $user->ID ) : 0;
2035
  } elseif ( $field == 'customer_first_order_date' ) {
2036
+ $first_order = self::get_customer_order( $user, $order_meta, 'first' );
2037
+ $row[ $field ] = $first_order ? ( $first_order->get_date_created() ? gmdate( 'Y-m-d H:i:s',
2038
+ $first_order->get_date_created()->getOffsetTimestamp() ) : '' ) : '';
2039
  } elseif ( $field == 'customer_last_order_date' ) {
2040
+ $last_order = self::get_customer_order( $user, $order_meta, 'last' );
2041
+ $row[ $field ] = $last_order? ( $last_order->get_date_created() ? gmdate( 'Y-m-d H:i:s',
2042
+ $last_order->get_date_created()->getOffsetTimestamp() ) : '' ) : '';
2043
  } elseif ( $field == 'billing_address' ) {
2044
  $row[ $field ] = join( ", ",
2045
  array_filter( array( $order_meta["_billing_address_1"], $order_meta["_billing_address_2"] ) ) );
2332
  return $shipping_methods;
2333
  }
2334
 
2335
+ private static function get_customer_order( $user, $order_meta, $first_or_last ) {
2336
  global $wpdb;
2337
 
2338
+ if( isset($user->ID)) {
2339
+ $meta_key = "_customer_user";
2340
+ $meta_value = $user->ID;
2341
+ } elseif( !empty($order_meta["_billing_email"]) ) {
2342
+ $meta_key = "_billing_email";
2343
+ $meta_value = $order_meta["_billing_email"];
2344
+ } else {
2345
+ return false;
2346
+ }
2347
+
2348
  if ( 'first' === $first_or_last ) {
2349
  $direction = 'ASC';
2350
  } else if ( 'last' === $first_or_last ) {
2352
  } else {
2353
  return false;
2354
  }
2355
+
2356
 
2357
  $order = $wpdb->get_var(
2358
  // phpcs:disable WordPress.DB.PreparedSQL.NotPrepared
2359
  "SELECT posts.ID
2360
  FROM $wpdb->posts AS posts
2361
  LEFT JOIN {$wpdb->postmeta} AS meta on posts.ID = meta.post_id
2362
+ WHERE meta.meta_key = '" . $meta_key ."'
2363
+ AND meta.meta_value = '" . esc_sql( $meta_value ) . "'
2364
  AND posts.post_type = 'shop_order'
2365
  AND posts.post_status IN ( '" . implode( "','", array_map( 'esc_sql', array_keys( wc_get_order_statuses() ) ) ) . "' )
2366
  ORDER BY posts.ID {$direction}"
classes/formats/abstract-class-woe-formatter-plain-format.php CHANGED
@@ -344,6 +344,8 @@ abstract class WOE_Formatter_Plain_Format extends WOE_Formatter {
344
  $this->rows = array();
345
  }
346
  $this->rows += $_SESSION['woe_summary_products'];
 
 
347
  } else {
348
  foreach ( $_SESSION['woe_summary_products'] as $item ) {
349
  $this->output( $item );
@@ -369,6 +371,8 @@ abstract class WOE_Formatter_Plain_Format extends WOE_Formatter {
369
  $this->rows = array();
370
  }
371
  $this->rows += $_SESSION['woe_summary_customers'];
 
 
372
  } else {
373
  foreach ( $_SESSION['woe_summary_customers'] as $item ) {
374
  $this->output( $item );
344
  $this->rows = array();
345
  }
346
  $this->rows += $_SESSION['woe_summary_products'];
347
+ // reset non-numerical indexes -- 0 will be bold in preview
348
+ $this->rows = array_values($this->rows);
349
  } else {
350
  foreach ( $_SESSION['woe_summary_products'] as $item ) {
351
  $this->output( $item );
371
  $this->rows = array();
372
  }
373
  $this->rows += $_SESSION['woe_summary_customers'];
374
+ // reset non-numerical indexes -- 0 will be bold in preview
375
+ $this->rows = array_values($this->rows);
376
  } else {
377
  foreach ( $_SESSION['woe_summary_customers'] as $item ) {
378
  $this->output( $item );
classes/formats/class-woe-formatter-pdf.php CHANGED
@@ -136,17 +136,18 @@ class WOE_Formatter_PDF extends WOE_Formatter_Csv {
136
  }
137
 
138
  $this->pdf->SetFillColor( null );
139
- $this->pdf->setProperties( array(
 
140
  'header' => array(
141
  'title' => $this->settings['header_text'],
142
  'style' => 'B',
143
- 'size' => '10',
144
  'text_color' => $this->hex2RGB( $this->settings['page_header_text_color'] ),
145
- 'logo' => array(
146
- 'source' => $this->settings['logo_source_id'] ? get_attached_file( $this->settings['logo_source_id'], true ) : $this->settings['logo_source'],
147
- 'width' => $this->settings['logo_width'],
148
- 'height' => $this->settings['logo_height'],
149
- 'align' => $this->settings['logo_align'],
150
  ),
151
  ),
152
  'table' => array(
@@ -155,7 +156,7 @@ class WOE_Formatter_PDF extends WOE_Formatter_Csv {
155
  'solid_width' => $solid_width,
156
  ),
157
  'table_header' => array(
158
- 'size' => 10,
159
  'repeat' => $this->repeat_header,
160
  'text_color' => $this->hex2RGB( $this->settings['table_header_text_color'] ),
161
  'background_color' => $this->hex2RGB( $this->settings['table_header_background_color'] ),
@@ -168,11 +169,13 @@ class WOE_Formatter_PDF extends WOE_Formatter_Csv {
168
  'footer' => array(
169
  'title' => $this->settings['footer_text'],
170
  'style' => 'B',
171
- 'size' => '10',
172
  'text_color' => $this->hex2RGB( $this->settings['page_footer_text_color'] ),
173
  'pagination' => $this->settings['pagination'],
174
  ),
175
- ) );
 
 
176
  $this->pdf->SetAligns( explode( ",", $this->settings['cols_align'] ) );
177
  do_action("woe_pdf_started", $this->pdf, $this);
178
 
136
  }
137
 
138
  $this->pdf->SetFillColor( null );
139
+
140
+ $pdf_props = apply_filters( 'woe_formatter_pdf_properties', array(
141
  'header' => array(
142
  'title' => $this->settings['header_text'],
143
  'style' => 'B',
144
+ 'size' => $this->font_size,
145
  'text_color' => $this->hex2RGB( $this->settings['page_header_text_color'] ),
146
+ 'logo' => array(
147
+ 'source' => $this->settings['logo_source_id'] ? get_attached_file( $this->settings['logo_source_id'], true ) : $this->settings['logo_source'],
148
+ 'width' => $this->settings['logo_width'],
149
+ 'height' => $this->settings['logo_height'],
150
+ 'align' => $this->settings['logo_align'],
151
  ),
152
  ),
153
  'table' => array(
156
  'solid_width' => $solid_width,
157
  ),
158
  'table_header' => array(
159
+ 'size' => $this->font_size,
160
  'repeat' => $this->repeat_header,
161
  'text_color' => $this->hex2RGB( $this->settings['table_header_text_color'] ),
162
  'background_color' => $this->hex2RGB( $this->settings['table_header_background_color'] ),
169
  'footer' => array(
170
  'title' => $this->settings['footer_text'],
171
  'style' => 'B',
172
+ 'size' => $this->font_size,
173
  'text_color' => $this->hex2RGB( $this->settings['page_footer_text_color'] ),
174
  'pagination' => $this->settings['pagination'],
175
  ),
176
+ ), $this->settings );
177
+
178
+ $this->pdf->setProperties( $pdf_props );
179
  $this->pdf->SetAligns( explode( ",", $this->settings['cols_align'] ) );
180
  do_action("woe_pdf_started", $this->pdf, $this);
181
 
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-08-19 13:22+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"
3
  msgstr ""
4
  "Project-Id-Version: Advanced Order Export For WooCommerce\n"
5
  "Report-Msgid-Bugs-To: \n"
6
+ "POT-Creation-Date: 2019-08-28 13:20+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"
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: woocommerce,export,order,xls,csv,xml,woo export lite,export orders,orders
5
  Requires PHP: 5.4.0
6
  Requires at least: 4.7
7
  Tested up to: 5.2
8
- Stable tag: 3.0.2
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -109,6 +109,11 @@ Yes, you can email a request to aprokaev@gmail.com. We intensively develop this
109
 
110
  == Changelog ==
111
 
 
 
 
 
 
112
  = 3.0.2 - 2019-08-20 =
113
  * Added "Summary by customers" report
114
  * Format PDF supports UTF8 chars
5
  Requires PHP: 5.4.0
6
  Requires at least: 4.7
7
  Tested up to: 5.2
8
+ Stable tag: 3.0.3
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
109
 
110
  == Changelog ==
111
 
112
+ = 3.0.3 - 2019-08-29 =
113
+ * Fixed CRITICAL bug - export wrong data if user added customer field "First Order Date" or "Last Order Date"
114
+ * Fixed bug - customer fields "First Order Date" or "Last Order Date" were empty for guests
115
+ * Fixed bug - wrong height for cells (PDF format only)
116
+
117
  = 3.0.2 - 2019-08-20 =
118
  * Added "Summary by customers" report
119
  * Format PDF supports UTF8 chars
woo-order-export-lite.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: Export orders from WooCommerce with ease (Excel/CSV/XML/JSON supported)
6
  * Author: AlgolPlus
7
  * Author URI: https://algolplus.com/
8
- * Version: 3.0.2
9
  * Text Domain: woo-order-export-lite
10
  * Domain Path: /i18n/languages/
11
  * WC requires at least: 2.6.0
@@ -39,7 +39,7 @@ if ( class_exists( 'WC_Order_Export_Admin' ) ) {
39
  return;
40
  }
41
 
42
- define( 'WOE_VERSION', '3.0.2' );
43
  define( 'WOE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
44
  define( 'WOE_PLUGIN_BASEPATH', dirname( __FILE__ ) );
45
 
5
  * Description: Export orders from WooCommerce with ease (Excel/CSV/XML/JSON supported)
6
  * Author: AlgolPlus
7
  * Author URI: https://algolplus.com/
8
+ * Version: 3.0.3
9
  * Text Domain: woo-order-export-lite
10
  * Domain Path: /i18n/languages/
11
  * WC requires at least: 2.6.0
39
  return;
40
  }
41
 
42
+ define( 'WOE_VERSION', '3.0.3' );
43
  define( 'WOE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
44
  define( 'WOE_PLUGIN_BASEPATH', dirname( __FILE__ ) );
45