Order Export & Order Import for WooCommerce - Version 1.2.5

Version Description

  • WP 4.8 and WC 3.1 Tested.
Download this release

Release Info

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

Code changes from version 1.2.4 to 1.2.5

includes/exporter/class-wf-cpnimpexpcsv-exporter.php CHANGED
@@ -90,6 +90,11 @@ class WF_CpnImpExpCsv_Exporter {
90
  break;
91
  foreach ($coupons as $product) {
92
  foreach ($csv_columns as $column => $value) {
 
 
 
 
 
93
  if (!$export_columns || in_array($column, $export_columns)) {
94
  if (isset($product->meta->$column)) {
95
  $row[] = self::format_data($product->meta->$column);
@@ -166,4 +171,4 @@ class WF_CpnImpExpCsv_Exporter {
166
  return $meta;
167
  }
168
 
169
- }
90
  break;
91
  foreach ($coupons as $product) {
92
  foreach ($csv_columns as $column => $value) {
93
+
94
+ if(is_array($product->$column)){
95
+ $product->$column = implode(',', $product->$column);
96
+ }
97
+
98
  if (!$export_columns || in_array($column, $export_columns)) {
99
  if (isset($product->meta->$column)) {
100
  $row[] = self::format_data($product->meta->$column);
171
  return $meta;
172
  }
173
 
174
+ }
includes/importer/class-wf-cpnimpexpcsv-coupon-import.php CHANGED
@@ -13,7 +13,7 @@ class WF_CpnImpExpCsv_Coupon_Import extends WP_Importer {
13
  var $id;
14
  var $file_url;
15
  var $delimiter;
16
- var $profile;
17
  var $merge_empty_cells;
18
 
19
  // mappings from old information to new
@@ -32,7 +32,11 @@ class WF_CpnImpExpCsv_Coupon_Import extends WP_Importer {
32
  */
33
  public function __construct() {
34
 
35
- $this->log = new WC_Logger();
 
 
 
 
36
  $this->import_page = 'coupon_csv';
37
  $this->file_url_import_enabled = apply_filters( 'coupon_csv_coupon_file_url_import_enabled', true );
38
  }
@@ -344,7 +348,7 @@ class WF_CpnImpExpCsv_Coupon_Import extends WP_Importer {
344
  data: data,
345
  type: 'POST',
346
  success: function( response ) {
347
- console.log( response );
348
  $('#import-progress tbody').append( '<tr class="complete"><td colspan="5">' + response + '</td></tr>' );
349
  $('.importer-loading').hide();
350
  }
@@ -529,8 +533,8 @@ class WF_CpnImpExpCsv_Coupon_Import extends WP_Importer {
529
 
530
  wp_suspend_cache_invalidation( true );
531
 
532
- $this->log->add( 'csv-import', '---' );
533
- $this->log->add( 'csv-import', __( 'Processing coupons.', 'wf_order_import_export' ) );
534
  foreach ( $this->parsed_data as $key => &$item )
535
  {
536
  $coupon = $this->parser->parse_coupon( $item, $this->merge_empty_cells );
@@ -541,7 +545,7 @@ class WF_CpnImpExpCsv_Coupon_Import extends WP_Importer {
541
 
542
  unset( $item, $coupon );
543
  }
544
- $this->log->add( 'csv-import', __( 'Finished processing coupons.', 'wf_order_import_export' ) );
545
  wp_suspend_cache_invalidation( false );
546
  }
547
 
@@ -555,13 +559,13 @@ class WF_CpnImpExpCsv_Coupon_Import extends WP_Importer {
555
  $memory = size_format( (WC()->version < '2.7.0')?woocommerce_let_to_num( ini_get( 'memory_limit' ) ):wc_let_to_num( ini_get( 'memory_limit' ) ) );
556
  $wp_memory = size_format( (WC()->version < '2.7.0')? woocommerce_let_to_num( WP_MEMORY_LIMIT ) : wc_let_to_num( WP_MEMORY_LIMIT ) );
557
 
558
- $this->log->add( 'csv-import', '---[ New Import ] PHP Memory: ' . $memory . ', WP Memory: ' . $wp_memory );
559
- $this->log->add( 'csv-import', __( 'Parsing coupons CSV.', 'wf_order_import_export' ) );
560
 
561
  $this->parser = new WF_CSV_Parser_Coupon( 'shop_coupon' );
562
 
563
  list( $this->parsed_data, $this->raw_headers, $position ) = $this->parser->parse_data( $file, $this->delimiter, $mapping, $start_pos, $end_pos, $eval_field );
564
- $this->log->add( 'csv-import', __( 'Finished parsing coupons CSV.', 'wf_order_import_export' ) );
565
 
566
  unset( $import_data );
567
 
@@ -666,13 +670,13 @@ class WF_CpnImpExpCsv_Coupon_Import extends WP_Importer {
666
  if ( ! empty( $post['post_title'] ) ) {
667
  $processing_coupon_title = $post['post_title'];
668
  }
669
- $post['post_type'] = 'shop_coupon';
670
 
671
 
672
  if ( ! empty( $processing_coupon_id ) && isset( $this->processed_posts[ $processing_coupon_id ] ) )
673
  {
674
  $this->add_import_result( 'skipped', __( 'Coupon already processed', 'wf_order_import_export' ), $processing_coupon_id, $processing_coupon_title );
675
- $this->log->add( 'csv-import', __('> Coupon ID already processed. Skipping.', 'wf_order_import_export'), true );
676
  unset( $post );
677
  return;
678
  }
@@ -680,7 +684,7 @@ class WF_CpnImpExpCsv_Coupon_Import extends WP_Importer {
680
  if ( ! empty ( $post['post_status'] ) && $post['post_status'] == 'auto-draft' )
681
  {
682
  $this->add_import_result( 'skipped', __( 'Skipping auto-draft', 'wf_order_import_export' ), $processing_coupon_id, $processing_coupon_title);
683
- $this->log->add( 'csv-import', __('> Skipping auto-draft.', 'wf_order_import_export'), true );
684
  unset( $post );
685
  return;
686
  }
@@ -694,8 +698,8 @@ class WF_CpnImpExpCsv_Coupon_Import extends WP_Importer {
694
  }else{
695
  $usr_msg = 'Coupon already exists.';
696
  }
697
- $this->add_import_result( 'skipped', __( $usr_msg, 'wf_order_import_export' ), $processing_coupon_id, $processing_coupon_title );
698
- $this->log->add( 'csv-import', sprintf( __('> &#8220;%s&#8221;'.$usr_msg, 'wf_order_import_export'), esc_html($processing_coupon_title) ), true );
699
  unset( $post );
700
  return;
701
  }
@@ -703,17 +707,18 @@ class WF_CpnImpExpCsv_Coupon_Import extends WP_Importer {
703
  if ( $processing_coupon_id && is_string( get_post_status( $processing_coupon_id ) ) )
704
  {
705
  $this->add_import_result( 'skipped', __( 'Importing coupon ID conflicts with an existing coupon ID', 'wf_order_import_export' ), $processing_coupon_id, get_the_title( $processing_coupon_id ) );
706
- $this->log->add( 'csv-import', sprintf( __('> &#8220;%s&#8221; ID already exists.', 'wf_order_import_export'), esc_html( $processing_coupon_id ) ), true );
707
  unset( $post );
708
  return;
709
  }
710
  }
711
- $is_post_exist_in_db = get_post_type( $processing_coupon_id );
712
 
713
  if ( $merging && $processing_coupon_id && !empty($is_post_exist_in_db) && (get_post_type( $processing_coupon_id ) !== $post['post_type'] ))
714
  {
715
  $this->add_import_result( 'skipped', __( 'Post is not a coupon', 'wf_order_import_export' ), $processing_coupon_id, $processing_coupon_title );
716
- $this->log->add( 'csv-import', sprintf( __('> &#8220;%s&#8221; is not a coupon.', 'wf_order_import_export'), esc_html($processing_coupon_id) ), true );
 
717
  unset( $post );
718
  return;
719
  }
@@ -722,7 +727,7 @@ class WF_CpnImpExpCsv_Coupon_Import extends WP_Importer {
722
  {
723
  $post_id = $processing_coupon_id;
724
 
725
- $this->log->add( 'csv-import', sprintf( __('> Merging coupon ID %s.', 'wf_order_import_export'), $post_id ), true );
726
 
727
  $postdata = array(
728
  'ID' => $post_id
@@ -774,19 +779,19 @@ class WF_CpnImpExpCsv_Coupon_Import extends WP_Importer {
774
  if ( ! $result )
775
  {
776
  $this->add_import_result( 'failed', __( 'Failed to update coupon', 'wf_order_import_export' ), $post_id, $processing_coupon_title );
777
- $this->log->add( 'csv-import', sprintf( __('> Failed to update coupon %s', 'wf_order_import_export'), $post_id ), true );
778
  unset( $post );
779
  return;
780
  } else {
781
- $this->log->add( 'csv-import', __( '> Merged post data: ', 'wf_order_import_export' ) . print_r( $postdata, true ) );
782
  }
783
  }
784
 
785
  } else
786
  {
787
- $merging = FALSE;
788
 
789
- $this->log->add( 'csv-import', sprintf( __('> Inserting %s', 'wf_order_import_export'), esc_html( $processing_coupon_title ) ), true );
790
  $postdata = array(
791
  'post_author' => $post['post_author'] ? absint( $post['post_author'] ) : get_current_user_id(),
792
  'post_date' => ( $post['post_date'] ) ? date( 'Y-m-d H:i:s', strtotime( $post['post_date'] )) : '',
@@ -805,13 +810,13 @@ class WF_CpnImpExpCsv_Coupon_Import extends WP_Importer {
805
  {
806
 
807
  $this->add_import_result( 'failed', __( 'Failed to import coupon', 'wf_order_import_export' ), $processing_coupon_id, $processing_coupon_title );
808
- $this->log->add( 'csv-import', sprintf( __( 'Failed to import coupon &#8220;%s&#8221;', 'wf_order_import_export' ), esc_html($processing_coupon_title) ) );
809
  unset( $post );
810
  return;
811
 
812
  } else {
813
 
814
- $this->log->add( 'csv-import', sprintf( __('> Inserted - coupon ID is %s.', 'wf_order_import_export'), $post_id ) );
815
 
816
  }
817
  }
@@ -847,10 +852,10 @@ class WF_CpnImpExpCsv_Coupon_Import extends WP_Importer {
847
  if ( $merging )
848
  {
849
  $this->add_import_result( 'merged', 'Coupon Merge successful', $post_id, $processing_coupon_title );
850
- $this->log->add( 'csv-import', sprintf( __('> Finished merging post ID %s.', 'wf_order_import_export'), $post_id ) );
851
  } else {
852
  $this->add_import_result( 'imported', 'Coupon Import successful', $post_id, $processing_coupon_title );
853
- $this->log->add( 'csv-import', sprintf( __('> Finished importing post ID %s.', 'wf_order_import_export'), $post_id ) );
854
  }
855
  unset( $post );
856
  }
@@ -1014,7 +1019,7 @@ class WF_CpnImpExpCsv_Coupon_Import extends WP_Importer {
1014
  $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
1015
  $size = size_format( $bytes );
1016
  $upload_dir = wp_upload_dir();
1017
- $ftp_settings = get_option( 'wf_coupon_tracking_importer_ftp');
1018
  include( 'views-coupon/html-wf-import-greeting.php' );
1019
  }
1020
 
@@ -1025,5 +1030,17 @@ class WF_CpnImpExpCsv_Coupon_Import extends WP_Importer {
1025
  public function bump_request_timeout( $val ) {
1026
  return 60;
1027
  }
 
 
 
 
 
 
 
 
 
 
 
 
1028
 
1029
  }
13
  var $id;
14
  var $file_url;
15
  var $delimiter;
16
+ var $profile;
17
  var $merge_empty_cells;
18
 
19
  // mappings from old information to new
32
  */
33
  public function __construct() {
34
 
35
+ if (WC()->version < '2.7.0') {
36
+ $this->log = new WC_Logger();
37
+ } else {
38
+ $this->log = wc_get_logger();
39
+ }
40
  $this->import_page = 'coupon_csv';
41
  $this->file_url_import_enabled = apply_filters( 'coupon_csv_coupon_file_url_import_enabled', true );
42
  }
348
  data: data,
349
  type: 'POST',
350
  success: function( response ) {
351
+ //console.log( response );
352
  $('#import-progress tbody').append( '<tr class="complete"><td colspan="5">' + response + '</td></tr>' );
353
  $('.importer-loading').hide();
354
  }
533
 
534
  wp_suspend_cache_invalidation( true );
535
 
536
+ $this->hf_coupon_log_data_change( 'coupon-csv-import', '---' );
537
+ $this->hf_coupon_log_data_change( 'coupon-csv-import', __( 'Processing coupons.', 'wf_order_import_export' ) );
538
  foreach ( $this->parsed_data as $key => &$item )
539
  {
540
  $coupon = $this->parser->parse_coupon( $item, $this->merge_empty_cells );
545
 
546
  unset( $item, $coupon );
547
  }
548
+ $this->hf_coupon_log_data_change( 'coupon-csv-import', __( 'Finished processing coupons.', 'wf_order_import_export' ) );
549
  wp_suspend_cache_invalidation( false );
550
  }
551
 
559
  $memory = size_format( (WC()->version < '2.7.0')?woocommerce_let_to_num( ini_get( 'memory_limit' ) ):wc_let_to_num( ini_get( 'memory_limit' ) ) );
560
  $wp_memory = size_format( (WC()->version < '2.7.0')? woocommerce_let_to_num( WP_MEMORY_LIMIT ) : wc_let_to_num( WP_MEMORY_LIMIT ) );
561
 
562
+ $this->hf_coupon_log_data_change( 'coupon-csv-import', '---[ New Import ] PHP Memory: ' . $memory . ', WP Memory: ' . $wp_memory );
563
+ $this->hf_coupon_log_data_change( 'coupon-csv-import', __( 'Parsing coupons CSV.', 'wf_order_import_export' ) );
564
 
565
  $this->parser = new WF_CSV_Parser_Coupon( 'shop_coupon' );
566
 
567
  list( $this->parsed_data, $this->raw_headers, $position ) = $this->parser->parse_data( $file, $this->delimiter, $mapping, $start_pos, $end_pos, $eval_field );
568
+ $this->hf_coupon_log_data_change( 'coupon-csv-import', __( 'Finished parsing coupons CSV.', 'wf_order_import_export' ) );
569
 
570
  unset( $import_data );
571
 
670
  if ( ! empty( $post['post_title'] ) ) {
671
  $processing_coupon_title = $post['post_title'];
672
  }
673
+ $post['post_type'] = 'shop_coupon';
674
 
675
 
676
  if ( ! empty( $processing_coupon_id ) && isset( $this->processed_posts[ $processing_coupon_id ] ) )
677
  {
678
  $this->add_import_result( 'skipped', __( 'Coupon already processed', 'wf_order_import_export' ), $processing_coupon_id, $processing_coupon_title );
679
+ $this->hf_coupon_log_data_change( 'coupon-csv-import', __('> Coupon ID already processed. Skipping.', 'wf_order_import_export'), true );
680
  unset( $post );
681
  return;
682
  }
684
  if ( ! empty ( $post['post_status'] ) && $post['post_status'] == 'auto-draft' )
685
  {
686
  $this->add_import_result( 'skipped', __( 'Skipping auto-draft', 'wf_order_import_export' ), $processing_coupon_id, $processing_coupon_title);
687
+ $this->hf_coupon_log_data_change( 'coupon-csv-import', __('> Skipping auto-draft.', 'wf_order_import_export'), true );
688
  unset( $post );
689
  return;
690
  }
698
  }else{
699
  $usr_msg = 'Coupon already exists.';
700
  }
701
+ $this->add_import_result( 'skipped', __( $usr_msg, 'wf_order_import_export' ), $processing_coupon_id, $processing_coupon_title );
702
+ $this->hf_coupon_log_data_change( 'coupon-csv-import', sprintf( __('> &#8220;%s&#8221;'.$usr_msg, 'wf_order_import_export'), esc_html($processing_coupon_title) ), true );
703
  unset( $post );
704
  return;
705
  }
707
  if ( $processing_coupon_id && is_string( get_post_status( $processing_coupon_id ) ) )
708
  {
709
  $this->add_import_result( 'skipped', __( 'Importing coupon ID conflicts with an existing coupon ID', 'wf_order_import_export' ), $processing_coupon_id, get_the_title( $processing_coupon_id ) );
710
+ $this->hf_coupon_log_data_change( 'coupon-csv-import', sprintf( __('> &#8220;%s&#8221; ID already exists.', 'wf_order_import_export'), esc_html( $processing_coupon_id ) ), true );
711
  unset( $post );
712
  return;
713
  }
714
  }
715
+ $is_post_exist_in_db = get_post_type( $processing_coupon_id );
716
 
717
  if ( $merging && $processing_coupon_id && !empty($is_post_exist_in_db) && (get_post_type( $processing_coupon_id ) !== $post['post_type'] ))
718
  {
719
  $this->add_import_result( 'skipped', __( 'Post is not a coupon', 'wf_order_import_export' ), $processing_coupon_id, $processing_coupon_title );
720
+ $this->hf_coupon_log_data_change( 'coupon-csv-import', sprintf( __('> &#8220;%s&#8221; is not a coupon.', 'wf_order_import_export'), esc_html($processing_coupon_id) ), true );
721
+
722
  unset( $post );
723
  return;
724
  }
727
  {
728
  $post_id = $processing_coupon_id;
729
 
730
+ $this->hf_coupon_log_data_change( 'coupon-csv-import', sprintf( __('> Merging coupon ID %s.', 'wf_order_import_export'), $post_id ), true );
731
 
732
  $postdata = array(
733
  'ID' => $post_id
779
  if ( ! $result )
780
  {
781
  $this->add_import_result( 'failed', __( 'Failed to update coupon', 'wf_order_import_export' ), $post_id, $processing_coupon_title );
782
+ $this->hf_coupon_log_data_change( 'coupon-csv-import', sprintf( __('> Failed to update coupon %s', 'wf_order_import_export'), $post_id ), true );
783
  unset( $post );
784
  return;
785
  } else {
786
+ $this->hf_coupon_log_data_change( 'coupon-csv-import', __( '> Merged post data: ', 'wf_order_import_export' ) . print_r( $postdata, true ) );
787
  }
788
  }
789
 
790
  } else
791
  {
792
+ $merging = FALSE;
793
 
794
+ $this->hf_coupon_log_data_change( 'coupon-csv-import', sprintf( __('> Inserting %s', 'wf_order_import_export'), esc_html( $processing_coupon_title ) ), true );
795
  $postdata = array(
796
  'post_author' => $post['post_author'] ? absint( $post['post_author'] ) : get_current_user_id(),
797
  'post_date' => ( $post['post_date'] ) ? date( 'Y-m-d H:i:s', strtotime( $post['post_date'] )) : '',
810
  {
811
 
812
  $this->add_import_result( 'failed', __( 'Failed to import coupon', 'wf_order_import_export' ), $processing_coupon_id, $processing_coupon_title );
813
+ $this->hf_coupon_log_data_change( 'coupon-csv-import', sprintf( __( 'Failed to import coupon &#8220;%s&#8221;', 'wf_order_import_export' ), esc_html($processing_coupon_title) ) );
814
  unset( $post );
815
  return;
816
 
817
  } else {
818
 
819
+ $this->hf_coupon_log_data_change( 'coupon-csv-import', sprintf( __('> Inserted - coupon ID is %s.', 'wf_order_import_export'), $post_id ) );
820
 
821
  }
822
  }
852
  if ( $merging )
853
  {
854
  $this->add_import_result( 'merged', 'Coupon Merge successful', $post_id, $processing_coupon_title );
855
+ $this->hf_coupon_log_data_change( 'coupon-csv-import', sprintf( __('> Finished merging post ID %s.', 'wf_order_import_export'), $post_id ) );
856
  } else {
857
  $this->add_import_result( 'imported', 'Coupon Import successful', $post_id, $processing_coupon_title );
858
+ $this->hf_coupon_log_data_change( 'coupon-csv-import', sprintf( __('> Finished importing post ID %s.', 'wf_order_import_export'), $post_id ) );
859
  }
860
  unset( $post );
861
  }
1019
  $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
1020
  $size = size_format( $bytes );
1021
  $upload_dir = wp_upload_dir();
1022
+ $ftp_settings = get_option( 'wf_coupon_tracking_importer_ftp');
1023
  include( 'views-coupon/html-wf-import-greeting.php' );
1024
  }
1025
 
1030
  public function bump_request_timeout( $val ) {
1031
  return 60;
1032
  }
1033
+
1034
+ public function hf_coupon_log_data_change ($content = 'coupon-csv-import',$data='')
1035
+ {
1036
+ if (WC()->version < '2.7.0')
1037
+ {
1038
+ $this->log->add($content,$data);
1039
+ }else
1040
+ {
1041
+ $context = array( 'source' => $content );
1042
+ $this->log->log("debug", $data ,$context);
1043
+ }
1044
+ }
1045
 
1046
  }
includes/importer/class-wf-csv-parser-coupon.php CHANGED
@@ -7,7 +7,7 @@ class WF_CSV_Parser_Coupon {
7
  var $row;
8
  var $post_type;
9
  var $reserved_fields; // Fields we map/handle (not custom fields)
10
- var $post_defaults; // Default post data
11
  var $postmeta_defaults; // default post meta
12
  var $postmeta_allowed; // post meta validation
13
  var $allowed_coupon_types; // Allowed product types
@@ -51,7 +51,7 @@ class WF_CSV_Parser_Coupon {
51
  * @return array
52
  */
53
  public function parse_data( $file, $delimiter, $mapping, $start_pos = 0, $end_pos = null, $eval_field ) {
54
- // Set locale
55
  $enc = mb_detect_encoding( $file, 'UTF-8, ISO-8859-1', true );
56
  if ( $enc )
57
  setlocale( LC_ALL, 'en_US.' . $enc );
@@ -73,27 +73,7 @@ class WF_CSV_Parser_Coupon {
73
  foreach ( $header as $key => $heading ) {
74
  $s_heading = $heading;
75
 
76
- // Check if this heading is being mapped to a different field
77
- if ( isset( $mapping[$s_heading] ) ) {
78
- if ( $mapping[$s_heading] == 'import_as_meta' ) {
79
 
80
- $s_heading = 'meta:' . $s_heading;
81
-
82
- } elseif ( $mapping[$s_heading] == 'import_as_images' ) {
83
-
84
- $s_heading = 'images';
85
-
86
- } else {
87
- $s_heading = esc_attr( $mapping[$s_heading] );
88
- }
89
- }
90
- if(!empty($mapping)){
91
- foreach ($mapping as $mkey => $mvalue) {
92
- if(trim($mvalue) === trim($heading)){
93
- $s_heading = $mkey;
94
- }
95
- }
96
- }
97
 
98
  if ( $s_heading == '' )
99
  continue;
@@ -101,9 +81,6 @@ class WF_CSV_Parser_Coupon {
101
  // Add the heading to the parsed data
102
  $row[$s_heading] = ( isset( $postmeta[$key] ) ) ? $this->format_data_from_csv( $postmeta[$key], $enc ) : '';
103
 
104
- if(isset($eval_field[$s_heading]))
105
- $row[$s_heading] = $this->evaluate_field($row[$s_heading], $eval_field[$s_heading]);
106
-
107
  // Raw Headers stores the actual column name in the CSV
108
  $raw_headers[ $s_heading ] = $heading;
109
  }
@@ -121,43 +98,7 @@ class WF_CSV_Parser_Coupon {
121
  return array( $parsed_data, $raw_headers, $position );
122
  }
123
 
124
- private function evaluate_field($value, $evaluation_field)
125
- {
126
- $processed_value = $value;
127
- if(!empty($evaluation_field)){
128
- $operator = substr($evaluation_field, 0, 1);
129
- if(in_array($operator, array('=', '+', '-', '*', '/', '&'))){
130
- $eval_val = substr($evaluation_field, 1);
131
- switch($operator){
132
- case '=':
133
- $processed_value = trim($eval_val);
134
- break;
135
- case '+':
136
- $processed_value = $this->hf_currency_formatter($value) + $eval_val;
137
- break;
138
- case '-':
139
- $processed_value = $value - $eval_val;
140
- break;
141
- case '*':
142
- $processed_value = $value * $eval_val;
143
- break;
144
- case '/':
145
- $processed_value = $value / $eval_val;
146
- break;
147
- case '&':
148
- if (strpos($eval_val, '[VAL]') !== false) {
149
- $processed_value = str_replace('[VAL]',$value,$eval_val);
150
- }
151
- else{
152
- $processed_value = $value . $eval_val;
153
- }
154
- break;
155
- }
156
- }
157
- }
158
- return $processed_value;
159
- }
160
-
161
  /**
162
  * Parse product
163
  * @param array $item
@@ -172,17 +113,17 @@ class WF_CSV_Parser_Coupon {
172
  $attributes = $default_attributes = $gpf_data = null;
173
  // Merging
174
  $merging = ( ! empty( $_GET['merge'] ) && $_GET['merge'] ) ? true : false;
175
- $this->post_defaults['post_type'] = 'shop_coupon';
176
 
177
  $post_id = ( ! empty( $item['id'] ) ) ? $item['id'] : 0;
178
  $post_id = ( ! empty( $item['post_id'] ) ) ? $item['post_id'] : $post_id;
179
  if ( $merging )
180
  {
181
  $product['merging'] = true;
182
- $WF_CSV_Coupon_Import->log->add( 'csv-import', sprintf( __('> Row %s - preparing for merge.', 'wf_order_import_export'), $this->row ) );
183
  if ( ! $post_id )
184
  {
185
- $WF_CSV_Coupon_Import->log->add( 'csv-import', __( '> > Cannot merge without id or sku. Importing instead.', 'wf_order_import_export') );
186
 
187
  $merging = false;
188
  } else
@@ -202,14 +143,14 @@ class WF_CSV_Parser_Coupon {
202
  $found_product_id = $wpdb->get_var($db_query);
203
  if ( ! $found_product_id )
204
  {
205
- $WF_CSV_Coupon_Import->log->add( 'csv-import', sprintf(__( '> > Skipped. Cannot find coupon with sku %s. Importing instead.', 'wf_order_import_export'), $item['sku']) );
206
  $merging = false;
207
 
208
  } else
209
  {
210
 
211
  $post_id = $found_product_id;
212
- $WF_CSV_Coupon_Import->log->add( 'csv-import', sprintf(__( '> > Found coupon with ID %s.', 'wf_order_import_export'), $post_id) );
213
 
214
  }
215
  }
@@ -221,14 +162,14 @@ class WF_CSV_Parser_Coupon {
221
  {
222
 
223
  $product['merging'] = false;
224
- $WF_CSV_Coupon_Import->log->add( 'csv-import', sprintf( __('> Row %s - preparing for import.', 'wf_order_import_export'), $this->row ) );
225
  if ( isset($item['post_parent']) && $item['post_parent']=== '' && $item['post_title']=== '') {
226
- $WF_CSV_Coupon_Import->log->add( 'csv-import', __( '> > Skipped. No post_title set for new coupon.', 'wf_order_import_export') );
227
  return new WP_Error( 'parse-error', __( 'No post_title set for new coupon.', 'wf_order_import_export' ) );
228
  }
229
  if ( isset($item['post_parent']) && $item['post_parent']!== '' && $item['post_parent']!== null && $item['parent_sku'] === '' )
230
  {
231
- $WF_CSV_Coupon_Import->log->add( 'csv-import', __( '> > Skipped. No parent set for new variation product.', 'wf_order_import_export') );
232
  return new WP_Error( 'parse-error', __( 'No parent set for new variation product.', 'wf_order_import_export' ) );
233
  }
234
  }
@@ -279,9 +220,5 @@ class WF_CSV_Parser_Coupon {
279
  unset( $item, $terms_array, $postmeta, $attributes, $gpf_data, $images );
280
  return $product;
281
  }
282
- function hf_currency_formatter($price)
283
- {
284
- $decimal_seperator = wc_get_price_decimal_separator();
285
- return preg_replace("[^0-9\\'.$decimal_seperator.']", "", $price);
286
- }
287
  }
7
  var $row;
8
  var $post_type;
9
  var $reserved_fields; // Fields we map/handle (not custom fields)
10
+ var $post_defaults; // Default post data
11
  var $postmeta_defaults; // default post meta
12
  var $postmeta_allowed; // post meta validation
13
  var $allowed_coupon_types; // Allowed product types
51
  * @return array
52
  */
53
  public function parse_data( $file, $delimiter, $mapping, $start_pos = 0, $end_pos = null, $eval_field ) {
54
+ // Set locale
55
  $enc = mb_detect_encoding( $file, 'UTF-8, ISO-8859-1', true );
56
  if ( $enc )
57
  setlocale( LC_ALL, 'en_US.' . $enc );
73
  foreach ( $header as $key => $heading ) {
74
  $s_heading = $heading;
75
 
 
 
 
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
 
78
  if ( $s_heading == '' )
79
  continue;
81
  // Add the heading to the parsed data
82
  $row[$s_heading] = ( isset( $postmeta[$key] ) ) ? $this->format_data_from_csv( $postmeta[$key], $enc ) : '';
83
 
 
 
 
84
  // Raw Headers stores the actual column name in the CSV
85
  $raw_headers[ $s_heading ] = $heading;
86
  }
98
  return array( $parsed_data, $raw_headers, $position );
99
  }
100
 
101
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  /**
103
  * Parse product
104
  * @param array $item
113
  $attributes = $default_attributes = $gpf_data = null;
114
  // Merging
115
  $merging = ( ! empty( $_GET['merge'] ) && $_GET['merge'] ) ? true : false;
116
+ $this->post_defaults['post_type'] = 'shop_coupon';
117
 
118
  $post_id = ( ! empty( $item['id'] ) ) ? $item['id'] : 0;
119
  $post_id = ( ! empty( $item['post_id'] ) ) ? $item['post_id'] : $post_id;
120
  if ( $merging )
121
  {
122
  $product['merging'] = true;
123
+ $WF_CSV_Coupon_Import->hf_coupon_log_data_change( 'coupon-csv-import', sprintf( __('> Row %s - preparing for merge.', 'wf_order_import_export'), $this->row ) );
124
  if ( ! $post_id )
125
  {
126
+ $WF_CSV_Coupon_Import->hf_coupon_log_data_change( 'coupon-csv-import', __( '> > Cannot merge without id or sku. Importing instead.', 'wf_order_import_export') );
127
 
128
  $merging = false;
129
  } else
143
  $found_product_id = $wpdb->get_var($db_query);
144
  if ( ! $found_product_id )
145
  {
146
+ $WF_CSV_Coupon_Import->hf_coupon_log_data_change( 'coupon-csv-import', sprintf(__( '> > Skipped. Cannot find coupon with sku %s. Importing instead.', 'wf_order_import_export'), $item['sku']) );
147
  $merging = false;
148
 
149
  } else
150
  {
151
 
152
  $post_id = $found_product_id;
153
+ $WF_CSV_Coupon_Import->hf_coupon_log_data_change( 'coupon-csv-import', sprintf(__( '> > Found coupon with ID %s.', 'wf_order_import_export'), $post_id) );
154
 
155
  }
156
  }
162
  {
163
 
164
  $product['merging'] = false;
165
+ $WF_CSV_Coupon_Import->hf_coupon_log_data_change( 'coupon-csv-import', sprintf( __('> Row %s - preparing for import.', 'wf_order_import_export'), $this->row ) );
166
  if ( isset($item['post_parent']) && $item['post_parent']=== '' && $item['post_title']=== '') {
167
+ $WF_CSV_Coupon_Import->hf_coupon_log_data_change( 'coupon-csv-import', __( '> > Skipped. No post_title set for new coupon.', 'wf_order_import_export') );
168
  return new WP_Error( 'parse-error', __( 'No post_title set for new coupon.', 'wf_order_import_export' ) );
169
  }
170
  if ( isset($item['post_parent']) && $item['post_parent']!== '' && $item['post_parent']!== null && $item['parent_sku'] === '' )
171
  {
172
+ $WF_CSV_Coupon_Import->hf_coupon_log_data_change( 'coupon-csv-import', __( '> > Skipped. No parent set for new variation product.', 'wf_order_import_export') );
173
  return new WP_Error( 'parse-error', __( 'No parent set for new variation product.', 'wf_order_import_export' ) );
174
  }
175
  }
220
  unset( $item, $terms_array, $postmeta, $attributes, $gpf_data, $images );
221
  return $product;
222
  }
223
+
 
 
 
 
224
  }
includes/importer/class-wf-csv-parser.php CHANGED
@@ -784,10 +784,6 @@ class WF_CSV_Parser {
784
  );
785
  }
786
 
787
- function hf_currency_formatter($price){
788
- $decimal_seperator = wc_get_price_decimal_separator();
789
- return ereg_replace("[^0-9\\'.$decimal_seperator.']", "", $price);
790
- }
791
  private function wc_get_order_statuses_neat() {
792
 
793
  $order_statuses = array();
784
  );
785
  }
786
 
 
 
 
 
787
  private function wc_get_order_statuses_neat() {
788
 
789
  $order_statuses = array();
order-import-export.php CHANGED
@@ -6,7 +6,7 @@ Plugin URI: https://www.xadapter.com/product/order-import-export-plugin-for-wooc
6
  Description: Export and Import Order detail including line items, From and To your WooCommerce Store.
7
  Author: XAdapter
8
  Author URI: https://www.xadapter.com/
9
- Version: 1.2.4
10
  Text Domain: wf_order_import_export
11
  */
12
 
6
  Description: Export and Import Order detail including line items, From and To your WooCommerce Store.
7
  Author: XAdapter
8
  Author URI: https://www.xadapter.com/
9
+ Version: 1.2.5
10
  Text Domain: wf_order_import_export
11
  */
12
 
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
- === Order / Coupon / Subscription Export Import Plugin for WooCommerce (BASIC) ===
2
  Contributors: xadapter, niwf, mujeebur
3
  Donate link:
4
  Tags: order, coupon, subscription, export, import, woocommerce
5
  Requires at least: 3.0.1
6
  Tested up to: 4.8
7
- Stable tag: 1.2.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -75,6 +75,8 @@ Yes. You can import or export order line item details.
75
  3. Exported sample order Screen
76
 
77
  == Changelog ==
 
 
78
  = 1.2.4 =
79
  * Fixed some warnings.
80
  = 1.2.3 =
@@ -128,6 +130,8 @@ Yes. You can import or export order line item details.
128
  * Export /Import WooCommerce Orders.
129
 
130
  == Upgrade Notice ==
 
 
131
  = 1.2.4 =
132
  * Fixed some warnings.
133
  = 1.2.3 =
1
+ === Order / Coupon / Subscription Export Import Plugin for WooCommerce (BASIC) ===
2
  Contributors: xadapter, niwf, mujeebur
3
  Donate link:
4
  Tags: order, coupon, subscription, export, import, woocommerce
5
  Requires at least: 3.0.1
6
  Tested up to: 4.8
7
+ Stable tag: 1.2.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
75
  3. Exported sample order Screen
76
 
77
  == Changelog ==
78
+ = 1.2.5 =
79
+ * WP 4.8 and WC 3.1 Tested.
80
  = 1.2.4 =
81
  * Fixed some warnings.
82
  = 1.2.3 =
130
  * Export /Import WooCommerce Orders.
131
 
132
  == Upgrade Notice ==
133
+ = 1.2.5 =
134
+ * WP 4.8 and WC 3.1 Tested.
135
  = 1.2.4 =
136
  * Fixed some warnings.
137
  = 1.2.3 =