Order Export & Order Import for WooCommerce - Version 1.1.2

Version Description

  • Optimized order line item import.
Download this release

Release Info

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

Code changes from version 1.1.1 to 1.1.2

includes/importer/class-wf-csv-parser.php CHANGED
@@ -564,25 +564,19 @@ class WF_CSV_Parser {
564
  }
565
  $name = array_shift( $_item_meta );
566
  $name = substr($name, strpos($name, ":") + 1);
567
- $product_identifier = array_shift( $_item_meta ); // sku or product_id:id
 
568
 
569
  $qty = array_shift( $_item_meta );
570
  $qty = substr($qty, strpos($qty, ":") + 1);
571
  $total = array_shift( $_item_meta );
572
  $total = substr($total, strpos($total, ":") + 1);
573
- //echo '<pre>';print_r($order);echo '</pre>';exit;
574
- // if ( ! $product_identifier || ! $qty || ! is_numeric( $total ) ) {
575
- // // invalid item
576
- // $WF_CSV_Order_Import->log->add( sprintf( __( '> > Skipped. Missing SKU, quantity or total for %s on row %s.', 'wf_order_import_export' ), 'line_item_' . $i, $row ) );
577
- // $skipped++;
578
- // $i++;
579
- // continue; // break outer loop
580
- // }
581
 
582
- // product_id or sku
583
- if ( false !== strpos( $product_identifier, 'product_id:' ) ) {
584
  // product by product_id
585
- $product_id = substr( $product_identifier, 11 );
586
 
587
  // not a product
588
  if ( ! in_array( get_post_type( $product_id ), array( 'product', 'product_variation' ) ) ) {
@@ -591,7 +585,7 @@ class WF_CSV_Parser {
591
 
592
  } else {
593
  // find by sku
594
- $product_sku = substr($product_identifier, strpos($product_identifier, ":") + 1);
595
  if($product_sku)
596
  $product_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_sku' AND meta_value=%s LIMIT 1", $product_sku ) );
597
  else $product_id = '';
564
  }
565
  $name = array_shift( $_item_meta );
566
  $name = substr($name, strpos($name, ":") + 1);
567
+ $product_identifier_by_id = array_shift( $_item_meta ); // product_id:id
568
+ $product_identifier_by_sku = array_shift( $_item_meta ); // sku
569
 
570
  $qty = array_shift( $_item_meta );
571
  $qty = substr($qty, strpos($qty, ":") + 1);
572
  $total = array_shift( $_item_meta );
573
  $total = substr($total, strpos($total, ":") + 1);
574
+
 
 
 
 
 
 
 
575
 
576
+ // find by id
577
+ if ( false !== strpos( $product_identifier_by_id, 'product_id:' ) ) {
578
  // product by product_id
579
+ $product_id = substr( $product_identifier_by_id, 11 );
580
 
581
  // not a product
582
  if ( ! in_array( get_post_type( $product_id ), array( 'product', 'product_variation' ) ) ) {
585
 
586
  } else {
587
  // find by sku
588
+ $product_sku = substr($product_identifier_by_sku, strpos($product_identifier_by_sku, ":") + 1);
589
  if($product_sku)
590
  $product_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_sku' AND meta_value=%s LIMIT 1", $product_sku ) );
591
  else $product_id = '';
includes/importer/class-wf-orderimpexpcsv-order-import.php CHANGED
@@ -582,6 +582,7 @@ class WF_OrderImpExpCsv_Order_Import extends WP_Importer {
582
  else{
583
  if($is_order_exist) {
584
  $order_id = $post['order_number'];
 
585
  } else {
586
  $order_id = wp_insert_post($order_data);
587
  $new_added = true;
@@ -597,13 +598,13 @@ class WF_OrderImpExpCsv_Order_Import extends WP_Importer {
597
 
598
  }
599
  // empty update to bump up the post_modified date to today's date (otherwise it would match the post_date, which isn't quite right)
600
- wp_update_post( array( 'ID' => $order_id ) );
601
 
602
  // handle special meta fields
603
  update_post_meta( $order_id, '_order_key', apply_filters( 'woocommerce_generate_order_key', uniqid( 'order_' ) ) );
604
  update_post_meta( $order_id, '_order_currency', get_woocommerce_currency() ); // TODO: fine to use store default?
605
  update_post_meta( $order_id, '_prices_include_tax', get_option( 'woocommerce_prices_include_tax' ) );
606
-
607
  // add order postmeta
608
  foreach ( $post['postmeta'] as $meta ) {
609
  $meta_processed = false;
582
  else{
583
  if($is_order_exist) {
584
  $order_id = $post['order_number'];
585
+ $wp_result = wp_update_post($order_data);
586
  } else {
587
  $order_id = wp_insert_post($order_data);
588
  $new_added = true;
598
 
599
  }
600
  // empty update to bump up the post_modified date to today's date (otherwise it would match the post_date, which isn't quite right)
601
+ //wp_update_post( array( 'ID' => $order_id ) );
602
 
603
  // handle special meta fields
604
  update_post_meta( $order_id, '_order_key', apply_filters( 'woocommerce_generate_order_key', uniqid( 'order_' ) ) );
605
  update_post_meta( $order_id, '_order_currency', get_woocommerce_currency() ); // TODO: fine to use store default?
606
  update_post_meta( $order_id, '_prices_include_tax', get_option( 'woocommerce_prices_include_tax' ) );
607
+ update_post_meta( $order_id, '_order_number', $post['order_number'] );
608
  // add order postmeta
609
  foreach ( $post['postmeta'] as $meta ) {
610
  $meta_processed = false;
order-import-export.php CHANGED
@@ -6,7 +6,7 @@ Plugin URI: http://www.xadapter.com/product/order-import-export-plugin-for-wooco
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
 
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.2
10
  Text Domain: wf_order_import_export
11
  */
12
 
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Order / Coupon / Subscription Export Import Plugin for WooCommerce (BASIC) ===
2
- Contributors: 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
 
@@ -75,6 +75,8 @@ Yes. You can import or export order line item details.
75
  3. Exported sample order Screen
76
 
77
  == Changelog ==
 
 
78
  = 1.1.1 =
79
  * Introduced coupon export import.
80
  * Support for Subscription Orders export import in premium.
@@ -102,6 +104,8 @@ Yes. You can import or export order line item details.
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.
1
  === Order / Coupon / Subscription Export Import Plugin for WooCommerce (BASIC) ===
2
+ Contributors: hikeforce, elvinwf
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.7
7
+ Stable tag: 1.1.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
75
  3. Exported sample order Screen
76
 
77
  == Changelog ==
78
+ = 1.1.2 =
79
+ * Optimized order line item import.
80
  = 1.1.1 =
81
  * Introduced coupon export import.
82
  * Support for Subscription Orders export import in premium.
104
  * Export /Import WooCommerce Orders.
105
 
106
  == Upgrade Notice ==
107
+ = 1.1.2 =
108
+ * Optimized order line item import.
109
  = 1.1.1 =
110
  * Introduced coupon export import.
111
  * Support for Subscription Orders export import in premium.