Order Export & Order Import for WooCommerce - Version 1.1.1

Version Description

  • Introduced coupon export import.
  • Support for Subscription Orders export import in premium.
Download this release

Release Info

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

Code changes from version 1.1.0 to 1.1.1

Files changed (27) hide show
  1. Sample_Coupon.csv +2 -0
  2. Order_Sample.csv → Sample_Order.csv +0 -0
  3. Sample_Subscription.csv +3 -0
  4. includes/class-wf-cpnimpexpcsv-admin-screen.php +96 -0
  5. includes/class-wf-cpnimpexpcsv-ajax-handler.php +20 -0
  6. includes/class-wf-cpnimpexpcsv-system-status-tools.php +55 -0
  7. includes/class-wf-orderimpexpcsv-admin-screen.php +6 -0
  8. includes/class-wf-orderimpexpcsv-ajax-handler.php +0 -6
  9. includes/exporter/class-wf-cpnimpexpcsv-exporter.php +169 -0
  10. includes/exporter/data/data-wf-post-columns-coupon.php +32 -0
  11. includes/importer/class-wf-cpnimpexpcsv-coupon-import.php +1029 -0
  12. includes/importer/class-wf-cpnimpexpcsv-importer.php +41 -0
  13. includes/importer/class-wf-csv-parser-coupon.php +284 -0
  14. includes/importer/data-coupon/data-wf-post-defaults.php +22 -0
  15. includes/importer/data-coupon/data-wf-postmeta-allowed.php +16 -0
  16. includes/importer/data-coupon/data-wf-postmeta-defaults.php +24 -0
  17. includes/importer/data-coupon/data-wf-reserved-fields-pair.php +31 -0
  18. includes/importer/data-coupon/data-wf-reserved-fields.php +34 -0
  19. includes/importer/views-coupon/html-wf-import-greeting.php +30 -0
  20. includes/importer/views-coupon/html-wf-import-options.php +18 -0
  21. includes/views/export/html-wf-export-coupons.php +11 -0
  22. includes/views/html-wf-admin-screen.php +8 -0
  23. includes/views/html-wf-getting-started-subscription.php +11 -0
  24. includes/views/import/html-wf-import-coupons.php +53 -0
  25. includes/views/import/html-wf-import-orders.php +10 -13
  26. order-import-export.php +140 -3
  27. readme.txt +25 -15
Sample_Coupon.csv ADDED
@@ -0,0 +1,2 @@
 
 
1
+ post_title,ID,post_excerpt,post_status,post_date,post_author,discount_type,coupon_amount,individual_use,product_ids,exclude_product_ids,usage_limit,usage_limit_per_user,limit_usage_to_x_items,expiry_date,free_shipping,exclude_sale_items,product_categories,exclude_product_categories,minimum_amount,maximum_amount,customer_email
2
+ coupon1003,502,Not so dummy,publish,8/26/2016 5:30,1,percent_product,57,yes,,,10,10,3,2/28/2017,no,yes,"8, 9, 6","2, 10, 7",70,80,"patra@gmail.com, patra@hotmail.com, patra@yahoo.co.in"
Order_Sample.csv → Sample_Order.csv RENAMED
File without changes
Sample_Subscription.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ subscription_id,subscription_status,customer_id,customer_username,customer_email,start_date,trial_end_date,next_payment_date,last_payment_date,end_date,post_parent,billing_period,billing_interval,order_shipping,order_shipping_tax,fee_total,fee_tax_total,order_tax,cart_discount,cart_discount_tax,order_total,order_currency,payment_method,payment_method_title,payment_method_post_meta,payment_method_user_meta,shipping_method,billing_first_name,billing_last_name,billing_email,billing_phone,billing_address_1,billing_address_2,billing_postcode,billing_city,billing_state,billing_country,billing_company,shipping_first_name,shipping_last_name,shipping_address_1,shipping_address_2,shipping_postcode,shipping_city,shipping_state,shipping_country,shipping_company,customer_note,order_items,order_notes,coupon_items,fee_items,tax_items,download_permissions,
2
+ 87,wc-active,2,mark,mark@xadapter.com,2016-08-30 07:22:27,2016-09-04 07:22:27,2016-09-04 07:22:27,2016-08-30 07:22:32,2016-12-04 07:22:27,86,month,1,0,0,0,0,0,0,0,9,USD,stripe,Credit card (Stripe),,,,Mark,Wough,mark@xadapter.com,74747474,1st Ave,San Deigo,90001,Naples,AL,US,MarkCO LTD,Steve,Wough,1st Ave,San Deigo,90001,Naples,AL,US,MarkCO LTD,,product_id:10|name:Test Subscription Prdocut|quantity:1|total:9.00|meta:|tax:0.00,Payment received.,Status changed from Pending to Active.,,,,1
3
+ 89,wc-on-hold,9,elvin,elvin@wooforce.com,2016-08-25 19:28:19,2016-08-30 19:28:19,2016-08-30 19:28:19,2016-08-31 06:18:25,2016-11-30 19:28:19,88,month,1,0,0,0,0,0,0,0,9,USD,stripe,Credit card (Stripe),,,,Elvin,j,elvin@xadapter.com,74747474,1st Ave,Naples,90001,Naples,AL,US,MarkCO LTD,Mark,Wough,1st Ave,Naples,90001,Naples,AL,US,ElvinCO LTD,Just checking Elvin Placed the Order,product_id:10|name:Test Subscription Prdocut|quantity:1|total:9.00|meta:|tax:0.00,"Payment failed.;Order <a href=""http://localhost/latestpress/wp-admin/post.php?post=233&#038;action=edit"">#233</a> created to record renewal.;Subscription renewal payment due: Status changed from Active to On hold.;Payment received.;Status changed from Pending to Active.",code:|description:|amount:0.00,,,0,
includes/class-wf-cpnimpexpcsv-admin-screen.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
+ class WF_CpnImpExpCsv_Admin_Screen {
7
+
8
+ public function __construct()
9
+ {
10
+ add_action( 'admin_menu', array( $this, 'admin_menu' ) );
11
+ add_action( 'admin_print_styles', array( $this, 'admin_scripts' ) );
12
+ add_action( 'admin_notices', array( $this, 'admin_notices' ) );
13
+
14
+ }
15
+
16
+ public function admin_notices()
17
+ {
18
+ if ( ! function_exists( 'mb_detect_encoding' ) ) {
19
+ echo '<div class="error"><p>' . __( 'Coupon CSV Import Export requires the function <code>mb_detect_encoding</code> to import and export CSV files. Please ask your hosting provider to enable this function.', 'wf_order_import_export' ) . '</p></div>';
20
+ }
21
+ }
22
+
23
+ public function admin_menu()
24
+ {
25
+ $page = add_submenu_page( 'woocommerce', __( 'Coupon Im-Ex', 'wf_order_import_export' ), __( 'Coupon Im-Ex', 'wf_order_import_export' ), apply_filters( 'coupon_csv_coupon_role', 'manage_woocommerce' ), 'wf_coupon_csv_im_ex', array( $this, 'output' ) );
26
+ }
27
+
28
+ public static function hf_get_wc_path()
29
+ {
30
+ if (function_exists('WC')){
31
+ $wc_path = WC()->plugin_url();
32
+ }else{
33
+ $wc_path = plugins_url() . '/woocommerce';
34
+ }
35
+ return $wc_path;
36
+ }
37
+
38
+ public function admin_scripts()
39
+ {
40
+ $wc_path = self::hf_get_wc_path();
41
+ wp_enqueue_style( 'woocommerce_admin_styles', $wc_path. '/assets/css/admin.css' );
42
+ wp_enqueue_style( 'woocommerce-coupon-csv-importer1', plugins_url( basename( plugin_dir_path( WF_CpnImpExpCsv_FILE ) ) . '/styles/wf-style.css', basename( __FILE__ ) ), '', '1.0.0', 'screen' );
43
+
44
+ }
45
+
46
+ public function output()
47
+ {
48
+ $tab = 'import';
49
+
50
+
51
+ if(! empty( $_GET['page'] ))
52
+ {
53
+ if ( $_GET['page'] == 'wf_coupon_csv_im_ex' ) {
54
+ $tab = 'coupon';
55
+ }
56
+ }
57
+ if( ! empty( $_GET['tab'] )) {
58
+ if( $_GET['tab'] == 'export' ) {
59
+ $tab = 'export';
60
+ }
61
+ else if ( $_GET['tab'] == 'settings' ) {
62
+ $tab = 'settings';
63
+ }
64
+ else if ( $_GET['tab'] == 'coupon' ) {
65
+ $tab = 'coupon';
66
+ }
67
+ }
68
+ include( 'views/html-wf-admin-screen.php' );
69
+ }
70
+
71
+
72
+ public function admin_import_page() {
73
+ include( 'views/html-wf-getting-started.php' );
74
+ include( 'views/import/html-wf-import-coupons.php' );
75
+ $post_columns = include( 'exporter/data/data-wf-post-columns.php' );
76
+ include( 'views/export/html-wf-export-coupons.php' );
77
+ }
78
+
79
+ public function admin_export_page() {
80
+ $post_columns = include( 'exporter/data/data-wf-post-columns.php' );
81
+ include( 'views/export/html-wf-export-orders.php' );
82
+ }
83
+
84
+ public function admin_coupon_page()
85
+ {
86
+ include( 'views/import/html-wf-import-coupons.php' );
87
+ include( 'views/export/html-wf-export-coupons.php' );
88
+ }
89
+
90
+ public function admin_settings_page()
91
+ {
92
+ include( 'views/settings/html-wf-all-settings.php' );
93
+ }
94
+ }
95
+
96
+ new WF_CpnImpExpCsv_Admin_Screen();
includes/class-wf-cpnimpexpcsv-ajax-handler.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!defined('ABSPATH')) {
4
+ exit;
5
+ }
6
+
7
+ class WF_CpnImpExpCsv_AJAX_Handler {
8
+
9
+ public function __construct() {
10
+ add_action('wp_ajax_coupon_csv_import_request', array($this, 'csv_import_request'));
11
+ }
12
+
13
+ public function csv_import_request() {
14
+ define('WP_LOAD_IMPORTERS', true);
15
+ WF_CpnImpExpCsv_Importer::coupon_importer();
16
+ }
17
+
18
+ }
19
+
20
+ new WF_CpnImpExpCsv_AJAX_Handler();
includes/class-wf-cpnimpexpcsv-system-status-tools.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
+ class WF_CpnImpExpCsv_System_Status_Tools {
7
+
8
+ /**
9
+ * Constructor
10
+ */
11
+ public function __construct() {
12
+ add_filter( 'woocommerce_debug_tools', array( $this, 'tools' ) );
13
+ }
14
+
15
+ /**
16
+ * Tools we add to WC
17
+ * @param array $tools
18
+ * @return array
19
+ */
20
+ public function tools( $tools ) {
21
+ $tools['delete_coupons'] = array(
22
+ 'name' => __( 'Delete Coupons','wf_order_import_export'),
23
+ 'button' => __( 'Delete ALL coupons','wf_order_import_export' ),
24
+ 'desc' => __( 'This tool will delete all coupons allowing you to start fresh.', 'wf_order_import_export' ),
25
+ 'callback' => array( $this, 'delete_coupons' )
26
+ );
27
+
28
+ return $tools;
29
+ }
30
+
31
+ /**
32
+ * Delete coupons
33
+ */
34
+ public function delete_coupons()
35
+ {
36
+ global $wpdb;
37
+
38
+ // Delete coupons
39
+ $result = absint( $wpdb->delete( $wpdb->posts, array( 'post_type' => 'shop_coupon' ) ) );
40
+
41
+
42
+ // Delete meta and term relationships with no post
43
+ $wpdb->query( "DELETE pm
44
+ FROM {$wpdb->postmeta} pm
45
+ LEFT JOIN {$wpdb->posts} wp ON wp.ID = pm.post_id
46
+ WHERE wp.ID IS NULL" );
47
+
48
+
49
+ echo '<div class="updated"><p>' . sprintf( __( '%d Coupons Deleted', 'wf_order_import_export' ), ( $result) ) . '</p></div>';
50
+ }
51
+
52
+
53
+ }
54
+
55
+ new WF_CpnImpExpCsv_System_Status_Tools();
includes/class-wf-orderimpexpcsv-admin-screen.php CHANGED
@@ -48,6 +48,8 @@ class WF_OrderImpExpCsv_Admin_Screen {
48
  if (!empty($_GET['tab'])) {
49
  if ($_GET['tab'] == 'export') {
50
  $tab = 'export';
 
 
51
  }
52
  }
53
  include( 'views/html-wf-admin-screen.php' );
@@ -69,6 +71,10 @@ class WF_OrderImpExpCsv_Admin_Screen {
69
  $post_columns = include( 'exporter/data/data-wf-post-columns.php' );
70
  include( 'views/export/html-wf-export-orders.php' );
71
  }
 
 
 
 
72
 
73
  }
74
 
48
  if (!empty($_GET['tab'])) {
49
  if ($_GET['tab'] == 'export') {
50
  $tab = 'export';
51
+ }elseif($_GET['tab'] == 'subscription' ) {
52
+ $tab = 'subscription';
53
  }
54
  }
55
  include( 'views/html-wf-admin-screen.php' );
71
  $post_columns = include( 'exporter/data/data-wf-post-columns.php' );
72
  include( 'views/export/html-wf-export-orders.php' );
73
  }
74
+ public function admin_subscription_page()
75
+ {
76
+ include( 'views/html-wf-getting-started-subscription.php' );
77
+ }
78
 
79
  }
80
 
includes/class-wf-orderimpexpcsv-ajax-handler.php CHANGED
@@ -20,12 +20,6 @@ class WF_OrderImpExpCsv_AJAX_Handler {
20
  WF_OrderImpExpCsv_Importer::order_importer();
21
  }
22
 
23
- /**
24
- * Die with a JSON formatted error message
25
- */
26
- public function die_json_error_msg( $id, $message ) {
27
- die( json_encode( array( 'error' => sprintf( __( '&quot;%1$s&quot; (ID %2$s) failed to resize. The error message was: %3$s', 'regenerate-thumbnails' ), esc_html( get_the_title( $id ) ), $id, $message ) ) ) );
28
- }
29
  }
30
 
31
  new WF_OrderImpExpCsv_AJAX_Handler();
20
  WF_OrderImpExpCsv_Importer::order_importer();
21
  }
22
 
 
 
 
 
 
 
23
  }
24
 
25
  new WF_OrderImpExpCsv_AJAX_Handler();
includes/exporter/class-wf-cpnimpexpcsv-exporter.php ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!defined('ABSPATH')) {
4
+ exit;
5
+ }
6
+
7
+ class WF_CpnImpExpCsv_Exporter {
8
+
9
+ public static function do_export($post_type = 'shop_coupon') {
10
+ global $wpdb;
11
+
12
+ $cpn_categories = !empty($_POST['cpn_categories']) ? $_POST['cpn_categories'] : array('fixed_cart', 'percent', 'fixed_product', 'percent_product');
13
+ $export_limit = !empty($_POST['limit']) ? intval($_POST['limit']) : 999999999;
14
+ $export_count = 0;
15
+ $limit = 100;
16
+ $current_offset = !empty($_POST['offset']) ? intval($_POST['offset']) : 0;
17
+ $sortcolumn = !empty($_POST['sortcolumn']) ? $_POST['sortcolumn'] : 'ID';
18
+ $delimiter = !empty($_POST['delimiter']) ? $_POST['delimiter'] : ',';
19
+
20
+ $csv_columns = include( 'data/data-wf-post-columns-coupon.php' );
21
+ $user_columns_name = !empty($_POST['columns_name']) ? $_POST['columns_name'] : $csv_columns;
22
+ $export_columns = !empty($_POST['columns']) ? $_POST['columns'] : '';
23
+ if ($limit > $export_limit)
24
+ $limit = $export_limit;
25
+
26
+
27
+ $wpdb->hide_errors();
28
+ @set_time_limit(0);
29
+ if (function_exists('apache_setenv'))
30
+ @apache_setenv('no-gzip', 1);
31
+ @ini_set('zlib.output_compression', 0);
32
+ @ob_clean();
33
+
34
+
35
+ header('Content-Type: text/csv; charset=UTF-8');
36
+ header('Content-Disposition: attachment; filename=woocommerce-coupon-export-' . date('Y_m_d_H_i_s', current_time('timestamp')) . '.csv');
37
+ header('Pragma: no-cache');
38
+ header('Expires: 0');
39
+
40
+ $fp = fopen('php://output', 'w');
41
+
42
+
43
+ $all_meta_pkeys = self::get_all_metakeys('shop_coupon');
44
+ $all_meta_keys = $all_meta_pkeys;
45
+
46
+ $found_coupon_meta = array();
47
+ foreach ($all_meta_keys as $meta) {
48
+ if (!$meta)
49
+ continue;
50
+ if (!in_array($meta, array_keys($csv_columns)) && substr((string) $meta, 0, 1) == '_')
51
+ continue;
52
+
53
+ if (in_array($meta, array_keys($csv_columns)))
54
+ continue;
55
+ $found_coupon_meta[] = $meta;
56
+ }
57
+ $found_coupon_meta = array_diff($found_coupon_meta, array_keys($csv_columns));
58
+ $row = array();
59
+ foreach ($csv_columns as $column => $value) {
60
+ $temp_head = esc_attr($user_columns_name[$column]);
61
+ if (!$export_columns || in_array($column, $export_columns))
62
+ $row[] = $temp_head;
63
+ }
64
+
65
+ if (!$export_columns || in_array('meta', $export_columns)) {
66
+ foreach ($found_coupon_meta as $coupon_meta) {
67
+ $row[] = 'meta:' . self::format_data($coupon_meta);
68
+ }
69
+ }
70
+
71
+
72
+ $row = array_map('WF_CpnImpExpCsv_Exporter::wrap_column', $row);
73
+ fwrite($fp, implode($delimiter, $row) . "\n");
74
+ unset($row);
75
+
76
+ while ($export_count < $export_limit) {
77
+ $coupon_args = apply_filters('coupon_csv_product_export_args', array(
78
+ 'numberposts' => $limit,
79
+ 'post_status' => array('publish', 'pending', 'private', 'draft'),
80
+ 'post_type' => 'shop_coupon',
81
+ 'orderby' => $sortcolumn,
82
+ 'suppress_filters' => false,
83
+ 'order' => 'ASC',
84
+ 'offset' => $current_offset
85
+ ));
86
+
87
+
88
+ $coupons = get_posts($coupon_args);
89
+ if (!$coupons || is_wp_error($coupons))
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);
96
+ } elseif (isset($product->$column) && !is_array($product->$column)) {
97
+ if ($column === 'post_title') {
98
+ $row[] = sanitize_text_field($product->$column);
99
+ } else {
100
+ $row[] = self::format_data($product->$column);
101
+ }
102
+ } else {
103
+ $row[] = '';
104
+ }
105
+ }
106
+ }
107
+
108
+ if (!$export_columns || in_array('meta', $export_columns)) {
109
+ foreach ($found_coupon_meta as $product_meta) {
110
+ if (isset($product->meta->$product_meta)) {
111
+ $row[] = self::format_data($product->meta->$product_meta);
112
+ } else {
113
+ $row[] = '';
114
+ }
115
+ }
116
+ }
117
+ $row = array_map('WF_CpnImpExpCsv_Exporter::wrap_column', $row);
118
+ fwrite($fp, implode($delimiter, $row) . "\n");
119
+ unset($row);
120
+ }
121
+
122
+ $current_offset += $limit;
123
+ $export_count += $limit;
124
+ unset($coupons);
125
+ }
126
+
127
+ fclose($fp);
128
+ exit;
129
+ }
130
+
131
+ public static function format_data($data) {
132
+ if (!is_array($data))
133
+ ;
134
+ $data = (string) urldecode($data);
135
+ $enc = mb_detect_encoding($data, 'UTF-8, ISO-8859-1', true);
136
+ $data = ( $enc == 'UTF-8' ) ? $data : utf8_encode($data);
137
+ return $data;
138
+ }
139
+
140
+ /**
141
+ * Wrap a column in quotes for the CSV
142
+ * @param string data to wrap
143
+ * @return string wrapped data
144
+ */
145
+ public static function wrap_column($data) {
146
+ return '"' . str_replace('"', '""', $data) . '"';
147
+ }
148
+
149
+ /**
150
+ * Get a list of all the meta keys for a post type. This includes all public, private,
151
+ * used, no-longer used etc. They will be sorted once fetched.
152
+ */
153
+ public static function get_all_metakeys($post_type = 'shop_coupon') {
154
+ global $wpdb;
155
+
156
+ $meta = $wpdb->get_col($wpdb->prepare(
157
+ "SELECT DISTINCT pm.meta_key
158
+ FROM {$wpdb->postmeta} AS pm
159
+ LEFT JOIN {$wpdb->posts} AS p ON p.ID = pm.post_id
160
+ WHERE p.post_type = %s
161
+ AND p.post_status IN ( 'publish', 'pending', 'private', 'draft' )", $post_type
162
+ ));
163
+
164
+ sort($meta);
165
+
166
+ return $meta;
167
+ }
168
+
169
+ }
includes/exporter/data/data-wf-post-columns-coupon.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
+ return apply_filters('coupon_csv_coupon_post_columns', array(
7
+ 'post_title' => 'post_title',
8
+ 'ID' => 'ID',
9
+ 'post_excerpt' => 'post_excerpt',
10
+ 'post_status' => 'post_status',
11
+ 'post_date' => 'post_date',
12
+ 'post_author' => 'post_author',
13
+
14
+ // // Meta
15
+ 'discount_type' => 'discount_type',
16
+ 'coupon_amount' => 'coupon_amount',
17
+ 'individual_use' => 'individual_use',
18
+ 'product_ids' => 'product_ids',
19
+ 'exclude_product_ids' => 'exclude_product_ids',
20
+ 'usage_limit' => 'usage_limit',
21
+ 'usage_limit_per_user' => 'usage_limit_per_user',
22
+ 'limit_usage_to_x_items' => 'limit_usage_to_x_items',
23
+ 'expiry_date' => 'expiry_date',
24
+ 'free_shipping' => 'free_shipping',
25
+ 'exclude_sale_items' => 'exclude_sale_items',
26
+ 'product_categories' => 'product_categories',
27
+ 'exclude_product_categories' => 'exclude_product_categories',
28
+ 'minimum_amount' => 'minimum_amount',
29
+ 'maximum_amount' => 'maximum_amount',
30
+ 'customer_email' => 'customer_email',
31
+
32
+ ) );
includes/importer/class-wf-cpnimpexpcsv-coupon-import.php ADDED
@@ -0,0 +1,1029 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WordPress Importer class for managing the import process of a CSV file
4
+ *
5
+ * @package WordPress
6
+ * @subpackage Importer
7
+ */
8
+ if ( ! class_exists( 'WP_Importer' ) )
9
+ return;
10
+
11
+ class WF_CpnImpExpCsv_Coupon_Import extends WP_Importer {
12
+
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
20
+ var $processed_terms = array();
21
+ var $processed_posts = array();
22
+ var $post_orphans = array();
23
+ var $attachments = array();
24
+ var $upsell_skus = array();
25
+ var $crosssell_skus = array();
26
+
27
+ // Results
28
+ var $import_results = array();
29
+
30
+ /**
31
+ * Constructor
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
+ }
39
+
40
+ /**
41
+ * Registered callback function for the WordPress Importer
42
+ *
43
+ * Manages the three separate stages of the CSV import process
44
+ */
45
+ public function dispatch() {
46
+ global $woocommerce, $wpdb;
47
+
48
+ if ( ! empty( $_POST['delimiter'] ) ) {
49
+ $this->delimiter = stripslashes( trim( $_POST['delimiter'] ) );
50
+ }else if ( ! empty( $_GET['delimiter'] ) ) {
51
+ $this->delimiter = stripslashes( trim( $_GET['delimiter'] ) );
52
+ }
53
+
54
+ if ( ! $this->delimiter )
55
+ $this->delimiter = ',';
56
+
57
+ if ( ! empty( $_POST['profile'] ) ) {
58
+ $this->profile = stripslashes( trim( $_POST['profile'] ) );
59
+ }else if ( ! empty( $_GET['profile'] ) ) {
60
+ $this->profile = stripslashes( trim( $_GET['profile'] ) );
61
+ }
62
+ if ( ! $this->profile )
63
+ $this->profile = '';
64
+
65
+ if ( ! empty( $_POST['merge_empty_cells'] ) || ! empty( $_GET['merge_empty_cells'] ) ) {
66
+ $this->merge_empty_cells = 1;
67
+ } else{
68
+ $this->merge_empty_cells = 0;
69
+ }
70
+
71
+ $step = empty( $_GET['step'] ) ? 0 : (int) $_GET['step'];
72
+
73
+ switch ( $step ) {
74
+ case 0 :
75
+ $this->header();
76
+ $this->greet();
77
+ break;
78
+ case 1 :
79
+ $this->header();
80
+
81
+ check_admin_referer( 'import-upload' );
82
+
83
+ if(!empty($_GET['file_url']))
84
+ $this->file_url = esc_attr( $_GET['file_url'] );
85
+ if(!empty($_GET['file_id']))
86
+ $this->id = $_GET['file_id'] ;
87
+
88
+ if ( !empty($_GET['clearmapping']) || $this->handle_upload() )
89
+ $this->import_options();
90
+ else
91
+ //_e( 'Error with handle_upload!', 'wf_order_import_export' );
92
+ wp_redirect(wp_get_referer().'&wf_coupon_ie_msg=3');
93
+ exit;
94
+ break;
95
+ case 2 :
96
+ $this->header();
97
+
98
+ check_admin_referer( 'import-woocommerce' );
99
+
100
+ $this->id = (int) $_POST['import_id'];
101
+
102
+ if ( $this->file_url_import_enabled )
103
+ $this->file_url = esc_attr( $_POST['import_url'] );
104
+
105
+ if ( $this->id )
106
+ $file = get_attached_file( $this->id );
107
+ else if ( $this->file_url_import_enabled )
108
+ $file = ABSPATH . $this->file_url;
109
+
110
+ $file = str_replace( "\\", "/", $file );
111
+
112
+ if ( $file ) {
113
+ ?>
114
+ <table id="import-progress" class="widefat_importer widefat">
115
+ <thead>
116
+ <tr>
117
+ <th class="status">&nbsp;</th>
118
+ <th class="row"><?php _e( 'Row', 'wf_order_import_export' ); ?></th>
119
+ <th><?php _e( 'Coupon Id', 'wf_order_import_export' ); ?></th>
120
+ <th><?php _e( 'Coupon Name', 'wf_order_import_export' ); ?></th>
121
+ <th class="reason"><?php _e( 'Status Msg', 'wf_order_import_export' ); ?></th>
122
+ </tr>
123
+ </thead>
124
+ <tfoot>
125
+ <tr class="importer-loading">
126
+ <td colspan="5"></td>
127
+ </tr>
128
+ </tfoot>
129
+ <tbody></tbody>
130
+ </table>
131
+ <script type="text/javascript">
132
+ jQuery(document).ready(function($) {
133
+
134
+ if ( ! window.console ) { window.console = function(){}; }
135
+
136
+ var processed_terms = [];
137
+ var processed_posts = [];
138
+ var post_orphans = [];
139
+ var attachments = [];
140
+ var upsell_skus = [];
141
+ var crosssell_skus = [];
142
+ var i = 1;
143
+ var done_count = 0;
144
+
145
+ function import_rows( start_pos, end_pos ) {
146
+
147
+ var data = {
148
+ action: 'coupon_csv_import_request',
149
+ file: '<?php echo addslashes( $file ); ?>',
150
+ mapping: '<?php echo json_encode( $_POST['map_from'] ); ?>',
151
+ profile: '<?php echo $this->profile; ?>',
152
+ eval_field: '<?php echo stripslashes(json_encode(($_POST['eval_field']),JSON_HEX_APOS)) ?>',
153
+ delimiter: '<?php echo $this->delimiter; ?>',
154
+ merge_empty_cells: '<?php echo $this->merge_empty_cells; ?>',
155
+ start_pos: start_pos,
156
+ end_pos: end_pos,
157
+ };
158
+ data.eval_field = $.parseJSON(data.eval_field);
159
+ return $.ajax({
160
+ url: '<?php echo add_query_arg( array( 'import_page' => $this->import_page, 'step' => '3', 'merge' => ! empty( $_GET['merge'] ) ? '1' : '0' ), admin_url( 'admin-ajax.php' ) ); ?>',
161
+ data: data,
162
+ type: 'POST',
163
+ success: function( response ) {
164
+ if ( response ) {
165
+
166
+ try {
167
+ // Get the valid JSON only from the returned string
168
+ if ( response.indexOf("<!--WC_START-->") >= 0 )
169
+ response = response.split("<!--WC_START-->")[1]; // Strip off before after WC_START
170
+
171
+ if ( response.indexOf("<!--WC_END-->") >= 0 )
172
+ response = response.split("<!--WC_END-->")[0]; // Strip off anything after WC_END
173
+
174
+ // Parse
175
+ var results = $.parseJSON( response );
176
+
177
+ if ( results.error ) {
178
+
179
+ $('#import-progress tbody').append( '<tr id="row-' + i + '" class="error"><td class="status" colspan="5">' + results.error + '</td></tr>' );
180
+
181
+ i++;
182
+
183
+ } else if ( results.import_results && $( results.import_results ).size() > 0 ) {
184
+
185
+ $.each( results.processed_terms, function( index, value ) {
186
+ processed_terms.push( value );
187
+ });
188
+
189
+ $.each( results.processed_posts, function( index, value ) {
190
+ processed_posts.push( value );
191
+ });
192
+
193
+ $.each( results.post_orphans, function( index, value ) {
194
+ post_orphans.push( value );
195
+ });
196
+
197
+ $.each( results.attachments, function( index, value ) {
198
+ attachments.push( value );
199
+ });
200
+
201
+ upsell_skus = jQuery.extend( {}, upsell_skus, results.upsell_skus );
202
+ crosssell_skus = jQuery.extend( {}, crosssell_skus, results.crosssell_skus );
203
+
204
+ $( results.import_results ).each(function( index, row ) {
205
+ $('#import-progress tbody').append( '<tr id="row-' + i + '" class="' + row['status'] + '"><td><mark class="result" title="' + row['status'] + '">' + row['status'] + '</mark></td><td class="row">' + i + '</td><td>' + row['post_id'] + '</td><td>' + row['post_title'] + '</td><td class="reason">' + row['reason'] + '</td></tr>' );
206
+
207
+ i++;
208
+ });
209
+ }
210
+
211
+ } catch(err) {}
212
+
213
+ } else {
214
+ $('#import-progress tbody').append( '<tr class="error"><td class="status" colspan="5">' + '<?php _e( 'AJAX Error', 'wf_order_import_export' ); ?>' + '</td></tr>' );
215
+ }
216
+
217
+ var w = $(window);
218
+ var row = $( "#row-" + ( i - 1 ) );
219
+
220
+ if ( row.length ) {
221
+ w.scrollTop( row.offset().top - (w.height()/2) );
222
+ }
223
+
224
+ done_count++;
225
+
226
+ $('body').trigger( 'coupon_csv_import_request_complete' );
227
+ }
228
+ });
229
+ }
230
+
231
+ var rows = [];
232
+
233
+ <?php
234
+ $limit = apply_filters( 'coupon_csv_import_limit_per_request', 10 );
235
+ $enc = mb_detect_encoding( $file, 'UTF-8, ISO-8859-1', true );
236
+ if ( $enc )
237
+ setlocale( LC_ALL, 'en_US.' . $enc );
238
+ @ini_set( 'auto_detect_line_endings', true );
239
+
240
+ $count = 0;
241
+ $previous_position = 0;
242
+ $position = 0;
243
+ $import_count = 0;
244
+
245
+ // Get CSV positions
246
+ if ( ( $handle = fopen( $file, "r" ) ) !== FALSE ) {
247
+
248
+ while ( ( $postmeta = fgetcsv( $handle, 0, $this->delimiter , '"', '"' ) ) !== FALSE ) {
249
+ $count++;
250
+
251
+ if ( $count >= $limit ) {
252
+ $previous_position = $position;
253
+ $position = ftell( $handle );
254
+ $count = 0;
255
+ $import_count ++;
256
+
257
+ // Import rows between $previous_position $position
258
+ ?>rows.push( [ <?php echo $previous_position; ?>, <?php echo $position; ?> ] ); <?php
259
+ }
260
+ }
261
+
262
+ // Remainder
263
+ if ( $count > 0 ) {
264
+ ?>rows.push( [ <?php echo $position; ?>, '' ] ); <?php
265
+ $import_count ++;
266
+ }
267
+
268
+ fclose( $handle );
269
+ }
270
+ ?>
271
+
272
+ var data = rows.shift();
273
+ var regen_count = 0;
274
+ import_rows( data[0], data[1] );
275
+
276
+ $('body').on( 'coupon_csv_import_request_complete', function() {
277
+ if ( done_count == <?php echo $import_count; ?> ) {
278
+
279
+ if ( attachments.length ) {
280
+
281
+ $('#import-progress tbody').append( '<tr class="regenerating"><td colspan="5"><div class="progress"></div></td></tr>' );
282
+
283
+ index = 0;
284
+
285
+ $.each( attachments, function( i, value ) {
286
+ regenerate_thumbnail( value );
287
+ index ++;
288
+ if ( index == attachments.length ) {
289
+ import_done();
290
+ }
291
+ });
292
+
293
+ } else {
294
+ import_done();
295
+ }
296
+
297
+ } else {
298
+ // Call next request
299
+ data = rows.shift();
300
+ import_rows( data[0], data[1] );
301
+ }
302
+ } );
303
+
304
+ // Regenerate a specified image via AJAX
305
+ function regenerate_thumbnail( id ) {
306
+ $.ajax({
307
+ type: 'POST',
308
+ url: ajaxurl,
309
+ data: { action: "coupon_csv_import_regenerate_thumbnail", id: id },
310
+ success: function( response ) {
311
+ if ( response !== Object( response ) || ( typeof response.success === "undefined" && typeof response.error === "undefined" ) ) {
312
+ response = new Object;
313
+ response.success = false;
314
+ response.error = "<?php printf( esc_js( __( 'The resize request was abnormally terminated (ID %s). This is likely due to the image exceeding available memory or some other type of fatal error.', 'wf_order_import_export' ) ), '" + id + "' ); ?>";
315
+ }
316
+
317
+ regen_count ++;
318
+
319
+ $('#import-progress tbody .regenerating .progress').css( 'width', ( ( regen_count / attachments.length ) * 100 ) + '%' ).html( regen_count + ' / ' + attachments.length + ' <?php echo esc_js( __( 'thumbnails regenerated', 'wf_order_import_export' ) ); ?>' );
320
+
321
+ if ( ! response.success ) {
322
+ $('#import-progress tbody').append( '<tr><td colspan="5">' + response.error + '</td></tr>' );
323
+ }
324
+ },
325
+ error: function( response ) {
326
+ $('#import-progress tbody').append( '<tr><td colspan="5">' + response.error + '</td></tr>' );
327
+ }
328
+ });
329
+ }
330
+
331
+ function import_done() {
332
+ var data = {
333
+ action: 'coupon_csv_import_request',
334
+ file: '<?php echo $file; ?>',
335
+ processed_terms: processed_terms,
336
+ processed_posts: processed_posts,
337
+ post_orphans: post_orphans,
338
+ upsell_skus: upsell_skus,
339
+ crosssell_skus: crosssell_skus
340
+ };
341
+
342
+ $.ajax({
343
+ url: '<?php echo add_query_arg( array( 'import_page' => $this->import_page, 'step' => '4', 'merge' => ! empty( $_GET['merge'] ) ? 1 : 0 ), admin_url( 'admin-ajax.php' ) ); ?>',
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
+ }
351
+ });
352
+ }
353
+ });
354
+ </script>
355
+ <?php
356
+ } else {
357
+ echo '<p class="error">' . __( 'Error finding uploaded file!', 'wf_order_import_export' ) . '</p>';
358
+ }
359
+ break;
360
+ case 3 :
361
+ // Check access - cannot use nonce here as it will expire after multiple requests
362
+ if ( ! current_user_can( 'manage_woocommerce' ) )
363
+ die();
364
+
365
+ add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );
366
+
367
+ if ( function_exists( 'gc_enable' ) )
368
+ gc_enable();
369
+
370
+ @set_time_limit(0);
371
+ @ob_flush();
372
+ @flush();
373
+ $wpdb->hide_errors();
374
+
375
+ $file = stripslashes( $_POST['file'] );
376
+ $mapping = json_decode( stripslashes( $_POST['mapping'] ), true );
377
+ $profile = isset( $_POST['profile'] ) ? $_POST['profile']:'';
378
+ $eval_field = $_POST['eval_field'];
379
+ $start_pos = isset( $_POST['start_pos'] ) ? absint( $_POST['start_pos'] ) : 0;
380
+ $end_pos = isset( $_POST['end_pos'] ) ? absint( $_POST['end_pos'] ) : '';
381
+
382
+ if($profile!== '')
383
+ {
384
+ $profile_array = get_option('wf_cpn_csv_imp_exp_mapping');
385
+ $profile_array[$profile] = array($mapping,$eval_field);
386
+ update_option('wf_cpn_csv_imp_exp_mapping', $profile_array);
387
+ }
388
+
389
+ $position = $this->import_start( $file, $mapping, $start_pos, $end_pos, $eval_field );
390
+ $this->import();
391
+ $this->import_end();
392
+
393
+ $results = array();
394
+ $results['import_results'] = $this->import_results;
395
+ $results['processed_terms'] = $this->processed_terms;
396
+ $results['processed_posts'] = $this->processed_posts;
397
+ $results['post_orphans'] = $this->post_orphans;
398
+ $results['attachments'] = $this->attachments;
399
+ $results['upsell_skus'] = $this->upsell_skus;
400
+ $results['crosssell_skus'] = $this->crosssell_skus;
401
+
402
+ echo "<!--WC_START-->";
403
+ echo json_encode( $results );
404
+ echo "<!--WC_END-->";
405
+ exit;
406
+ break;
407
+ case 4 :
408
+ // Check access - cannot use nonce here as it will expire after multiple requests
409
+ if ( ! current_user_can( 'manage_woocommerce' ) )
410
+ die();
411
+
412
+ add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );
413
+
414
+ if ( function_exists( 'gc_enable' ) )
415
+ gc_enable();
416
+
417
+ @set_time_limit(0);
418
+ @ob_flush();
419
+ @flush();
420
+ $wpdb->hide_errors();
421
+
422
+ $this->processed_terms = isset( $_POST['processed_terms'] ) ? $_POST['processed_terms'] : array();
423
+ $this->processed_posts = isset( $_POST['processed_posts']) ? $_POST['processed_posts'] : array();
424
+ $this->post_orphans = isset( $_POST['post_orphans']) ? $_POST['post_orphans'] : array();
425
+ $this->crosssell_skus = isset( $_POST['crosssell_skus']) ? array_filter( (array) $_POST['crosssell_skus'] ) : array();
426
+ $this->upsell_skus = isset( $_POST['upsell_skus']) ? array_filter( (array) $_POST['upsell_skus'] ) : array();
427
+
428
+ _e( 'Step 1...', 'wf_order_import_export' ) . ' ';
429
+
430
+ wp_defer_term_counting( true );
431
+ wp_defer_comment_counting( true );
432
+
433
+ _e( 'Step 2...', 'wf_order_import_export' ) . ' ';
434
+
435
+ echo 'Step 3...' . ' '; // Easter egg
436
+ _e( 'Finalizing...', 'wf_order_import_export' ) . ' ';
437
+
438
+
439
+ // SUCCESS
440
+ _e( 'Finished. Import complete.', 'wf_order_import_export' );
441
+
442
+ $this->import_end();
443
+ exit;
444
+ break;
445
+ }
446
+
447
+ $this->footer();
448
+ }
449
+
450
+ /**
451
+ * format_data_from_csv
452
+ */
453
+ public function format_data_from_csv( $data, $enc ) {
454
+ return ( $enc == 'UTF-8' ) ? $data : utf8_encode( $data );
455
+ }
456
+
457
+ /**
458
+ * Display pre-import options
459
+ */
460
+ public function import_options()
461
+ {
462
+ $j = 0;
463
+
464
+ if ( $this->id )
465
+ $file = get_attached_file( $this->id );
466
+ else if ( $this->file_url_import_enabled )
467
+ $file = ABSPATH . $this->file_url;
468
+ else
469
+ return;
470
+
471
+ // Set locale
472
+ $enc = mb_detect_encoding( $file, 'UTF-8, ISO-8859-1', true );
473
+ if ( $enc ) setlocale( LC_ALL, 'en_US.' . $enc );
474
+ @ini_set( 'auto_detect_line_endings', true );
475
+
476
+ // Get headers
477
+ if ( ( $handle = fopen( $file, "r" ) ) !== FALSE )
478
+ {
479
+ $row = $raw_headers = array();
480
+
481
+ $header = fgetcsv( $handle, 0, $this->delimiter , '"', '"');
482
+
483
+ while ( ( $postmeta = fgetcsv( $handle, 0, $this->delimiter , '"', '"') ) !== FALSE )
484
+ {
485
+ foreach ( $header as $key => $heading )
486
+ {
487
+ if ( ! $heading ) continue;
488
+ $s_heading = strtolower( $heading );
489
+ $row[$s_heading] = ( isset( $postmeta[$key] ) ) ? $this->format_data_from_csv( $postmeta[$key], $enc ) : '';
490
+ $raw_headers[ $s_heading ] = $heading;
491
+ }
492
+ break;
493
+ }
494
+ fclose( $handle );
495
+ }
496
+
497
+ $mapping_from_db = get_option( 'wf_cpn_csv_imp_exp_mapping');
498
+
499
+ if( $this->profile!=='' && !empty($_GET['clearmapping']))
500
+ {
501
+ unset($mapping_from_db[$this->profile]);
502
+ update_option('wf_cpn_csv_imp_exp_mapping', $mapping_from_db);
503
+ $this->profile = '';
504
+ }
505
+ if($this->profile !== '')
506
+ $mapping_from_db = $mapping_from_db[$this->profile];
507
+
508
+ $saved_mapping = null;
509
+ $saved_evaluation = null;
510
+ if($mapping_from_db && is_array($mapping_from_db) && count($mapping_from_db) == 2 && empty($_GET['clearmapping']))
511
+ {
512
+ $reset_action = 'admin.php?clearmapping=1&amp;profile='.$this->profile.'&amp;import=' . $this->import_page . '&amp;step=1&amp;merge=' . ( ! empty( $_GET['merge'] ) ? 1 : 0 ) . '&amp;file_url=' . $this->file_url . '&amp;delimiter=' . $this->delimiter . '&amp;merge_empty_cells=' . $this->merge_empty_cells . '&amp;file_id=' . $this->id . '';
513
+ $reset_action = esc_attr(wp_nonce_url($reset_action, 'import-upload'));
514
+ echo '<h3>' . __( 'Columns are pre-selected using the Mapping file: "<b style="color:gray">'.$this->profile.'</b>". <a href="'.$reset_action.'"> Delete</a> this mapping file.', 'wf_order_import_export' ) . '</h3>';
515
+ $saved_mapping = $mapping_from_db[0];
516
+ $saved_evaluation = $mapping_from_db[1];
517
+ }
518
+
519
+ $merge = (!empty($_GET['merge']) && $_GET['merge']) ? 1 : 0;
520
+ include( 'views-coupon/html-wf-import-options.php' );
521
+ }
522
+
523
+ /**
524
+ * The main controller for the actual import stage.
525
+ */
526
+ public function import()
527
+ {
528
+ global $woocommerce, $wpdb;
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 );
537
+ if ( ! is_wp_error( $coupon ) )
538
+ $this->process_coupon( $coupon );
539
+ else
540
+ $this->add_import_result( 'failed', $coupon->get_error_message(), 'Not parsed', json_encode( $item ) );
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
+
548
+ /**
549
+ * Parses the CSV file and prepares us for the task of processing parsed data
550
+ *
551
+ * @param string $file Path to the CSV file for importing
552
+ */
553
+ public function import_start( $file, $mapping, $start_pos, $end_pos, $eval_field ) {
554
+
555
+ $memory = size_format( woocommerce_let_to_num( ini_get( 'memory_limit' ) ) );
556
+ $wp_memory = size_format( woocommerce_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
+
568
+ wp_defer_term_counting( true );
569
+ wp_defer_comment_counting( true );
570
+
571
+ return $position;
572
+ }
573
+
574
+ /**
575
+ * Performs post-import cleanup of files and the cache
576
+ */
577
+ public function import_end() {
578
+
579
+ do_action( 'import_end' );
580
+ }
581
+
582
+ /**
583
+ * Handles the CSV upload and initial parsing of the file to prepare for
584
+ * displaying author import options
585
+ *
586
+ * @return bool False if error uploading or invalid file, true otherwise
587
+ */
588
+ public function handle_upload() {
589
+ if($this->handle_ftp()){
590
+ return true;
591
+ }
592
+ if ( empty( $_POST['file_url'] ) ) {
593
+
594
+ $file = wp_import_handle_upload();
595
+
596
+ if ( isset( $file['error'] ) ) {
597
+ echo '<p><strong>' . __( 'Sorry, there has been an error.', 'wf_order_import_export' ) . '</strong><br />';
598
+ echo esc_html( $file['error'] ) . '</p>';
599
+ return false;
600
+ }
601
+
602
+ $this->id = (int) $file['id'];
603
+ return true;
604
+
605
+ } else {
606
+
607
+ if ( file_exists( ABSPATH . $_POST['file_url'] ) )
608
+ {
609
+ $this->file_url = esc_attr( $_POST['file_url'] );
610
+ return true;
611
+ } else {
612
+ echo '<p><strong>' . __( 'Sorry, there has been an error.', 'wf_order_import_export' ) . '</strong></p>';
613
+ return false;
614
+ }
615
+
616
+ }
617
+
618
+ return false;
619
+ }
620
+
621
+ public function coupon_exists( $title, $ID = '', $post_name = '' )
622
+ {
623
+ global $wpdb;
624
+
625
+ // Post Title Check
626
+ $post_title = stripslashes( sanitize_post_field( 'post_title', $title, 0, 'db' ) );
627
+
628
+ $query = "SELECT ID FROM $wpdb->posts WHERE post_type = 'shop_coupon' AND post_status IN ( 'publish', 'private', 'draft', 'pending', 'future' )";
629
+ $args = array();
630
+
631
+ if ( ! empty ( $post_name ) )
632
+ {
633
+ $query .= ' AND post_name = %s';
634
+ $args[] = $post_name;
635
+ }
636
+
637
+ if ( ! empty ( $args ) )
638
+ {
639
+ $posts_that_exist = $wpdb->get_col( $wpdb->prepare( $query, $args ) );
640
+ if ( $posts_that_exist )
641
+ {
642
+ foreach( $posts_that_exist as $post_exists )
643
+ {
644
+ if ( $ID == $post_exists )
645
+ {
646
+ return true;
647
+ }
648
+ }
649
+ }
650
+ }
651
+ return false;
652
+ }
653
+
654
+ /**
655
+ * Create new posts based on import information
656
+ */
657
+ public function process_coupon( $post )
658
+ {
659
+
660
+ $processing_coupon_id = absint( $post['post_id'] );
661
+ $processing_coupon = get_post( $processing_coupon_id );
662
+ $processing_coupon_title = $processing_coupon ? $processing_coupon->post_title : '';
663
+ $processing_coupon_sku = $processing_coupon ? $processing_coupon->sku : '';
664
+ $merging = ! empty( $post['merging'] );
665
+
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
+ }
679
+
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
+ }
687
+ if ( ! $merging )
688
+ {
689
+ if ( $this->coupon_exists( $processing_coupon_title, $processing_coupon_id, $post['post_name'] ) )
690
+ {
691
+ if(!$processing_coupon_id)
692
+ {
693
+ $usr_msg = 'Coupon with same title already exists.';
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
+ }
702
+
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
+ }
720
+
721
+ if ( $merging && !empty($is_post_exist_in_db) )
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
729
+ );
730
+
731
+ if ( $this->merge_empty_cells )
732
+ {
733
+ if ( isset( $post['post_content'] ) ) {
734
+ $postdata['post_content'] = $post['post_content'];
735
+ }
736
+ if ( isset( $post['post_excerpt'] ) ) {
737
+ $postdata['post_excerpt'] = $post['post_excerpt'];
738
+ }
739
+
740
+ } else {
741
+ if ( ! empty( $post['post_content'] ) ) {
742
+ $postdata['post_content'] = $post['post_content'];
743
+ }
744
+ if ( ! empty( $post['post_excerpt'] ) ) {
745
+ $postdata['post_excerpt'] = $post['post_excerpt'];
746
+ }
747
+
748
+ }
749
+
750
+ if ( ! empty( $post['post_title'] ) ) {
751
+ $postdata['post_title'] = $post['post_title'];
752
+ }
753
+
754
+ if ( ! empty( $post['post_author'] ) ) {
755
+ $postdata['post_author'] = absint( $post['post_author'] );
756
+ }
757
+ if ( ! empty( $post['post_date'] ) ) {
758
+ $postdata['post_date'] = date("Y-m-d H:i:s", strtotime( $post['post_date'] ) );
759
+ }
760
+ if ( ! empty( $post['post_date_gmt'] ) ) {
761
+ $postdata['post_date_gmt'] = date("Y-m-d H:i:s", strtotime( $post['post_date_gmt'] ) );
762
+ }
763
+ if ( ! empty( $post['post_name'] ) ) {
764
+ $postdata['post_name'] = $post['post_name'];
765
+ }
766
+ if ( ! empty( $post['post_status'] ) ) {
767
+ $postdata['post_status'] = $post['post_status'];
768
+ }
769
+
770
+ if ( sizeof( $postdata ) > 1 )
771
+ {
772
+ $result = wp_update_post( $postdata );
773
+
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'] )) : '',
793
+ 'post_date_gmt' => ( $post['post_date_gmt'] ) ? date( 'Y-m-d H:i:s', strtotime( $post['post_date_gmt'] )) : '',
794
+ 'post_content' => $post['post_excerpt'],
795
+ 'post_excerpt' => $post['post_excerpt'],
796
+ 'post_title' => $post['post_title'],
797
+ 'post_name' => ( $post['post_name'] ) ? $post['post_name'] : sanitize_title( $post['post_title'] ),
798
+ 'post_status' => ( $post['post_status'] ) ? $post['post_status'] : 'publish',
799
+ 'post_type' => 'shop_coupon',
800
+ );
801
+
802
+ $post_id = wp_insert_post( $postdata, true );
803
+
804
+ if ( is_wp_error( $post_id ) )
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
+ }
818
+
819
+ unset( $postdata );
820
+
821
+ if ( empty( $processing_coupon_id ) ) {
822
+ $processing_coupon_id = (int) $post_id;
823
+ }
824
+
825
+ $this->processed_posts[ intval( $processing_coupon_id ) ] = (int) $post_id;
826
+ if ( ! empty( $post['postmeta'] ) && is_array( $post['postmeta'] ) )
827
+ {
828
+ foreach ( $post['postmeta'] as $meta )
829
+ {
830
+ $key = apply_filters( 'import_post_meta_key', $meta['key'] );
831
+
832
+ if ( $key )
833
+ {
834
+ if($key == 'product_categories' || $key == 'exclude_product_categories')
835
+ {
836
+ update_post_meta( $post_id, $key, explode(",",$meta['value'] ) );
837
+ }
838
+ else
839
+ {
840
+ update_post_meta( $post_id, $key, maybe_unserialize( $meta['value'] ) );
841
+ }
842
+
843
+ }
844
+ }
845
+ unset( $post['postmeta'] );
846
+ }
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
+ }
857
+
858
+ /**
859
+ * Log a row's import status
860
+ */
861
+ protected function add_import_result( $status, $reason, $post_id = '', $post_title = '' ) {
862
+ $this->import_results[] = array(
863
+ 'post_title' => $post_title,
864
+ 'post_id' => $post_id,
865
+ 'status' => $status,
866
+ 'reason' => $reason
867
+ );
868
+ }
869
+ /**
870
+ * Attempt to download a remote file attachment
871
+ */
872
+ public function fetch_remote_file( $url, $post )
873
+ {
874
+
875
+ // extract the file name and extension from the url
876
+ $file_name = basename( current( explode( '?', $url ) ) );
877
+ $wp_filetype = wp_check_filetype( $file_name, null );
878
+ $parsed_url = @parse_url( $url );
879
+
880
+ // Check parsed URL
881
+ if ( ! $parsed_url || ! is_array( $parsed_url ) )
882
+ return new WP_Error( 'import_file_error', 'Invalid URL' );
883
+
884
+ // Ensure url is valid
885
+ $url = str_replace( " ", '%20', $url );
886
+
887
+ // Get the file
888
+ $response = wp_remote_get( $url, array(
889
+ 'timeout' => 10
890
+ ) );
891
+
892
+ if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) !== 200 )
893
+ return new WP_Error( 'import_file_error', 'Error getting remote image' );
894
+
895
+ // Ensure we have a file name and type
896
+ if ( ! $wp_filetype['type'] ) {
897
+
898
+ $headers = wp_remote_retrieve_headers( $response );
899
+
900
+ if ( isset( $headers['content-disposition'] ) && strstr( $headers['content-disposition'], 'filename=' ) ) {
901
+
902
+ $disposition = end( explode( 'filename=', $headers['content-disposition'] ) );
903
+ $disposition = sanitize_file_name( $disposition );
904
+ $file_name = $disposition;
905
+
906
+ } elseif ( isset( $headers['content-type'] ) && strstr( $headers['content-type'], 'image/' ) ) {
907
+
908
+ $file_name = 'image.' . str_replace( 'image/', '', $headers['content-type'] );
909
+
910
+ }
911
+
912
+ unset( $headers );
913
+ }
914
+
915
+ // Upload the file
916
+ $upload = wp_upload_bits( $file_name, '', wp_remote_retrieve_body( $response ) );
917
+
918
+ if ( $upload['error'] )
919
+ return new WP_Error( 'upload_dir_error', $upload['error'] );
920
+
921
+ // Get filesize
922
+ $filesize = filesize( $upload['file'] );
923
+
924
+ if ( 0 == $filesize ) {
925
+ @unlink( $upload['file'] );
926
+ unset( $upload );
927
+ return new WP_Error( 'import_file_error', __('Zero size file downloaded', 'wf_order_import_export') );
928
+ }
929
+
930
+ unset( $response );
931
+
932
+ return $upload;
933
+ }
934
+ private function handle_ftp()
935
+ {
936
+ $enable_ftp_ie = !empty( $_POST['enable_ftp_ie'] ) ? true : false;
937
+ if($enable_ftp_ie == false)
938
+ {
939
+ $settings_in_db = get_option( 'wf_coupon_tracking_importer_ftp', null );
940
+ $settings_in_db['enable_ftp_ie'] = false;
941
+ update_option( 'wf_coupon_tracking_importer_ftp', $settings_in_db );
942
+ return false;
943
+ }
944
+
945
+ $ftp_server = ! empty( $_POST['ftp_server'] ) ? $_POST['ftp_server'] : '';
946
+ $ftp_server_path = ! empty( $_POST['ftp_server_path'] ) ? $_POST['ftp_server_path'] : '';
947
+ $ftp_user = ! empty( $_POST['ftp_user'] ) ? $_POST['ftp_user'] : '';
948
+ $ftp_password = ! empty( $_POST['ftp_password'] ) ? $_POST['ftp_password'] : '';
949
+ $use_ftps = ! empty( $_POST['use_ftps'] ) ? true : false;
950
+
951
+
952
+ $settings = array();
953
+ $settings[ 'ftp_server' ] = $ftp_server;
954
+ $settings[ 'ftp_user' ] = $ftp_user;
955
+ $settings[ 'ftp_password' ] = $ftp_password;
956
+ $settings[ 'use_ftps' ] = $use_ftps;
957
+ $settings[ 'enable_ftp_ie' ] = $enable_ftp_ie;
958
+ $settings[ 'ftp_server_path' ] = $ftp_server_path;
959
+
960
+
961
+ $local_file = 'wp-content/plugins/order-import-export-for-woocommerce/temp-import.csv';
962
+ $server_file = $ftp_server_path;
963
+
964
+ update_option( 'wf_coupon_tracking_importer_ftp', $settings );
965
+
966
+ $ftp_conn = $use_ftps ? ftp_ssl_connect($ftp_server) : ftp_connect($ftp_server);
967
+ $error_message = "";
968
+ $success = false;
969
+ if($ftp_conn == false){
970
+ $error_message = "There is connection problem\n";
971
+ }
972
+
973
+ if(empty($error_message)){
974
+ if(ftp_login($ftp_conn, $ftp_user, $ftp_password) == false){
975
+ $error_message = "Not able to login \n";
976
+ }
977
+ }
978
+ if(empty($error_message)){
979
+
980
+ if (ftp_get($ftp_conn, ABSPATH.$local_file, $server_file, FTP_BINARY)) {
981
+ $error_message = "";
982
+ $success = true;
983
+ } else {
984
+ $error_message = "There was a problem\n";
985
+ }
986
+ }
987
+
988
+ ftp_close($ftp_conn);
989
+ if($success){
990
+ $this->file_url = $local_file;
991
+ }else{
992
+ die($error_message);
993
+ }
994
+ return true;
995
+ }
996
+
997
+ // Display import page title
998
+ public function header() {
999
+ echo '<div class="wrap"><div class="icon32" id="icon-woocommerce-importer"><br></div>';
1000
+ echo '<h2>' . ( empty( $_GET['merge'] ) ? __( 'Import', 'wf_order_import_export' ) : __( 'Merge Coupons', 'wf_order_import_export' ) ) . '</h2>';
1001
+ }
1002
+
1003
+ // Close div.wrap
1004
+ public function footer() {
1005
+ echo '</div>';
1006
+ }
1007
+
1008
+ /**
1009
+ * Display introductory text and file upload form
1010
+ */
1011
+ public function greet()
1012
+ {
1013
+ $action = 'admin.php?import=coupon_csv&amp;step=1&amp;merge=' . ( ! empty( $_GET['merge'] ) ? 1 : 0 );
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
+
1021
+ /**
1022
+ * Added to http_request_timeout filter to force timeout at 60 seconds during import
1023
+ * @return int 60
1024
+ */
1025
+ public function bump_request_timeout( $val ) {
1026
+ return 60;
1027
+ }
1028
+
1029
+ }
includes/importer/class-wf-cpnimpexpcsv-importer.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
+ class WF_CpnImpExpCsv_Importer {
7
+
8
+ /**
9
+ * Coupon Exporter Tool
10
+ */
11
+ public static function load_wp_importer() {
12
+ // Load Importer API
13
+ require_once ABSPATH . 'wp-admin/includes/import.php';
14
+
15
+ if ( ! class_exists( 'WP_Importer' ) ) {
16
+ $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
17
+ if ( file_exists( $class_wp_importer ) ) {
18
+ require $class_wp_importer;
19
+ }
20
+ }
21
+ }
22
+
23
+ /**
24
+ * Coupon Importer Tool
25
+ */
26
+ public static function coupon_importer() {
27
+ if ( ! defined( 'WP_LOAD_IMPORTERS' ) ) {
28
+ return;
29
+ }
30
+
31
+ self::load_wp_importer();
32
+
33
+ // includes
34
+ require_once 'class-wf-cpnimpexpcsv-coupon-import.php';
35
+ require_once 'class-wf-csv-parser-coupon.php';
36
+
37
+ // Dispatch
38
+ $GLOBALS['WF_CSV_Coupon_Import'] = new WF_CpnImpExpCsv_Coupon_Import();
39
+ $GLOBALS['WF_CSV_Coupon_Import'] ->dispatch();
40
+ }
41
+ }
includes/importer/class-wf-csv-parser-coupon.php ADDED
@@ -0,0 +1,284 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WooCommerce CSV Importer class for managing parsing of CSV files.
4
+ */
5
+ class WF_CSV_Parser_Coupon {
6
+
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
14
+
15
+ /**
16
+ * Constructor
17
+ */
18
+ public function __construct( $post_type = 'shop_coupon' )
19
+ {
20
+ $this->post_type = $post_type;
21
+ $this->reserved_fields = include( 'data-coupon/data-wf-reserved-fields.php' );
22
+ $this->post_defaults = include( 'data-coupon/data-wf-post-defaults.php' );
23
+ $this->postmeta_defaults = include( 'data-coupon/data-wf-postmeta-defaults.php' );
24
+ $this->postmeta_allowed = include( 'data-coupon/data-wf-postmeta-allowed.php' );
25
+ $this->allowed_coupon_types = array(
26
+ 'fixed_cart' ,
27
+ 'percent',
28
+ 'fixed_product',
29
+ 'percent_product'
30
+ );
31
+
32
+ }
33
+
34
+ /**
35
+ * Format data from the csv file
36
+ * @param string $data
37
+ * @param string $enc
38
+ * @return string
39
+ */
40
+ public function format_data_from_csv( $data, $enc ) {
41
+ return ( $enc == 'UTF-8' ) ? $data : utf8_encode( $data );
42
+ }
43
+
44
+ /**
45
+ * Parse the data
46
+ * @param string $file [description]
47
+ * @param string $delimiter [description]
48
+ * @param array $mapping [description]
49
+ * @param integer $start_pos [description]
50
+ * @param integer $end_pos [description]
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 );
58
+ @ini_set( 'auto_detect_line_endings', true );
59
+
60
+ $parsed_data = array();
61
+ $raw_headers = array();
62
+
63
+ // Put all CSV data into an associative array
64
+ if ( ( $handle = fopen( $file, "r" ) ) !== FALSE ) {
65
+
66
+ $header = fgetcsv( $handle, 0, $delimiter , '"', '"' );
67
+ if ( $start_pos != 0 )
68
+ fseek( $handle, $start_pos );
69
+
70
+ while ( ( $postmeta = fgetcsv( $handle, 0, $delimiter , '"', '"' ) ) !== FALSE ) {
71
+ $row = array();
72
+
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
+ foreach ($mapping as $mkey => $mvalue) {
91
+ if(trim($mvalue) === trim($heading)){
92
+ $s_heading = $mkey;
93
+ }
94
+ }
95
+
96
+ if ( $s_heading == '' )
97
+ continue;
98
+
99
+ // Add the heading to the parsed data
100
+ $row[$s_heading] = ( isset( $postmeta[$key] ) ) ? $this->format_data_from_csv( $postmeta[$key], $enc ) : '';
101
+
102
+ $row[$s_heading] = $this->evaluate_field($row[$s_heading], $eval_field[$s_heading]);
103
+
104
+ // Raw Headers stores the actual column name in the CSV
105
+ $raw_headers[ $s_heading ] = $heading;
106
+ }
107
+ $parsed_data[] = $row;
108
+
109
+ unset( $postmeta, $row );
110
+
111
+ $position = ftell( $handle );
112
+
113
+ if ( $end_pos && $position >= $end_pos )
114
+ break;
115
+ }
116
+ fclose( $handle );
117
+ }
118
+ return array( $parsed_data, $raw_headers, $position );
119
+ }
120
+
121
+ private function evaluate_field($value, $evaluation_field)
122
+ {
123
+ $processed_value = $value;
124
+ if(!empty($evaluation_field)){
125
+ $operator = substr($evaluation_field, 0, 1);
126
+ if(in_array($operator, array('=', '+', '-', '*', '/', '&'))){
127
+ $eval_val = substr($evaluation_field, 1);
128
+ switch($operator){
129
+ case '=':
130
+ $processed_value = trim($eval_val);
131
+ break;
132
+ case '+':
133
+ $processed_value = $this->hf_currency_formatter($value) + $eval_val;
134
+ break;
135
+ case '-':
136
+ $processed_value = $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
+ if (strpos($eval_val, '[VAL]') !== false) {
146
+ $processed_value = str_replace('[VAL]',$value,$eval_val);
147
+ }
148
+ else{
149
+ $processed_value = $value . $eval_val;
150
+ }
151
+ break;
152
+ }
153
+ }
154
+ }
155
+ return $processed_value;
156
+ }
157
+
158
+ /**
159
+ * Parse product
160
+ * @param array $item
161
+ * @param integer $merge_empty_cells
162
+ * @return array
163
+ */
164
+ public function parse_coupon( $item, $merge_empty_cells = 0 ) {
165
+ global $WF_CSV_Coupon_Import, $wpdb;
166
+ $this->row++;
167
+
168
+ $terms_array = $postmeta = $product = array();
169
+ $attributes = $default_attributes = $gpf_data = null;
170
+ // Merging
171
+ $merging = ( ! empty( $_GET['merge'] ) && $_GET['merge'] ) ? true : false;
172
+ $this->post_defaults['post_type'] = 'shop_coupon';
173
+
174
+ $post_id = ( ! empty( $item['id'] ) ) ? $item['id'] : 0;
175
+ $post_id = ( ! empty( $item['post_id'] ) ) ? $item['post_id'] : $post_id;
176
+ if ( $merging )
177
+ {
178
+ $product['merging'] = true;
179
+ $WF_CSV_Coupon_Import->log->add( 'csv-import', sprintf( __('> Row %s - preparing for merge.', 'wf_order_import_export'), $this->row ) );
180
+ if ( ! $post_id )
181
+ {
182
+ $WF_CSV_Coupon_Import->log->add( 'csv-import', __( '> > Cannot merge without id or sku. Importing instead.', 'wf_order_import_export') );
183
+
184
+ $merging = false;
185
+ } else
186
+ {
187
+ if ( ! $post_id )
188
+ {
189
+ $post_db_type = $this->post_defaults['post_type'];
190
+ $post_pass_type = '"'.$post_db_type.'"';
191
+ $db_query = $wpdb->prepare("
192
+ SELECT $wpdb->posts.ID
193
+ FROM $wpdb->posts
194
+ LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id)
195
+ WHERE $wpdb->posts.post_type = $post_pass_type
196
+ AND $wpdb->posts.post_status IN ( 'publish', 'private', 'draft', 'pending', 'future' )
197
+ AND $wpdb->posts.ID = '%d'
198
+ ", $item['ID']);
199
+ $found_product_id = $wpdb->get_var($db_query);
200
+ if ( ! $found_product_id )
201
+ {
202
+ $WF_CSV_Coupon_Import->log->add( 'csv-import', sprintf(__( '> > Skipped. Cannot find coupon with sku %s. Importing instead.', 'wf_order_import_export'), $item['sku']) );
203
+ $merging = false;
204
+
205
+ } else
206
+ {
207
+
208
+ $post_id = $found_product_id;
209
+ $WF_CSV_Coupon_Import->log->add( 'csv-import', sprintf(__( '> > Found coupon with ID %s.', 'wf_order_import_export'), $post_id) );
210
+
211
+ }
212
+ }
213
+ $product['merging'] = true;
214
+ }
215
+ }
216
+
217
+ if ( ! $merging )
218
+ {
219
+
220
+ $product['merging'] = false;
221
+ $WF_CSV_Coupon_Import->log->add( 'csv-import', sprintf( __('> Row %s - preparing for import.', 'wf_order_import_export'), $this->row ) );
222
+ if ( isset($item['post_parent']) && $item['post_parent']=== '' && $item['post_title']=== '') {
223
+ $WF_CSV_Coupon_Import->log->add( 'csv-import', __( '> > Skipped. No post_title set for new coupon.', 'wf_order_import_export') );
224
+ return new WP_Error( 'parse-error', __( 'No post_title set for new coupon.', 'wf_order_import_export' ) );
225
+ }
226
+ if ( isset($item['post_parent']) && $item['post_parent']!== '' && $item['post_parent']!== null && $item['parent_sku'] === '' )
227
+ {
228
+ $WF_CSV_Coupon_Import->log->add( 'csv-import', __( '> > Skipped. No parent set for new variation product.', 'wf_order_import_export') );
229
+ return new WP_Error( 'parse-error', __( 'No parent set for new variation product.', 'wf_order_import_export' ) );
230
+ }
231
+ }
232
+
233
+ $product['post_id'] = $post_id;
234
+ foreach ( $this->post_defaults as $column => $default )
235
+ {
236
+ if ( isset( $item[ $column ] ) ) $product[ $column ] = $item[ $column ];
237
+ }
238
+
239
+ // Get custom fields
240
+ foreach ( $this->postmeta_defaults as $column => $default )
241
+ {
242
+ if ( isset( $item[$column] ) )
243
+ $postmeta[$column] = (string) $item[$column];
244
+ elseif ( isset( $item[$column] ) )
245
+ $postmeta[$column] = (string) $item[$column];
246
+
247
+ // Check custom fields are valid
248
+ if ( isset( $postmeta[$column] ) && isset( $this->postmeta_allowed[$column] ) && ! in_array( $postmeta[$column], $this->postmeta_allowed[$column] ) )
249
+ {
250
+ $postmeta[$column] = $this->postmeta_defaults[$column];
251
+ }
252
+ }
253
+
254
+ if ( ! $merging )
255
+ {
256
+ // Merge post meta with defaults
257
+ $product = wp_parse_args( $product, $this->post_defaults );
258
+ $postmeta = wp_parse_args( $postmeta, $this->postmeta_defaults );
259
+ }
260
+ if ( ! empty( $product['post_status'] ) )
261
+ {
262
+ if ( ! in_array( $product['post_status'], array( 'publish', 'private', 'draft', 'pending', 'future', 'inherit', 'trash' ) ) ) {
263
+ $product['post_status'] = 'publish';
264
+ }
265
+
266
+ if ( ! in_array( $product['post_status'], array( 'private', 'publish' ) ) ) {
267
+ $product['post_status'] = 'publish';
268
+ }
269
+
270
+ }
271
+ foreach ( $postmeta as $key => $value ) {
272
+ $product['postmeta'][] = array( 'key' => esc_attr($key), 'value' => $value );
273
+ }
274
+
275
+ $product['post_title'] = ( ! empty( $item['post_title'] ) ) ? $item['post_title'] : '';
276
+ unset( $item, $terms_array, $postmeta, $attributes, $gpf_data, $images );
277
+ return $product;
278
+ }
279
+ function hf_currency_formatter($price)
280
+ {
281
+ $decimal_seperator = wc_get_price_decimal_separator();
282
+ return preg_replace("[^0-9\\'.$decimal_seperator.']", "", $price);
283
+ }
284
+ }
includes/importer/data-coupon/data-wf-post-defaults.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
+ // New post defaults
7
+ return array(
8
+ 'post_type' => 'shop_coupon',
9
+ 'menu_order' => '',
10
+ 'postmeta' => array(),
11
+ 'post_status' => 'publish',
12
+ 'post_title' => '',
13
+ 'post_name' => '',
14
+ 'post_date' => '',
15
+ 'post_date_gmt' => '',
16
+ //'post_content' => '',
17
+ 'post_excerpt' => '',
18
+ 'post_parent' => '',
19
+ //'post_password' => '',
20
+ 'post_author' => '',
21
+ //'comment_status'=> 'open'
22
+ );
includes/importer/data-coupon/data-wf-postmeta-allowed.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
+ // New postmeta allowed
7
+ return array(
8
+ /*'downloadable' => array( 'yes', 'no' ),
9
+ 'virtual' => array( 'yes', 'no' ),
10
+ 'visibility' => array( 'visible', 'catalog', 'search', 'hidden' ),
11
+ 'stock_status' => array( 'instock', 'outofstock' ),
12
+ 'backorders' => array( 'yes', 'no', 'notify' ),
13
+ 'manage_stock' => array( 'yes', 'no' ),
14
+ 'tax_status' => array( 'taxable', 'shipping', 'none' ),
15
+ 'featured' => array( 'yes', 'no' ),*/
16
+ );
includes/importer/data-coupon/data-wf-postmeta-defaults.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
+ // New postmeta defaults
7
+ return apply_filters( 'coupon_csv_product_postmeta_defaults', array(
8
+ 'discount_type' => '',
9
+ 'coupon_amount' => '',
10
+ 'individual_use' => 'yes',
11
+ 'product_ids' => '',
12
+ 'exclude_product_ids' => '',
13
+ 'usage_limit' => '',
14
+ 'usage_limit_per_user' => '',
15
+ 'limit_usage_to_x_items' => '',
16
+ 'expiry_date' => '',
17
+ 'free_shipping' => 'no',
18
+ 'exclude_sale_items' => 'no',
19
+ 'product_categories' => '',
20
+ 'exclude_product_categories' => '',
21
+ 'minimum_amount' => '',
22
+ 'maximum_amount' => '',
23
+ 'customer_email' => '',
24
+ ) );
includes/importer/data-coupon/data-wf-reserved-fields-pair.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) {
3
+ exit;
4
+ }
5
+ // Reserved column names
6
+ return apply_filters('hf_coupon_csv_alter_order_data_columns', array(
7
+ 'id' => 'Coupon ID | Coupon ID',
8
+ 'post_title' => 'Coupon Title | Name of the coupon ',
9
+ //'post_name' => 'Coupon Permalink | Unique part of the coupon URL',
10
+ 'post_status' => 'Coupon Status | Coupon Status ( published , draft ...)',
11
+ //'post_content' => 'Coupon Description | Description about the Coupon',
12
+ 'post_excerpt' => 'Coupon Short Description | Short description about the Coupon',
13
+ 'post_date' => 'Post Date | Coupon posted date',
14
+ 'discount_type' => 'Coupon Type | fixed_cart OR percent OR fixed_product OR percent_product',
15
+ 'coupon_amount' => 'Coupon Amount | Numeric values',
16
+ 'individual_use' => 'Individual Use? | yes or no',
17
+ 'product_ids' => 'Assocoated Product Ids | With comma(,) Separator',
18
+ 'exclude_product_ids' => 'Exclude Product Ids | With comma(,) Separator',
19
+ 'usage_limit' => 'Usage Limit Per Coupon | Numeric Values',
20
+ 'usage_limit_per_user' => 'Usage Limit Per User | Numeric Values',
21
+ 'limit_usage_to_x_items' => 'Limit Usage To X Items | Maximum Number Of Individual Items This Coupon Can Apply',
22
+ 'expiry_date' => 'Expiry Date | YYYY-MM-DD',
23
+ 'free_shipping' => 'Is Free Shipping? | yes or no',
24
+ 'exclude_sale_items' => 'Is Exclude Sale Items? | yes or no',
25
+ 'product_categories' => 'Product Categories | with comma(,) Separator',
26
+ 'exclude_product_categories' => 'Exclude Product Categories | With comma(,) Separator',
27
+ 'minimum_amount' => 'Minimum Amount | Numeric',
28
+ 'maximum_amount' => 'Maximum Amount | Numeric',
29
+ 'customer_email' => 'Restricted Customers Email Ids| With comma(,) Separator',
30
+ //'post_date_gmt' => 'Post Date GMT | Tooltip data Status',
31
+ ));
includes/importer/data-coupon/data-wf-reserved-fields.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('ABSPATH')) {
3
+ exit;
4
+ }
5
+ // Reserved column names
6
+ return array(
7
+ 'id',
8
+ 'discount_type',
9
+ 'post_id',
10
+ 'post_title',
11
+ 'post_name',
12
+ 'post_status',
13
+ 'post_date',
14
+ 'post_date_gmt',
15
+ 'post_excerpt',
16
+ 'post_type',
17
+ 'post_author',
18
+ 'postmeta',
19
+ 'coupon_amount',
20
+ 'individual_use',
21
+ 'product_ids',
22
+ 'exclude_product_ids',
23
+ 'usage_limit',
24
+ 'usage_limit_per_user',
25
+ 'limit_usage_to_x_items',
26
+ 'expiry_date',
27
+ 'free_shipping',
28
+ 'exclude_sale_items',
29
+ 'product_categories',
30
+ 'exclude_product_categories',
31
+ 'minimum_amount',
32
+ 'maximum_amount',
33
+ 'customer_email',
34
+ );
includes/importer/views-coupon/html-wf-import-greeting.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div>
2
+ <p><?php _e( 'You can import coupons (in CSV format) in to the shop using any of below methods.', 'wf_order_import_export' ); ?></p>
3
+
4
+ <?php if ( ! empty( $upload_dir['error'] ) ) : ?>
5
+ <div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:'); ?></p>
6
+ <p><strong><?php echo $upload_dir['error']; ?></strong></p></div>
7
+ <?php else : ?>
8
+ <form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo esc_attr(wp_nonce_url($action, 'import-upload')); ?>">
9
+ <table class="form-table">
10
+ <tbody>
11
+ <tr>
12
+ <th>
13
+ <label for="upload"><?php _e( 'Method 1: Select a file from your computer' ); ?></label>
14
+ </th>
15
+ <td>
16
+ <input type="file" id="upload" name="import" size="25" />
17
+ <input type="hidden" name="action" value="save" />
18
+ <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
19
+ <small><?php printf( __('Maximum size: %s' ), $size ); ?></small>
20
+ </td>
21
+ </tr>
22
+
23
+ </tbody>
24
+ </table>
25
+ <p class="submit">
26
+ <input type="submit" class="button button-primary" value="<?php esc_attr_e( 'Upload file and import' ); ?>" />
27
+ </p>
28
+ </form>
29
+ <?php endif; ?>
30
+ </div>
includes/importer/views-coupon/html-wf-import-options.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <form action="<?php echo admin_url('admin.php?import=' . $this->import_page . '&step=2&merge=' . $merge); ?>" method="post" id="nomap">
2
+ <?php wp_nonce_field('import-woocommerce'); ?>
3
+ <input type="hidden" name="import_id" value="<?php echo $this->id; ?>" />
4
+ <?php if ($this->file_url_import_enabled) : ?>
5
+ <input type="hidden" name="import_url" value="<?php echo $this->file_url; ?>" />
6
+ <?php endif; ?>
7
+
8
+ <p class="submit">
9
+ <input style="display:none" type="submit" class="button button-primary" value="<?php esc_attr_e('Submit', 'wf_order_import_export'); ?>" />
10
+ <input type="hidden" name="delimiter" value="<?php echo $this->delimiter ?>" />
11
+ <input type="hidden" name="merge_empty_cells" value="<?php echo $this->merge_empty_cells ?>" />
12
+ </p>
13
+ </form>
14
+ <script type="text/javascript">
15
+ jQuery(document).ready(function () {
16
+ jQuery("form#nomap").submit();
17
+ });
18
+ </script>
includes/views/export/html-wf-export-coupons.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="tool-box">
2
+ <h3 class="title"><?php _e('Export Coupon in CSV Format:', 'wf_order_import_export'); ?></h3>
3
+ <p><?php _e('Export and download your coupons in CSV format. This file can be used to import coupons back into your Woocommerce shop.', 'wf_order_import_export'); ?></p>
4
+ <form action="<?php echo admin_url('admin.php?page=wf_coupon_csv_im_ex&action=export'); ?>" method="post">
5
+
6
+ <table class="form-table">
7
+
8
+ </table>
9
+ <p class="submit"><input type="submit" class="button button-primary" value="<?php _e('Export Coupons', 'wf_order_import_export'); ?>" /></p>
10
+ </form>
11
+ </div>
includes/views/html-wf-admin-screen.php CHANGED
@@ -2,6 +2,8 @@
2
  <div class="icon32" id="icon-woocommerce-importer"><br></div>
3
  <h2 class="nav-tab-wrapper woo-nav-tab-wrapper">
4
  <a href="<?php echo admin_url('admin.php?page=wf_woocommerce_order_im_ex') ?>" class="nav-tab <?php echo ($tab == 'import') ? 'nav-tab-active' : ''; ?>"><?php _e('Order Import / Export', 'wf_order_import_export'); ?></a>
 
 
5
  </h2>
6
 
7
  <?php
@@ -9,6 +11,12 @@
9
  case "export" :
10
  $this->admin_export_page();
11
  break;
 
 
 
 
 
 
12
  default :
13
  $this->admin_import_page();
14
  break;
2
  <div class="icon32" id="icon-woocommerce-importer"><br></div>
3
  <h2 class="nav-tab-wrapper woo-nav-tab-wrapper">
4
  <a href="<?php echo admin_url('admin.php?page=wf_woocommerce_order_im_ex') ?>" class="nav-tab <?php echo ($tab == 'import') ? 'nav-tab-active' : ''; ?>"><?php _e('Order Import / Export', 'wf_order_import_export'); ?></a>
5
+ <a href="<?php echo admin_url('admin.php?page=wf_coupon_csv_im_ex&tab=coupon') ?>" class="nav-tab <?php echo ($tab == 'coupon') ? 'nav-tab-active' : ''; ?>"><?php _e('Coupon Import / Export', 'wf_order_import_export'); ?></a>
6
+ <a href="<?php echo admin_url('admin.php?page=wf_woocommerce_order_im_ex&tab=subscription') ?>" class="nav-tab <?php echo ($tab == 'subscription') ? 'nav-tab-active' : ''; ?>"><?php _e('Subscription Import / Export', 'wf_order_import_export'); ?></a>
7
  </h2>
8
 
9
  <?php
11
  case "export" :
12
  $this->admin_export_page();
13
  break;
14
+ case "coupon" :
15
+ $this->admin_coupon_page();
16
+ break;
17
+ case "subscription" :
18
+ $this->admin_subscription_page();
19
+ break;
20
  default :
21
  $this->admin_import_page();
22
  break;
includes/views/html-wf-getting-started-subscription.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="message" class="updated woocommerce-message wc-connect">
2
+ <div class="squeezer">
3
+ <h4><?php _e('<strong>This Feature is only available in Premium version</strong>', 'wf_order_import_export'); ?></h4>
4
+ <p class="submit">
5
+ <a href="http://www.xadapter.com/product/order-import-export-plugin-for-woocommerce/" target="_blank" class="button button-primary"><?php _e('Upgrade to Premium Version', 'wf_order_import_export'); ?></a>
6
+ <a href="http://orderimportexport.hikeforce.com/wp-admin/admin.php?page=wf_woocommerce_order_im_ex" target="_blank" class="button"><?php _e('Live Demo', 'wf_order_import_export'); ?></a>
7
+ <a href="http://www.xadapter.com/2016/06/20/setting-up-order-import-export-plugin-for-woocommerce/" target="_blank" class="button"><?php _e('Documentation', 'wf_order_import_export'); ?></a>
8
+ <a href="<?php echo plugins_url('Sample_Subscription.csv', WF_OrderImpExpCsv_FILE); ?>" target="_blank" class="button"><?php _e('Sample Subscription CSV', 'wf_order_import_export'); ?></a>
9
+ </p>
10
+ </div>
11
+ </div>
includes/views/import/html-wf-import-coupons.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="wf-banner updated below-h2">
2
+ <p class="main">
3
+ <li style='color:red;'><strong><?php _e('Your Business is precious! Go Premium!' , 'wf_order_import_export');?></strong></li>
4
+ <strong><?php _e('Order Import Export Plugin Premium version helps you to seamlessly import/export orders , coupons and subscriptions into your Woocommerce Store.', 'wf_order_import_export'); ?></strong>
5
+ <p>
6
+ <?php _e('-Filtering options while Export using Coupon Types, Coupon Amount, Coupon Expiry Date, Offset and Limit.', 'wf_order_import_export'); ?><br/>
7
+ <?php _e('-Import orders , coupons and subscriptions from any CSV format ( Magento, Shopify, OpenCart etc. ) into your WooComemrce Store using Column Mapping Feature.', 'wf_order_import_export'); ?><br/>
8
+ <?php _e('-Export orders , coupons and subscriptions right from the WooCommerce Admin Order Listing page.', 'wf_order_import_export'); ?><br/>
9
+ <?php _e('-Change values while import using Evaluation Field feature.', 'wf_order_import_export'); ?><br/>
10
+ <?php _e('-Supports WooCommerce URL Coupons Import Export.', 'wf_order_import_export'); ?><br/>
11
+ <?php _e('-Import and Export orders , coupons and subscriptions from/to remote location via FTP.', 'wf_order_import_export'); ?><br/>
12
+ <?php _e('-Automatic Import/Export orders , coupons and subscriptions from/to remote location via FTP on specified interval .', 'wf_order_import_export'); ?><br/>
13
+ <?php _e('-Excellent Support for setting it up!', 'wf_order_import_export'); ?><br/>
14
+ </p>
15
+ </p>
16
+ <p>
17
+ <a href="http://www.xadapter.com/product/order-import-export-plugin-for-woocommerce/" target="_blank" class="button button-primary"><?php _e('Upgrade to Premium Version', 'wf_order_import_export'); ?></a>
18
+ <a href="http://orderimportexport.hikeforce.com/wp-admin/admin.php?page=wf_woocommerce_order_im_ex" target="_blank" class="button"><?php _e('Live Demo', 'wf_order_import_export'); ?></a>
19
+ <a href="http://www.xadapter.com/2016/06/20/setting-up-order-import-export-plugin-for-woocommerce/" target="_blank" class="button"><?php _e('Documentation', 'wf_order_import_export'); ?></a>
20
+ <a href="<?php echo plugins_url('Sample_Coupon.csv', WF_OrderImpExpCsv_FILE); ?>" target="_blank" class="button"><?php _e('Sample Coupon CSV', 'wf_order_import_export'); ?></a>
21
+ </p>
22
+ </div>
23
+ <style>
24
+ .wf-banner img {
25
+ float: right;
26
+ margin-left: 1em;
27
+ padding: 15px 0
28
+ }
29
+ </style>
30
+
31
+
32
+ <div class="tool-box">
33
+ <h3 class="title"><?php _e('Import Coupons in CSV Format:', 'wf_order_import_export'); ?></h3>
34
+ <p><?php _e('Import coupons in CSV format from different sources ( from your computer OR from another server via FTP )', 'wf_order_import_export'); ?></p>
35
+ <p class="submit">
36
+ <?php
37
+ $merge_url = admin_url('admin.php?import=coupon_csv&merge=1');
38
+ $import_url = admin_url('admin.php?import=coupon_csv');
39
+ ?>
40
+ <a class="button button-primary" id="mylink" href="<?php echo admin_url('admin.php?import=coupon_csv'); ?>"><?php _e('Import Coupons', 'wf_order_import_export'); ?></a>
41
+ &nbsp;
42
+ <input type="checkbox" id="merge" value="0"><?php _e('Merge coupons if exists', 'wf_order_import_export'); ?> <br>
43
+ </p>
44
+ </div>
45
+ <script type="text/javascript">
46
+ jQuery('#merge').click(function () {
47
+ if (this.checked) {
48
+ jQuery("#mylink").attr("href", '<?php echo $merge_url ?>');
49
+ } else {
50
+ jQuery("#mylink").attr("href", '<?php echo $import_url ?>');
51
+ }
52
+ });
53
+ </script>
includes/views/import/html-wf-import-orders.php CHANGED
@@ -1,20 +1,22 @@
1
  <div class="wf-banner updated below-h2">
2
  <p class="main">
3
  <li style='color:red;'><strong><?php _e('Your Business is precious! Go Premium!' , 'wf_order_import_export');?></strong></li>
4
- <strong><?php _e('Order Import Export Plugin Premium version helps you to seamlessly import/export orders into your Woocommerce Store.', 'wf_order_import_export'); ?></strong>
5
  <p>
6
  <?php _e('-Filtering options while Export using Order Status, Start Date, End Date, Offset and Limit.', 'wf_order_import_export'); ?><br/>
7
- <?php _e('-Import orders from any CSV format ( Magento, Shopify, OpenCart etc. ) into your WooComemrce Store using Column Mapping Feature.', 'wf_order_import_export'); ?><br/>
8
- <?php _e('-Export orders right from the WooCommerce Admin Order Listing page.', 'wf_order_import_export'); ?><br/>
9
- <?php _e('-Import and Export orders from/to remote location via FTP.', 'wf_order_import_export'); ?><br/>
 
 
10
  <?php _e('-Excellent Support for setting it up!', 'wf_order_import_export'); ?><br/>
11
  </p>
12
  </p>
13
  <p>
14
- <a href="http://www.xadapter.com/product/order-import-export-plugin-for-woocommerce/" target="_blank" class="button button-primary"><?php _e('Upgrade to Premium Version', 'wf_csv_import_export'); ?></a>
15
- <a href="http://orderimportexport.hikeforce.com/wp-admin/admin.php?page=wf_woocommerce_order_im_ex" target="_blank" class="button"><?php _e('Live Demo', 'wf_csv_import_export'); ?></a>
16
- <a href="http://www.xadapter.com/2016/06/20/setting-up-order-import-export-plugin-for-woocommerce/" target="_blank" class="button"><?php _e('Documentation', 'wf_csv_import_export'); ?></a>
17
- <a href="<?php echo plugins_url('Order_Sample.csv', WF_OrderImpExpCsv_FILE); ?>" target="_blank" class="button"><?php _e('Sample CSV', 'wf_csv_import_export'); ?></a>
18
  </p>
19
  </div>
20
  <style>
@@ -47,9 +49,4 @@
47
  jQuery("#mylink").attr("href", '<?php echo $import_url ?>');
48
  }
49
  });
50
- jQuery(document).on( 'click', '.notice-dismiss', function() {
51
- jQuery(this).parents('div.rate-us:first').slideUp();
52
- jQuery.post('admin.php?page=wf_woocommerce_order_im_ex', {dismiss: true}, function (data) {
53
- }, 'json');
54
- });
55
  </script>
1
  <div class="wf-banner updated below-h2">
2
  <p class="main">
3
  <li style='color:red;'><strong><?php _e('Your Business is precious! Go Premium!' , 'wf_order_import_export');?></strong></li>
4
+ <strong><?php _e('Order Import Export Plugin Premium version helps you to seamlessly import/export orders , coupons and subscriptions into your Woocommerce Store.', 'wf_order_import_export'); ?></strong>
5
  <p>
6
  <?php _e('-Filtering options while Export using Order Status, Start Date, End Date, Offset and Limit.', 'wf_order_import_export'); ?><br/>
7
+ <?php _e('-Import orders , coupons and subscriptions from any CSV format ( Magento, Shopify, OpenCart etc. ) into your WooComemrce Store using Column Mapping Feature.', 'wf_order_import_export'); ?><br/>
8
+ <?php _e('-Export orders , coupons and subscriptions right from the WooCommerce Admin Order Listing page.', 'wf_order_import_export'); ?><br/>
9
+ <?php _e('-Change values while import using Evaluation Field feature.', 'wf_order_import_export'); ?><br/>
10
+ <?php _e('-Import and Export orders , coupons and subscriptions from/to remote location via FTP.', 'wf_order_import_export'); ?><br/>
11
+ <?php _e('-Automatic Import/Export orders , coupons and subscriptions from/to remote location via FTP on specified interval .', 'wf_order_import_export'); ?><br/>
12
  <?php _e('-Excellent Support for setting it up!', 'wf_order_import_export'); ?><br/>
13
  </p>
14
  </p>
15
  <p>
16
+ <a href="http://www.xadapter.com/product/order-import-export-plugin-for-woocommerce/" target="_blank" class="button button-primary"><?php _e('Upgrade to Premium Version', 'wf_order_import_export'); ?></a>
17
+ <a href="http://orderimportexport.hikeforce.com/wp-admin/admin.php?page=wf_woocommerce_order_im_ex" target="_blank" class="button"><?php _e('Live Demo', 'wf_order_import_export'); ?></a>
18
+ <a href="http://www.xadapter.com/2016/06/20/setting-up-order-import-export-plugin-for-woocommerce/" target="_blank" class="button"><?php _e('Documentation', 'wf_order_import_export'); ?></a>
19
+ <a href="<?php echo plugins_url('Sample_Order.csv', WF_OrderImpExpCsv_FILE); ?>" target="_blank" class="button"><?php _e('Sample Order CSV', 'wf_order_import_export'); ?></a>
20
  </p>
21
  </div>
22
  <style>
49
  jQuery("#mylink").attr("href", '<?php echo $import_url ?>');
50
  }
51
  });
 
 
 
 
 
52
  </script>
order-import-export.php CHANGED
@@ -1,12 +1,12 @@
1
  <?php
2
  /*
3
  *
4
- Plugin Name: Woocommerce Order Export Import(BASIC)
5
  Plugin URI: http://www.xadapter.com/product/order-import-export-plugin-for-woocommerce/
6
  Description: Export and Import Order detail including line items, From and To your WooCommerce Store.
7
  Author: HikeForce
8
  Author URI: http://www.xadapter.com/vendor/hikeforce/
9
- Version: 1.1.0
10
  Text Domain: wf_order_import_export
11
  */
12
 
@@ -17,6 +17,9 @@ if ( ! defined( 'ABSPATH' ) || ! is_admin() ) {
17
  define( "WF_ORDER_IMP_EXP_ID", "wf_order_imp_exp" );
18
  define( "WF_WOOCOMMERCE_ORDER_IM_EX", "wf_woocommerce_order_im_ex" );
19
 
 
 
 
20
  /**
21
  * Check if WooCommerce is active
22
  */
@@ -43,7 +46,6 @@ if (in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', ge
43
  add_action( 'init', array( $this, 'catch_save_settings' ), 20 );
44
  add_action( 'admin_init', array( $this, 'register_importers' ) );
45
 
46
- include_once( 'includes/class-wf-orderimpexpcsv-system-status-tools.php' );
47
  include_once( 'includes/class-wf-orderimpexpcsv-admin-screen.php' );
48
  include_once( 'includes/importer/class-wf-orderimpexpcsv-importer.php' );
49
 
@@ -130,5 +132,140 @@ if (in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', ge
130
  endif;
131
 
132
  new WF_Order_Import_Export_CSV();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
 
134
  }
1
  <?php
2
  /*
3
  *
4
+ Plugin Name: Order / Coupon / Subscription Export Import Plugin for WooCommerce (BASIC)
5
  Plugin URI: http://www.xadapter.com/product/order-import-export-plugin-for-woocommerce/
6
  Description: Export and Import Order detail including line items, From and To your WooCommerce Store.
7
  Author: HikeForce
8
  Author URI: http://www.xadapter.com/vendor/hikeforce/
9
+ Version: 1.1.1
10
  Text Domain: wf_order_import_export
11
  */
12
 
17
  define( "WF_ORDER_IMP_EXP_ID", "wf_order_imp_exp" );
18
  define( "WF_WOOCOMMERCE_ORDER_IM_EX", "wf_woocommerce_order_im_ex" );
19
 
20
+ define("WF_CPN_IMP_EXP_ID", "wf_cpn_imp_exp");
21
+ define("wf_coupon_csv_im_ex", "wf_coupon_csv_im_ex");
22
+
23
  /**
24
  * Check if WooCommerce is active
25
  */
46
  add_action( 'init', array( $this, 'catch_save_settings' ), 20 );
47
  add_action( 'admin_init', array( $this, 'register_importers' ) );
48
 
 
49
  include_once( 'includes/class-wf-orderimpexpcsv-admin-screen.php' );
50
  include_once( 'includes/importer/class-wf-orderimpexpcsv-importer.php' );
51
 
132
  endif;
133
 
134
  new WF_Order_Import_Export_CSV();
135
+
136
+
137
+
138
+ if (!class_exists('WF_Coupon_Import_Export_CSV')) :
139
+
140
+ class WF_Coupon_Import_Export_CSV {
141
+
142
+ public $cron;
143
+ public $cron_import;
144
+
145
+ /**
146
+ * Constructor
147
+ */
148
+ public function __construct() {
149
+ define('WF_CpnImpExpCsv_FILE', __FILE__);
150
+
151
+
152
+ if (is_admin()) {
153
+ add_action('admin_notices', array($this, 'wf_coupon_ie_admin_notice'), 15);
154
+ }
155
+
156
+ add_filter('woocommerce_screen_ids', array($this, 'woocommerce_screen_ids'));
157
+ add_action('init', array($this, 'load_plugin_textdomain'));
158
+ add_action('init', array($this, 'catch_export_request'), 20);
159
+ add_action('init', array($this, 'catch_save_settings'), 20);
160
+ add_action('admin_init', array($this, 'register_importers'));
161
+
162
+ include_once( 'includes/class-wf-cpnimpexpcsv-admin-screen.php' );
163
+ include_once( 'includes/importer/class-wf-cpnimpexpcsv-importer.php' );
164
+
165
+
166
+
167
+ if (defined('DOING_AJAX')) {
168
+ include_once( 'includes/class-wf-cpnimpexpcsv-ajax-handler.php' );
169
+ }
170
+
171
+
172
+ }
173
+
174
+
175
+ function wf_coupon_ie_admin_notice() {
176
+ global $pagenow;
177
+ global $post;
178
+
179
+ if (!isset($_GET["wf_coupon_ie_msg"]) && empty($_GET["wf_coupon_ie_msg"])) {
180
+ return;
181
+ }
182
+
183
+ $wf_coupon_ie_msg = $_GET["wf_coupon_ie_msg"];
184
+
185
+ switch ($wf_coupon_ie_msg) {
186
+ case "1":
187
+ echo '<div class="update"><p>' . __('Successfully uploaded via FTP.', 'wf_order_import_export') . '</p></div>';
188
+ break;
189
+ case "2":
190
+ echo '<div class="error"><p>' . __('Error while uploading via FTP.', 'wf_order_import_export') . '</p></div>';
191
+ break;
192
+ case "3":
193
+ echo '<div class="error"><p>' . __('Please choose the file in CSV format using Method 1.', 'wf_order_import_export') . '</p></div>';
194
+ break;
195
+ }
196
+ }
197
+
198
+ /**
199
+ * Add screen ID
200
+ */
201
+ public function woocommerce_screen_ids($ids) {
202
+ $ids[] = 'admin'; // For import screen
203
+ return $ids;
204
+ }
205
+
206
+ /**
207
+ * Handle localisation
208
+ */
209
+ public function load_plugin_textdomain() {
210
+ load_plugin_textdomain('wf_order_import_export', false, dirname(plugin_basename(__FILE__)) . '/lang/');
211
+ }
212
+
213
+ /**
214
+ * Catches an export request and exports the data. This class is only loaded in admin.
215
+ */
216
+ public function catch_export_request() {
217
+ if (!empty($_GET['action']) && !empty($_GET['page']) && $_GET['page'] == 'wf_coupon_csv_im_ex') {
218
+ switch ($_GET['action']) {
219
+ case "export" :
220
+ $user_ok = $this->hf_user_permission();
221
+ if ($user_ok) {
222
+ include_once( 'includes/exporter/class-wf-cpnimpexpcsv-exporter.php' );
223
+ WF_CpnImpExpCsv_Exporter::do_export('shop_coupon');
224
+ } else {
225
+ wp_redirect(wp_login_url());
226
+ }
227
+ break;
228
+ }
229
+ }
230
+ }
231
+
232
+ public function catch_save_settings() {
233
+ if (!empty($_GET['action']) && !empty($_GET['page']) && $_GET['page'] == 'wf_coupon_csv_im_ex') {
234
+ switch ($_GET['action']) {
235
+ case "settings" :
236
+ include_once( 'includes/settings/class-wf-allimpexpcsv-settings.php' );
237
+ wf_allImpExpCsv_Settings::save_settings();
238
+ break;
239
+ }
240
+ }
241
+ }
242
+
243
+ /**
244
+ * Register importers for use
245
+ */
246
+ public function register_importers() {
247
+ register_importer('coupon_csv', 'WooCommerce Coupons (CSV)', __('Import <strong>coupon</strong> to your store via a csv file.', 'wf_order_import_export'), 'WF_CpnImpExpCsv_Importer::coupon_importer');
248
+ }
249
+
250
+ private function hf_user_permission() {
251
+ // Check if user has rights to export
252
+ $current_user = wp_get_current_user();
253
+ $user_ok = false;
254
+ $wf_roles = apply_filters('hf_user_permission_roles', array('administrator', 'shop_manager'));
255
+ if ($current_user instanceof WP_User) {
256
+ $can_users = array_intersect($wf_roles, $current_user->roles);
257
+ if (!empty($can_users)) {
258
+ $user_ok = true;
259
+ }
260
+ }
261
+ return $user_ok;
262
+ }
263
+
264
+ }
265
+
266
+ endif;
267
+
268
+ new WF_Coupon_Import_Export_CSV();
269
+
270
 
271
  }
readme.txt CHANGED
@@ -1,33 +1,32 @@
1
- === Order Export Import for WooCommerce ===
2
  Contributors: hikeforce
3
  Donate link:
4
- Tags: woocommerce export orders, woocommerce import orders, woocommerce export import orders, export woocommerce orders with line item details
5
  Requires at least: 3.0.1
6
  Tested up to: 4.6
7
- Stable tag: 1.1.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- WooCommerce Export Orders Made Easy! WooCommerce Order Export plugin is fast way for export and import Order Data.
12
 
13
  == Description ==
14
 
15
  = Introduction =
16
-
17
- WooCommerce Order Export Import Plugin helps you to easily export and import orders in your store. This plugin lets you import/export all orders with line item details. It is super simple!
18
-
19
  <ul>
20
- <li>Export Orders into a CSV file.</li>
21
- <li>Import Orders from CSV file into WooCommerce Store.</li>
 
22
  </ul>
23
 
24
- Highlights: Simply Export Orders, Customer Order CSV Export, Export Orders to Excel. Best WooCommerce Order Export Plugin in Market.
25
 
26
  = How does it work? =
27
 
28
- The WooCommerce Order Export Import Plugin takes CSV (Comma-Separated Values) file as input. You must create a CSV file and enter the order details in a structured format as explained in the tutorial. This is to match each field of CSV file to the field of a particular order that otherwise Admin need to input manually.
29
 
30
- You can create the CSV from scratch or you can export the order to get the format of CSV. You can use a spreadsheet program, such as Excel, or Google Spreadsheets for creating and modifying the CSV file. Save this file with extension .CSV. After entering all details about orders in spreadsheet, you can import order to your online store. With this plugin, you can also export and download order details as a CSV file.
31
 
32
 
33
  <blockquote>
@@ -35,9 +34,14 @@ You can create the CSV from scratch or you can export the order to get the forma
35
  = Premium Version Features =
36
  <ul>
37
  <li>Filtering options while Export using Order Status, Start Date, End Date, Offset and Limit.</li>
38
- <li>Import orders from any CSV format ( Magento, Shopify, OpenCart etc. ) into your WooComemrce Store using Column Mapping Feature.</li>
39
- <li>Export orders right from the WooCommerce Admin Order Listing page.</li>
40
- <li>Import and Export orders from/to remote location via FTP.</li>
 
 
 
 
 
41
  <li>Excellent Support for setting it up!</li>
42
  </ul>
43
 
@@ -71,6 +75,9 @@ Yes. You can import or export order line item details.
71
  3. Exported sample order Screen
72
 
73
  == Changelog ==
 
 
 
74
  = 1.1.0 =
75
  * Security related improvements and bug fixes.
76
  = 1.0.9 =
@@ -95,6 +102,9 @@ Yes. You can import or export order line item details.
95
  * Export /Import WooCommerce Orders.
96
 
97
  == Upgrade Notice ==
 
 
 
98
  = 1.1.0 =
99
  * Security related improvements and bug fixes.
100
  = 1.0.9 =
1
+ === Order / Coupon / Subscription Export Import Plugin for WooCommerce (BASIC) ===
2
  Contributors: hikeforce
3
  Donate link:
4
+ Tags: woocommerce export orders, woocommerce import orders, woocommerce export import orders, export woocommerce orders with line item details,woocommerce export coupons, woocommerce import coupons, woocommerce export import coupons
5
  Requires at least: 3.0.1
6
  Tested up to: 4.6
7
+ Stable tag: 1.1.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ WooCommerce Export Orders, Coupons and Subscription Orders Made Easy! WooCommerce Order Export plugin is fast way for export and import Orders.
12
 
13
  == Description ==
14
 
15
  = Introduction =
16
+ This is perfect tool if you are migrating an existing shop on a different eCommerce platform to WooCommerce, allowing you to maintain your order history including subscription orders (available in premium). Plugin will even allow you to migrate thousands of coupons from your old eCommerce platform or Campaigns.
 
 
17
  <ul>
18
+ <li>Import and Export Orders to CSV file.</li>
19
+ <li>Import and Export Coupons to CSV file.</li>
20
+ <li>Import and Export Subscription Orders to CSV file(Premium Feature).</li>
21
  </ul>
22
 
23
+ Highlights: Simply Export Orders, Customer Order CSV Export, Export Orders to Excel, Export Coupons, Import Coupons, Export Subscriptions, Import Subscriptions. Best WooCommerce Order Export Plugin in Market.
24
 
25
  = How does it work? =
26
 
27
+ The Order / Coupon / Subscription Export Import Plugin's simple interface makes it extremely easy to map the data in your CSV file to the appropriate fields in WooCommerce. The plugin supports Custom Fields, dates, and pretty much every other WooCommerce Order / Subscription / Coupon field.
28
 
29
+ Our Plugin is designed to be efficient with large imports as it splits large import files into smaller chunks, making it possible to import large files with thousands of data and records, even on slow hosting providers.
30
 
31
 
32
  <blockquote>
34
  = Premium Version Features =
35
  <ul>
36
  <li>Filtering options while Export using Order Status, Start Date, End Date, Offset and Limit.</li>
37
+ <li>Filtering options while Export using Coupon Types, Coupon Amount, Coupon Expiry Date, Offset and Limit.</li>
38
+ <li>Import and Export Subscription Orders with Filtering and Mapping Options.</li>
39
+ <li>Change values while import using Evaluation Field feature.</li>
40
+ <li>Supports WooCommerce URL Coupons Import Export.</li>
41
+ <li>Import orders , coupons and subscriptions from any CSV format ( Magento, Shopify, OpenCart etc. ) into your WooComemrce Store using Column Mapping Feature.</li>
42
+ <li>Export orders , coupons and subscriptions right from the WooCommerce Admin Listing page.</li>
43
+ <li>Import and Export orders , coupons and subscriptions from/to remote location via FTP.</li>
44
+ <li>Schedule automatic Import/Export orders , coupons and subscriptions from/to remote location via FTP on a specified interval using Cron Job Feature.</li>
45
  <li>Excellent Support for setting it up!</li>
46
  </ul>
47
 
75
  3. Exported sample order Screen
76
 
77
  == Changelog ==
78
+ = 1.1.1 =
79
+ * Introduced coupon export import.
80
+ * Support for Subscription Orders export import in premium.
81
  = 1.1.0 =
82
  * Security related improvements and bug fixes.
83
  = 1.0.9 =
102
  * Export /Import WooCommerce Orders.
103
 
104
  == Upgrade Notice ==
105
+ = 1.1.1 =
106
+ * Introduced coupon export import.
107
+ * Support for Subscription Orders export import in premium.
108
  = 1.1.0 =
109
  * Security related improvements and bug fixes.
110
  = 1.0.9 =