Order Export & Order Import for WooCommerce - Version 1.6.0

Version Description

  • Bug Fix:- Delete uploaded CSV temp file after import.
Download this release

Release Info

Developer webtoffee
Plugin Icon 128x128 Order Export & Order Import for WooCommerce
Version 1.6.0
Comparing to
See all releases

Code changes from version 1.5.9 to 1.6.0

includes/importer/class-wf-cpnimpexpcsv-coupon-import.php CHANGED
@@ -277,6 +277,7 @@ class WF_CpnImpExpCsv_Coupon_Import extends WP_Importer {
277
  $wpdb->hide_errors();
278
 
279
  $this->processed_posts = isset( $_POST['processed_posts']) ? $_POST['processed_posts'] : array();
 
280
 
281
  _e( 'Step 1...', 'order-import-export-for-woocommerce' ) . ' ';
282
  wp_defer_term_counting( true );
@@ -286,6 +287,7 @@ class WF_CpnImpExpCsv_Coupon_Import extends WP_Importer {
286
  _e( 'Finalizing...', 'order-import-export-for-woocommerce' ) . ' ';
287
  // SUCCESS
288
  _e( 'Finished. Import complete.', 'order-import-export-for-woocommerce' );
 
289
  $this->import_end();
290
  exit;
291
  break;
277
  $wpdb->hide_errors();
278
 
279
  $this->processed_posts = isset( $_POST['processed_posts']) ? $_POST['processed_posts'] : array();
280
+ $file = isset($_POST['file']) ? stripslashes($_POST['file']) : '';
281
 
282
  _e( 'Step 1...', 'order-import-export-for-woocommerce' ) . ' ';
283
  wp_defer_term_counting( true );
287
  _e( 'Finalizing...', 'order-import-export-for-woocommerce' ) . ' ';
288
  // SUCCESS
289
  _e( 'Finished. Import complete.', 'order-import-export-for-woocommerce' );
290
+ unlink($file);
291
  $this->import_end();
292
  exit;
293
  break;
includes/importer/class-wf-csv-parser.php CHANGED
@@ -145,6 +145,7 @@ class WF_CSV_Parser {
145
  }
146
  $row++;
147
  if ($row <= $record_offset) {
 
148
  $WF_CSV_Order_Import->hf_order_log_data_change('order-csv-import', sprintf(__('> Row %s - skipped due to record offset.', 'order-import-export-for-woocommerce'), $row));
149
  unset($item);
150
  return;
@@ -159,12 +160,14 @@ class WF_CSV_Parser {
159
  if (is_numeric($order_number_formatted) && !$order_number)
160
  $order_number = $order_number_formatted; // use formatted for underlying order number if possible
161
  if ($order_number && !is_numeric($order_number)) {
 
162
  $WF_CSV_Order_Import->hf_order_log_data_change('order-csv-import', sprintf(__('> > Skipped. Order number field must be an integer: %s.', 'order-import-export-for-woocommerce'), $order_number));
163
  $skipped++;
164
  unset($item);
165
  return;
166
  }
167
  if ($order_number_formatted && !$order_number) {
 
168
  $WF_CSV_Order_Import->hf_order_log_data_change('order-csv-import', __('> > Skipped. Formatted order number provided but no numerical order number, see the documentation for further details.', 'order-import-export-for-woocommerce'));
169
  $skipped++;
170
  unset($item);
@@ -192,6 +195,7 @@ class WF_CSV_Parser {
192
  $order_id = apply_filters('woocommerce_find_order_by_order_number', $order_id, $order_number_formatted);
193
  if ($order_id) {
194
  // skip if order ID already exist.
 
195
  $WF_CSV_Order_Import->hf_order_log_data_change('order-csv-import', sprintf(__('> > Skipped. Order %s already exists.', 'order-import-export-for-woocommerce'), $order_number_formatted));
196
  $skipped++;
197
  unset($item);
@@ -205,11 +209,11 @@ class WF_CSV_Parser {
205
  if (is_int($item['customer_id'])) {
206
  $found_customer = get_user_by('id', $item['customer_id']);
207
  if (!$found_customer) {
 
208
  $WF_CSV_Order_Import->hf_order_log_data_change('order-csv-import', sprintf(__('> > Skipped. Cannot find customer with id %s.', 'order-import-export-for-woocommerce'), $item['customer_id']));
209
  $skipped++;
210
  unset($item);
211
- return;
212
- ;
213
  }
214
  } elseif (is_email($item['customer_id'])) {
215
  // check by email
@@ -245,6 +249,7 @@ class WF_CSV_Parser {
245
  $available_statuses[] = $status_slug;
246
  }
247
  if (!$found_status) {
 
248
  $WF_CSV_Order_Import->hf_order_log_data_change('order-csv-import', sprintf(__('> > Skipped. Unknown order status %s (%s).', 'order-import-export-for-woocommerce'), $item['status'], implode($available_statuses, ', ')));
249
  $skipped++;
250
  unset($item);
@@ -263,6 +268,7 @@ class WF_CSV_Parser {
263
  }
264
  if (false === ( $item['date'] = strtotime($item['date']) )) {
265
  // invalid date format
 
266
  $WF_CSV_Order_Import->hf_order_log_data_change('order-csv-import', sprintf(__('> > Skipped. Invalid date format %s.', 'order-import-export-for-woocommerce'), $item['date']));
267
  $skipped++;
268
  unset($item);
@@ -551,6 +557,7 @@ class WF_CSV_Parser {
551
  $total = $item['row_price'];
552
  if (!$sku || !$qty || !is_numeric($total)) {
553
  // invalid item
 
554
  $WF_CSV_Order_Import->hf_order_log_data_change('order-csv-import', sprintf(__('> > Row %d - %s - skipped. Missing SKU, quantity or total', 'order-import-export-for-woocommerce'), $row, $item['order_id']));
555
  $skipped++;
556
  unset($item);
@@ -560,6 +567,7 @@ class WF_CSV_Parser {
560
  $product_id = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_sku' AND meta_value=%s LIMIT 1", $sku));
561
  if (!$product_id) {
562
  // unknown product
 
563
  $WF_CSV_Order_Import->hf_order_log_data_change('order-csv-import', sprintf(__('> > Row %d - %s - skipped. Unknown order item: %s.', 'order-import-export-for-woocommerce'), $row, $item['order_id'], $sku));
564
  $skipped++;
565
  unset($item);
145
  }
146
  $row++;
147
  if ($row <= $record_offset) {
148
+ $WF_CSV_Order_Import->add_import_result('skipped', __('skipped due to record offset', 'order-import-export-for-woocommerce'));
149
  $WF_CSV_Order_Import->hf_order_log_data_change('order-csv-import', sprintf(__('> Row %s - skipped due to record offset.', 'order-import-export-for-woocommerce'), $row));
150
  unset($item);
151
  return;
160
  if (is_numeric($order_number_formatted) && !$order_number)
161
  $order_number = $order_number_formatted; // use formatted for underlying order number if possible
162
  if ($order_number && !is_numeric($order_number)) {
163
+ $WF_CSV_Order_Import->add_import_result('skipped', sprintf(__('> > Skipped. Order number field must be an integer: %s.', 'order-import-export-for-woocommerce'), $order_number));
164
  $WF_CSV_Order_Import->hf_order_log_data_change('order-csv-import', sprintf(__('> > Skipped. Order number field must be an integer: %s.', 'order-import-export-for-woocommerce'), $order_number));
165
  $skipped++;
166
  unset($item);
167
  return;
168
  }
169
  if ($order_number_formatted && !$order_number) {
170
+ $WF_CSV_Order_Import->add_import_result('skipped', __('Skipped. Formatted order number provided but no numerical order number, see the documentation for further details.', 'order-import-export-for-woocommerce'));
171
  $WF_CSV_Order_Import->hf_order_log_data_change('order-csv-import', __('> > Skipped. Formatted order number provided but no numerical order number, see the documentation for further details.', 'order-import-export-for-woocommerce'));
172
  $skipped++;
173
  unset($item);
195
  $order_id = apply_filters('woocommerce_find_order_by_order_number', $order_id, $order_number_formatted);
196
  if ($order_id) {
197
  // skip if order ID already exist.
198
+ $WF_CSV_Order_Import->add_import_result('skipped', sprintf(__('Skipped. Order %s already exists.', 'order-import-export-for-woocommerce'), $order_number_formatted));
199
  $WF_CSV_Order_Import->hf_order_log_data_change('order-csv-import', sprintf(__('> > Skipped. Order %s already exists.', 'order-import-export-for-woocommerce'), $order_number_formatted));
200
  $skipped++;
201
  unset($item);
209
  if (is_int($item['customer_id'])) {
210
  $found_customer = get_user_by('id', $item['customer_id']);
211
  if (!$found_customer) {
212
+ $WF_CSV_Order_Import->add_import_result('skipped', sprintf(__('Skipped. Unknown order status (%s).', 'order-import-export-for-woocommerce'), $item['status']));
213
  $WF_CSV_Order_Import->hf_order_log_data_change('order-csv-import', sprintf(__('> > Skipped. Cannot find customer with id %s.', 'order-import-export-for-woocommerce'), $item['customer_id']));
214
  $skipped++;
215
  unset($item);
216
+ return;
 
217
  }
218
  } elseif (is_email($item['customer_id'])) {
219
  // check by email
249
  $available_statuses[] = $status_slug;
250
  }
251
  if (!$found_status) {
252
+ $WF_CSV_Order_Import->add_import_result('skipped', sprintf(__('Skipped. Unknown order status (%s).', 'order-import-export-for-woocommerce'), $item['status']));
253
  $WF_CSV_Order_Import->hf_order_log_data_change('order-csv-import', sprintf(__('> > Skipped. Unknown order status %s (%s).', 'order-import-export-for-woocommerce'), $item['status'], implode($available_statuses, ', ')));
254
  $skipped++;
255
  unset($item);
268
  }
269
  if (false === ( $item['date'] = strtotime($item['date']) )) {
270
  // invalid date format
271
+ $WF_CSV_Order_Import->add_import_result('skipped', __('Skipped. Invalid date format', 'order-import-export-for-woocommerce'));
272
  $WF_CSV_Order_Import->hf_order_log_data_change('order-csv-import', sprintf(__('> > Skipped. Invalid date format %s.', 'order-import-export-for-woocommerce'), $item['date']));
273
  $skipped++;
274
  unset($item);
557
  $total = $item['row_price'];
558
  if (!$sku || !$qty || !is_numeric($total)) {
559
  // invalid item
560
+ $WF_CSV_Order_Import->add_import_result('skipped', __('skipped. Missing SKU, quantity or total', 'order-import-export-for-woocommerce'));
561
  $WF_CSV_Order_Import->hf_order_log_data_change('order-csv-import', sprintf(__('> > Row %d - %s - skipped. Missing SKU, quantity or total', 'order-import-export-for-woocommerce'), $row, $item['order_id']));
562
  $skipped++;
563
  unset($item);
567
  $product_id = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_sku' AND meta_value=%s LIMIT 1", $sku));
568
  if (!$product_id) {
569
  // unknown product
570
+ $WF_CSV_Order_Import->add_import_result('skipped', __('skipped. Unknown order item', 'order-import-export-for-woocommerce'));
571
  $WF_CSV_Order_Import->hf_order_log_data_change('order-csv-import', sprintf(__('> > Row %d - %s - skipped. Unknown order item: %s.', 'order-import-export-for-woocommerce'), $row, $item['order_id'], $sku));
572
  $skipped++;
573
  unset($item);
includes/importer/class-wf-orderimpexpcsv-order-import.php CHANGED
@@ -289,6 +289,7 @@ class WF_OrderImpExpCsv_Order_Import extends WP_Importer {
289
  $wpdb->hide_errors();
290
  $this->processed_terms = isset($_POST['processed_terms']) ? $_POST['processed_terms'] : array();
291
  $this->processed_posts = isset($_POST['processed_posts']) ? $_POST['processed_posts'] : array();
 
292
 
293
  _e('Step 1...', 'order-import-export-for-woocommerce') . ' ';
294
 
@@ -304,7 +305,9 @@ class WF_OrderImpExpCsv_Order_Import extends WP_Importer {
304
  // SUCCESS
305
  _e('Finished. Import complete.', 'order-import-export-for-woocommerce');
306
 
 
307
  $this->import_end();
 
308
  exit;
309
  break;
310
  }
@@ -367,7 +370,6 @@ class WF_OrderImpExpCsv_Order_Import extends WP_Importer {
367
  foreach ($this->parsed_data as $key => &$item) {
368
  $order = $this->parser->parse_orders($item, $this->raw_headers, $merging, $record_offset);
369
  if (empty($order)) {
370
- $this->add_import_result('skipped', __('Order Skipped, please check the log file', 'order-import-export-for-woocommerce'));
371
  unset($item, $order);
372
  continue;
373
  }
@@ -868,7 +870,7 @@ class WF_OrderImpExpCsv_Order_Import extends WP_Importer {
868
  /**
869
  * Log a row's import status
870
  */
871
- protected function add_import_result($status, $reason, $post_id = '', $post_title = '', $order_number = '') {
872
  $this->import_results[] = array(
873
  'post_title' => $post_title,
874
  'post_id' => $post_id,
289
  $wpdb->hide_errors();
290
  $this->processed_terms = isset($_POST['processed_terms']) ? $_POST['processed_terms'] : array();
291
  $this->processed_posts = isset($_POST['processed_posts']) ? $_POST['processed_posts'] : array();
292
+ $file = isset($_POST['file']) ? stripslashes($_POST['file']) : '';
293
 
294
  _e('Step 1...', 'order-import-export-for-woocommerce') . ' ';
295
 
305
  // SUCCESS
306
  _e('Finished. Import complete.', 'order-import-export-for-woocommerce');
307
 
308
+ unlink($file);
309
  $this->import_end();
310
+
311
  exit;
312
  break;
313
  }
370
  foreach ($this->parsed_data as $key => &$item) {
371
  $order = $this->parser->parse_orders($item, $this->raw_headers, $merging, $record_offset);
372
  if (empty($order)) {
 
373
  unset($item, $order);
374
  continue;
375
  }
870
  /**
871
  * Log a row's import status
872
  */
873
+ public function add_import_result($status, $reason, $post_id = '', $post_title = '', $order_number = '') {
874
  $this->import_results[] = array(
875
  'post_title' => $post_title,
876
  'post_id' => $post_id,
order-import-export-for-woocommerce.php CHANGED
@@ -6,7 +6,7 @@ Plugin URI: https://wordpress.org/plugins/order-import-export-for-woocommerce/
6
  Description: Export and Import Order detail including line items, From and To your WooCommerce Store.
7
  Author: WebToffee
8
  Author URI: https://www.webtoffee.com/product/woocommerce-order-coupon-subscription-export-import/
9
- Version: 1.5.9
10
  Text Domain: order-import-export-for-woocommerce
11
  WC tested up to: 3.9.2
12
  License: GPLv3
@@ -24,7 +24,7 @@ define("WF_CPN_IMP_EXP_ID", "wf_cpn_imp_exp");
24
  define("wf_coupon_csv_im_ex", "wf_coupon_csv_im_ex");
25
 
26
  if (!defined('WF_ORDERIMPEXP_CURRENT_VERSION')) {
27
- define("WF_ORDERIMPEXP_CURRENT_VERSION", "1.5.9");
28
  }
29
 
30
  /**
6
  Description: Export and Import Order detail including line items, From and To your WooCommerce Store.
7
  Author: WebToffee
8
  Author URI: https://www.webtoffee.com/product/woocommerce-order-coupon-subscription-export-import/
9
+ Version: 1.6.0
10
  Text Domain: order-import-export-for-woocommerce
11
  WC tested up to: 3.9.2
12
  License: GPLv3
24
  define("wf_coupon_csv_im_ex", "wf_coupon_csv_im_ex");
25
 
26
  if (!defined('WF_ORDERIMPEXP_CURRENT_VERSION')) {
27
+ define("WF_ORDERIMPEXP_CURRENT_VERSION", "1.6.0");
28
  }
29
 
30
  /**
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.webtoffee.com/plugins/
4
  Tags: order export, order import, woocommerce export orders, woocommerce import orders, export orders, import orders, order, export, import, woocommerce, csv, coupon, coupon export, coupon import, woocommerce export coupon , woocommerce import coupon , export coupons, import coupons, woocommerce coupon generator
5
  Requires at least: 3.0.1
6
  Tested up to: 5.3.2
7
- Stable tag: 1.5.9
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -115,6 +115,8 @@ By default, admin and store manager are given access to export orders from your
115
 
116
  == Changelog ==
117
 
 
 
118
  = 1.5.9 =
119
  * Tested OK with WC 3.9.2
120
  = 1.5.8 =
4
  Tags: order export, order import, woocommerce export orders, woocommerce import orders, export orders, import orders, order, export, import, woocommerce, csv, coupon, coupon export, coupon import, woocommerce export coupon , woocommerce import coupon , export coupons, import coupons, woocommerce coupon generator
5
  Requires at least: 3.0.1
6
  Tested up to: 5.3.2
7
+ Stable tag: 1.6.0
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
115
 
116
  == Changelog ==
117
 
118
+ = 1.6.0 =
119
+ * Bug Fix:- Delete uploaded CSV temp file after import.
120
  = 1.5.9 =
121
  * Tested OK with WC 3.9.2
122
  = 1.5.8 =