Version Description
2022-07-04 = * WooCommerce 6.6 Tested OK. * Enhancement: Export to CSV option to Bulk Action drop-down menu in WC Orders listing page. * Enhancement: Import progress screen improvements.
Download this release
Release Info
Developer | webtoffee |
Plugin | Order Export & Order Import for WooCommerce |
Version | 2.2.5 |
Comparing to | |
See all releases |
Code changes from version 2.2.4 to 2.2.5
- admin/class-wt-import-export-for-woo-admin.php +3 -3
- admin/css/wt-import-export-for-woo-admin.css +152 -0
- admin/js/wt-import-export-for-woo-admin.js +10 -1
- admin/modules/coupon/coupon.php +52 -1
- admin/modules/coupon/export/class-wt-cpnimpexpcsv-basic-exporter.php +164 -0
- admin/modules/coupon/import/import.php +7 -6
- admin/modules/export/assets/js/main.js +4 -1
- admin/modules/export/export.php +2 -2
- admin/modules/history/assets/js/main.js +2 -1
- admin/modules/import/assets/js/main.js +122 -8
- admin/modules/import/import.php +44 -1
- admin/modules/import/views/main.php +53 -0
- admin/modules/order/data/data-order-post-columns.php +8 -0
- admin/modules/order/data/data/data-wf-reserved-fields-pair.php +8 -0
- admin/modules/order/export/class-wt-orderimpexpcsv-basic-exporter.php +638 -0
- admin/modules/order/export/export.php +18 -1
- admin/modules/order/import/import.php +32 -4
- admin/modules/order/order.php +64 -1
- includes/class-wt-import-export-for-woo.php +1 -1
- order-import-export-for-woocommerce.php +22 -3
- readme.txt +11 -6
admin/class-wt-import-export-for-woo-admin.php
CHANGED
@@ -461,7 +461,7 @@ class Wt_Import_Export_For_Woo_Admin_Basic {
|
|
461 |
|
462 |
public function tools_wtexport_text(){
|
463 |
|
464 |
-
echo "<p><b>" . sprintf( __( 'Export WooCommerce orders and coupons in CSV format using <a href="%s">this exporter</a>.' ), admin_url( 'admin.php?page=wt_import_export_for_woo_basic_export' ) ) . "</b></p>";
|
465 |
|
466 |
if( !is_plugin_active( 'users-customers-import-export-for-wp-woocommerce/users-customers-import-export-for-wp-woocommerce.php' ) ){
|
467 |
echo "<p><b>" . sprintf(
|
@@ -470,7 +470,7 @@ class Wt_Import_Export_For_Woo_Admin_Basic {
|
|
470 |
admin_url('plugin-install.php?tab=plugin-information&plugin=users-customers-import-export-for-wp-woocommerce')
|
471 |
) . "</b></p>";
|
472 |
}else{
|
473 |
-
echo "<p><b>" . sprintf( __( 'Export Users and WooCommerce customers in CSV format using <a href="%s">this exporter</a>.' ), admin_url( 'admin.php?page=wt_import_export_for_woo_basic_export' ) ) . "</b></p>";
|
474 |
}
|
475 |
|
476 |
if( !is_plugin_active( 'product-import-export-for-woo/product-import-export-for-woo.php' ) ){
|
@@ -480,7 +480,7 @@ class Wt_Import_Export_For_Woo_Admin_Basic {
|
|
480 |
admin_url('plugin-install.php?tab=plugin-information&plugin=product-import-export-for-woo')
|
481 |
) . "</b></p>";
|
482 |
}else{
|
483 |
-
echo "<p><b>" . sprintf( __( 'Export WooCommerce products, product categories, product tags and product reviews in CSV format using <a href="%s">this exporter</a>.' ), admin_url( 'admin.php?page=wt_import_export_for_woo_basic_export' ) ) . "</b></p>";
|
484 |
}
|
485 |
|
486 |
}
|
461 |
|
462 |
public function tools_wtexport_text(){
|
463 |
|
464 |
+
echo "<p><b>" . sprintf( __( 'Export WooCommerce orders and coupons in CSV format using <a href="%s">this exporter</a>.' ), admin_url( 'admin.php?page=wt_import_export_for_woo_basic_export&wt_to_export=order' ) ) . "</b></p>";
|
465 |
|
466 |
if( !is_plugin_active( 'users-customers-import-export-for-wp-woocommerce/users-customers-import-export-for-wp-woocommerce.php' ) ){
|
467 |
echo "<p><b>" . sprintf(
|
470 |
admin_url('plugin-install.php?tab=plugin-information&plugin=users-customers-import-export-for-wp-woocommerce')
|
471 |
) . "</b></p>";
|
472 |
}else{
|
473 |
+
echo "<p><b>" . sprintf( __( 'Export Users and WooCommerce customers in CSV format using <a href="%s">this exporter</a>.' ), admin_url( 'admin.php?page=wt_import_export_for_woo_basic_export&wt_to_export=user' ) ) . "</b></p>";
|
474 |
}
|
475 |
|
476 |
if( !is_plugin_active( 'product-import-export-for-woo/product-import-export-for-woo.php' ) ){
|
480 |
admin_url('plugin-install.php?tab=plugin-information&plugin=product-import-export-for-woo')
|
481 |
) . "</b></p>";
|
482 |
}else{
|
483 |
+
echo "<p><b>" . sprintf( __( 'Export WooCommerce products, product categories, product tags and product reviews in CSV format using <a href="%s">this exporter</a>.' ), admin_url( 'admin.php?page=wt_import_export_for_woo_basic_export&wt_to_export=product' ) ) . "</b></p>";
|
484 |
}
|
485 |
|
486 |
}
|
admin/css/wt-import-export-for-woo-admin.css
CHANGED
@@ -241,6 +241,158 @@ span.wt_iew_mapping_field_val::after {
|
|
241 |
/* popup */
|
242 |
.wt_iew_overlay{ position:fixed; z-index:100000000; width:100%; height:100%; background-color:rgba(0,0,0,.5); left:0px; top:0px; display:none;}
|
243 |
.wt_iew_popup{position:fixed; z-index:100000001; background:#fff; border:solid 1px #eee; text-align:center; box-shadow:0px 2px 5px #333; left:50%; display:none;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
.wt_iew_popup_hd{display:inline-block; width:100%; box-sizing:border-box; font-weight:bold; background-color:#f3f3f3; height:40px; text-align:left; line-height:40px; padding:0px 20px;}
|
245 |
.wt_iew_popup_close{float:right; width:40px; height:40px; text-align:right; line-height:40px; cursor:pointer;}
|
246 |
.wt_iew_popup_footer{width:100%; text-align:right; margin-top:10px;}
|
241 |
/* popup */
|
242 |
.wt_iew_overlay{ position:fixed; z-index:100000000; width:100%; height:100%; background-color:rgba(0,0,0,.5); left:0px; top:0px; display:none;}
|
243 |
.wt_iew_popup{position:fixed; z-index:100000001; background:#fff; border:solid 1px #eee; text-align:center; box-shadow:0px 2px 5px #333; left:50%; display:none;}
|
244 |
+
|
245 |
+
|
246 |
+
|
247 |
+
|
248 |
+
|
249 |
+
.wt_iew_import_progress_wrap{
|
250 |
+
position: fixed;
|
251 |
+
overflow: scroll;
|
252 |
+
display: none;
|
253 |
+
top: 15px;
|
254 |
+
left: 50%;
|
255 |
+
width: 100%;
|
256 |
+
/*max-width: 580px;*/
|
257 |
+
height: 700px;
|
258 |
+
margin-left: -260px;
|
259 |
+
background: #ffffff;
|
260 |
+
border-radius: 3px;
|
261 |
+
z-index: 100000001;
|
262 |
+
box-shadow: 0 10px 10px rgba(0, 0, 0, 0.25);
|
263 |
+
}
|
264 |
+
.wt_iew_import_progress_wrap.open {
|
265 |
+
display: flex;
|
266 |
+
flex-direction: column;
|
267 |
+
}
|
268 |
+
.wt_iew_import_progress_content{
|
269 |
+
height: 100%;
|
270 |
+
overflow-y: auto;
|
271 |
+
/*padding: 10px;*/
|
272 |
+
}
|
273 |
+
.wt_iew_import_progress_header{
|
274 |
+
padding: 15px;
|
275 |
+
top: 15px;
|
276 |
+
border-radius: 3px 3px 0 0;
|
277 |
+
}
|
278 |
+
.wt_iew_import_progress_wrap th, .wt_iew_import_progress_wrap td{text-align: center}
|
279 |
+
.wt_iew_import_progress{border: none !important;}
|
280 |
+
|
281 |
+
|
282 |
+
|
283 |
+
|
284 |
+
.wt_iew_import_progress table, .wt_iew_import_progress td {
|
285 |
+
border-collapse: collapse;
|
286 |
+
/*border: 1px solid #000;*/
|
287 |
+
}
|
288 |
+
|
289 |
+
.wt_iew_import_progress thead {
|
290 |
+
display: table; /* to take the same width as tr */
|
291 |
+
width: 100%;
|
292 |
+
}
|
293 |
+
|
294 |
+
.wt_iew_import_progress tbody {
|
295 |
+
display: block; /* to enable vertical scrolling */
|
296 |
+
max-height: 430px; /* e.g. */
|
297 |
+
overflow-y: scroll; /* keeps the scrollbar even if it doesn't need it; display purpose */
|
298 |
+
}
|
299 |
+
|
300 |
+
.wt_iew_import_progress th, .wt_iew_import_progress td {
|
301 |
+
/*width: 33.33%;*/
|
302 |
+
/* to enable "word-break: break-all" */
|
303 |
+
padding: 5px;
|
304 |
+
word-break: break-all; /* 4. */
|
305 |
+
}
|
306 |
+
|
307 |
+
.wt_iew_import_progress tr {
|
308 |
+
display: table; /* display purpose; th's border */
|
309 |
+
width: 100%;
|
310 |
+
box-sizing: border-box; /* because of the border (Chrome needs this line, but not FF) */
|
311 |
+
}
|
312 |
+
|
313 |
+
.wt_iew_import_progress td {
|
314 |
+
text-align: center;
|
315 |
+
border-bottom: none;
|
316 |
+
border-left: none;
|
317 |
+
}
|
318 |
+
|
319 |
+
progress {
|
320 |
+
height: 30px;
|
321 |
+
border-radius: 30px;
|
322 |
+
width:100%;
|
323 |
+
}
|
324 |
+
progress[value]::-webkit-progress-bar {
|
325 |
+
background-color: #EDEDED;
|
326 |
+
border-radius: 40px;
|
327 |
+
}
|
328 |
+
progress[value]::-moz-progress-bar {
|
329 |
+
background-color: #008000;
|
330 |
+
border-radius: 40px;
|
331 |
+
}
|
332 |
+
progress[value]::-webkit-progress-value {
|
333 |
+
border-radius: 40px;
|
334 |
+
background-color:#008000;
|
335 |
+
}
|
336 |
+
|
337 |
+
.wt-iew-import-result-row {
|
338 |
+
display: table;
|
339 |
+
width: 100%; /*Optional*/
|
340 |
+
table-layout: fixed; /*Optional*/
|
341 |
+
border-spacing: 10px; /*Optional*/
|
342 |
+
}
|
343 |
+
.wt-iew-import-result-column {
|
344 |
+
display: table-cell;
|
345 |
+
padding-bottom: 20px;
|
346 |
+
}
|
347 |
+
.wt-iew-import-completed .dashicons-yes:before{color: green;}
|
348 |
+
|
349 |
+
#wt_iew_import_progress .dashicons-dismiss:before {color: red;}
|
350 |
+
#wt_iew_import_progress .dashicons-yes-alt:before {color: green;}
|
351 |
+
|
352 |
+
.wt_iew_view_imported_items:focus, .wt_iew_view_imported_items:visited{
|
353 |
+
outline: none !important;
|
354 |
+
box-shadow: none !important;
|
355 |
+
}
|
356 |
+
|
357 |
+
.progressa {
|
358 |
+
border-radius: 50px !important;
|
359 |
+
line-height: 36px;
|
360 |
+
font-size: 14px;
|
361 |
+
overflow: hidden;
|
362 |
+
margin-bottom: 45px;
|
363 |
+
background-color: #dadada80;
|
364 |
+
border-radius: 4px;
|
365 |
+
-webkit-box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
|
366 |
+
box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
|
367 |
+
line-height: 30px;
|
368 |
+
height: 40px;
|
369 |
+
font-size: 14px;
|
370 |
+
/*border: 3px solid transparent;*/
|
371 |
+
margin-left:25px;
|
372 |
+
width:95%;
|
373 |
+
}
|
374 |
+
.progressab {
|
375 |
+
/*background-image: -webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);
|
376 |
+
background-image: -o-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);
|
377 |
+
*/
|
378 |
+
-webkit-background-size: 40px 40px;
|
379 |
+
background-size: 40px 40px;
|
380 |
+
-webkit-transition: width .25s ease,height .25s ease,font-size .25s ease;
|
381 |
+
-moz-transition: width .25s ease,height .25s ease,font-size .25s ease;
|
382 |
+
-ms-transition: width .25s ease,height .25s ease,font-size .25s ease;
|
383 |
+
-o-transition: width .25s ease,height .25s ease,font-size .25s ease;
|
384 |
+
transition: width .25s ease,height .25s ease,font-size .25s ease;
|
385 |
+
width: 0;
|
386 |
+
color: #fff;
|
387 |
+
text-align: center;
|
388 |
+
font-family: 'Open Sans',sans-serif !important;
|
389 |
+
animation: progress-bar-stripes 2s linear infinite reverse;
|
390 |
+
}
|
391 |
+
|
392 |
+
|
393 |
+
|
394 |
+
|
395 |
+
|
396 |
.wt_iew_popup_hd{display:inline-block; width:100%; box-sizing:border-box; font-weight:bold; background-color:#f3f3f3; height:40px; text-align:left; line-height:40px; padding:0px 20px;}
|
397 |
.wt_iew_popup_close{float:right; width:40px; height:40px; text-align:right; line-height:40px; cursor:pointer;}
|
398 |
.wt_iew_popup_footer{width:100%; text-align:right; margin-top:10px;}
|
admin/js/wt-import-export-for-woo-admin.js
CHANGED
@@ -266,6 +266,15 @@ wt_iew_popup={
|
|
266 |
popup_elm.find('.wt_iew_popup_body').css({'max-height':ph+'px','overflow':'auto'});
|
267 |
jQuery('.wt_iew_overlay').show();
|
268 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
hidePopup:function()
|
270 |
{
|
271 |
jQuery('.wt_iew_popup_close').click();
|
@@ -278,7 +287,7 @@ wt_iew_popup={
|
|
278 |
wt_iew_popup.hidePopup();
|
279 |
}
|
280 |
});
|
281 |
-
jQuery('.wt_iew_popup_close, .wt_iew_popup_cancel').unbind('click').click(function(){
|
282 |
jQuery('.wt_iew_overlay, .wt_iew_popup').hide();
|
283 |
});
|
284 |
}
|
266 |
popup_elm.find('.wt_iew_popup_body').css({'max-height':ph+'px','overflow':'auto'});
|
267 |
jQuery('.wt_iew_overlay').show();
|
268 |
},
|
269 |
+
showimportPopup:function(popup_elm)
|
270 |
+
{
|
271 |
+
var pw=popup_elm.outerWidth();
|
272 |
+
var wh=jQuery(window).height();
|
273 |
+
var ph=wh-150;
|
274 |
+
popup_elm.css({'margin-left':((pw/2)*-1),'display':'block','top':'50px'});
|
275 |
+
popup_elm.find('.wt_iew_popup_body').css({'max-height':ph+'px','overflow':'auto'});
|
276 |
+
jQuery('.wt_iew_overlay').show();
|
277 |
+
},
|
278 |
hidePopup:function()
|
279 |
{
|
280 |
jQuery('.wt_iew_popup_close').click();
|
287 |
wt_iew_popup.hidePopup();
|
288 |
}
|
289 |
});
|
290 |
+
jQuery('.wt_iew_popup_close, .wt_iew_popup_cancel, .wt_iew_popup_close_btn').unbind('click').click(function(){
|
291 |
jQuery('.wt_iew_overlay, .wt_iew_popup').hide();
|
292 |
});
|
293 |
}
|
admin/modules/coupon/coupon.php
CHANGED
@@ -68,8 +68,52 @@ class Wt_Import_Export_For_Woo_Basic_Coupon {
|
|
68 |
add_filter('wt_iew_importer_do_import_basic', array($this, 'importer_do_import'), 10, 8);
|
69 |
|
70 |
add_filter('wt_iew_importer_steps_basic', array($this, 'importer_steps'), 10, 2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
}
|
72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
/**
|
74 |
* Altering advanced step description
|
75 |
*/
|
@@ -505,7 +549,14 @@ class Wt_Import_Export_For_Woo_Basic_Coupon {
|
|
505 |
return $fields;
|
506 |
}
|
507 |
public function get_item_by_id($id) {
|
508 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
509 |
$post['title'] = get_the_title($id);
|
510 |
return $post;
|
511 |
}
|
68 |
add_filter('wt_iew_importer_do_import_basic', array($this, 'importer_do_import'), 10, 8);
|
69 |
|
70 |
add_filter('wt_iew_importer_steps_basic', array($this, 'importer_steps'), 10, 2);
|
71 |
+
|
72 |
+
add_action('admin_footer-edit.php', array($this, 'add_coupons_bulk_actions'));
|
73 |
+
add_action('load-edit.php', array($this, 'process_coupons_bulk_actions'));
|
74 |
+
}
|
75 |
+
|
76 |
+
|
77 |
+
public function add_coupons_bulk_actions() {
|
78 |
+
global $post_type, $post_status;
|
79 |
+
|
80 |
+
if ($post_type == 'shop_coupon' && $post_status != 'trash') {
|
81 |
+
?>
|
82 |
+
<script type="text/javascript">
|
83 |
+
jQuery(document).ready(function ($) {
|
84 |
+
var $downloadToCSV = $('<option>').val('wt_ier_download_coupons').text('<?php _e('Export to CSV') ?>');
|
85 |
+
$('select[name^="action"]').append($downloadToCSV);
|
86 |
+
});
|
87 |
+
</script>
|
88 |
+
<?php
|
89 |
+
}
|
90 |
}
|
91 |
|
92 |
+
public function process_coupons_bulk_actions() {
|
93 |
+
global $typenow;
|
94 |
+
if ($typenow == 'shop_coupon') {
|
95 |
+
// get the action list
|
96 |
+
$wp_list_table = _get_list_table('WP_Posts_List_Table');
|
97 |
+
$action = $wp_list_table->current_action();
|
98 |
+
if (!in_array($action, array('wt_ier_download_coupons'))) {
|
99 |
+
return;
|
100 |
+
}
|
101 |
+
check_admin_referer('bulk-posts');
|
102 |
+
|
103 |
+
if (isset($_REQUEST['post'])) {
|
104 |
+
$coupon_ids = array_map('absint', $_REQUEST['post']);
|
105 |
+
}
|
106 |
+
if (empty($coupon_ids)) {
|
107 |
+
return;
|
108 |
+
}
|
109 |
+
@set_time_limit(0);
|
110 |
+
|
111 |
+
if ($action == 'wt_ier_download_coupons') {
|
112 |
+
include_once( 'export/class-wt-cpnimpexpcsv-basic-exporter.php' );
|
113 |
+
Wt_Import_Export_For_Woo_Basic_Coupon_Bulk_Export::do_export('shop_coupon', $coupon_ids);
|
114 |
+
}
|
115 |
+
}
|
116 |
+
}
|
117 |
/**
|
118 |
* Altering advanced step description
|
119 |
*/
|
549 |
return $fields;
|
550 |
}
|
551 |
public function get_item_by_id($id) {
|
552 |
+
$post = array();
|
553 |
+
$post['edit_url'] = get_edit_post_link($id);
|
554 |
+
$post['title'] = get_the_title($id);
|
555 |
+
return $post;
|
556 |
+
}
|
557 |
+
public static function get_item_link_by_id($id) {
|
558 |
+
$post = array();
|
559 |
+
$post['edit_url'] = get_edit_post_link($id);
|
560 |
$post['title'] = get_the_title($id);
|
561 |
return $post;
|
562 |
}
|
admin/modules/coupon/export/class-wt-cpnimpexpcsv-basic-exporter.php
ADDED
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!defined('ABSPATH')) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
class Wt_Import_Export_For_Woo_Basic_Coupon_Bulk_Export {
|
8 |
+
|
9 |
+
public static function do_export($post_type = 'shop_coupon', $coupon_ids = array()) {
|
10 |
+
global $wpdb;
|
11 |
+
|
12 |
+
$delimiter = !empty($_POST['delimiter']) ? $_POST['delimiter'] : ','; // WPCS: CSRF ok, input var ok.
|
13 |
+
|
14 |
+
$csv_columns = include_once( __DIR__ . '/../data/data-coupon-post-columns.php' );
|
15 |
+
$csv_columns = array_combine(array_keys($csv_columns), array_keys($csv_columns));
|
16 |
+
$user_columns_name = !empty($_POST['columns_name']) ? wc_clean($_POST['columns_name']) : $csv_columns;
|
17 |
+
$export_columns = !empty($_POST['columns']) ? wc_clean($_POST['columns']) : '';
|
18 |
+
$include_hidden_meta = true;
|
19 |
+
|
20 |
+
$wpdb->hide_errors();
|
21 |
+
@set_time_limit(0);
|
22 |
+
if (function_exists('apache_setenv'))
|
23 |
+
@apache_setenv('no-gzip', 1);
|
24 |
+
@ini_set('zlib.output_compression', 0);
|
25 |
+
@ob_end_clean();
|
26 |
+
|
27 |
+
header('Content-Type: text/csv; charset=UTF-8');
|
28 |
+
header('Content-Disposition: attachment; filename=coupon_export_' . date('Y_m_d_H_i_s', current_time('timestamp')) . '.csv');
|
29 |
+
header('Pragma: no-cache');
|
30 |
+
header('Expires: 0');
|
31 |
+
|
32 |
+
$fp = fopen('php://output', 'w');
|
33 |
+
|
34 |
+
$row = array();
|
35 |
+
foreach ($csv_columns as $column => $value) {
|
36 |
+
$temp_head = esc_attr($user_columns_name[$column]);
|
37 |
+
if (!$export_columns || in_array($column, $export_columns))
|
38 |
+
$row[] = $temp_head;
|
39 |
+
}
|
40 |
+
|
41 |
+
$row = apply_filters('wt_ier_alter_coupon_csv_header', $row); //Alter Coupon CSV Header
|
42 |
+
|
43 |
+
$row = array_map('Wt_Import_Export_For_Woo_Basic_Coupon_Bulk_Export::wrap_column', $row);
|
44 |
+
fwrite($fp, implode($delimiter, $row) . "\n");
|
45 |
+
unset($row);
|
46 |
+
|
47 |
+
$coupon_args = array(
|
48 |
+
'post_status' => array('publish', 'pending', 'private', 'draft'),
|
49 |
+
'post_type' => 'shop_coupon',
|
50 |
+
'numberposts' => 9999
|
51 |
+
);
|
52 |
+
|
53 |
+
$coupon_args['post__in'] = $coupon_ids;
|
54 |
+
|
55 |
+
$coupons = get_posts($coupon_args);
|
56 |
+
|
57 |
+
foreach ($coupons as $coupon) {
|
58 |
+
foreach ($csv_columns as $column => $value) {
|
59 |
+
if (!$export_columns || in_array($column, $export_columns)) {
|
60 |
+
if (isset($coupon->$column)) {
|
61 |
+
if (is_array($coupon->$column)) {
|
62 |
+
$coupon->$column = implode(",", $coupon->$column);
|
63 |
+
}
|
64 |
+
if ($column == 'product_ids') {
|
65 |
+
$hf_val = self::format_data($coupon->$column);
|
66 |
+
$sku = self::get_sku_from_id($hf_val);
|
67 |
+
$row[] = str_replace(',', '|', $hf_val);
|
68 |
+
continue;
|
69 |
+
}
|
70 |
+
if ($column == 'exclude_product_ids') {
|
71 |
+
$ex_val = self::format_data($coupon->$column);
|
72 |
+
$exsku = self::get_sku_from_id($ex_val);
|
73 |
+
$row[] = str_replace(',', '|', $ex_val);
|
74 |
+
continue;
|
75 |
+
}
|
76 |
+
$row[] = self::format_data($coupon->$column);
|
77 |
+
} elseif (isset($coupon->$column) && !is_array($coupon->$column)) {
|
78 |
+
if ($column === 'post_title') {
|
79 |
+
$row[] = sanitize_text_field($coupon->$column);
|
80 |
+
} else {
|
81 |
+
$row[] = self::format_data($coupon->$column);
|
82 |
+
}
|
83 |
+
} elseif ($column === 'product_SKUs') {
|
84 |
+
$row[] = !empty($sku) ? $sku : '';
|
85 |
+
unset($sku);
|
86 |
+
} elseif ($column === 'exclude_product_SKUs') {
|
87 |
+
$row[] = !empty($exsku) ? $exsku : '';
|
88 |
+
unset($exsku);
|
89 |
+
} elseif ($column === 'expiry_date') {
|
90 |
+
$exp_date = get_post_meta($coupon->ID, 'date_expires');
|
91 |
+
$row[] = !empty($exp_date[0]) ? date("Y-m-d", $exp_date[0]) : '';
|
92 |
+
} else {
|
93 |
+
$row[] = '';
|
94 |
+
}
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
$row = apply_filters('wt_ier_alter_coupon_csv_data', $row); // Alter Coupon CSV data if needed
|
99 |
+
$row = array_map('Wt_Import_Export_For_Woo_Basic_Coupon_Bulk_Export::wrap_column', $row);
|
100 |
+
fwrite($fp, implode($delimiter, $row) . "\n");
|
101 |
+
unset($row);
|
102 |
+
}
|
103 |
+
|
104 |
+
fclose($fp);
|
105 |
+
exit;
|
106 |
+
}
|
107 |
+
|
108 |
+
public static function format_data($data) {
|
109 |
+
if (!is_array($data))
|
110 |
+
;
|
111 |
+
$data = (string) urldecode($data);
|
112 |
+
$enc = mb_detect_encoding($data, 'UTF-8, ISO-8859-1', true);
|
113 |
+
$data = ( $enc == 'UTF-8' ) ? $data : utf8_encode($data);
|
114 |
+
return $data;
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Wrap a column in quotes for the CSV
|
119 |
+
* @param string data to wrap
|
120 |
+
* @return string wrapped data
|
121 |
+
*/
|
122 |
+
public static function wrap_column($data) {
|
123 |
+
return '"' . str_replace('"', '""', $data) . '"';
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Get a list of all the meta keys for a post type. This includes all public, private,
|
128 |
+
* used, no-longer used etc. They will be sorted once fetched.
|
129 |
+
*/
|
130 |
+
public static function get_all_metakeys($post_type = 'shop_coupon') {
|
131 |
+
global $wpdb;
|
132 |
+
|
133 |
+
$meta = $wpdb->get_col($wpdb->prepare(
|
134 |
+
"SELECT DISTINCT pm.meta_key
|
135 |
+
FROM {$wpdb->postmeta} AS pm
|
136 |
+
LEFT JOIN {$wpdb->posts} AS p ON p.ID = pm.post_id
|
137 |
+
WHERE p.post_type = %s
|
138 |
+
AND p.post_status IN ( 'publish', 'pending', 'private', 'draft' )", $post_type
|
139 |
+
));
|
140 |
+
|
141 |
+
sort($meta);
|
142 |
+
|
143 |
+
return $meta;
|
144 |
+
}
|
145 |
+
|
146 |
+
public static function get_sku_from_id($val) {
|
147 |
+
$pro_id = explode(",", $val);
|
148 |
+
$sku_arr = array();
|
149 |
+
if ($pro_id) {
|
150 |
+
foreach ($pro_id as $value) {
|
151 |
+
$product_exist = get_post_type($value);
|
152 |
+
if ($product_exist == 'product' || $product_exist == 'product_variation') {
|
153 |
+
$psku = get_post_meta($value, '_sku', TRUE);
|
154 |
+
if (!empty($psku)) {
|
155 |
+
$sku_arr[] = $psku;
|
156 |
+
}
|
157 |
+
}
|
158 |
+
}
|
159 |
+
}
|
160 |
+
$new_sku = implode("|", $sku_arr);
|
161 |
+
return $new_sku;
|
162 |
+
}
|
163 |
+
|
164 |
+
}
|
admin/modules/coupon/import/import.php
CHANGED
@@ -59,16 +59,16 @@ class Wt_Import_Export_For_Woo_Basic_Coupon_Import {
|
|
59 |
if($this->is_coupon_exist){
|
60 |
$msg = 'Coupon updated successfully.';
|
61 |
}
|
62 |
-
$this->import_results[$row] = array('row'=>$row, 'message'=>$msg, 'status'=>true, 'post_id'=>$result['id']);
|
63 |
Wt_Import_Export_For_Woo_Basic_Logwriter::write_log($this->parent_module->module_base, 'import', "Row :$row - ".$msg);
|
64 |
$success++;
|
65 |
}else{
|
66 |
-
$this->import_results[$row] = array('row'=>$row, 'message'=>$result->get_error_message(), 'status'=>false, 'post_id'=>'');
|
67 |
Wt_Import_Export_For_Woo_Basic_Logwriter::write_log($this->parent_module->module_base, 'import', "Row :$row - Processing failed. Reason: ".$result->get_error_message());
|
68 |
$failed++;
|
69 |
}
|
70 |
}else{
|
71 |
-
$this->import_results[$row] = array('row'=>$row, 'message'=>$parsed_data->get_error_message(), 'status'=>false, 'post_id'=>'');
|
72 |
Wt_Import_Export_For_Woo_Basic_Logwriter::write_log($this->parent_module->module_base, 'import', "Row :$row - Parsing failed. Reason: ".$parsed_data->get_error_message());
|
73 |
$failed++;
|
74 |
}
|
@@ -313,8 +313,7 @@ class Wt_Import_Export_For_Woo_Basic_Coupon_Import {
|
|
313 |
if ( 'percent_product' === $discount_type ) {
|
314 |
$discount_type = 'percent'; // Backwards compatibility.
|
315 |
}
|
316 |
-
if ( ! in_array( $discount_type, array_keys( wc_get_coupon_types() ), true ) ) {
|
317 |
-
$this->error( 'coupon_invalid_discount_type', __( 'Invalid discount type', 'woocommerce' ) );
|
318 |
throw new Exception(sprintf('Invalid discount type. Type: %s',$discount_type ));
|
319 |
}
|
320 |
|
@@ -678,7 +677,9 @@ class Wt_Import_Export_For_Woo_Basic_Coupon_Import {
|
|
678 |
foreach ($cpn_product_categories as $cpn_product_category_name) {
|
679 |
|
680 |
$cpn_product_category_obj = get_term_by( 'name', $cpn_product_category_name, 'product_cat' );
|
681 |
-
|
|
|
|
|
682 |
|
683 |
}
|
684 |
|
59 |
if($this->is_coupon_exist){
|
60 |
$msg = 'Coupon updated successfully.';
|
61 |
}
|
62 |
+
$this->import_results[$row] = array('row'=>$row, 'message'=>$msg, 'status'=>true, 'status_msg' => __( 'Success' ), 'post_id'=>$result['id'], 'post_link' => Wt_Import_Export_For_Woo_Basic_Coupon::get_item_link_by_id($result['id']));
|
63 |
Wt_Import_Export_For_Woo_Basic_Logwriter::write_log($this->parent_module->module_base, 'import', "Row :$row - ".$msg);
|
64 |
$success++;
|
65 |
}else{
|
66 |
+
$this->import_results[$row] = array('row'=>$row, 'message'=>$result->get_error_message(), 'status'=>false, 'status_msg' => __( 'Failed/Skipped' ), 'post_id'=>'', 'post_link' => array( 'title' => __( 'Untitled' ), 'edit_url' => false ) );
|
67 |
Wt_Import_Export_For_Woo_Basic_Logwriter::write_log($this->parent_module->module_base, 'import', "Row :$row - Processing failed. Reason: ".$result->get_error_message());
|
68 |
$failed++;
|
69 |
}
|
70 |
}else{
|
71 |
+
$this->import_results[$row] = array('row'=>$row, 'message'=>$parsed_data->get_error_message(), 'status'=>false, 'status_msg' => __( 'Failed/Skipped' ), 'post_id'=>'', 'post_link' => array( 'title' => __( 'Untitled' ), 'edit_url' => false ) );
|
72 |
Wt_Import_Export_For_Woo_Basic_Logwriter::write_log($this->parent_module->module_base, 'import', "Row :$row - Parsing failed. Reason: ".$parsed_data->get_error_message());
|
73 |
$failed++;
|
74 |
}
|
313 |
if ( 'percent_product' === $discount_type ) {
|
314 |
$discount_type = 'percent'; // Backwards compatibility.
|
315 |
}
|
316 |
+
if ( ! in_array( $discount_type, array_keys( wc_get_coupon_types() ), true ) ) {
|
|
|
317 |
throw new Exception(sprintf('Invalid discount type. Type: %s',$discount_type ));
|
318 |
}
|
319 |
|
677 |
foreach ($cpn_product_categories as $cpn_product_category_name) {
|
678 |
|
679 |
$cpn_product_category_obj = get_term_by( 'name', $cpn_product_category_name, 'product_cat' );
|
680 |
+
if(is_object($cpn_product_category_obj)){
|
681 |
+
$cpn_product_category_ids[] = $cpn_product_category_obj->term_id;
|
682 |
+
}
|
683 |
|
684 |
}
|
685 |
|
admin/modules/export/assets/js/main.js
CHANGED
@@ -5,7 +5,7 @@ var wt_iew_basic_export=(function( $ ) {
|
|
5 |
ajax_data:{},
|
6 |
selected_template:0,
|
7 |
selected_template_name:'',
|
8 |
-
to_export:'order',
|
9 |
to_export_title:'',
|
10 |
export_method:'',
|
11 |
current_step:'',
|
@@ -627,6 +627,9 @@ var wt_iew_basic_export=(function( $ ) {
|
|
627 |
if(this.to_export!="" && this.to_export_title=='')
|
628 |
{
|
629 |
$('[name="wt_iew_export_post_type"]').val(this.to_export);
|
|
|
|
|
|
|
630 |
this.to_export_title=$('[name="wt_iew_export_post_type"] option:selected').text();
|
631 |
}
|
632 |
$('.wt_iew_step_head_post_type_name').html(this.to_export_title);
|
5 |
ajax_data:{},
|
6 |
selected_template:0,
|
7 |
selected_template_name:'',
|
8 |
+
to_export:( wt_iew_export_basic_params.to_export !== '' ) ? wt_iew_export_basic_params.to_export : 'order',
|
9 |
to_export_title:'',
|
10 |
export_method:'',
|
11 |
current_step:'',
|
627 |
if(this.to_export!="" && this.to_export_title=='')
|
628 |
{
|
629 |
$('[name="wt_iew_export_post_type"]').val(this.to_export);
|
630 |
+
if(wt_iew_export_basic_params.to_export !== ''){
|
631 |
+
$('[name="wt_iew_export_post_type"]').trigger('change');
|
632 |
+
}
|
633 |
this.to_export_title=$('[name="wt_iew_export_post_type"] option:selected').text();
|
634 |
}
|
635 |
$('.wt_iew_step_head_post_type_name').html(this.to_export_title);
|
admin/modules/export/export.php
CHANGED
@@ -303,7 +303,7 @@ class Wt_Import_Export_For_Woo_Basic_Export
|
|
303 |
'sele_vals'=>Wt_Iew_IE_Basic_Helper::_get_csv_delimiters(),
|
304 |
'help_text'=>__( 'Separator for differentiating the columns in the CSV file. Assumes ‘,’ by default.' ),
|
305 |
'validation_rule'=>array('type'=>'skip'),
|
306 |
-
'after_form_field'=>'<input type="text" class="wt_iew_custom_delimiter" name="wt_iew_delimiter" value="'.$delimiter_default.'" />',
|
307 |
)
|
308 |
);
|
309 |
|
@@ -379,7 +379,7 @@ class Wt_Import_Export_For_Woo_Basic_Export
|
|
379 |
'item_type'=>'',
|
380 |
'steps'=>$this->steps,
|
381 |
'rerun_id'=>$this->rerun_id,
|
382 |
-
'to_export'
|
383 |
'export_method'=>$this->export_method,
|
384 |
'msgs'=>array(
|
385 |
'choosed_template'=>__('Choosed template: '),
|
303 |
'sele_vals'=>Wt_Iew_IE_Basic_Helper::_get_csv_delimiters(),
|
304 |
'help_text'=>__( 'Separator for differentiating the columns in the CSV file. Assumes ‘,’ by default.' ),
|
305 |
'validation_rule'=>array('type'=>'skip'),
|
306 |
+
'after_form_field'=>'<input type="text" class="wt_iew_custom_delimiter" name="wt_iew_delimiter" value="'.$delimiter_default.'" maxlength = "1" />',
|
307 |
)
|
308 |
);
|
309 |
|
379 |
'item_type'=>'',
|
380 |
'steps'=>$this->steps,
|
381 |
'rerun_id'=>$this->rerun_id,
|
382 |
+
'to_export'=> isset( $_GET['wt_to_export'] ) ? sanitize_text_field( $_GET['wt_to_export'] ) : $this->to_export,
|
383 |
'export_method'=>$this->export_method,
|
384 |
'msgs'=>array(
|
385 |
'choosed_template'=>__('Choosed template: '),
|
admin/modules/history/assets/js/main.js
CHANGED
@@ -11,7 +11,8 @@ var wt_iew_basic_history=(function( $ ) {
|
|
11 |
},
|
12 |
reg_view_log:function()
|
13 |
{
|
14 |
-
jQuery(document).on('click', ".wt_iew_view_log_btn", function(){
|
|
|
15 |
wt_iew_basic_history.show_log_popup();
|
16 |
var history_id=$(this).attr('data-history-id');
|
17 |
if(history_id>0)
|
11 |
},
|
12 |
reg_view_log:function()
|
13 |
{
|
14 |
+
jQuery(document).on('click', ".wt_iew_view_log_btn", function(){
|
15 |
+
jQuery('.wt_iew_overlay, .wt_iew_popup').hide();
|
16 |
wt_iew_basic_history.show_log_popup();
|
17 |
var history_id=$(this).attr('data-history-id');
|
18 |
if(history_id>0)
|
admin/modules/import/assets/js/main.js
CHANGED
@@ -20,8 +20,10 @@ var wt_iew_basic_import=(function( $ ) {
|
|
20 |
local_import_file:'',
|
21 |
url_import_file:'',
|
22 |
on_rerun:false,
|
|
|
23 |
rerun_id:0,
|
24 |
import_delimiter:',',
|
|
|
25 |
Set:function()
|
26 |
{
|
27 |
this.step_keys=Object.keys(wt_iew_import_basic_params.steps);
|
@@ -263,7 +265,7 @@ var wt_iew_basic_import=(function( $ ) {
|
|
263 |
{
|
264 |
wt_iew_basic_import.set_import_progress_info(wt_iew_import_basic_params.msgs.processing_file);
|
265 |
}
|
266 |
-
$.ajax({
|
267 |
type: 'POST',
|
268 |
url:wt_iew_basic_params.ajax_url,
|
269 |
data:this.ajax_data,
|
@@ -283,32 +285,103 @@ var wt_iew_basic_import=(function( $ ) {
|
|
283 |
//wt_iew_notify_msg.success(wt_iew_basic_params.msgs.success);
|
284 |
|
285 |
}else if(action=='import')
|
286 |
-
|
|
|
287 |
if(data.finished==1)
|
288 |
{
|
289 |
-
|
290 |
-
|
291 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
292 |
}
|
293 |
else
|
294 |
{
|
295 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
296 |
wt_iew_basic_import.ajax_data['offset']=data.new_offset;
|
297 |
wt_iew_basic_import.ajax_data['import_id']=data.import_id;
|
298 |
wt_iew_basic_import.ajax_data['total_records']=data.total_records;
|
299 |
wt_iew_basic_import.ajax_data['offset_count']=data.offset_count;
|
300 |
-
|
301 |
wt_iew_basic_import.ajax_data['total_success']=data.total_success;
|
302 |
wt_iew_basic_import.ajax_data['total_failed']=data.total_failed;
|
303 |
wt_iew_basic_import.do_nonstep_action(action);
|
304 |
}
|
305 |
-
}
|
|
|
306 |
{
|
307 |
wt_iew_basic_import.set_import_progress_info(data.msg);
|
308 |
wt_iew_basic_import.ajax_data['import_id']=data.import_id;
|
309 |
wt_iew_basic_import.ajax_data['total_records']=data.total_records;
|
310 |
if(data.finished==3)/* finished file processing */
|
311 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
312 |
wt_iew_basic_import.ajax_data['offset']=0;
|
313 |
wt_iew_basic_import.ajax_data['offset_count']=0;
|
314 |
wt_iew_basic_import.ajax_data['import_action']='import';
|
@@ -374,6 +447,34 @@ var wt_iew_basic_import=(function( $ ) {
|
|
374 |
}
|
375 |
});
|
376 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
377 |
reg_button_actions:function()
|
378 |
{
|
379 |
$('.wt_iew_import_action_btn').unbind('click').click(function(e){
|
@@ -412,6 +513,19 @@ var wt_iew_basic_import=(function( $ ) {
|
|
412 |
wt_iew_basic_import.nonstep_actions(action);
|
413 |
}
|
414 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
415 |
},
|
416 |
get_file_from:function()
|
417 |
{
|
20 |
local_import_file:'',
|
21 |
url_import_file:'',
|
22 |
on_rerun:false,
|
23 |
+
import_finished:false,
|
24 |
rerun_id:0,
|
25 |
import_delimiter:',',
|
26 |
+
import_start_time:0,
|
27 |
Set:function()
|
28 |
{
|
29 |
this.step_keys=Object.keys(wt_iew_import_basic_params.steps);
|
265 |
{
|
266 |
wt_iew_basic_import.set_import_progress_info(wt_iew_import_basic_params.msgs.processing_file);
|
267 |
}
|
268 |
+
wt_iew_basic_import.import_ajax_xhr = $.ajax({
|
269 |
type: 'POST',
|
270 |
url:wt_iew_basic_params.ajax_url,
|
271 |
data:this.ajax_data,
|
285 |
//wt_iew_notify_msg.success(wt_iew_basic_params.msgs.success);
|
286 |
|
287 |
}else if(action=='import')
|
288 |
+
{
|
289 |
+
|
290 |
if(data.finished==1)
|
291 |
{
|
292 |
+
wt_iew_basic_import.temp_import_file='';
|
293 |
+
let [firstKey] = Object.keys(data.log_data);
|
294 |
+
if(data.log_data[firstKey].post_link){
|
295 |
+
|
296 |
+
wt_iew_basic_import.show_import_popup();
|
297 |
+
$('.wt_iew_import_progress_wrap').addClass('open');
|
298 |
+
|
299 |
+
var newk = 0;
|
300 |
+
$.each(data.log_data, function (j) {
|
301 |
+
var status_icon = (data.log_data[j].status == true ) ? 'yes-alt' : 'dismiss';
|
302 |
+
var item_name = (data.log_data[j].post_link.edit_url) ? '<a href="'+data.log_data[j].post_link.edit_url+'" target="_blank">'+data.log_data[j].post_link.title+'</a>' : data.log_data[j].post_link.title;
|
303 |
+
$('#wt_iew_import_progress tbody').append( '<tr id="row-' + data.log_data[j].row + '" class="' + data.log_data[j].status + '"><td style="width:15%"><span class="result" title="' + data.log_data[j].row + '">' + data.log_data[j].row + '</span></td><td style="width:20%" class="row">' + item_name + '</td><td style="width:50%">' + data.log_data[j].message + '</td><td style="width:20%" class="reason"><span class="dashicons dashicons-'+status_icon+'"></span></td></tr>' );
|
304 |
+
newk = j;
|
305 |
+
});
|
306 |
+
//$('.wt-iew-importer-progress').val(data.total_percent);
|
307 |
+
var elm = document.getElementsByClassName('progressab')[0];
|
308 |
+
elm.style.width = 100+"%";
|
309 |
+
document.getElementById('row-' + ( newk )).scrollIntoView(false);
|
310 |
+
$('.progressa').hide();
|
311 |
+
|
312 |
+
$('#wt-iew-import-results-total-count').html((data.total_success + data.total_failed));
|
313 |
+
$('#wt-iew-import-results-imported-count').html(data.total_success);
|
314 |
+
$('#wt-iew-import-results-failed-count').html(data.total_failed);
|
315 |
+
|
316 |
+
$('.wt-iew-import-completed').show();
|
317 |
+
var time_taken = new Date().getTime() - wt_iew_basic_import.import_start_time;
|
318 |
+
time_taken = (time_taken/1000); // convert to seconds
|
319 |
+
$('#wt-iew-import-time-taken').html(wt_iew_basic_import.toHHMMSS(time_taken));
|
320 |
+
$('.wt-iew-import-time').show();
|
321 |
+
$('.wt_iew_view_log_btn').attr('data-log-file', data.log_file);
|
322 |
+
$('.wt_iew_view_log_btn').show();
|
323 |
+
$('.wt_iew_view_imported_items').attr('href', wt_iew_import_basic_params.addons[wt_iew_basic_import.to_import].page_link);
|
324 |
+
$('.wt_iew_view_imported_items').text(wt_iew_import_basic_params.addons[wt_iew_basic_import.to_import].text);
|
325 |
+
$('.wt_iew_view_imported_items').show();
|
326 |
+
$('.wt_iew_popup_close_btn').show();
|
327 |
+
$('.wt_iew_popup_cancel_btn').hide();
|
328 |
+
}else{
|
329 |
+
wt_iew_notify_msg.success(wt_iew_basic_params.msgs.success, false);
|
330 |
+
wt_iew_basic_import.set_import_progress_info(data.msg);
|
331 |
+
}
|
332 |
+
wt_iew_basic_import.import_finished = true;
|
333 |
}
|
334 |
else
|
335 |
{
|
336 |
+
let [firstKey] = Object.keys(data.log_data);
|
337 |
+
if(data.log_data[firstKey].post_link){
|
338 |
+
wt_iew_basic_import.show_import_popup();
|
339 |
+
$('.wt_iew_import_progress_wrap').addClass('open');
|
340 |
+
var newk = 0;
|
341 |
+
$.each(data.log_data, function (j) {
|
342 |
+
var status_icon = (data.log_data[j].status == true ) ? 'yes-alt' : 'dismiss';
|
343 |
+
var item_name = (data.log_data[j].post_link.edit_url) ? '<a href="'+data.log_data[j].post_link.edit_url+'" target="_blank">'+data.log_data[j].post_link.title+'</a>' : data.log_data[j].post_link.title;
|
344 |
+
$('#wt_iew_import_progress tbody').append( '<tr id="row-' + data.log_data[j].row + '" class="' + data.log_data[j].status + '"><td style="width:15%"><span class="result" title="' + data.log_data[j].row + '">' + data.log_data[j].row + '</span></td><td style="width:20%" class="row">' + item_name + '</td><td style="width:50%">' + data.log_data[j].message + '</td><td style="width:20%" class="reason"><span class="dashicons dashicons-'+status_icon+'"></span></td></tr>' );
|
345 |
+
newk = j;
|
346 |
+
});
|
347 |
+
|
348 |
+
var progressval = data.total_percent;
|
349 |
+
var elm = document.getElementsByClassName('progressab')[0];
|
350 |
+
elm.style.width = progressval+"%";
|
351 |
+
|
352 |
+
elm.innerText = progressval+"%";
|
353 |
+
elm.style.backgroundColor = '#5FBA89';
|
354 |
+
//$('.wt-iew-importer-progress').val(data.total_percent);
|
355 |
+
document.getElementById('row-' + ( newk )).scrollIntoView({block: 'end', behavior: 'smooth'});
|
356 |
+
}else{
|
357 |
+
wt_iew_basic_import.set_import_progress_info(data.msg);
|
358 |
+
}
|
359 |
wt_iew_basic_import.ajax_data['offset']=data.new_offset;
|
360 |
wt_iew_basic_import.ajax_data['import_id']=data.import_id;
|
361 |
wt_iew_basic_import.ajax_data['total_records']=data.total_records;
|
362 |
wt_iew_basic_import.ajax_data['offset_count']=data.offset_count;
|
|
|
363 |
wt_iew_basic_import.ajax_data['total_success']=data.total_success;
|
364 |
wt_iew_basic_import.ajax_data['total_failed']=data.total_failed;
|
365 |
wt_iew_basic_import.do_nonstep_action(action);
|
366 |
}
|
367 |
+
}
|
368 |
+
else if(action=='download')
|
369 |
{
|
370 |
wt_iew_basic_import.set_import_progress_info(data.msg);
|
371 |
wt_iew_basic_import.ajax_data['import_id']=data.import_id;
|
372 |
wt_iew_basic_import.ajax_data['total_records']=data.total_records;
|
373 |
if(data.finished==3)/* finished file processing */
|
374 |
{
|
375 |
+
wt_iew_basic_import.import_start_time = new Date().getTime();
|
376 |
+
$("#wt_iew_import_progress_tbody").empty();
|
377 |
+
//$('#import-start-area').hide();
|
378 |
+
$('.progressa').show();
|
379 |
+
$('.wt-iew-import-completed').hide();
|
380 |
+
$('.wt-iew-import-time').hide();
|
381 |
+
$('.wt_iew_popup_close_btn').hide();
|
382 |
+
$('.wt_iew_view_imported_items').hide();
|
383 |
+
$('.wt_iew_view_log_btn').hide();
|
384 |
+
$('.wt_iew_popup_cancel_btn').show();
|
385 |
wt_iew_basic_import.ajax_data['offset']=0;
|
386 |
wt_iew_basic_import.ajax_data['offset_count']=0;
|
387 |
wt_iew_basic_import.ajax_data['import_action']='import';
|
447 |
}
|
448 |
});
|
449 |
},
|
450 |
+
show_import_popup:function()
|
451 |
+
{
|
452 |
+
var pop_elm=$('.wt_iew_import_progress_wrap');
|
453 |
+
var ww=$(window).width();
|
454 |
+
pop_w=(ww<1300 ? ww : 1300)-200;
|
455 |
+
pop_w=(pop_w<200 ? 200 : pop_w);
|
456 |
+
pop_elm.width(pop_w);
|
457 |
+
|
458 |
+
wh=$(window).height();
|
459 |
+
pop_h=(wh>=400 ? (wh-200) : wh);
|
460 |
+
$('.wt_iew_import_progress').css({'max-height':pop_h+'px','overflow':'auto'});
|
461 |
+
wt_iew_popup.showimportPopup(pop_elm);
|
462 |
+
pop_elm.css({'display':'flex'});
|
463 |
+
},
|
464 |
+
toHHMMSS:function(sec_taken){
|
465 |
+
var sec_num = parseInt(sec_taken, 10); // don't forget the second param
|
466 |
+
var hours = Math.floor(sec_num / 3600);
|
467 |
+
var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
|
468 |
+
var seconds = sec_num - (hours * 3600) - (minutes * 60);
|
469 |
+
if(seconds === 0){
|
470 |
+
seconds = 1;
|
471 |
+
}
|
472 |
+
|
473 |
+
if (hours < 10) {hours = "0"+hours;}
|
474 |
+
if (minutes < 10) {minutes = "0"+minutes;}
|
475 |
+
if (seconds < 10) {seconds = "0"+seconds;}
|
476 |
+
return hours + ':' + minutes + ':' + seconds;
|
477 |
+
},
|
478 |
reg_button_actions:function()
|
479 |
{
|
480 |
$('.wt_iew_import_action_btn').unbind('click').click(function(e){
|
513 |
wt_iew_basic_import.nonstep_actions(action);
|
514 |
}
|
515 |
});
|
516 |
+
$('.wt_iew_popup_cancel_btn').unbind('click').click(function(e){
|
517 |
+
if (confirm("Are you sure to stop the import?") == true) {
|
518 |
+
var temp_err_message = wt_iew_basic_params.msgs.error;
|
519 |
+
wt_iew_basic_params.msgs.error = 'Import cancelled';
|
520 |
+
wt_iew_basic_import.import_ajax_xhr.abort();
|
521 |
+
wt_iew_basic_params.msgs.error = temp_err_message;
|
522 |
+
var progressval = 1;
|
523 |
+
var elm = document.getElementsByClassName('progressab')[0];
|
524 |
+
elm.style.width = progressval+"%";
|
525 |
+
elm.innerText = progressval+"%";
|
526 |
+
jQuery('.wt_iew_overlay, .wt_iew_popup').hide();
|
527 |
+
}
|
528 |
+
});
|
529 |
},
|
530 |
get_file_from:function()
|
531 |
{
|
admin/modules/import/import.php
CHANGED
@@ -404,6 +404,40 @@ class Wt_Import_Export_For_Woo_Basic_Import
|
|
404 |
'upload_done'=>sprintf(__('%s Done.'), '<span class="dashicons dashicons-yes-alt" style="color:#3fa847;"></span>'),
|
405 |
'remove'=>__('Remove'),
|
406 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
407 |
);
|
408 |
wp_localize_script($this->module_id, 'wt_iew_import_basic_params', $params);
|
409 |
|
@@ -939,6 +973,7 @@ class Wt_Import_Export_For_Woo_Basic_Import
|
|
939 |
/* checking action is finshed */
|
940 |
$is_last_offset=false;
|
941 |
$new_offset=$input_data['offset']; //increase the offset
|
|
|
942 |
if($new_offset>=$total_records) //finished
|
943 |
{
|
944 |
$is_last_offset=true;
|
@@ -969,7 +1004,7 @@ class Wt_Import_Export_For_Woo_Basic_Import
|
|
969 |
);
|
970 |
|
971 |
$import_response=apply_filters('wt_iew_importer_do_import_basic', $input_data['data_arr'], $to_process, $step, $form_data, $this->selected_template_data, $this->import_method, $offset_count, $is_last_offset);
|
972 |
-
|
973 |
/**
|
974 |
* Writing import log to file
|
975 |
*/
|
@@ -1015,6 +1050,14 @@ class Wt_Import_Export_For_Woo_Basic_Import
|
|
1015 |
$log_summary_msg=$this->generate_log_summary($out, $is_last_offset);
|
1016 |
|
1017 |
$out['finished']=1; //finished
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1018 |
$out['msg']=$log_summary_msg;
|
1019 |
|
1020 |
/* updating finished status */
|
404 |
'upload_done'=>sprintf(__('%s Done.'), '<span class="dashicons dashicons-yes-alt" style="color:#3fa847;"></span>'),
|
405 |
'remove'=>__('Remove'),
|
406 |
),
|
407 |
+
'addons' => array(
|
408 |
+
'product' => array(
|
409 |
+
'text' => __( 'View Products' ),
|
410 |
+
'page_link' => admin_url('edit.php?post_type=product')
|
411 |
+
),
|
412 |
+
'product_categories' => array(
|
413 |
+
'text' => __( 'View Product categories' ),
|
414 |
+
'page_link' => admin_url('edit-tags.php?taxonomy=product_cat&post_type=product')
|
415 |
+
),
|
416 |
+
'product_tags' => array(
|
417 |
+
'text' => __( 'View Product tags' ),
|
418 |
+
'page_link' => admin_url('edit-tags.php?taxonomy=product_tag&post_type=product')
|
419 |
+
),
|
420 |
+
'product_review' => array(
|
421 |
+
'text' => __( 'View Product reviews' ),
|
422 |
+
'page_link' => admin_url('edit-comments.php')
|
423 |
+
),
|
424 |
+
'order' => array(
|
425 |
+
'text' => __( 'View Orders' ),
|
426 |
+
'page_link' => admin_url('edit.php?post_type=shop_order')
|
427 |
+
),
|
428 |
+
'coupon' => array(
|
429 |
+
'text' => __( 'View Coupons' ),
|
430 |
+
'page_link' => admin_url('edit.php?post_type=shop_coupon')
|
431 |
+
),
|
432 |
+
'user' => array(
|
433 |
+
'text' => __( 'View Users' ),
|
434 |
+
'page_link' => admin_url('users.php')
|
435 |
+
),
|
436 |
+
'subscription' => array(
|
437 |
+
'text' => __( 'View Subscriptions' ),
|
438 |
+
'page_link' => admin_url('edit.php?post_type=shop_subscription')
|
439 |
+
)
|
440 |
+
)
|
441 |
);
|
442 |
wp_localize_script($this->module_id, 'wt_iew_import_basic_params', $params);
|
443 |
|
973 |
/* checking action is finshed */
|
974 |
$is_last_offset=false;
|
975 |
$new_offset=$input_data['offset']; //increase the offset
|
976 |
+
$out['total_percent']= ceil(($new_offset/$total_records)*100);
|
977 |
if($new_offset>=$total_records) //finished
|
978 |
{
|
979 |
$is_last_offset=true;
|
1004 |
);
|
1005 |
|
1006 |
$import_response=apply_filters('wt_iew_importer_do_import_basic', $input_data['data_arr'], $to_process, $step, $form_data, $this->selected_template_data, $this->import_method, $offset_count, $is_last_offset);
|
1007 |
+
$out['log_data'] = $import_response['log_data'];
|
1008 |
/**
|
1009 |
* Writing import log to file
|
1010 |
*/
|
1050 |
$log_summary_msg=$this->generate_log_summary($out, $is_last_offset);
|
1051 |
|
1052 |
$out['finished']=1; //finished
|
1053 |
+
$log_file_name = '';
|
1054 |
+
$log_path=Wt_Import_Export_For_Woo_Basic_Log::$log_dir;
|
1055 |
+
$log_files = glob($log_path.'/'.$out['history_id'].'_*'.'.log');
|
1056 |
+
if(is_array($log_files) && count($log_files)>0)
|
1057 |
+
{
|
1058 |
+
$log_file_name=basename($log_files[0]);
|
1059 |
+
}
|
1060 |
+
$out['log_file'] = $log_file_name;
|
1061 |
$out['msg']=$log_summary_msg;
|
1062 |
|
1063 |
/* updating finished status */
|
admin/modules/import/views/main.php
CHANGED
@@ -31,6 +31,59 @@ select[name=wt_iew_file_from]{visibility: hidden;}
|
|
31 |
|
32 |
</div>
|
33 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
<?php
|
35 |
Wt_Iew_IE_Basic_Helper::debug_panel($this->module_base);
|
36 |
?>
|
31 |
|
32 |
</div>
|
33 |
</div>
|
34 |
+
|
35 |
+
<div class="wt_iew_import_progress_wrap wt_iew_popup">
|
36 |
+
<div class="wt_iew_popup_hd wt_iew_import_progress_header">
|
37 |
+
<span style="line-height:40px;" class="dashicons dashicons-media-text"></span>
|
38 |
+
<span class="wt_iew_popup_hd_label"><?php _e('Import progress');?></span>
|
39 |
+
<div class="wt_iew_popup_close">X</div>
|
40 |
+
</div>
|
41 |
+
<div class="wt_iew_import_progress_content" style="max-height:620px;overflow: auto;">
|
42 |
+
<table id="wt_iew_import_progress" class="widefat_importer widefat wt_iew_import_progress wp-list-table fixed striped history_list_tb log_list_tb">
|
43 |
+
<thead>
|
44 |
+
<tr>
|
45 |
+
<th style="width:15%" class="row"><?php _e( 'Row' ); ?></th>
|
46 |
+
<th style="width:20%"><?php _e( 'Item' ); ?></th>
|
47 |
+
<th style="width:50%"><?php _e( 'Message' ); ?></th>
|
48 |
+
<th style="width:20%" class="reason"><?php _e( 'Status' ); ?></th>
|
49 |
+
</tr>
|
50 |
+
</thead>
|
51 |
+
<tbody id="wt_iew_import_progress_tbody"></tbody>
|
52 |
+
</table>
|
53 |
+
</div>
|
54 |
+
<br/>
|
55 |
+
<div id="wt_iew_import_progress_end"></div>
|
56 |
+
<div class="progressa">
|
57 |
+
<div class="progressab" style="background-color: rgb(178, 222, 75);width:5px; "></div>
|
58 |
+
</div>
|
59 |
+
|
60 |
+
<div class="wt-iew-import-completed" style="display:none;border-top: 1px outset;">
|
61 |
+
<h3><?php _e('Import Completed'); ?><span style="color:green" class="dashicons dashicons-yes-alt"></span></h3>
|
62 |
+
<div class="wt-iew-import-results">
|
63 |
+
<div class="wt-iew-import-result-row">
|
64 |
+
<div class="wt-iew-import-results-total wt-iew-import-result-column"><?php _e('Total records identified'); ?>:<span id="wt-iew-import-results-total-count"></span></div>
|
65 |
+
<div style="color:green" class="wt-iew-import-results-imported wt-iew-import-result-column"><?php _e('Imported successfully'); ?>:<span id="wt-iew-import-results-imported-count"></span></div>
|
66 |
+
<div style="color:red" class="wt-iew-import-results-failed wt-iew-import-result-column"><?php _e('Failed/Skipped'); ?>:<span id="wt-iew-import-results-failed-count"></span></div>
|
67 |
+
</div>
|
68 |
+
</div>
|
69 |
+
</div>
|
70 |
+
|
71 |
+
|
72 |
+
<div class="wt-iew-plugin-toolbar bottom" style="padding:5px;margin-left:-10px;">
|
73 |
+
<div style="float: left">
|
74 |
+
<div class="wt-iew-import-time" style="display:none;padding-left: 40px;margin-top:10px;" ><?php _e( 'Time taken to complete' );?>:<span id="wt-iew-import-time-taken"></span></div>
|
75 |
+
</div>
|
76 |
+
<div style="float:right;">
|
77 |
+
<div style="float:right;">
|
78 |
+
<a target="_blank" href="#" class="button button-primary wt_iew_view_imported_items" data-log-file="" style="display:none" type="button" style="margin-right:10px;"><?php _e( 'View Item' );?></a>
|
79 |
+
<button class="button button-primary wt_iew_view_log_btn" data-log-file="" style="display:none" type="button" style="margin-right:10px;"><?php _e( 'View Log' );?></button>
|
80 |
+
<button class="button button-primary wt_iew_popup_cancel_btn" type="button" style="margin-right:10px;"><?php _e( 'Cancel' );?></button>
|
81 |
+
<button class="button button-primary wt_iew_popup_close_btn" style="display:none" type="button" style="margin-right:10px;"><?php _e( 'Close' );?></button>
|
82 |
+
</div>
|
83 |
+
</div>
|
84 |
+
</div>
|
85 |
+
</div>
|
86 |
+
|
87 |
<?php
|
88 |
Wt_Iew_IE_Basic_Helper::debug_panel($this->module_base);
|
89 |
?>
|
admin/modules/order/data/data-order-post-columns.php
CHANGED
@@ -83,4 +83,12 @@ if (class_exists('Zorem_Woocommerce_Advanced_Shipment_Tracking') || class_exists
|
|
83 |
$base_columns['meta:_wc_shipment_tracking_items'] = 'Advanced/WC shipment tracking';
|
84 |
endif;
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
return apply_filters('hf_csv_order_post_columns', $base_columns);
|
83 |
$base_columns['meta:_wc_shipment_tracking_items'] = 'Advanced/WC shipment tracking';
|
84 |
endif;
|
85 |
|
86 |
+
if (class_exists('WPO_WCPDF')):
|
87 |
+
$base_columns['meta:_wcpdf_invoice_number'] = 'WCPDF Invoice number';
|
88 |
+
$base_columns['meta:_wcpdf_invoice_date'] = 'WCPDF Invoice date';
|
89 |
+
$base_columns['meta:_wcpdf_invoice_number_data'] = 'WCPDF Invoice number details';
|
90 |
+
$base_columns['meta:_wcpdf_invoice_date_formatted'] = 'WCPDF Invoice date formatted';
|
91 |
+
$base_columns['meta:_wcpdf_invoice_settings'] = 'WCPDF Invoice settings';
|
92 |
+
endif;
|
93 |
+
|
94 |
return apply_filters('hf_csv_order_post_columns', $base_columns);
|
admin/modules/order/data/data/data-wf-reserved-fields-pair.php
CHANGED
@@ -83,5 +83,13 @@ if (class_exists('Zorem_Woocommerce_Advanced_Shipment_Tracking') || class_exists
|
|
83 |
$base_reserved_columns['meta:_wc_shipment_tracking_items'] = array('title' => 'Shipment Tracking', 'description' => 'Shipment tracking');
|
84 |
endif;
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
// Reserved column names
|
87 |
return apply_filters('woocommerce_csv_order_reserved_fields_pair', $base_reserved_columns);
|
83 |
$base_reserved_columns['meta:_wc_shipment_tracking_items'] = array('title' => 'Shipment Tracking', 'description' => 'Shipment tracking');
|
84 |
endif;
|
85 |
|
86 |
+
if (class_exists('WPO_WCPDF')):
|
87 |
+
$base_reserved_columns['meta:_wcpdf_invoice_number'] = array('title' => 'WCPDF Invoice number', 'description' => 'WCPDF Invoice number');
|
88 |
+
$base_reserved_columns['meta:_wcpdf_invoice_date'] = array('title' => 'WCPDF Invoice date', 'description' => 'WCPDF Invoice date');
|
89 |
+
$base_reserved_columns['meta:_wcpdf_invoice_number_data'] = array('title' => 'WCPDF Invoice number details', 'description' => 'WCPDF Invoice number details');
|
90 |
+
$base_reserved_columns['meta:_wcpdf_invoice_date_formatted'] = array('title' => 'WCPDF Invoice date formatted', 'description' => 'WCPDF Invoice date formatted');
|
91 |
+
$base_reserved_columns['meta:_wcpdf_invoice_settings'] = array('title' => 'WCPDF Invoice settings', 'description' => 'WCPDF Invoice settings');
|
92 |
+
endif;
|
93 |
+
|
94 |
// Reserved column names
|
95 |
return apply_filters('woocommerce_csv_order_reserved_fields_pair', $base_reserved_columns);
|
admin/modules/order/export/class-wt-orderimpexpcsv-basic-exporter.php
ADDED
@@ -0,0 +1,638 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!defined('ABSPATH')) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
class Wt_Import_Export_For_Woo_Basic_Order_Bulk_Export {
|
8 |
+
|
9 |
+
public static $temp_order_metadata;
|
10 |
+
public static $line_item_meta;
|
11 |
+
public static $include_hidden_meta;
|
12 |
+
public static $is_wt_invoice_active;
|
13 |
+
public static $shipment_tracking_active;
|
14 |
+
public static $wpo_wcpdf;
|
15 |
+
public static $is_yith_tracking_active;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Order Exporter
|
19 |
+
*/
|
20 |
+
public static function do_export($post_type = 'shop_order', $order_IDS = array(), $xmldata = '0') {
|
21 |
+
global $wpdb;
|
22 |
+
|
23 |
+
|
24 |
+
if (is_plugin_active('print-invoices-packing-slip-labels-for-woocommerce/print-invoices-packing-slip-labels-for-woocommerce.php')):
|
25 |
+
self::$is_wt_invoice_active = true;
|
26 |
+
endif;
|
27 |
+
if (class_exists('Zorem_Woocommerce_Advanced_Shipment_Tracking') || class_exists('WC_Shipment_Tracking')):
|
28 |
+
self::$shipment_tracking_active = true;
|
29 |
+
endif;
|
30 |
+
if (class_exists('WPO_WCPDF')):
|
31 |
+
self::$wpo_wcpdf = true;
|
32 |
+
endif;
|
33 |
+
if (is_plugin_active('yith-woocommerce-order-tracking-premium/init.php')):
|
34 |
+
self::$is_yith_tracking_active = true;
|
35 |
+
endif;
|
36 |
+
|
37 |
+
$csv_columns = include_once( __DIR__ . '/../data/data-order-post-columns.php' );
|
38 |
+
$csv_columns = array_combine(array_keys($csv_columns), array_keys($csv_columns));
|
39 |
+
|
40 |
+
$exclude_hidden_meta_columns = array();
|
41 |
+
$user_columns_name = !empty($_POST['columns_name']) ? wc_clean($_POST['columns_name']) : $csv_columns;
|
42 |
+
$export_columns = !empty($_POST['columns']) ? wc_clean($_POST['columns']) : array();
|
43 |
+
|
44 |
+
|
45 |
+
$delimiter = !empty($_POST['delimiter']) ? $_POST['delimiter'] : ','; // WPCS: CSRF ok, input var ok.
|
46 |
+
$exclude_already_exported = false;
|
47 |
+
$export_to_separate_columns = false;
|
48 |
+
self::$include_hidden_meta = false;
|
49 |
+
|
50 |
+
if (self::$include_hidden_meta) {
|
51 |
+
self::$temp_order_metadata = apply_filters('wt_hidden_meta_columns', self::get_all_metakeys('shop_order'));
|
52 |
+
}
|
53 |
+
//ord_auto_export_ftp_file_name
|
54 |
+
|
55 |
+
|
56 |
+
$wpdb->hide_errors();
|
57 |
+
|
58 |
+
if (function_exists('apache_setenv'))
|
59 |
+
@apache_setenv('no-gzip', 1);
|
60 |
+
@ini_set('zlib.output_compression', 0);
|
61 |
+
@ob_end_clean();
|
62 |
+
|
63 |
+
$order_ids = $order_IDS;
|
64 |
+
|
65 |
+
|
66 |
+
$file_name = apply_filters('wt_iew_product_bulk_export_order_filename', 'order_export_' . date('Y-m-d-h-i-s') . '.csv');
|
67 |
+
|
68 |
+
header('Content-Type: text/csv; charset=UTF-8');
|
69 |
+
header('Content-Disposition: attachment; filename=' . $file_name);
|
70 |
+
header('Pragma: no-cache');
|
71 |
+
header('Expires: 0');
|
72 |
+
|
73 |
+
$fp = fopen('php://output', 'w');
|
74 |
+
|
75 |
+
$order_ids = apply_filters('wt_iew_product_bulk_export_order_ids', $order_ids);
|
76 |
+
// Variable to hold the CSV data we're exporting
|
77 |
+
$row = array();
|
78 |
+
|
79 |
+
// Export header rows
|
80 |
+
foreach ($csv_columns as $column => $value) {
|
81 |
+
if (!isset($user_columns_name[$column]))
|
82 |
+
continue;
|
83 |
+
$temp_head = esc_attr($user_columns_name[$column]);
|
84 |
+
if (!$export_columns || in_array($column, $export_columns))
|
85 |
+
$row[] = self::format_data($temp_head);
|
86 |
+
}
|
87 |
+
|
88 |
+
if (self::$include_hidden_meta) {
|
89 |
+
$found_order_meta = array();
|
90 |
+
// Some of the values may not be usable (e.g. arrays of arrays) but the worse
|
91 |
+
// that can happen is we get an empty column.
|
92 |
+
foreach (self::$temp_order_metadata as $meta) {
|
93 |
+
if (!$meta)
|
94 |
+
continue;
|
95 |
+
if (in_array(substr($meta, 1), array_keys($csv_columns)))
|
96 |
+
continue;
|
97 |
+
if (in_array($meta, $exclude_hidden_meta_columns) || in_array($meta, array_keys($csv_columns)))
|
98 |
+
continue;
|
99 |
+
$found_order_meta[] = $meta;
|
100 |
+
}
|
101 |
+
$found_order_meta = array_diff($found_order_meta, array_keys($csv_columns));
|
102 |
+
$export_column_count = count($export_columns);
|
103 |
+
$csv_column_count = count($row);
|
104 |
+
$rows1 = $row;
|
105 |
+
foreach ($found_order_meta as $key => $val) {
|
106 |
+
$rows1[] = 'meta:' . self::format_data($val);
|
107 |
+
}
|
108 |
+
$row = $rows1;
|
109 |
+
}
|
110 |
+
|
111 |
+
$max_line_items = self::get_max_line_items($order_ids);
|
112 |
+
for ($i = 1; $i <= $max_line_items; $i++) {
|
113 |
+
$row[] = "line_item_{$i}";
|
114 |
+
}
|
115 |
+
|
116 |
+
if ($export_to_separate_columns) {
|
117 |
+
self::$line_item_meta = self::get_all_line_item_metakeys();
|
118 |
+
for ($i = 1; $i <= $max_line_items; $i++) {
|
119 |
+
foreach (self::$line_item_meta as $meta_value) {
|
120 |
+
$new_val = str_replace("_", " ", $meta_value);
|
121 |
+
$row["line_item_{$i}_name"] = "Product Item {$i} Name";
|
122 |
+
$row["line_item_{$i}_product_id"] = "Product Item {$i} id";
|
123 |
+
$row["line_item_{$i}_sku"] = "Product Item {$i} SKU";
|
124 |
+
$row["line_item_{$i}_quantity"] = "Product Item {$i} Quantity";
|
125 |
+
$row["line_item_{$i}_total"] = "Product Item {$i} Total";
|
126 |
+
$row["line_item_{$i}_subtotal"] = "Product Item {$i} Subtotal";
|
127 |
+
if (in_array($meta_value, array("_product_id", "_qty", "_variation_id", "_line_total", "_line_subtotal", "_tax_class", "_line_tax", "_line_tax_data", "_line_subtotal_tax"))) {
|
128 |
+
continue;
|
129 |
+
} else {
|
130 |
+
$row["line_item_{$i}_$meta_value"] = "Product Item {$i} $new_val";
|
131 |
+
}
|
132 |
+
}
|
133 |
+
}
|
134 |
+
}
|
135 |
+
$filter_args = array('export_columns' => $export_columns, 'csv_columns' => $csv_columns, 'max_line_items' => $max_line_items, 'order_ids' => $order_ids, 'file_pointer' => $fp);
|
136 |
+
$row = apply_filters('wt_iew_product_bulk_export_order_csv_header', $row, $filter_args); //Alter CSV Header
|
137 |
+
|
138 |
+
if (!empty($row)) {
|
139 |
+
$row = array_map('Wt_Import_Export_For_Woo_Basic_Order_Bulk_Export::wrap_column', $row);
|
140 |
+
fwrite($fp, implode($delimiter, $row) . "\n");
|
141 |
+
}
|
142 |
+
$filter_args['header_row'] = $row;
|
143 |
+
unset($row);
|
144 |
+
// Loop orders
|
145 |
+
foreach ($order_ids as $order_id) {
|
146 |
+
//$row = array();
|
147 |
+
$data = self::get_orders_csv_row($order_id, $export_columns, $max_line_items, $user_columns_name);
|
148 |
+
// Add to csv
|
149 |
+
|
150 |
+
$data = apply_filters('wt_iew_product_bulk_export_order_csv_data', $data, $filter_args); //Alter CSV Data
|
151 |
+
if (!empty($data)) {
|
152 |
+
$row = array_map('Wt_Import_Export_For_Woo_Basic_Order_Bulk_Export::wrap_column', $data);
|
153 |
+
fwrite($fp, implode($delimiter, $row) . "\n");
|
154 |
+
}
|
155 |
+
unset($row);
|
156 |
+
unset($data);
|
157 |
+
// updating records with expoted status
|
158 |
+
update_post_meta($order_id, 'wf_order_exported_status', TRUE);
|
159 |
+
}
|
160 |
+
|
161 |
+
|
162 |
+
fclose($fp);
|
163 |
+
exit;
|
164 |
+
}
|
165 |
+
|
166 |
+
public static function format_data($data) {
|
167 |
+
if (!is_array($data))
|
168 |
+
;
|
169 |
+
$data = (string) urldecode($data);
|
170 |
+
$enc = mb_detect_encoding($data, 'UTF-8, ISO-8859-1', true);
|
171 |
+
$data = ( $enc == 'UTF-8' ) ? $data : utf8_encode($data);
|
172 |
+
return $data;
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Wrap a column in quotes for the CSV
|
177 |
+
* @param string data to wrap
|
178 |
+
* @return string wrapped data
|
179 |
+
*/
|
180 |
+
public static function wrap_column($data) {
|
181 |
+
return '"' . str_replace('"', '""', $data) . '"';
|
182 |
+
}
|
183 |
+
|
184 |
+
public static function get_max_line_items($order_ids) {
|
185 |
+
$max_line_items = 0;
|
186 |
+
foreach ($order_ids as $order_id) {
|
187 |
+
$order = wc_get_order($order_id);
|
188 |
+
$line_items_count = count($order->get_items());
|
189 |
+
if ($line_items_count >= $max_line_items) {
|
190 |
+
$max_line_items = $line_items_count;
|
191 |
+
}
|
192 |
+
}
|
193 |
+
return $max_line_items;
|
194 |
+
}
|
195 |
+
|
196 |
+
public static function get_orders_csv_row($order_id, $export_columns, $max_line_items, $user_columns_name = array()) {
|
197 |
+
$csv_columns = include( __DIR__ . '/../data/data-order-post-columns.php' );
|
198 |
+
|
199 |
+
// Get an instance of the WC_Order object
|
200 |
+
$order = wc_get_order($order_id);
|
201 |
+
$line_items = $shipping_items = $fee_items = $tax_items = $coupon_items = $refund_items = array();
|
202 |
+
|
203 |
+
// get line items
|
204 |
+
foreach ($order->get_items() as $item_id => $item) {
|
205 |
+
$product = (WC()->version < '4.4.0') ? $order->get_product_from_item($item) : $item->get_product(); // $order->get_product_from_item($item) deprecated since version 4.4.0
|
206 |
+
if (!is_object($product)) {
|
207 |
+
$product = new WC_Product(0);
|
208 |
+
}
|
209 |
+
//$item_meta = function_exists('wc_get_order_item_meta') ? wc_get_order_item_meta($item_id, '', false) : $order->get_item_meta($item_id);
|
210 |
+
$item_meta = self::get_order_line_item_meta($item_id);
|
211 |
+
$prod_type = (WC()->version < '3.0.0') ? $product->product_type : $product->get_type();
|
212 |
+
$line_item = array(
|
213 |
+
'name' => html_entity_decode(!empty($item['name']) ? $item['name'] : $product->get_title(), ENT_NOQUOTES, 'UTF-8'),
|
214 |
+
'product_id' => (WC()->version < '2.7.0') ? $product->id : (($prod_type == 'variable' || $prod_type == 'variation' || $prod_type == 'subscription_variation') ? $product->get_parent_id() : $product->get_id()),
|
215 |
+
'sku' => $product->get_sku(),
|
216 |
+
'quantity' => $item['qty'],
|
217 |
+
'total' => wc_format_decimal($order->get_line_total($item), 2),
|
218 |
+
'sub_total' => wc_format_decimal($order->get_line_subtotal($item), 2),
|
219 |
+
//'meta' => html_entity_decode($meta, ENT_NOQUOTES, 'UTF-8'),
|
220 |
+
);
|
221 |
+
|
222 |
+
//add line item tax
|
223 |
+
$line_tax_data = isset($item['line_tax_data']) ? $item['line_tax_data'] : array();
|
224 |
+
$tax_data = maybe_unserialize($line_tax_data);
|
225 |
+
$tax_detail = isset($tax_data['total']) ? wc_format_decimal(wc_round_tax_total(array_sum((array) $tax_data['total'])), 2) : '';
|
226 |
+
if ($tax_detail != '0.00' && !empty($tax_detail)) {
|
227 |
+
$line_item['tax'] = $tax_detail;
|
228 |
+
$line_tax_ser = json_encode($tax_data);
|
229 |
+
$line_item['tax_data'] = $line_tax_ser;
|
230 |
+
}
|
231 |
+
|
232 |
+
foreach ($item_meta as $key => $value) {
|
233 |
+
switch ($key) {
|
234 |
+
case '_qty':
|
235 |
+
case '_variation_id':
|
236 |
+
case '_product_id':
|
237 |
+
case '_line_total':
|
238 |
+
case '_line_subtotal':
|
239 |
+
case '_tax_class':
|
240 |
+
case '_line_tax':
|
241 |
+
case '_line_tax_data':
|
242 |
+
case '_line_subtotal_tax':
|
243 |
+
break;
|
244 |
+
|
245 |
+
default:
|
246 |
+
if (is_object($value))
|
247 |
+
$value = $value->meta_value;
|
248 |
+
if (is_array($value))
|
249 |
+
$value = implode(',', $value);
|
250 |
+
$line_item[$key] = $value;
|
251 |
+
break;
|
252 |
+
}
|
253 |
+
}
|
254 |
+
|
255 |
+
$refunded = wc_format_decimal($order->get_total_refunded_for_item($item_id), 2);
|
256 |
+
if ($refunded != '0.00') {
|
257 |
+
$line_item['refunded'] = $refunded;
|
258 |
+
}
|
259 |
+
|
260 |
+
if ($prod_type === 'variable' || $prod_type === 'variation' || $prod_type === 'subscription_variation') {
|
261 |
+
$line_item['_variation_id'] = (WC()->version > '2.7') ? $product->get_id() : $product->variation_id;
|
262 |
+
}
|
263 |
+
$line_items[] = $line_item;
|
264 |
+
}
|
265 |
+
|
266 |
+
/*
|
267 |
+
foreach ($order->get_shipping_methods() as $_ => $shipping_item) {
|
268 |
+
|
269 |
+
$shipping_items[] = implode('|', array(
|
270 |
+
'method:' . $shipping_item['name'],
|
271 |
+
'total:' . wc_format_decimal($shipping_item['cost'], 2),
|
272 |
+
));
|
273 |
+
}
|
274 |
+
*
|
275 |
+
*/
|
276 |
+
//shipping items is just product x qty under shipping method
|
277 |
+
$line_items_shipping = $order->get_items('shipping');
|
278 |
+
foreach ($line_items_shipping as $item_id => $item) {
|
279 |
+
$item_meta = self::get_order_line_item_meta($item_id);
|
280 |
+
foreach ($item_meta as $key => $value) {
|
281 |
+
switch ($key) {
|
282 |
+
case 'Items':
|
283 |
+
case 'method_id':
|
284 |
+
if (is_object($value))
|
285 |
+
$value = $value->meta_value;
|
286 |
+
if (is_array($value))
|
287 |
+
$value = implode(',', $value);
|
288 |
+
|
289 |
+
$meta[$key] = $value;
|
290 |
+
break;
|
291 |
+
case 'taxes':
|
292 |
+
if (is_object($value))
|
293 |
+
$value = $value->meta_value;
|
294 |
+
if (is_array($value))
|
295 |
+
$value = implode(',', $value);
|
296 |
+
|
297 |
+
$value = maybe_unserialize($value);
|
298 |
+
$meta[$key] = json_encode($value);
|
299 |
+
break;
|
300 |
+
}
|
301 |
+
}
|
302 |
+
foreach (array('Items', 'method_id', 'taxes') as $value) {
|
303 |
+
if (!isset($meta[$value])) {
|
304 |
+
$meta[$value] = '';
|
305 |
+
}
|
306 |
+
}
|
307 |
+
$shipping_items[] = trim(implode('|', array('items:' . $meta['Items'], 'method_id:' . $meta['method_id'], 'taxes:' . $meta['taxes'])));
|
308 |
+
}
|
309 |
+
|
310 |
+
//get fee and total
|
311 |
+
$fee_total = 0;
|
312 |
+
$fee_tax_total = 0;
|
313 |
+
foreach ($order->get_fees() as $fee_id => $fee) {
|
314 |
+
$fee_items[] = implode('|', array(
|
315 |
+
'name:' . html_entity_decode($fee['name'], ENT_NOQUOTES, 'UTF-8'),
|
316 |
+
'total:' . wc_format_decimal($fee['line_total'], 2),
|
317 |
+
'tax:' . wc_format_decimal($fee['line_tax'], 2),
|
318 |
+
'tax_data:' . json_encode($fee['line_tax_data'])
|
319 |
+
));
|
320 |
+
$fee_total += $fee['line_total'];
|
321 |
+
$fee_tax_total += $fee['line_tax'];
|
322 |
+
}
|
323 |
+
|
324 |
+
$order_taxes = $order->get_taxes();
|
325 |
+
if (!empty($order_taxes)) {
|
326 |
+
foreach ($order_taxes as $tax_id => $tax_item) {
|
327 |
+
|
328 |
+
if (!empty($tax_item->get_shipping_tax_total())) {
|
329 |
+
$total = $tax_item->get_tax_total() + $tax_item->get_shipping_tax_total();
|
330 |
+
} else {
|
331 |
+
$total = $tax_item->get_tax_total();
|
332 |
+
}
|
333 |
+
$tax_items[] = implode('|', array(
|
334 |
+
'rate_id:' . $tax_item->get_rate_id(),
|
335 |
+
'code:' . $tax_item->get_rate_code(),
|
336 |
+
'total:' . wc_format_decimal($tax_item->get_tax_total(), 2),
|
337 |
+
'label:' . $tax_item->get_label(),
|
338 |
+
'tax_rate_compound:' . $tax_item->get_compound(),
|
339 |
+
));
|
340 |
+
}
|
341 |
+
}
|
342 |
+
|
343 |
+
// add coupons
|
344 |
+
if ( (WC()->version < '4.4.0' ) ) {
|
345 |
+
foreach ( $order->get_items('coupon') as $_ => $coupon_item ) {
|
346 |
+
$discount_amount = !empty( $coupon_item[ 'discount_amount' ] ) ? $coupon_item[ 'discount_amount' ] : 0;
|
347 |
+
$coupon_items[] = implode( '|', array(
|
348 |
+
'code:' . $coupon_item[ 'name' ],
|
349 |
+
'amount:' . wc_format_decimal( $discount_amount, 2 ),
|
350 |
+
) );
|
351 |
+
}
|
352 |
+
} else {
|
353 |
+
foreach ( $order->get_coupon_codes() as $_ => $coupon_code ) {
|
354 |
+
$coupon_obj = new WC_Coupon($coupon_code);
|
355 |
+
$discount_amount = !empty( $coupon_obj->get_amount() ) ? $coupon_obj->get_amount() : 0;
|
356 |
+
$coupon_items[] = implode( '|', array(
|
357 |
+
'code:' . $coupon_code,
|
358 |
+
'amount:' . wc_format_decimal( $discount_amount, 2 ),
|
359 |
+
) );
|
360 |
+
}
|
361 |
+
}
|
362 |
+
|
363 |
+
foreach ($order->get_refunds() as $refunded_items) {
|
364 |
+
|
365 |
+
if ((WC()->version < '2.7.0')) {
|
366 |
+
$refund_items[] = implode('|', array(
|
367 |
+
'amount:' . $refunded_items->get_refund_amount(),
|
368 |
+
'reason:' . $refunded_items->reason,
|
369 |
+
'date:' . date('Y-m-d H:i:s', strtotime($refunded_items->date_created)),
|
370 |
+
));
|
371 |
+
} else {
|
372 |
+
$refund_items[] = implode('|', array(
|
373 |
+
'amount:' . $refunded_items->get_amount(),
|
374 |
+
'reason:' . $refunded_items->get_reason(),
|
375 |
+
'date:' . date('Y-m-d H:i:s', strtotime($refunded_items->get_date_created())),
|
376 |
+
));
|
377 |
+
}
|
378 |
+
}
|
379 |
+
|
380 |
+
|
381 |
+
$order_data = array(
|
382 |
+
'order_id' => $order->get_id(),
|
383 |
+
'order_number' => $order->get_order_number(),
|
384 |
+
'order_date' => date('Y-m-d H:i:s', strtotime(get_post($order->get_id())->post_date)),
|
385 |
+
'paid_date' => $order->get_date_paid(),
|
386 |
+
'status' => $order->get_status(),
|
387 |
+
'shipping_total' => $order->get_total_shipping(),
|
388 |
+
'shipping_tax_total' => wc_format_decimal($order->get_shipping_tax(), 2),
|
389 |
+
'fee_total' => wc_format_decimal($fee_total, 2),
|
390 |
+
'fee_tax_total' => wc_format_decimal($fee_tax_total, 2),
|
391 |
+
'tax_total' => wc_format_decimal($order->get_total_tax(), 2),
|
392 |
+
'cart_discount' => (defined('WC_VERSION') && (WC_VERSION >= 2.3)) ? wc_format_decimal($order->get_total_discount(), 2) : wc_format_decimal($order->get_cart_discount(), 2),
|
393 |
+
'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),
|
394 |
+
'discount_total' => wc_format_decimal($order->get_total_discount(), 2),
|
395 |
+
'order_total' => wc_format_decimal($order->get_total(), 2),
|
396 |
+
'order_key' => $order->get_order_key(),
|
397 |
+
'order_currency' => $order->get_currency(),
|
398 |
+
'payment_method' => $order->get_payment_method(),
|
399 |
+
'payment_method_title' => $order->get_payment_method_title(),
|
400 |
+
'transaction_id' => $order->get_transaction_id(),
|
401 |
+
'customer_ip_address' => $order->get_customer_ip_address(),
|
402 |
+
'customer_user_agent' => $order->get_customer_user_agent(),
|
403 |
+
'shipping_method' => $order->get_shipping_method(),
|
404 |
+
'customer_id' => $order->get_user_id(),
|
405 |
+
'customer_user' => $order->get_user_id(),
|
406 |
+
'customer_email' => ($a = get_userdata($order->get_user_id())) ? $a->user_email : '',
|
407 |
+
'billing_first_name' => $order->get_billing_first_name(),
|
408 |
+
'billing_last_name' => $order->get_billing_last_name(),
|
409 |
+
'billing_company' => $order->get_billing_company(),
|
410 |
+
'billing_email' => $order->get_billing_email(),
|
411 |
+
'billing_phone' => $order->get_billing_phone(),
|
412 |
+
'billing_address_1' => $order->get_billing_address_1(),
|
413 |
+
'billing_address_2' => $order->get_billing_address_2(),
|
414 |
+
'billing_postcode' => $order->get_billing_postcode(),
|
415 |
+
'billing_city' => $order->get_billing_city(),
|
416 |
+
'billing_state' => $order->get_billing_state(),
|
417 |
+
'billing_country' => $order->get_billing_country(),
|
418 |
+
'shipping_first_name' => $order->get_shipping_first_name(),
|
419 |
+
'shipping_last_name' => $order->get_shipping_last_name(),
|
420 |
+
'shipping_company' => $order->get_shipping_company(),
|
421 |
+
'shipping_phone' => (version_compare(WC_VERSION, '5.6', '<')) ? '' : $order->get_shipping_phone(),
|
422 |
+
'shipping_address_1' => $order->get_shipping_address_1(),
|
423 |
+
'shipping_address_2' => $order->get_shipping_address_2(),
|
424 |
+
'shipping_postcode' => $order->get_shipping_postcode(),
|
425 |
+
'shipping_city' => $order->get_shipping_city(),
|
426 |
+
'shipping_state' => $order->get_shipping_state(),
|
427 |
+
'shipping_country' => $order->get_shipping_country(),
|
428 |
+
'customer_note' => $order->get_customer_note(),
|
429 |
+
'wt_import_key' => $order->get_order_number(),
|
430 |
+
'shipping_items' => self::format_data(implode(';', $shipping_items)),
|
431 |
+
'fee_items' => implode('||', $fee_items),
|
432 |
+
'tax_items' => implode(';', $tax_items),
|
433 |
+
'coupon_items' => implode(';', $coupon_items),
|
434 |
+
'refund_items' => implode(';', $refund_items),
|
435 |
+
'order_notes' => implode('||', (defined('WC_VERSION') && (WC_VERSION >= 3.2)) ? self::get_order_notes_new($order) : self::get_order_notes($order)),
|
436 |
+
'download_permissions' => $order->is_download_permitted() ? $order->is_download_permitted() : 0,
|
437 |
+
);
|
438 |
+
|
439 |
+
foreach ($order_data as $key => $value) {
|
440 |
+
if (!$export_columns || in_array($key, $export_columns)) {
|
441 |
+
// need to modify code
|
442 |
+
} else {
|
443 |
+
unset($order_data[$key]);
|
444 |
+
}
|
445 |
+
}
|
446 |
+
|
447 |
+
if (self::$is_wt_invoice_active):
|
448 |
+
$invoice_date = get_post_meta($order_data['order_id'], '_wf_invoice_date', true);
|
449 |
+
$invoice_number = get_post_meta($order_data['order_id'], 'wf_invoice_number', true);
|
450 |
+
$order_data['meta:wf_invoice_number'] = empty($invoice_number) ? '' : $invoice_number;
|
451 |
+
$order_data['meta:_wf_invoice_date'] = empty($invoice_date) ? '' : date_i18n(get_option( 'date_format' ), $invoice_date);
|
452 |
+
endif;
|
453 |
+
if (self::$is_yith_tracking_active):
|
454 |
+
$ywot_tracking_code = get_post_meta($order_data['order_id'], 'ywot_tracking_code', true);
|
455 |
+
$ywot_tracking_postcode = get_post_meta($order_data['order_id'], 'ywot_tracking_postcode', true);
|
456 |
+
$ywot_carrier_id = get_post_meta($order_data['order_id'], 'ywot_carrier_id', true);
|
457 |
+
$ywot_pick_up_date = get_post_meta($order_data['order_id'], 'ywot_pick_up_date', true);
|
458 |
+
$ywot_picked_up = get_post_meta($order_data['order_id'], 'ywot_picked_up', true);
|
459 |
+
$order_data['meta:ywot_tracking_code'] = empty($ywot_tracking_code) ? '' : $ywot_tracking_code;
|
460 |
+
$order_data['meta:ywot_tracking_postcode'] = empty($ywot_tracking_postcode) ? '' : $ywot_tracking_postcode;
|
461 |
+
$order_data['meta:ywot_carrier_id'] = empty($ywot_carrier_id) ? '' : $ywot_carrier_id;
|
462 |
+
$order_data['meta:ywot_pick_up_date'] = empty($ywot_pick_up_date) ? '' : $ywot_pick_up_date;
|
463 |
+
$order_data['meta:ywot_picked_up'] = empty($ywot_picked_up) ? '' : $ywot_picked_up;
|
464 |
+
endif;
|
465 |
+
if (self::$shipment_tracking_active):
|
466 |
+
$advanced_shipment_tracking = get_post_meta($order_data['order_id'], '_wc_shipment_tracking_items', true);
|
467 |
+
$order_data['meta:_wc_shipment_tracking_items'] = empty($advanced_shipment_tracking) ? '' : json_encode($advanced_shipment_tracking);
|
468 |
+
endif;
|
469 |
+
if (self::$wpo_wcpdf):
|
470 |
+
$_wcpdf_invoice_number = get_post_meta($order_data['order_id'], '_wcpdf_invoice_number', true);
|
471 |
+
$_wcpdf_invoice_date = get_post_meta($order_data['order_id'], '_wcpdf_invoice_date', true);
|
472 |
+
$_wcpdf_invoice_number_data = get_post_meta($order_data['order_id'], '_wcpdf_invoice_number_data', true);
|
473 |
+
$_wcpdf_invoice_date_formatted = get_post_meta($order_data['order_id'], '_wcpdf_invoice_date_formatted', true);
|
474 |
+
$_wcpdf_invoice_settings = get_post_meta($order_data['order_id'], '_wcpdf_invoice_settings', true);
|
475 |
+
|
476 |
+
$order_data['meta:_wcpdf_invoice_number'] = empty($_wcpdf_invoice_number) ? '' : $_wcpdf_invoice_number;
|
477 |
+
$order_data['meta:_wcpdf_invoice_date'] = empty($_wcpdf_invoice_date) ? '' : $_wcpdf_invoice_date;
|
478 |
+
$order_data['meta:_wcpdf_invoice_number_data'] = empty($_wcpdf_invoice_number_data) ? '' : json_encode($_wcpdf_invoice_number_data);
|
479 |
+
$order_data['meta:_wcpdf_invoice_date_formatted'] = empty($_wcpdf_invoice_date_formatted) ? '' : $_wcpdf_invoice_date_formatted;
|
480 |
+
$order_data['meta:_wcpdf_invoice_settings'] = empty($_wcpdf_invoice_settings) ? '' : json_encode($_wcpdf_invoice_settings);
|
481 |
+
endif;
|
482 |
+
|
483 |
+
|
484 |
+
$li = 1;
|
485 |
+
foreach ($line_items as $line_item) {
|
486 |
+
foreach ($line_item as $name => $value) {
|
487 |
+
$line_item[$name] = $name . ':' . $value;
|
488 |
+
}
|
489 |
+
$line_item = implode(apply_filters('wt_change_item_separator', '|'), $line_item);
|
490 |
+
$order_data["line_item_{$li}"] = $line_item;
|
491 |
+
$li++;
|
492 |
+
}
|
493 |
+
|
494 |
+
for ($i = 1; $i <= $max_line_items; $i++) {
|
495 |
+
$order_data["line_item_{$i}"] = !empty($order_data["line_item_{$i}"]) ? self::format_data($order_data["line_item_{$i}"]) : '';
|
496 |
+
}
|
497 |
+
$export_to_separate_columns = !empty($_POST['export_to_separate_columns']) ? true : false;
|
498 |
+
if ($export_to_separate_columns) {
|
499 |
+
$line_item_values = self::get_all_metakeys_and_values($order);
|
500 |
+
for ($i = 1; $i <= $max_line_items; $i++) {
|
501 |
+
$line_item_array = explode('|', $order_data["line_item_{$i}"]);
|
502 |
+
foreach (self::$line_item_meta as $meta_val) {
|
503 |
+
$order_data["line_item_{$i}_name"] = !empty($line_item_array[0]) ? substr($line_item_array[0], strpos($line_item_array[0], ':') + 1) : '';
|
504 |
+
$order_data["line_item_{$i}_product_id"] = !empty($line_item_array[1]) ? substr($line_item_array[1], strpos($line_item_array[1], ':') + 1) : '';
|
505 |
+
$order_data["line_item_{$i}_sku"] = !empty($line_item_array[2]) ? substr($line_item_array[2], strpos($line_item_array[2], ':') + 1) : '';
|
506 |
+
$order_data["line_item_{$i}_quantity"] = !empty($line_item_array[3]) ? substr($line_item_array[3], strpos($line_item_array[3], ':') + 1) : '';
|
507 |
+
$order_data["line_item_{$i}_total"] = !empty($line_item_array[4]) ? substr($line_item_array[4], strpos($line_item_array[4], ':') + 1) : '';
|
508 |
+
$order_data["line_item_{$i}_subtotal"] = !empty($line_item_array[5]) ? substr($line_item_array[5], strpos($line_item_array[5], ':') + 1) : '';
|
509 |
+
if (in_array($meta_val, array("_product_id", "_qty", "_variation_id", "_line_total", "_line_subtotal", "_tax_class", "_line_tax", "_line_tax_data", "_line_subtotal_tax"))) {
|
510 |
+
continue;
|
511 |
+
} else {
|
512 |
+
$order_data["line_item_{$i}_$meta_val"] = !empty($line_item_values[$i][$meta_val]) ? $line_item_values[$i][$meta_val] : '';
|
513 |
+
}
|
514 |
+
}
|
515 |
+
}
|
516 |
+
}
|
517 |
+
$order_data_filter_args = array('export_columns' => $export_columns, 'user_columns_name' => $user_columns_name, 'max_line_items' => $max_line_items);
|
518 |
+
return apply_filters('wt_iew_product_bulk_export_order_data', $order_data, $order_data_filter_args);
|
519 |
+
}
|
520 |
+
|
521 |
+
public static function get_order_notes($order) {
|
522 |
+
$callback = array('WC_Comments', 'exclude_order_comments');
|
523 |
+
$args = array(
|
524 |
+
'post_id' => (WC()->version < '2.7.0') ? $order->id : $order->get_id(),
|
525 |
+
'approve' => 'approve',
|
526 |
+
'type' => 'order_note'
|
527 |
+
);
|
528 |
+
remove_filter('comments_clauses', $callback);
|
529 |
+
$notes = get_comments($args);
|
530 |
+
add_filter('comments_clauses', $callback);
|
531 |
+
$notes = array_reverse($notes);
|
532 |
+
$order_notes = array();
|
533 |
+
foreach ($notes as $note) {
|
534 |
+
$date = $note->comment_date;
|
535 |
+
$customer_note = 0;
|
536 |
+
if (get_comment_meta($note->comment_ID, 'is_customer_note', '1')) {
|
537 |
+
$customer_note = 1;
|
538 |
+
}
|
539 |
+
$order_notes[] = implode('|', array(
|
540 |
+
'content:' . str_replace(array("\r", "\n"), ' ', $note->comment_content),
|
541 |
+
'date:' . (!empty($date) ? $date : current_time('mysql')),
|
542 |
+
'customer:' . $customer_note,
|
543 |
+
'added_by:' . $note->added_by
|
544 |
+
));
|
545 |
+
}
|
546 |
+
return $order_notes;
|
547 |
+
}
|
548 |
+
|
549 |
+
public static function get_order_notes_new($order) {
|
550 |
+
$notes = wc_get_order_notes(array('order_id' => $order->get_id(), 'order_by' => 'date_created', 'order' => 'ASC'));
|
551 |
+
$order_notes = array();
|
552 |
+
foreach ($notes as $note) {
|
553 |
+
$order_notes[] = implode('|', array(
|
554 |
+
'content:' . str_replace(array("\r", "\n"), ' ', $note->content),
|
555 |
+
'date:' . $note->date_created->date('Y-m-d H:i:s'),
|
556 |
+
'customer:' . $note->customer_note,
|
557 |
+
'added_by:' . $note->added_by
|
558 |
+
));
|
559 |
+
}
|
560 |
+
return $order_notes;
|
561 |
+
}
|
562 |
+
|
563 |
+
public static function get_all_metakeys($post_type = 'shop_order') {
|
564 |
+
global $wpdb;
|
565 |
+
$meta = $wpdb->get_col($wpdb->prepare(
|
566 |
+
"SELECT DISTINCT pm.meta_key
|
567 |
+
FROM {$wpdb->postmeta} AS pm
|
568 |
+
LEFT JOIN {$wpdb->posts} AS p ON p.ID = pm.post_id
|
569 |
+
WHERE p.post_type = %s
|
570 |
+
AND p.post_status IN ( 'wc-pending', 'wc-processing', 'wc-on-hold', 'wc-completed', 'wc-cancelled', 'wc-refunded', 'wc-failed' ) ORDER BY pm.meta_key", $post_type
|
571 |
+
));
|
572 |
+
//sort($meta);
|
573 |
+
return $meta;
|
574 |
+
}
|
575 |
+
|
576 |
+
public static function get_all_line_item_metakeys() {
|
577 |
+
global $wpdb;
|
578 |
+
$filter_meta = apply_filters('wt_order_export_select_line_item_meta', array());
|
579 |
+
$filter_meta = !empty($filter_meta) ? implode("','", $filter_meta) : '';
|
580 |
+
$query = "SELECT DISTINCT om.meta_key
|
581 |
+
FROM {$wpdb->prefix}woocommerce_order_itemmeta AS om
|
582 |
+
INNER JOIN {$wpdb->prefix}woocommerce_order_items AS oi ON om.order_item_id = oi.order_item_id
|
583 |
+
WHERE oi.order_item_type = 'line_item'";
|
584 |
+
if (!empty($filter_meta)) {
|
585 |
+
$query .= " AND om.meta_key IN ('" . $filter_meta . "')";
|
586 |
+
}
|
587 |
+
$meta_keys = $wpdb->get_col($query);
|
588 |
+
return $meta_keys;
|
589 |
+
}
|
590 |
+
|
591 |
+
public static function get_order_line_item_meta($item_id) {
|
592 |
+
global $wpdb;
|
593 |
+
$filtered_meta = apply_filters('wt_order_export_select_line_item_meta', array());
|
594 |
+
$filtered_meta = !empty($filtered_meta) ? implode("','", $filtered_meta) : '';
|
595 |
+
$query = "SELECT meta_key,meta_value
|
596 |
+
FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE order_item_id = '$item_id'";
|
597 |
+
if (!empty($filtered_meta)) {
|
598 |
+
$query .= " AND meta_key IN ('" . $filtered_meta . "')";
|
599 |
+
}
|
600 |
+
$meta_keys = $wpdb->get_results($query, OBJECT_K);
|
601 |
+
return $meta_keys;
|
602 |
+
}
|
603 |
+
|
604 |
+
|
605 |
+
public static function get_all_metakeys_and_values($order = null) {
|
606 |
+
$line_item_values = array();
|
607 |
+
$in = 1;
|
608 |
+
foreach ($order->get_items() as $item_id => $item) {
|
609 |
+
//$item_meta = function_exists('wc_get_order_item_meta') ? wc_get_order_item_meta($item_id, '', false) : $order->get_item_meta($item_id);
|
610 |
+
$item_meta = self::get_order_line_item_meta($item_id);
|
611 |
+
foreach ($item_meta as $key => $value) {
|
612 |
+
switch ($key) {
|
613 |
+
case '_qty':
|
614 |
+
case '_product_id':
|
615 |
+
case '_line_total':
|
616 |
+
case '_line_subtotal':
|
617 |
+
case '_tax_class':
|
618 |
+
case '_line_tax':
|
619 |
+
case '_line_tax_data':
|
620 |
+
case '_line_subtotal_tax':
|
621 |
+
break;
|
622 |
+
|
623 |
+
default:
|
624 |
+
if (is_object($value))
|
625 |
+
$value = $value->meta_value;
|
626 |
+
if (is_array($value))
|
627 |
+
$value = implode(',', $value);
|
628 |
+
$line_item_value[$key] = $value;
|
629 |
+
break;
|
630 |
+
}
|
631 |
+
}
|
632 |
+
$line_item_values[$in] = !empty($line_item_value) ? $line_item_value : '';
|
633 |
+
$in++;
|
634 |
+
}
|
635 |
+
return $line_item_values;
|
636 |
+
}
|
637 |
+
|
638 |
+
}
|
admin/modules/order/export/export.php
CHANGED
@@ -15,6 +15,7 @@ class Wt_Import_Export_For_Woo_Basic_Order_Export {
|
|
15 |
private $is_wt_invoice_active = false;
|
16 |
private $is_yith_tracking_active = false;
|
17 |
private $shipment_tracking_active = false;
|
|
|
18 |
|
19 |
public function __construct($parent_object) {
|
20 |
|
@@ -30,7 +31,10 @@ class Wt_Import_Export_For_Woo_Basic_Order_Export {
|
|
30 |
endif;
|
31 |
if (class_exists('Zorem_Woocommerce_Advanced_Shipment_Tracking') || class_exists('WC_Shipment_Tracking')):
|
32 |
$this->shipment_tracking_active = true;
|
33 |
-
endif;
|
|
|
|
|
|
|
34 |
if (is_plugin_active('yith-woocommerce-order-tracking-premium/init.php')):
|
35 |
$this->is_yith_tracking_active = true;
|
36 |
endif;
|
@@ -765,6 +769,19 @@ class Wt_Import_Export_For_Woo_Basic_Order_Export {
|
|
765 |
$advanced_shipment_tracking = get_post_meta($order_data['order_id'], '_wc_shipment_tracking_items', true);
|
766 |
$order_data['meta:_wc_shipment_tracking_items'] = empty($advanced_shipment_tracking) ? '' : json_encode($advanced_shipment_tracking);
|
767 |
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
768 |
|
769 |
$order_export_data = array();
|
770 |
foreach ($csv_columns as $key => $value) {
|
15 |
private $is_wt_invoice_active = false;
|
16 |
private $is_yith_tracking_active = false;
|
17 |
private $shipment_tracking_active = false;
|
18 |
+
private $wpo_wcpdf = false;
|
19 |
|
20 |
public function __construct($parent_object) {
|
21 |
|
31 |
endif;
|
32 |
if (class_exists('Zorem_Woocommerce_Advanced_Shipment_Tracking') || class_exists('WC_Shipment_Tracking')):
|
33 |
$this->shipment_tracking_active = true;
|
34 |
+
endif;
|
35 |
+
if (class_exists('WPO_WCPDF')):
|
36 |
+
$this->wpo_wcpdf = true;
|
37 |
+
endif;
|
38 |
if (is_plugin_active('yith-woocommerce-order-tracking-premium/init.php')):
|
39 |
$this->is_yith_tracking_active = true;
|
40 |
endif;
|
769 |
$advanced_shipment_tracking = get_post_meta($order_data['order_id'], '_wc_shipment_tracking_items', true);
|
770 |
$order_data['meta:_wc_shipment_tracking_items'] = empty($advanced_shipment_tracking) ? '' : json_encode($advanced_shipment_tracking);
|
771 |
endif;
|
772 |
+
if ($this->wpo_wcpdf):
|
773 |
+
$_wcpdf_invoice_number = get_post_meta($order_data['order_id'], '_wcpdf_invoice_number', true);
|
774 |
+
$_wcpdf_invoice_date = get_post_meta($order_data['order_id'], '_wcpdf_invoice_date', true);
|
775 |
+
$_wcpdf_invoice_number_data = get_post_meta($order_data['order_id'], '_wcpdf_invoice_number_data', true);
|
776 |
+
$_wcpdf_invoice_date_formatted = get_post_meta($order_data['order_id'], '_wcpdf_invoice_date_formatted', true);
|
777 |
+
$_wcpdf_invoice_settings = get_post_meta($order_data['order_id'], '_wcpdf_invoice_settings', true);
|
778 |
+
|
779 |
+
$order_data['meta:_wcpdf_invoice_number'] = empty($_wcpdf_invoice_number) ? '' : $_wcpdf_invoice_number;
|
780 |
+
$order_data['meta:_wcpdf_invoice_date'] = empty($_wcpdf_invoice_date) ? '' : $_wcpdf_invoice_date;
|
781 |
+
$order_data['meta:_wcpdf_invoice_number_data'] = empty($_wcpdf_invoice_number_data) ? '' : json_encode($_wcpdf_invoice_number_data);
|
782 |
+
$order_data['meta:_wcpdf_invoice_date_formatted'] = empty($_wcpdf_invoice_date_formatted) ? '' : $_wcpdf_invoice_date_formatted;
|
783 |
+
$order_data['meta:_wcpdf_invoice_settings'] = empty($_wcpdf_invoice_settings) ? '' : json_encode($_wcpdf_invoice_settings);
|
784 |
+
endif;
|
785 |
|
786 |
$order_export_data = array();
|
787 |
foreach ($csv_columns as $key => $value) {
|
admin/modules/order/import/import.php
CHANGED
@@ -68,16 +68,16 @@ class Wt_Import_Export_For_Woo_Basic_Order_Import {
|
|
68 |
if($this->is_order_exist){
|
69 |
$msg = 'Order updated successfully.';
|
70 |
}
|
71 |
-
$this->import_results[$row] = array('row'=>$row, 'message'=>$msg, 'status'=>true, 'post_id'=>$result['id']);
|
72 |
Wt_Import_Export_For_Woo_Basic_Logwriter::write_log($this->parent_module->module_base, 'import', "Row :$row - ".$msg);
|
73 |
$success++;
|
74 |
}else{
|
75 |
-
|
76 |
Wt_Import_Export_For_Woo_Basic_Logwriter::write_log($this->parent_module->module_base, 'import', "Row :$row - Processing failed. Reason: ".$result->get_error_message());
|
77 |
$failed++;
|
78 |
}
|
79 |
}else{
|
80 |
-
$this->import_results[$row] = array('row'=>$row, 'message'=>$parsed_data->get_error_message(), 'status'=>false, 'post_id'=>'');
|
81 |
Wt_Import_Export_For_Woo_Basic_Logwriter::write_log($this->parent_module->module_base, 'import', "Row :$row - Parsing failed. Reason: ".$parsed_data->get_error_message());
|
82 |
$failed++;
|
83 |
}
|
@@ -455,7 +455,35 @@ class Wt_Import_Export_For_Woo_Basic_Order_Import {
|
|
455 |
$this->item_data['meta_data'][] = array('key'=>'_wc_shipment_tracking_items', 'value'=> json_decode($value, true) );
|
456 |
}
|
457 |
continue;
|
458 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
459 |
|
460 |
if(strstr($column, 'line_item_')){
|
461 |
$this->item_data['order_items'][] = $this->wt_parse_line_item_field($value,$column);
|
68 |
if($this->is_order_exist){
|
69 |
$msg = 'Order updated successfully.';
|
70 |
}
|
71 |
+
$this->import_results[$row] = array('row'=>$row, 'message'=>$msg, 'status'=>true, 'status_msg' => __( 'Success' ), 'post_id'=>$result['id'], 'post_link' => Wt_Import_Export_For_Woo_Basic_Order::get_item_link_by_id($result['id']));
|
72 |
Wt_Import_Export_For_Woo_Basic_Logwriter::write_log($this->parent_module->module_base, 'import', "Row :$row - ".$msg);
|
73 |
$success++;
|
74 |
}else{
|
75 |
+
$this->import_results[$row] = array('row'=>$row, 'message'=>$result->get_error_message(), 'status'=>false, 'status_msg' => __( 'Failed/Skipped' ), 'post_id'=>'', 'post_link' => array( 'title' => __( 'Untitled' ), 'edit_url' => false ) );
|
76 |
Wt_Import_Export_For_Woo_Basic_Logwriter::write_log($this->parent_module->module_base, 'import', "Row :$row - Processing failed. Reason: ".$result->get_error_message());
|
77 |
$failed++;
|
78 |
}
|
79 |
}else{
|
80 |
+
$this->import_results[$row] = array('row'=>$row, 'message'=>$parsed_data->get_error_message(), 'status'=>false, 'status_msg' => __( 'Failed/Skipped' ), 'post_id'=>'', 'post_link' => array( 'title' => __( 'Untitled' ), 'edit_url' => false ) );
|
81 |
Wt_Import_Export_For_Woo_Basic_Logwriter::write_log($this->parent_module->module_base, 'import', "Row :$row - Parsing failed. Reason: ".$parsed_data->get_error_message());
|
82 |
$failed++;
|
83 |
}
|
455 |
$this->item_data['meta_data'][] = array('key'=>'_wc_shipment_tracking_items', 'value'=> json_decode($value, true) );
|
456 |
}
|
457 |
continue;
|
458 |
+
}
|
459 |
+
|
460 |
+
// WPO WCPDF plugin
|
461 |
+
|
462 |
+
if ('meta:_wcpdf_invoice_number' == $column ) {
|
463 |
+
$this->item_data['meta_data'][] = array('key'=>'_wcpdf_invoice_number', 'value'=> $value);
|
464 |
+
continue;
|
465 |
+
}
|
466 |
+
if ('meta:_wcpdf_invoice_date' == $column ) {
|
467 |
+
$this->item_data['meta_data'][] = array('key'=>'_wcpdf_invoice_date', 'value'=> $value);
|
468 |
+
continue;
|
469 |
+
}
|
470 |
+
if ('meta:_wcpdf_invoice_number_data' == $column ) {
|
471 |
+
if(!empty($value)){
|
472 |
+
$this->item_data['meta_data'][] = array('key'=>'_wcpdf_invoice_number_data', 'value'=> json_decode($value, true) );
|
473 |
+
}
|
474 |
+
continue;
|
475 |
+
}
|
476 |
+
if ('meta:_wcpdf_invoice_date_formatted' == $column ) {
|
477 |
+
$this->item_data['meta_data'][] = array('key'=>'_wcpdf_invoice_date_formatted', 'value'=> $value);
|
478 |
+
continue;
|
479 |
+
}
|
480 |
+
if ('meta:_wcpdf_invoice_settings' == $column ) {
|
481 |
+
if(!empty($value)){
|
482 |
+
$this->item_data['meta_data'][] = array('key'=>'_wcpdf_invoice_settings', 'value'=> json_decode($value, true) );
|
483 |
+
}
|
484 |
+
continue;
|
485 |
+
}
|
486 |
+
|
487 |
|
488 |
if(strstr($column, 'line_item_')){
|
489 |
$this->item_data['order_items'][] = $this->wt_parse_line_item_field($value,$column);
|
admin/modules/order/order.php
CHANGED
@@ -71,8 +71,64 @@ class Wt_Import_Export_For_Woo_Basic_Order {
|
|
71 |
add_filter('wt_iew_importer_do_import_basic', array($this, 'importer_do_import'), 10, 8);
|
72 |
|
73 |
add_filter('wt_iew_importer_steps_basic', array($this, 'importer_steps'), 10, 2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
/**
|
77 |
* Altering advanced step description
|
78 |
*/
|
@@ -628,7 +684,14 @@ class Wt_Import_Export_For_Woo_Basic_Order {
|
|
628 |
}
|
629 |
|
630 |
public function get_item_by_id($id) {
|
631 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
632 |
$post['title'] = $id;
|
633 |
return $post;
|
634 |
}
|
71 |
add_filter('wt_iew_importer_do_import_basic', array($this, 'importer_do_import'), 10, 8);
|
72 |
|
73 |
add_filter('wt_iew_importer_steps_basic', array($this, 'importer_steps'), 10, 2);
|
74 |
+
|
75 |
+
|
76 |
+
add_action('admin_footer-edit.php', array($this, 'wt_add_order_bulk_actions'));
|
77 |
+
add_action('load-edit.php', array($this, 'wt_process_order_bulk_actions'));
|
78 |
+
}
|
79 |
+
|
80 |
+
|
81 |
+
|
82 |
+
|
83 |
+
public function wt_add_order_bulk_actions() {
|
84 |
+
global $post_type, $post_status;
|
85 |
+
|
86 |
+
if ($post_type == 'shop_order' && $post_status != 'trash') {
|
87 |
+
?>
|
88 |
+
<script type="text/javascript">
|
89 |
+
jQuery(document).ready(function ($) {
|
90 |
+
var $downloadOrders = $('<option>').val('wt_ier_download_orders').text('<?php _e('Export to CSV') ?>');
|
91 |
+
$('select[name^="action"]').append($downloadOrders);
|
92 |
+
});
|
93 |
+
</script>
|
94 |
+
<?php
|
95 |
+
}
|
96 |
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Order page bulk export action
|
100 |
+
*
|
101 |
+
*/
|
102 |
+
public function wt_process_order_bulk_actions() {
|
103 |
+
global $typenow;
|
104 |
+
if ($typenow == 'shop_order') {
|
105 |
+
// get the action list
|
106 |
+
$wp_list_table = _get_list_table('WP_Posts_List_Table');
|
107 |
+
$action = $wp_list_table->current_action();
|
108 |
+
if (!in_array($action, array('wt_ier_download_orders'))) {
|
109 |
+
return;
|
110 |
+
}
|
111 |
+
// security check
|
112 |
+
check_admin_referer('bulk-posts');
|
113 |
+
|
114 |
+
if (isset($_REQUEST['post'])) {
|
115 |
+
$order_ids = array_map('absint', $_REQUEST['post']);
|
116 |
+
}
|
117 |
+
if (empty($order_ids)) {
|
118 |
+
return;
|
119 |
+
}
|
120 |
+
// give an unlimited timeout if possible
|
121 |
+
@set_time_limit(0);
|
122 |
|
123 |
+
if ($action == 'wt_ier_download_orders') {
|
124 |
+
|
125 |
+
|
126 |
+
include_once( 'export/class-wt-orderimpexpcsv-basic-exporter.php' );
|
127 |
+
Wt_Import_Export_For_Woo_Basic_Order_Bulk_Export::do_export('shop_order', $order_ids);
|
128 |
+
}
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
132 |
/**
|
133 |
* Altering advanced step description
|
134 |
*/
|
684 |
}
|
685 |
|
686 |
public function get_item_by_id($id) {
|
687 |
+
$post = array();
|
688 |
+
$post['edit_url'] = get_edit_post_link($id);
|
689 |
+
$post['title'] = $id;
|
690 |
+
return $post;
|
691 |
+
}
|
692 |
+
public static function get_item_link_by_id($id) {
|
693 |
+
$post = array();
|
694 |
+
$post['edit_url'] = get_edit_post_link($id);
|
695 |
$post['title'] = $id;
|
696 |
return $post;
|
697 |
}
|
includes/class-wt-import-export-for-woo.php
CHANGED
@@ -80,7 +80,7 @@ class Wt_Import_Export_For_Woo_Basic {
|
|
80 |
if ( defined( 'WT_O_IEW_VERSION' ) ) {
|
81 |
$this->version = WT_O_IEW_VERSION;
|
82 |
} else {
|
83 |
-
$this->version = '2.2.
|
84 |
}
|
85 |
$this->plugin_name = 'wt-import-export-for-woo-basic';
|
86 |
|
80 |
if ( defined( 'WT_O_IEW_VERSION' ) ) {
|
81 |
$this->version = WT_O_IEW_VERSION;
|
82 |
} else {
|
83 |
+
$this->version = '2.2.5';
|
84 |
}
|
85 |
$this->plugin_name = 'wt-import-export-for-woo-basic';
|
86 |
|
order-import-export-for-woocommerce.php
CHANGED
@@ -6,12 +6,12 @@ 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: 2.2.
|
10 |
Text Domain: order-import-export-for-woocommerce
|
11 |
Domain Path: /languages
|
12 |
Requires at least: 3.0
|
13 |
Requires PHP: 5.6
|
14 |
-
WC tested up to: 6.
|
15 |
License: GPLv3
|
16 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
17 |
*/
|
@@ -48,7 +48,7 @@ if ( !defined( 'WT_IEW_DEBUG_BASIC_TROUBLESHOOT' ) ) {
|
|
48 |
* Start at version 1.0.0 and use SemVer - https://semver.org
|
49 |
* Rename this for your plugin and update it as you release new versions.
|
50 |
*/
|
51 |
-
define( 'WT_O_IEW_VERSION', '2.2.
|
52 |
|
53 |
/**
|
54 |
* The code that runs during plugin activation.
|
@@ -281,3 +281,22 @@ function wt_order_addon_basic_gopro_content() {
|
|
281 |
<?php
|
282 |
}
|
283 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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: 2.2.5
|
10 |
Text Domain: order-import-export-for-woocommerce
|
11 |
Domain Path: /languages
|
12 |
Requires at least: 3.0
|
13 |
Requires PHP: 5.6
|
14 |
+
WC tested up to: 6.6
|
15 |
License: GPLv3
|
16 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
17 |
*/
|
48 |
* Start at version 1.0.0 and use SemVer - https://semver.org
|
49 |
* Rename this for your plugin and update it as you release new versions.
|
50 |
*/
|
51 |
+
define( 'WT_O_IEW_VERSION', '2.2.5' );
|
52 |
|
53 |
/**
|
54 |
* The code that runs during plugin activation.
|
281 |
<?php
|
282 |
}
|
283 |
}
|
284 |
+
|
285 |
+
/**
|
286 |
+
* Add Export to CSV link in order listing page near the filter button.
|
287 |
+
*
|
288 |
+
* @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
|
289 |
+
*/
|
290 |
+
function export_csv_linkin_order_listing_page($which) {
|
291 |
+
|
292 |
+
$currentScreen = get_current_screen();
|
293 |
+
|
294 |
+
if ('edit-shop_order' === $currentScreen->id || 'edit-shop_coupon' === $currentScreen->id) {
|
295 |
+
$post_type = ( 'edit-shop_order' === $currentScreen->id ) ? 'order' : 'coupon';
|
296 |
+
$style = ( 'order' === $post_type ) ? 'style="height:32px;"' : '';
|
297 |
+
echo '<a target="_blank" href="' . admin_url('admin.php?page=wt_import_export_for_woo_basic_export&wt_to_export='.$post_type.'') . '" class="button"'.$style.' >' . __('Export to CSV') . ' </a>';
|
298 |
+
}
|
299 |
+
}
|
300 |
+
|
301 |
+
add_filter('manage_posts_extra_tablenav', 'export_csv_linkin_order_listing_page');
|
302 |
+
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: order export, woocommerce, order, export, csv, order import, woocommerce e
|
|
5 |
Requires at least: 3.0.1
|
6 |
Tested up to: 6.0
|
7 |
Requires PHP: 5.6
|
8 |
-
Stable tag: 2.2.
|
9 |
License: GPLv3
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
11 |
|
@@ -28,7 +28,7 @@ The following are functionalities offered by the basic version of the plugin.
|
|
28 |
🔸 Bulk update WooCommerce orders and coupons.
|
29 |
🔸 Compatible with YITH WooCommerce Order Tracking plugin.
|
30 |
🔸 Supports various export filters (order status, product, coupon, customer, date range)
|
31 |
-
🔸 Tested OK with WooCommerce 6.
|
32 |
🔸 Tested OK with WordPress 6.0
|
33 |
🔸 Tested OK with PHP 8.0
|
34 |
|
@@ -53,6 +53,7 @@ More information about the setup of the plugin and a sample CSV that is taken as
|
|
53 |
* [WooCommerce PDF Invoices, Packing Slips, Delivery Notes & Shipping Labels by WebToffee](https://wordpress.org/plugins/print-invoices-packing-slip-labels-for-woocommerce/)
|
54 |
* [Advanced Shipment Tracking for WooCommerce](https://wordpress.org/plugins/woo-advanced-shipment-tracking/)
|
55 |
* [WooCommerce Shipment Tracking](https://woocommerce.com/products/shipment-tracking/)
|
|
|
56 |
|
57 |
<blockquote>
|
58 |
|
@@ -228,6 +229,10 @@ Yes.
|
|
228 |
|
229 |
== Changelog ==
|
230 |
|
|
|
|
|
|
|
|
|
231 |
= 2.2.4 2022-05-26 =
|
232 |
* WordPress 6.0 Tested OK.
|
233 |
* WooCommerce 6.5 Tested OK.
|
@@ -506,7 +511,7 @@ Yes.
|
|
506 |
|
507 |
== Upgrade Notice ==
|
508 |
|
509 |
-
= 2.2.
|
510 |
-
*
|
511 |
-
*
|
512 |
-
* Enhancement:
|
5 |
Requires at least: 3.0.1
|
6 |
Tested up to: 6.0
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 2.2.5
|
9 |
License: GPLv3
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
11 |
|
28 |
🔸 Bulk update WooCommerce orders and coupons.
|
29 |
🔸 Compatible with YITH WooCommerce Order Tracking plugin.
|
30 |
🔸 Supports various export filters (order status, product, coupon, customer, date range)
|
31 |
+
🔸 Tested OK with WooCommerce 6.6
|
32 |
🔸 Tested OK with WordPress 6.0
|
33 |
🔸 Tested OK with PHP 8.0
|
34 |
|
53 |
* [WooCommerce PDF Invoices, Packing Slips, Delivery Notes & Shipping Labels by WebToffee](https://wordpress.org/plugins/print-invoices-packing-slip-labels-for-woocommerce/)
|
54 |
* [Advanced Shipment Tracking for WooCommerce](https://wordpress.org/plugins/woo-advanced-shipment-tracking/)
|
55 |
* [WooCommerce Shipment Tracking](https://woocommerce.com/products/shipment-tracking/)
|
56 |
+
* [WooCommerce PDF Invoices & Packing Slips](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/)
|
57 |
|
58 |
<blockquote>
|
59 |
|
229 |
|
230 |
== Changelog ==
|
231 |
|
232 |
+
= 2.2.5 2022-07-04 =
|
233 |
+
* WooCommerce 6.6 Tested OK.
|
234 |
+
* Enhancement: Export to CSV option to Bulk Action drop-down menu in WC Orders listing page.
|
235 |
+
* Enhancement: Import progress screen improvements.
|
236 |
= 2.2.4 2022-05-26 =
|
237 |
* WordPress 6.0 Tested OK.
|
238 |
* WooCommerce 6.5 Tested OK.
|
511 |
|
512 |
== Upgrade Notice ==
|
513 |
|
514 |
+
= 2.2.5 =
|
515 |
+
* WooCommerce 6.6 Tested OK.
|
516 |
+
* Enhancement: Export to CSV option to Bulk Action drop-down menu in WC Orders listing page.
|
517 |
+
* Enhancement: Import progress screen improvements.
|