Order Export & Order Import for WooCommerce - Version 1.5.7

Version Description

  • Bug Fix:-Shipping tax not importing.
  • Tested OK with WP 5.3.2
Download this release

Release Info

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

Code changes from version 1.5.6 to 1.5.7

includes/exporter/class-wf-orderimpexpcsv-exporter.php CHANGED
@@ -138,11 +138,37 @@ class WF_OrderImpExpCsv_Exporter {
138
  $line_items[] = $line_item;
139
  }
140
 
141
- foreach ($order->get_shipping_methods() as $_ => $shipping_item) {
142
  $shipping_items[] = implode('|', array(
143
  'method:' . $shipping_item['name'],
144
  'total:' . wc_format_decimal($shipping_item['cost'], 2),
145
  ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  }
147
 
148
  // get fee items & total
@@ -361,4 +387,17 @@ class WF_OrderImpExpCsv_Exporter {
361
  }
362
  return $order_notes;
363
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
364
  }
138
  $line_items[] = $line_item;
139
  }
140
 
141
+ /* foreach ($order->get_shipping_methods() as $_ => $shipping_item) {
142
  $shipping_items[] = implode('|', array(
143
  'method:' . $shipping_item['name'],
144
  'total:' . wc_format_decimal($shipping_item['cost'], 2),
145
  ));
146
+ }*/
147
+
148
+ $line_items_shipping = $order->get_items('shipping');
149
+
150
+ foreach ($line_items_shipping as $item_id => $item) {
151
+ $item_meta = self::get_order_line_item_meta($item_id);
152
+ foreach ($item_meta as $key => $value) {
153
+ switch ($key){
154
+ case 'Items':
155
+ case 'method_id':
156
+ case 'taxes':
157
+ if(is_object($value))
158
+ $value = $value->meta_value;
159
+ if (is_array($value))
160
+ $value = implode(',', $value);
161
+ $meta[$key] = $value;
162
+ break;
163
+
164
+ }
165
+ }
166
+ foreach (array('Items','method_id','taxes') as $value){
167
+ if(!isset($meta[$value])){
168
+ $meta[$value] = '';
169
+ }
170
+ }
171
+ $shipping_items[] = trim(implode('|', array('items:' .$meta['Items'], 'method_id:' .$meta['method_id'], 'taxes:' .$meta['taxes'])));
172
  }
173
 
174
  // get fee items & total
387
  }
388
  return $order_notes;
389
  }
390
+
391
+ public static function get_order_line_item_meta($item_id){
392
+ global $wpdb;
393
+ $filtered_meta = apply_filters('wt_order_export_select_line_item_meta',array());
394
+ $filtered_meta = !empty($filtered_meta) ? implode("','",$filtered_meta) : '';
395
+ $query = "SELECT meta_key,meta_value
396
+ FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE order_item_id = '$item_id'";
397
+ if(!empty($filtered_meta)){
398
+ $query .= " AND meta_key IN ('".$filtered_meta."')";
399
+ }
400
+ $meta_keys = $wpdb->get_results($query , OBJECT_K );
401
+ return $meta_keys;
402
+ }
403
  }
includes/importer/class-wf-csv-parser.php CHANGED
@@ -679,6 +679,23 @@ class WF_CSV_Parser {
679
  }
680
  }
681
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
682
  if ($order) {
683
  $order['postmeta'] = $postmeta;
684
  $order['order_items'] = $order_items;
@@ -687,6 +704,7 @@ class WF_CSV_Parser {
687
  $order['order_shipping'] = $order_shipping_methods;
688
  $order['tax_items'] = $tax_items;
689
  $order['fee_items'] = $fee_items;
 
690
  // the order array will now contain the necessary name-value pairs for the wp_posts table, and also any meta data in the 'postmeta' array
691
  $results[] = $order;
692
  }
679
  }
680
  }
681
 
682
+ $shipping_items = $shipping_line_items = array();
683
+ if(isset($item['shipping_items']) && !empty($item['shipping_items'])){
684
+ $shipping_line_items = explode('|', $item['shipping_items']);
685
+ $items = array_shift($shipping_line_items);
686
+ $items = substr($items, strpos($items, ":") + 1);
687
+ $method_id = array_shift($shipping_line_items);
688
+ $method_id = substr($method_id, strpos($method_id, ":") + 1);
689
+ $taxes = array_shift($shipping_line_items);
690
+ $taxes = substr($taxes, strpos($taxes, ":") + 1);
691
+
692
+ $shipping_items = array(
693
+ 'Items' => $items,
694
+ 'method_id' => $method_id,
695
+ 'taxes' => $taxes
696
+ );
697
+ }
698
+
699
  if ($order) {
700
  $order['postmeta'] = $postmeta;
701
  $order['order_items'] = $order_items;
704
  $order['order_shipping'] = $order_shipping_methods;
705
  $order['tax_items'] = $tax_items;
706
  $order['fee_items'] = $fee_items;
707
+ $order['shipping_items'] = $shipping_items;
708
  // the order array will now contain the necessary name-value pairs for the wp_posts table, and also any meta data in the 'postmeta' array
709
  $results[] = $order;
710
  }
includes/importer/class-wf-orderimpexpcsv-order-import.php CHANGED
@@ -657,7 +657,16 @@ class WF_OrderImpExpCsv_Order_Import extends WP_Importer {
657
  wc_add_order_item_meta($shipping_order_item_id, 'cost', $order_shipping['cost']);
658
  }
659
  }
660
-
 
 
 
 
 
 
 
 
 
661
  // create the fee order items
662
  if (!empty($post['fee_items'])) {
663
  if ($merging && $is_order_exist) {
657
  wc_add_order_item_meta($shipping_order_item_id, 'cost', $order_shipping['cost']);
658
  }
659
  }
660
+ if (!empty($post['shipping_items'])) {
661
+ foreach ($post['shipping_items'] as $key => $value) {
662
+ if ($shipping_order_item_id) {
663
+ wc_add_order_item_meta($shipping_order_item_id, $key, $value);
664
+ } else {
665
+ $shipping_order_item_id = wc_add_order_item($order_id, $shipping_order_item);
666
+ wc_add_order_item_meta($shipping_order_item_id, $key, $value);
667
+ }
668
+ }
669
+ }
670
  // create the fee order items
671
  if (!empty($post['fee_items'])) {
672
  if ($merging && $is_order_exist) {
order-import-export-for-woocommerce.php CHANGED
@@ -6,7 +6,7 @@ Plugin URI: https://wordpress.org/plugins/order-import-export-for-woocommerce/
6
  Description: Export and Import Order detail including line items, From and To your WooCommerce Store.
7
  Author: WebToffee
8
  Author URI: https://www.webtoffee.com/product/woocommerce-order-coupon-subscription-export-import/
9
- Version: 1.5.6
10
  Text Domain: order-import-export-for-woocommerce
11
  WC tested up to: 3.8.1
12
  License: GPLv3
@@ -24,7 +24,7 @@ define("WF_CPN_IMP_EXP_ID", "wf_cpn_imp_exp");
24
  define("wf_coupon_csv_im_ex", "wf_coupon_csv_im_ex");
25
 
26
  if (!defined('WF_ORDERIMPEXP_CURRENT_VERSION')) {
27
- define("WF_ORDERIMPEXP_CURRENT_VERSION", "1.5.6");
28
  }
29
 
30
  /**
6
  Description: Export and Import Order detail including line items, From and To your WooCommerce Store.
7
  Author: WebToffee
8
  Author URI: https://www.webtoffee.com/product/woocommerce-order-coupon-subscription-export-import/
9
+ Version: 1.5.7
10
  Text Domain: order-import-export-for-woocommerce
11
  WC tested up to: 3.8.1
12
  License: GPLv3
24
  define("wf_coupon_csv_im_ex", "wf_coupon_csv_im_ex");
25
 
26
  if (!defined('WF_ORDERIMPEXP_CURRENT_VERSION')) {
27
+ define("WF_ORDERIMPEXP_CURRENT_VERSION", "1.5.7");
28
  }
29
 
30
  /**
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: webtoffee
3
  Donate link: https://www.webtoffee.com/plugins/
4
  Tags: Order Export, Order Import, WooCommerce Export Orders , WooCommerce Import Orders , Export Orders, Import Orders , order, export, import, woocommerce, csv, coupon, coupon export, coupon import, woocommerce export coupon , woocommerce import coupon , export coupons, import coupons,
5
  Requires at least: 3.0.1
6
- Tested up to: 5.3
7
- Stable tag: 1.5.6
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -115,6 +115,9 @@ By default, admin and store manager are given access to export orders from your
115
 
116
  == Changelog ==
117
 
 
 
 
118
  = 1.5.6 =
119
  * provision to export for Super Admin users.
120
  * Tested OK with WP 5.3 and WC 3.8.1
3
  Donate link: https://www.webtoffee.com/plugins/
4
  Tags: Order Export, Order Import, WooCommerce Export Orders , WooCommerce Import Orders , Export Orders, Import Orders , order, export, import, woocommerce, csv, coupon, coupon export, coupon import, woocommerce export coupon , woocommerce import coupon , export coupons, import coupons,
5
  Requires at least: 3.0.1
6
+ Tested up to: 5.3.2
7
+ Stable tag: 1.5.7
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
115
 
116
  == Changelog ==
117
 
118
+ = 1.5.7 =
119
+ * Bug Fix:-Shipping tax not importing.
120
+ * Tested OK with WP 5.3.2
121
  = 1.5.6 =
122
  * provision to export for Super Admin users.
123
  * Tested OK with WP 5.3 and WC 3.8.1