Version Description
- Bug fix: Refund,Coupon,Fee Items export import.
Download this release
Release Info
Developer | webtoffee |
Plugin | Order Export & Order Import for WooCommerce |
Version | 1.4.9 |
Comparing to | |
See all releases |
Code changes from version 1.4.8 to 1.4.9
- Sample_Order.csv +7 -7
- includes/exporter/class-wf-orderimpexpcsv-exporter.php +18 -9
- includes/exporter/data/data-wf-post-columns.php +2 -1
- includes/importer/class-wf-csv-parser.php +52 -2
- includes/importer/class-wf-orderimpexpcsv-order-import.php +81 -2
- includes/importer/data/data-wf-reserved-fields-pair.php +1 -1
- order-import-export-for-woocommerce.php +2 -2
- readme.txt +6 -7
Sample_Order.csv
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
-
order_id,order_number,order_date,status,shipping_total,shipping_tax_total,fee_total,fee_tax_total,tax_total,cart_discount,order_discount,discount_total,order_total,
|
2 |
-
1001,1001,16-05-2018 07:32:06,completed,10,1.8,1,0.18,3.42,0,0,0,22.42,
|
3 |
-
",name:Gift Wrap|total:1.00|tax:0.18,code:GST-1|total:3.42
|
4 |
-
1002,1002,16-05-2018 07:25:28,on-hold,10,1.8,0,0,5.04,0,0,0,33.04,
|
5 |
-
",,code:GST-1|total:5.04,,Order status changed from Pending payment to Processing.|Washing machine (A15) stock reduced from 30 to 29.|IPN payment completed,1,name:Washing machine|product_id:616773451|sku:A15|quantity:1|total:18.00|tax:3.24,,
|
6 |
-
1003,1003,16-05-2018 07:21:32,processing,10,1.8,0,0,8.99,10,10,10,58.98,
|
7 |
-
",,code:GST-1|total:8.99,code:flat20|
|
1 |
+
order_id,order_number,order_date,status,shipping_total,shipping_tax_total,fee_total,fee_tax_total,tax_total,cart_discount,order_discount,discount_total,order_total,order_currency,payment_method,shipping_method,customer_id,customer_user,customer_email,billing_first_name,billing_last_name,billing_company,billing_email,billing_phone,billing_address_1,billing_address_2,billing_postcode,billing_city,billing_state,billing_country,shipping_first_name,shipping_last_name,shipping_company,shipping_address_1,shipping_address_2,shipping_postcode,shipping_city,shipping_state,shipping_country,customer_note,shipping_items,fee_items,tax_items,coupon_items,refund_items,order_notes,download_permissions,line_item_1,line_item_2,line_item_3
|
2 |
+
1001,1001,16-05-2018 07:32:06,completed,10,1.8,1,0.18,3.42,0,0,0,22.42,USD,cod,Express Delivery,3,3,lilly@example.com,Lilly,Gordon,,lilly@example.com,9898989898,20 Maple Avenue,,90731,San Pedro,CA,US,Lilly,Gordon,,20 Maple Avenue,"Door No,16",90731,San Pedro,CA,US,Deliver with a smile!,"item:Items|value:Formal shoe X 1
|
3 |
+
",name:Gift Wrap|total:1.00|tax:0.18,code:GST-1|total:3.42,,,Order status changed from Processing to Completed.|Formal shoe (A12) stock reduced from 20 to 19.|Payment to be made upon delivery. Order status changed from Pending payment to Processing.,1,name:Formal shoe|product_id:13|sku:A12|quantity:1|total:8.00|tax:1.44,,
|
4 |
+
1002,1002,16-05-2018 07:25:28,on-hold,10,1.8,0,0,5.04,0,0,0,33.04,USD,paypal,Express Delivery,0,0,,John,Edward,,john@example.com,9999999,300 BOYLSTON AVE E,,98102,Seattle,WA,US,John,Edward,,300 BOYLSTON AVE E,,98102,Seattle,WA,US,,"item:Items|value:Washing machine X 1
|
5 |
+
",,code:GST-1|total:5.04,,amount:46.00|reason:refund|date:2019-06-19 12:13:48,Order status changed from Pending payment to Processing.|Washing machine (A15) stock reduced from 30 to 29.|IPN payment completed,1,name:Washing machine|product_id:616773451|sku:A15|quantity:1|total:18.00|tax:3.24,,
|
6 |
+
1003,1003,16-05-2018 07:21:32,processing,10,1.8,0,0,8.99,10,10,10,58.98,USD,eh_stripe_pay,Express Delivery,2,2,mark@example.com,Mark,Xa,Xadapter,mark@example.com,9898989898,20 Maple Avenue,,90731,San Pedro,CA,US,Mark,Xa,Xadapter,20 Maple Avenue,,90731,San Pedro,CA,US,,"item:Items|value:LED TV X 1, Samsung Galaxy Ace Duos X 1, Men's Cotton T-Shirt - Red X 1
|
7 |
+
",,code:GST-1|total:8.99,code:flat20|amount:10.00,,"Order status changed from Pending payment to Processing.|LED TV (A13) stock reduced from 19 to 18.|Samsung Galaxy Ace Duos (A11) stock reduced from 10 to 9.|Men's Cotton T-Shirt - Red (B11V2)<span class=""description""></span> stock reduced from 9 to 8.|Payment Status : Succeeded [ 2018-05-16 12:51:06 ] . Source : Visa( credit ). Charge Status :Captured. Transaction ID : txn_1CSJwcJ91uK4qPibEmTjip6P:is_customer_note",1,name:LED TV|product_id:616773447|sku:A13|quantity:1|total:23.19|tax:4.17,name:Samsung Galaxy Ace Duos|product_id:616773443|sku:A11|quantity:1|total:8.80|tax:1.58,name:Men's Cotton T-Shirt|product_id:616773455|sku:B11V2|quantity:1|total:8.00|color:Red|_variation_id:616773455|tax:1.44
|
includes/exporter/class-wf-orderimpexpcsv-exporter.php
CHANGED
@@ -109,7 +109,7 @@ class WF_OrderImpExpCsv_Exporter {
|
|
109 |
|
110 |
public static function get_orders_csv_row($order_id , $export_columns) {
|
111 |
$order = wc_get_order($order_id);
|
112 |
-
$line_items = $shipping_items = $fee_items = $tax_items = $coupon_items = array();
|
113 |
|
114 |
// get line items
|
115 |
foreach ($order->get_items() as $item_id => $item) {
|
@@ -124,6 +124,7 @@ class WF_OrderImpExpCsv_Exporter {
|
|
124 |
'sku' => $product->get_sku(),
|
125 |
'quantity' => $item['qty'],
|
126 |
'total' => wc_format_decimal($order->get_line_total($item), 2),
|
|
|
127 |
// 'refunded' => wc_format_decimal($order->get_total_refunded_for_item($item_id), 2),
|
128 |
//'meta' => html_entity_decode($meta, ENT_NOQUOTES, 'UTF-8'),
|
129 |
);
|
@@ -150,7 +151,7 @@ class WF_OrderImpExpCsv_Exporter {
|
|
150 |
|
151 |
foreach ($order->get_fees() as $fee_id => $fee) {
|
152 |
$fee_items[] = implode('|', array(
|
153 |
-
'name:' . $fee['name'],
|
154 |
'total:' . wc_format_decimal($fee['line_total'], 2),
|
155 |
'tax:' . wc_format_decimal($fee['line_tax'], 2),
|
156 |
));
|
@@ -171,12 +172,18 @@ class WF_OrderImpExpCsv_Exporter {
|
|
171 |
|
172 |
// add coupons
|
173 |
foreach ($order->get_items('coupon') as $_ => $coupon_item) {
|
174 |
-
$
|
175 |
-
$coupon_post = get_post((WC()->version < '2.7.0')?$coupon->id:$coupon->get_id());
|
176 |
$coupon_items[] = implode('|', array(
|
177 |
-
|
178 |
-
|
179 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
));
|
181 |
}
|
182 |
|
@@ -195,7 +202,7 @@ class WF_OrderImpExpCsv_Exporter {
|
|
195 |
'order_discount' => (defined( 'WC_VERSION' ) && (WC_VERSION >= 2.3)) ? wc_format_decimal($order->get_total_discount(), 2) : wc_format_decimal($order->get_order_discount(), 2),
|
196 |
'discount_total' => wc_format_decimal($order->get_total_discount(), 2),
|
197 |
'order_total' => wc_format_decimal($order->get_total(), 2),
|
198 |
-
'refunded_total' => wc_format_decimal($order->get_total_refunded(), 2),
|
199 |
'order_currency' => $order->get_order_currency(),
|
200 |
'payment_method' => $order->payment_method,
|
201 |
'shipping_method' => $order->get_shipping_method(),
|
@@ -227,6 +234,7 @@ class WF_OrderImpExpCsv_Exporter {
|
|
227 |
'fee_items' => implode(';', $fee_items),
|
228 |
'tax_items' => implode(';', $tax_items),
|
229 |
'coupon_items' => implode(';', $coupon_items),
|
|
|
230 |
'order_notes' => implode('||', WF_OrderImpExpCsv_Exporter::get_order_notes($order)),
|
231 |
'download_permissions' => $order->download_permissions_granted ? $order->download_permissions_granted : 0,
|
232 |
);
|
@@ -245,7 +253,7 @@ class WF_OrderImpExpCsv_Exporter {
|
|
245 |
'order_discount' => (defined('WC_VERSION') && (WC_VERSION >= 2.3)) ? wc_format_decimal($order->get_total_discount(), 2) : wc_format_decimal($order->get_order_discount(), 2),
|
246 |
'discount_total' => wc_format_decimal($order->get_total_discount(), 2),
|
247 |
'order_total' => @wc_format_decimal($order->get_total(), 2),
|
248 |
-
'refunded_total' => wc_format_decimal($order->get_total_refunded(), 2),
|
249 |
'order_currency' => $order->get_currency(),
|
250 |
'payment_method' => $order->get_payment_method(),
|
251 |
'shipping_method' => $order->get_shipping_method(),
|
@@ -277,6 +285,7 @@ class WF_OrderImpExpCsv_Exporter {
|
|
277 |
'fee_items' => implode(';', $fee_items),
|
278 |
'tax_items' => implode(';', $tax_items),
|
279 |
'coupon_items' => implode(';', $coupon_items),
|
|
|
280 |
'order_notes' => implode('||', (defined('WC_VERSION') && (WC_VERSION >= 3.2)) ? WF_OrderImpExpCsv_Exporter::get_order_notes_new($order) : WF_OrderImpExpCsv_Exporter::get_order_notes($order)),
|
281 |
'download_permissions' => $order->is_download_permitted() ? $order->is_download_permitted() : 0,
|
282 |
);
|
109 |
|
110 |
public static function get_orders_csv_row($order_id , $export_columns) {
|
111 |
$order = wc_get_order($order_id);
|
112 |
+
$line_items = $shipping_items = $fee_items = $tax_items = $coupon_items = $refund_items = array();
|
113 |
|
114 |
// get line items
|
115 |
foreach ($order->get_items() as $item_id => $item) {
|
124 |
'sku' => $product->get_sku(),
|
125 |
'quantity' => $item['qty'],
|
126 |
'total' => wc_format_decimal($order->get_line_total($item), 2),
|
127 |
+
'sub_total' => wc_format_decimal($order->get_line_subtotal($item), 2),
|
128 |
// 'refunded' => wc_format_decimal($order->get_total_refunded_for_item($item_id), 2),
|
129 |
//'meta' => html_entity_decode($meta, ENT_NOQUOTES, 'UTF-8'),
|
130 |
);
|
151 |
|
152 |
foreach ($order->get_fees() as $fee_id => $fee) {
|
153 |
$fee_items[] = implode('|', array(
|
154 |
+
'name:' . html_entity_decode($fee['name'], ENT_NOQUOTES, 'UTF-8'),
|
155 |
'total:' . wc_format_decimal($fee['line_total'], 2),
|
156 |
'tax:' . wc_format_decimal($fee['line_tax'], 2),
|
157 |
));
|
172 |
|
173 |
// add coupons
|
174 |
foreach ($order->get_items('coupon') as $_ => $coupon_item) {
|
175 |
+
$discount_amount = !empty($coupon_item['discount_amount']) ? $coupon_item['discount_amount'] : 0;
|
|
|
176 |
$coupon_items[] = implode('|', array(
|
177 |
+
'code:' . $coupon_item['name'],
|
178 |
+
'amount:' . wc_format_decimal($discount_amount, 2),
|
179 |
+
));
|
180 |
+
}
|
181 |
+
|
182 |
+
foreach ($order->get_refunds() as $refunded_items){
|
183 |
+
$refund_items[] = implode('|', array(
|
184 |
+
'amount:' . $refunded_items->get_amount(),
|
185 |
+
'reason:' . $refunded_items->get_reason(),
|
186 |
+
'date:'. date('Y-m-d H:i:s',strtotime((WC()->version < '2.7.0') ? $refunded_items->date_created : $refunded_items->get_date_created())),
|
187 |
));
|
188 |
}
|
189 |
|
202 |
'order_discount' => (defined( 'WC_VERSION' ) && (WC_VERSION >= 2.3)) ? wc_format_decimal($order->get_total_discount(), 2) : wc_format_decimal($order->get_order_discount(), 2),
|
203 |
'discount_total' => wc_format_decimal($order->get_total_discount(), 2),
|
204 |
'order_total' => wc_format_decimal($order->get_total(), 2),
|
205 |
+
// 'refunded_total' => wc_format_decimal($order->get_total_refunded(), 2),
|
206 |
'order_currency' => $order->get_order_currency(),
|
207 |
'payment_method' => $order->payment_method,
|
208 |
'shipping_method' => $order->get_shipping_method(),
|
234 |
'fee_items' => implode(';', $fee_items),
|
235 |
'tax_items' => implode(';', $tax_items),
|
236 |
'coupon_items' => implode(';', $coupon_items),
|
237 |
+
'refund_items' => implode(';', $refund_items),
|
238 |
'order_notes' => implode('||', WF_OrderImpExpCsv_Exporter::get_order_notes($order)),
|
239 |
'download_permissions' => $order->download_permissions_granted ? $order->download_permissions_granted : 0,
|
240 |
);
|
253 |
'order_discount' => (defined('WC_VERSION') && (WC_VERSION >= 2.3)) ? wc_format_decimal($order->get_total_discount(), 2) : wc_format_decimal($order->get_order_discount(), 2),
|
254 |
'discount_total' => wc_format_decimal($order->get_total_discount(), 2),
|
255 |
'order_total' => @wc_format_decimal($order->get_total(), 2),
|
256 |
+
// 'refunded_total' => wc_format_decimal($order->get_total_refunded(), 2),
|
257 |
'order_currency' => $order->get_currency(),
|
258 |
'payment_method' => $order->get_payment_method(),
|
259 |
'shipping_method' => $order->get_shipping_method(),
|
285 |
'fee_items' => implode(';', $fee_items),
|
286 |
'tax_items' => implode(';', $tax_items),
|
287 |
'coupon_items' => implode(';', $coupon_items),
|
288 |
+
'refund_items' => implode(';', $refund_items),
|
289 |
'order_notes' => implode('||', (defined('WC_VERSION') && (WC_VERSION >= 3.2)) ? WF_OrderImpExpCsv_Exporter::get_order_notes_new($order) : WF_OrderImpExpCsv_Exporter::get_order_notes($order)),
|
290 |
'download_permissions' => $order->is_download_permitted() ? $order->is_download_permitted() : 0,
|
291 |
);
|
includes/exporter/data/data-wf-post-columns.php
CHANGED
@@ -18,7 +18,7 @@ return apply_filters('woocommerce_csv_order_post_columns', array(
|
|
18 |
'order_discount' => 'order_discount',
|
19 |
'discount_total' => 'discount_total',
|
20 |
'order_total' => 'order_total',
|
21 |
-
'refunded_total' => 'refunded_total',
|
22 |
'order_currency' => 'order_currency',
|
23 |
'payment_method' => 'payment_method',
|
24 |
'shipping_method' => 'shipping_method',
|
@@ -50,6 +50,7 @@ return apply_filters('woocommerce_csv_order_post_columns', array(
|
|
50 |
'fee_items' => 'fee_items',
|
51 |
'tax_items' => 'tax_items',
|
52 |
'coupon_items' => 'coupon_items',
|
|
|
53 |
'order_notes' => 'order_notes',
|
54 |
'download_permissions' => 'download_permissions'
|
55 |
));
|
18 |
'order_discount' => 'order_discount',
|
19 |
'discount_total' => 'discount_total',
|
20 |
'order_total' => 'order_total',
|
21 |
+
// 'refunded_total' => 'refunded_total',
|
22 |
'order_currency' => 'order_currency',
|
23 |
'payment_method' => 'payment_method',
|
24 |
'shipping_method' => 'shipping_method',
|
50 |
'fee_items' => 'fee_items',
|
51 |
'tax_items' => 'tax_items',
|
52 |
'coupon_items' => 'coupon_items',
|
53 |
+
'refund_items' => 'refund_items',
|
54 |
'order_notes' => 'order_notes',
|
55 |
'download_permissions' => 'download_permissions'
|
56 |
));
|
includes/importer/class-wf-csv-parser.php
CHANGED
@@ -34,7 +34,6 @@ class WF_CSV_Parser {
|
|
34 |
"fee_tax_total",
|
35 |
"tax_total",
|
36 |
"discount_total",
|
37 |
-
"refunded_total",
|
38 |
"customer_user",
|
39 |
"cart_discount",
|
40 |
"order_discount",
|
@@ -499,6 +498,8 @@ class WF_CSV_Parser {
|
|
499 |
$qty = substr($qty, strpos($qty, ":") + 1);
|
500 |
$total = array_shift($_item_meta);
|
501 |
$total = substr($total, strpos($total, ":") + 1);
|
|
|
|
|
502 |
$tax = array_shift($_item_meta);
|
503 |
$tax = substr($tax, strpos($tax, ":") + 1);
|
504 |
$tax_data = array_shift($_item_meta);
|
@@ -539,7 +540,7 @@ class WF_CSV_Parser {
|
|
539 |
$value = substr($pair, $split + 1);
|
540 |
$item_meta[$name] = $value;
|
541 |
}
|
542 |
-
$order_items[] = array('product_id' => $product_id, 'qty' => $qty, 'total' => $total,'tax' => $tax, 'tax_data' => $tax_data, 'meta' => $item_meta, 'unknown_product_name' => $unknown_product_name);
|
543 |
$i++;
|
544 |
}
|
545 |
}
|
@@ -566,6 +567,20 @@ class WF_CSV_Parser {
|
|
566 |
}
|
567 |
$order_items[] = array('product_id' => $product_id, 'qty' => $qty, 'total' => $total);
|
568 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
569 |
$tax_items = array();
|
570 |
// standard tax item format which supports multiple tax items in numbered columns containing a pipe-delimated, colon-labeled format
|
571 |
if (isset($item['tax_items']) && !empty($item['tax_items'])) {
|
@@ -632,11 +647,46 @@ class WF_CSV_Parser {
|
|
632 |
// add the order tax totals to the order meta
|
633 |
$postmeta[] = array('key' => '_order_tax', 'value' => number_format((float) $order_tax, 2, '.', ''));
|
634 |
$postmeta[] = array('key' => '_order_shipping_tax', 'value' => number_format((float) $order_shipping_tax, 2, '.', ''));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
635 |
if ($order) {
|
636 |
$order['postmeta'] = $postmeta;
|
637 |
$order['order_items'] = $order_items;
|
|
|
|
|
638 |
$order['order_shipping'] = $order_shipping_methods;
|
639 |
$order['tax_items'] = $tax_items;
|
|
|
640 |
// 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
|
641 |
$results[] = $order;
|
642 |
}
|
34 |
"fee_tax_total",
|
35 |
"tax_total",
|
36 |
"discount_total",
|
|
|
37 |
"customer_user",
|
38 |
"cart_discount",
|
39 |
"order_discount",
|
498 |
$qty = substr($qty, strpos($qty, ":") + 1);
|
499 |
$total = array_shift($_item_meta);
|
500 |
$total = substr($total, strpos($total, ":") + 1);
|
501 |
+
$sub_total = array_shift($_item_meta);
|
502 |
+
$sub_total = substr($sub_total, strpos($sub_total, ":") + 1);
|
503 |
$tax = array_shift($_item_meta);
|
504 |
$tax = substr($tax, strpos($tax, ":") + 1);
|
505 |
$tax_data = array_shift($_item_meta);
|
540 |
$value = substr($pair, $split + 1);
|
541 |
$item_meta[$name] = $value;
|
542 |
}
|
543 |
+
$order_items[] = array('product_id' => $product_id, 'qty' => $qty, 'total' => $total,'sub_total' => $sub_total,'tax' => $tax, 'tax_data' => $tax_data, 'meta' => $item_meta, 'unknown_product_name' => $unknown_product_name);
|
544 |
$i++;
|
545 |
}
|
546 |
}
|
567 |
}
|
568 |
$order_items[] = array('product_id' => $product_id, 'qty' => $qty, 'total' => $total);
|
569 |
}
|
570 |
+
|
571 |
+
// standard format
|
572 |
+
$coupon_item = array();
|
573 |
+
|
574 |
+
if(isset($item['coupon_items']) && !empty($item['coupon_items'])){
|
575 |
+
$coupon_item = explode(';', $item['coupon_items']);
|
576 |
+
}
|
577 |
+
|
578 |
+
//added since refund not importing
|
579 |
+
$refund_item = array();
|
580 |
+
if(isset($item['refund_items']) && !empty($item['refund_items'])){
|
581 |
+
$refund_item = explode(';', $item['refund_items']);
|
582 |
+
}
|
583 |
+
|
584 |
$tax_items = array();
|
585 |
// standard tax item format which supports multiple tax items in numbered columns containing a pipe-delimated, colon-labeled format
|
586 |
if (isset($item['tax_items']) && !empty($item['tax_items'])) {
|
647 |
// add the order tax totals to the order meta
|
648 |
$postmeta[] = array('key' => '_order_tax', 'value' => number_format((float) $order_tax, 2, '.', ''));
|
649 |
$postmeta[] = array('key' => '_order_shipping_tax', 'value' => number_format((float) $order_shipping_tax, 2, '.', ''));
|
650 |
+
|
651 |
+
// fee items
|
652 |
+
$fee_items = $fee_line_items = array();
|
653 |
+
if (isset($item['fee_items']) && !empty($item['fee_items'])) {
|
654 |
+
$fee_line_items = explode(';', $item['fee_items']);
|
655 |
+
|
656 |
+
$fee_item_data = array();
|
657 |
+
foreach ($fee_line_items as $fee_line_item) {
|
658 |
+
foreach (explode('|', $fee_line_item) as $piece) {
|
659 |
+
list( $name, $value ) = explode(':', $piece);
|
660 |
+
$fee_item_data[trim($name)] = trim($value);
|
661 |
+
}
|
662 |
+
|
663 |
+
if (!isset($fee_item_data['name'])) {
|
664 |
+
$fee_item_data['name'] = 'fee';
|
665 |
+
}
|
666 |
+
|
667 |
+
if (!isset($fee_item_data['total'])) {
|
668 |
+
$fee_item_data['total'] = 0;
|
669 |
+
}
|
670 |
+
if (!isset($fee_item_data['tax'])) {
|
671 |
+
$fee_item_data['tax'] = 0;
|
672 |
+
}
|
673 |
+
|
674 |
+
$fee_items[] = array(
|
675 |
+
'name' => $fee_item_data['name'],
|
676 |
+
'total' => $fee_item_data['total'],
|
677 |
+
'tax' => $fee_item_data['tax'],
|
678 |
+
);
|
679 |
+
}
|
680 |
+
}
|
681 |
+
|
682 |
if ($order) {
|
683 |
$order['postmeta'] = $postmeta;
|
684 |
$order['order_items'] = $order_items;
|
685 |
+
$order['coupon_items'] = $coupon_item;
|
686 |
+
$order['refund_items'] = $refund_item;
|
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 |
}
|
includes/importer/class-wf-orderimpexpcsv-order-import.php
CHANGED
@@ -610,7 +610,7 @@ class WF_OrderImpExpCsv_Order_Import extends WP_Importer {
|
|
610 |
'_tax_class' => '', // Tax class (adjusted by filters)
|
611 |
'_product_id' => $item['product_id'],
|
612 |
'_variation_id' => $var_id,
|
613 |
-
'_line_subtotal' => number_format((float) $item['
|
614 |
'_line_subtotal_tax' => number_format((float) $item['tax'], 2, '.', ''), // Line tax (before discounts)
|
615 |
'_line_total' => number_format((float) $item['total'], 2, '.', ''), // Line total (after discounts)
|
616 |
'_line_tax' => number_format((float) $item['tax'], 2, '.', ''), // Line Tax (after discounts)
|
@@ -646,6 +646,25 @@ class WF_OrderImpExpCsv_Order_Import extends WP_Importer {
|
|
646 |
wc_add_order_item_meta($shipping_order_item_id, 'cost', $order_shipping['cost']);
|
647 |
}
|
648 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
649 |
|
650 |
// create the tax order items
|
651 |
if(!empty($post['tax_items'])){
|
@@ -670,6 +689,66 @@ class WF_OrderImpExpCsv_Order_Import extends WP_Importer {
|
|
670 |
}
|
671 |
}
|
672 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
673 |
// Grant downloadalbe product permissions
|
674 |
if ($add_download_permissions) {
|
675 |
wc_downloadable_product_permissions($order_id);
|
@@ -719,7 +798,7 @@ class WF_OrderImpExpCsv_Order_Import extends WP_Importer {
|
|
719 |
$this->processed_posts[$post['order_number_formatted']] = $post['order_number_formatted'];
|
720 |
}
|
721 |
if ($merging && !$new_added)
|
722 |
-
$out_msg = 'Order Successfully
|
723 |
else
|
724 |
$out_msg = 'Order Imported Successfully.';
|
725 |
|
610 |
'_tax_class' => '', // Tax class (adjusted by filters)
|
611 |
'_product_id' => $item['product_id'],
|
612 |
'_variation_id' => $var_id,
|
613 |
+
'_line_subtotal' => number_format((float) $item['sub_total'], 2, '.', ''), // Line subtotal (before discounts)
|
614 |
'_line_subtotal_tax' => number_format((float) $item['tax'], 2, '.', ''), // Line tax (before discounts)
|
615 |
'_line_total' => number_format((float) $item['total'], 2, '.', ''), // Line total (after discounts)
|
616 |
'_line_tax' => number_format((float) $item['tax'], 2, '.', ''), // Line Tax (after discounts)
|
646 |
wc_add_order_item_meta($shipping_order_item_id, 'cost', $order_shipping['cost']);
|
647 |
}
|
648 |
}
|
649 |
+
|
650 |
+
// create the fee order items
|
651 |
+
if (!empty($post['fee_items'])) {
|
652 |
+
if ($merging && $is_order_exist) {
|
653 |
+
$fee_str = 'fee';
|
654 |
+
$wpdb->query($wpdb->prepare("DELETE items,itemmeta FROM {$wpdb->prefix}woocommerce_order_itemmeta itemmeta INNER JOIN {$wpdb->prefix}woocommerce_order_items items WHERE itemmeta.order_item_id = items.order_item_id and items.order_id = %d and items.order_item_type = %s", $order_id, $fee_str));
|
655 |
+
}
|
656 |
+
foreach ($post['fee_items'] as $key => $fee_item) {
|
657 |
+
$fee_order_item = array(
|
658 |
+
'order_item_name' => $fee_item['name'],
|
659 |
+
'order_item_type' => "fee"
|
660 |
+
);
|
661 |
+
$fee_order_item_id = wc_add_order_item($order_id, $fee_order_item);
|
662 |
+
if ($fee_order_item_id) {
|
663 |
+
wc_add_order_item_meta($fee_order_item_id, '_line_tax', $fee_item['tax']);
|
664 |
+
wc_add_order_item_meta($fee_order_item_id, '_line_total', $fee_item['total']);
|
665 |
+
}
|
666 |
+
}
|
667 |
+
}
|
668 |
|
669 |
// create the tax order items
|
670 |
if(!empty($post['tax_items'])){
|
689 |
}
|
690 |
}
|
691 |
}
|
692 |
+
|
693 |
+
//importing coupon items
|
694 |
+
if (!empty($post['coupon_items'])) {
|
695 |
+
if ($merging && $is_order_exist) {
|
696 |
+
$applied_coupons = $order->get_used_coupons();
|
697 |
+
if (!empty($applied_coupons)) {
|
698 |
+
foreach ($applied_coupons as $coupon) {
|
699 |
+
$order->remove_coupon($coupon);
|
700 |
+
}
|
701 |
+
}
|
702 |
+
}
|
703 |
+
$coupon_item = array();
|
704 |
+
foreach ($post['coupon_items'] as $coupon) {
|
705 |
+
$_citem_meta = explode('|', $coupon);
|
706 |
+
$coupon_code = array_shift($_citem_meta);
|
707 |
+
$coupon_code = substr($coupon_code, strpos($coupon_code, ":") + 1);
|
708 |
+
$discount_amount = array_shift($_citem_meta);
|
709 |
+
$discount_amount = substr($discount_amount, strpos($discount_amount, ":") + 1);
|
710 |
+
$id = wc_get_coupon_id_by_code($coupon_code);
|
711 |
+
if ($id && $merging && $is_order_exist) {
|
712 |
+
$order->apply_coupon($coupon_code);
|
713 |
+
} else {
|
714 |
+
$coupon_item['order_item_name'] = $coupon_code;
|
715 |
+
$coupon_item['order_item_type'] = 'coupon';
|
716 |
+
$order_item_id = wc_add_order_item($order_id, $coupon_item);
|
717 |
+
wc_add_order_item_meta($order_item_id, 'discount_amount', $discount_amount);
|
718 |
+
}
|
719 |
+
}
|
720 |
+
}
|
721 |
+
|
722 |
+
// importing refund items
|
723 |
+
if (!empty($post['refund_items'])) {
|
724 |
+
if ($merging && $is_order_exist) {
|
725 |
+
$refund = 'shop_order_refund';
|
726 |
+
$wpdb->query($wpdb->prepare("DELETE po,pm FROM $wpdb->posts AS po INNER JOIN $wpdb->postmeta AS pm ON po.ID = pm.post_id WHERE post_parent = %d and post_type = %s", $order_id, $refund));
|
727 |
+
}
|
728 |
+
foreach ($post['refund_items'] as $refund) {
|
729 |
+
$single_refund = explode('|', $refund);
|
730 |
+
$amount = array_shift($single_refund);
|
731 |
+
$amount = substr($amount, strpos($amount, ":") + 1);
|
732 |
+
$reason = array_shift($single_refund);
|
733 |
+
$reason = substr($reason, strpos($reason, ":") + 1);
|
734 |
+
$date = array_shift($single_refund);
|
735 |
+
$date = substr($date, strpos($date, ":") + 1);
|
736 |
+
|
737 |
+
$args = array(
|
738 |
+
'amount' => $amount,
|
739 |
+
'reason' => $reason,
|
740 |
+
'date_created' => $date,
|
741 |
+
'order_id' => $order_id,
|
742 |
+
);
|
743 |
+
remove_all_actions('woocommerce_order_status_refunded_notification');
|
744 |
+
remove_all_actions('woocommerce_order_partially_refunded_notification');
|
745 |
+
remove_action('woocommerce_order_status_refunded', array('WC_Emails', 'send_transactional_email'));
|
746 |
+
remove_action('woocommerce_order_partially_refunded', array('WC_Emails', 'send_transactional_email'));
|
747 |
+
remove_action('woocommerce_order_fully_refunded', array('WC_Emails', 'send_transactional_email'));
|
748 |
+
wc_create_refund($args);
|
749 |
+
}
|
750 |
+
}
|
751 |
+
|
752 |
// Grant downloadalbe product permissions
|
753 |
if ($add_download_permissions) {
|
754 |
wc_downloadable_product_permissions($order_id);
|
798 |
$this->processed_posts[$post['order_number_formatted']] = $post['order_number_formatted'];
|
799 |
}
|
800 |
if ($merging && !$new_added)
|
801 |
+
$out_msg = 'Order Successfully Updated.';
|
802 |
else
|
803 |
$out_msg = 'Order Imported Successfully.';
|
804 |
|
includes/importer/data/data-wf-reserved-fields-pair.php
CHANGED
@@ -17,7 +17,6 @@ return array(
|
|
17 |
'order_discount' => 'Order Discount | Order Discount',
|
18 |
'discount_total' => 'Discount Total | Discount Total',
|
19 |
'order_total' => 'Order Total | Order Total',
|
20 |
-
'refunded_total' => 'refunded_total | refunded_total',
|
21 |
'order_currency' => 'order_currency | order_currency',
|
22 |
'payment_method' => 'payment_method | payment_method',
|
23 |
'shipping_method' => 'shipping_method | shipping_method',
|
@@ -48,6 +47,7 @@ return array(
|
|
48 |
'fee_items' => 'fee_items | fee_items',
|
49 |
'tax_items' => 'tax_items | tax_items',
|
50 |
'coupon_items' => 'coupon_items | coupons',
|
|
|
51 |
'order_notes' => 'order_notes | order_notes',
|
52 |
'download_permissions' => 'Downloadable Product Permissions | Permissions for order items will automatically be granted when the order status changes to processing or completed.'
|
53 |
);
|
17 |
'order_discount' => 'Order Discount | Order Discount',
|
18 |
'discount_total' => 'Discount Total | Discount Total',
|
19 |
'order_total' => 'Order Total | Order Total',
|
|
|
20 |
'order_currency' => 'order_currency | order_currency',
|
21 |
'payment_method' => 'payment_method | payment_method',
|
22 |
'shipping_method' => 'shipping_method | shipping_method',
|
47 |
'fee_items' => 'fee_items | fee_items',
|
48 |
'tax_items' => 'tax_items | tax_items',
|
49 |
'coupon_items' => 'coupon_items | coupons',
|
50 |
+
'refund_items' => 'refund_items | refunds',
|
51 |
'order_notes' => 'order_notes | order_notes',
|
52 |
'download_permissions' => 'Downloadable Product Permissions | Permissions for order items will automatically be granted when the order status changes to processing or completed.'
|
53 |
);
|
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.4.
|
10 |
Text Domain: order-import-export-for-woocommerce
|
11 |
WC tested up to: 3.6.4
|
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.4.
|
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.4.9
|
10 |
Text Domain: order-import-export-for-woocommerce
|
11 |
WC tested up to: 3.6.4
|
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.4.9");
|
28 |
}
|
29 |
|
30 |
/**
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.webtoffee.com/plugins/
|
|
4 |
Tags: Order Export, Order Import, WooCommerce Export Orders , WooCommerce Import Orders , Export Orders, Import Orders , order, export, import, woocommerce, csv, coupon, coupon export, coupon import, woocommerce export coupon , woocommerce import coupon , export coupons, import coupons,
|
5 |
Requires at least: 3.0.1
|
6 |
Tested up to: 5.2
|
7 |
-
Stable tag: 1.4.
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -102,7 +102,7 @@ Yes. You can import or export order line item details.
|
|
102 |
|
103 |
= Are you redirected to dashboard or login page while exporting? =
|
104 |
|
105 |
-
By default, admin and store manager are given access to export orders from your store.
|
106 |
|
107 |
|
108 |
== Screenshots ==
|
@@ -115,6 +115,8 @@ By default, admin and store manager are given access to export orders from your
|
|
115 |
|
116 |
== Changelog ==
|
117 |
|
|
|
|
|
118 |
= 1.4.8 =
|
119 |
* Tested OK with WP 5.2.2 and WC 3.6.4
|
120 |
* Bug fix: Orders getting imported to new IDs when import ID conflicts with existing post IDs.
|
@@ -246,8 +248,5 @@ By default, admin and store manager are given access to export orders from your
|
|
246 |
* Export /Import WooCommerce Orders.
|
247 |
|
248 |
== Upgrade Notice ==
|
249 |
-
= 1.4.
|
250 |
-
*
|
251 |
-
* Bug fix: Orders getting imported to new IDs when import ID conflicts with existing post IDs.
|
252 |
-
* Issue with using the plugin in multi-site setup.
|
253 |
-
* Help tab modification.
|
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.2
|
7 |
+
Stable tag: 1.4.9
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
102 |
|
103 |
= Are you redirected to dashboard or login page while exporting? =
|
104 |
|
105 |
+
By default, admin and store manager are given access to export orders from your store. Please visit <a rel="nofollow" href="https://www.webtoffee.com/how-to-export-woocommerce-items-without-user-role-restriction/">How to export WooCommerce items without user role restriction</a> for more details
|
106 |
|
107 |
|
108 |
== Screenshots ==
|
115 |
|
116 |
== Changelog ==
|
117 |
|
118 |
+
= 1.4.9 =
|
119 |
+
* Bug fix: Refund,Coupon,Fee Items export import.
|
120 |
= 1.4.8 =
|
121 |
* Tested OK with WP 5.2.2 and WC 3.6.4
|
122 |
* Bug fix: Orders getting imported to new IDs when import ID conflicts with existing post IDs.
|
248 |
* Export /Import WooCommerce Orders.
|
249 |
|
250 |
== Upgrade Notice ==
|
251 |
+
= 1.4.9 =
|
252 |
+
* Bug fix: Refund,Coupon,Fee Items export import.
|
|
|
|
|
|