Version Description
- Tested OK with WC 3.4.3
- Image import process improved.
Download this release
Release Info
Developer | mujeebur |
Plugin | Product Import Export for WooCommerce |
Version | 1.4.5 |
Comparing to | |
See all releases |
Code changes from version 1.4.4 to 1.4.5
- Product_Commercial_Sample_CSV.csv +9 -9
- Product_WooCommerce_Sample_CSV.csv +9 -9
- images/wf-ajax-loader.gif +0 -0
- images/wf-failed.png +0 -0
- images/wf-import.png +0 -0
- images/wf-notice.png +0 -0
- images/wf-success.png +0 -0
- includes/class-wf-prodimpexpcsv-admin-screen.php +130 -130
- includes/class-wf-prodimpexpcsv-ajax-handler.php +68 -68
- includes/class-wf-prodimpexpcsv-system-status-tools.php +102 -102
- includes/exporter/class-wf-prodimpexpcsv-exporter.php +527 -527
- includes/exporter/data/data-wf-hidden-meta-columns.php +19 -19
- includes/exporter/data/data-wf-post-columns.php +50 -50
- includes/importer/class-wf-csv-parser.php +853 -853
- includes/importer/class-wf-prodimpexpcsv-importer.php +40 -40
- includes/importer/class-wf-prodimpexpcsv-product-import.php +1564 -1488
- includes/importer/data/data-wf-post-defaults.php +21 -21
- includes/importer/data/data-wf-postmeta-allowed.php +15 -15
- includes/importer/data/data-wf-postmeta-defaults.php +43 -43
- includes/importer/data/data-wf-reserved-fields-pair.php +51 -51
- includes/importer/data/data-wf-reserved-fields.php +59 -59
- includes/importer/views/html-wf-import-greeting.php +83 -83
- includes/importer/views/html-wf-import-options.php +130 -130
- includes/settings/class-wf-prodimpexpcsv-settings.php +20 -20
- includes/views/export/html-wf-export-products.php +100 -100
- includes/views/html-wf-admin-screen.php +26 -26
- includes/views/import/html-wf-import-products.php +22 -22
- includes/views/market.php +41 -41
- license.txt +704 -704
- product-csv-import-export.php +416 -416
- readme.txt +240 -237
- styles/wf-style.css +231 -231
Product_Commercial_Sample_CSV.csv
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
-
Parent SKU,SKU,Product Name,Short Description,Description,Regular Price,Sale Price,Weight,Images,Product Type,Prodcut Categories,Product Tags,meta:attribute_pa_color,attribute:pa_care-instructions,attribute_data:pa_care-instructions,attribute:pa_color,attribute_data:pa_color,attribute_default:pa_color,attribute:pa_fabric,attribute_data:pa_fabric,attribute:pa_fitting-type,attribute_data:pa_fitting-type
|
2 |
,A11,Samsung Galaxy Ace Duos,"-5 MP Primary Camera
|
3 |
-3.5 inch Capacitive Touchscreen
|
4 |
-Wi-Fi Enabled
|
5 |
-
","Having a much vaunted reputation of being one of the world’s leading budget smartphone makers, the Samsung Galaxy Ace Duos S6802 does quite well to maintain Samsung’s authority in the current market. The device comes in a bar shape and has a sleek look to it. The Ace Duos S6802 is a Smart Dual Active SIM, (GSM + GSM) device with both the inserted SIM cards being active at the same time. If you are on a call on sim 1 and you get a call on sim 2, the call would be diverted to sim 1 and the display would show it as call waiting.The same will be apply for both the Sims. So that we cannot miss out any calls on sim 1 and sim 2. This Samsung phone is run on the Android v2.3 (Gingerbread) OS with a snappy processor speed of 832 MHz. To assure the smooth running of apps, the device comes with an adequate 512 MB of RAM.",29.99,11.52,0.5,http://productimportexport.
|
6 |
-
,A12,Formal shoe,Formal shoe leather made,"Formal shoe leather made , black color",10,8,0.5
|
7 |
-
,A13,LED TV,LED TV 20 inches,LED TV 20 inches by samsung,30,29,1,http://productimportexport.
|
8 |
-
,A14,Refrigerator,Double door Refrigerator,Double door Refrigerator with auto power saving,35,32,2,http://productimportexport.
|
9 |
-
,A15,Washing machine,Washing machine with remote control,Washing machine with remote controle and much more options,20,18,2,http://productimportexport.
|
10 |
-
,B11,Men's Cotton T-Shirt,The images represent actual product though color of the image and product may slightly differ.,Strut on the streets in comfort adorning this slim-fit T-Shirt from the house of Tinted. This unique creation is made using rayon that will highlight your torso. Work hard and play hard as you party through the night in this utterly comfortable T-Shirt.,10,,1,http://productimportexport.
|
11 |
-
B11,B11V2,,,,24,12,,http://productimportexport.
|
12 |
-
B11,B11V1,,,,22,11,,http://productimportexport.
|
1 |
+
Parent SKU,SKU,Product Name,Short Description,Description,Regular Price,Sale Price,Weight,Images,Product Type,Prodcut Categories,Product Tags,meta:attribute_pa_color,attribute:pa_care-instructions,attribute_data:pa_care-instructions,attribute:pa_color,attribute_data:pa_color,attribute_default:pa_color,attribute:pa_fabric,attribute_data:pa_fabric,attribute:pa_fitting-type,attribute_data:pa_fitting-type
|
2 |
,A11,Samsung Galaxy Ace Duos,"-5 MP Primary Camera
|
3 |
-3.5 inch Capacitive Touchscreen
|
4 |
-Wi-Fi Enabled
|
5 |
+
","Having a much vaunted reputation of being one of the world’s leading budget smartphone makers, the Samsung Galaxy Ace Duos S6802 does quite well to maintain Samsung’s authority in the current market. The device comes in a bar shape and has a sleek look to it. The Ace Duos S6802 is a Smart Dual Active SIM, (GSM + GSM) device with both the inserted SIM cards being active at the same time. If you are on a call on sim 1 and you get a call on sim 2, the call would be diverted to sim 1 and the display would show it as call waiting.The same will be apply for both the Sims. So that we cannot miss out any calls on sim 1 and sim 2. This Samsung phone is run on the Android v2.3 (Gingerbread) OS with a snappy processor speed of 832 MHz. To assure the smooth running of apps, the device comes with an adequate 512 MB of RAM.",29.99,11.52,0.5,http://productimportexport.webtoffee.com/public_html/wp-includes/images/products/hikeforce-mobile.jpg|http://productimportexport.webtoffee.com/public_html/wp-includes/images/products/hikeforce-mobile-2.jpg,simple,Mobile Phone,Smart Phone,,,,,,,,,,
|
6 |
+
,A12,Formal shoe,Formal shoe leather made,"Formal shoe leather made , black color",10,8,0.5,,simple,Shoes,Foot Wears,,,,,,,,,,
|
7 |
+
,A13,LED TV,LED TV 20 inches,LED TV 20 inches by samsung,30,29,1,http://productimportexport.webtoffee.com/public_html/wp-includes/images/products/hikeforce-model-tv.jpg,simple,Tele Vision,Electronics,,,,,,,,,,
|
8 |
+
,A14,Refrigerator,Double door Refrigerator,Double door Refrigerator with auto power saving,35,32,2,http://productimportexport.webtoffee.com/public_html/wp-includes/images/products/hikeforce-model-fridge.jpg,simple,Refrigerator,Electronics,,,,,,,,,,
|
9 |
+
,A15,Washing machine,Washing machine with remote control,Washing machine with remote controle and much more options,20,18,2,http://productimportexport.webtoffee.com/public_html/wp-includes/images/products/hikeforce-model-wm.jpg,simple,washing Machine,Electronics,,,,,,,,,,
|
10 |
+
,B11,Men's Cotton T-Shirt,The images represent actual product though color of the image and product may slightly differ.,Strut on the streets in comfort adorning this slim-fit T-Shirt from the house of Tinted. This unique creation is made using rayon that will highlight your torso. Work hard and play hard as you party through the night in this utterly comfortable T-Shirt.,10,,1,http://productimportexport.webtoffee.com/public_html/wp-includes/images/products/hikeforce-men-t-shirt-red.png,variable,Clothing & Accessories > Men > Tops & Tees > T-Shirts,T-Shirts,,Wash dark colors seperately,2|1|0,Blue|Red,3|0|1,red,Cotton,0|1|0,Regular Fit,1|1|0
|
11 |
+
B11,B11V2,,,,24,12,,http://productimportexport.webtoffee.com/public_html/wp-includes/images/products/hikeforce-men-t-shirt-red.png,,,,red,,,,,,,,,
|
12 |
+
B11,B11V1,,,,22,11,,http://productimportexport.webtoffee.com/public_html/wp-includes/images/products/hikeforce-men-t-shirt-blue.png,,,,blue,,,,,,,,,
|
Product_WooCommerce_Sample_CSV.csv
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
-
parent_sku,sku,post_title,post_excerpt,post_content,regular_price,sale_price,weight,Images,tax:product_type,tax:product_cat,tax:product_tag,meta:attribute_pa_color,attribute:pa_care-instructions,attribute_data:pa_care-instructions,attribute:pa_color,attribute_data:pa_color,attribute_default:pa_color,attribute:pa_fabric,attribute_data:pa_fabric,attribute:pa_fitting-type,attribute_data:pa_fitting-type
|
2 |
,A11,Samsung Galaxy Ace Duos,"-5 MP Primary Camera
|
3 |
-3.5 inch Capacitive Touchscreen
|
4 |
-Wi-Fi Enabled
|
5 |
-
","Having a much vaunted reputation of being one of the world’s leading budget smartphone makers, the Samsung Galaxy Ace Duos S6802 does quite well to maintain Samsung’s authority in the current market. The device comes in a bar shape and has a sleek look to it. The Ace Duos S6802 is a Smart Dual Active SIM, (GSM + GSM) device with both the inserted SIM cards being active at the same time. If you are on a call on sim 1 and you get a call on sim 2, the call would be diverted to sim 1 and the display would show it as call waiting.The same will be apply for both the Sims. So that we cannot miss out any calls on sim 1 and sim 2. This Samsung phone is run on the Android v2.3 (Gingerbread) OS with a snappy processor speed of 832 MHz. To assure the smooth running of apps, the device comes with an adequate 512 MB of RAM.",29.99,11.52,0.5,http://productimportexport.
|
6 |
-
,A12,Formal shoe,Formal shoe leather made,"Formal shoe leather made , black color",10,8,0.5
|
7 |
-
,A13,LED TV,LED TV 20 inches,LED TV 20 inches by samsung,30,29,1,http://productimportexport.
|
8 |
-
,A14,Refrigerator,Double door Refrigerator,Double door Refrigerator with auto power saving,35,32,2,http://productimportexport.
|
9 |
-
,A15,Washing machine,Washing machine with remote control,Washing machine with remote controle and much more options,20,18,2,http://productimportexport.
|
10 |
-
,B11,Men's Cotton T-Shirt,The images represent actual product though color of the image and product may slightly differ.,Strut on the streets in comfort adorning this slim-fit T-Shirt from the house of Tinted. This unique creation is made using rayon that will highlight your torso. Work hard and play hard as you party through the night in this utterly comfortable T-Shirt.,10,,1,http://productimportexport.
|
11 |
-
B11,B11V2,,,,24,12,,http://productimportexport.
|
12 |
-
B11,B11V1,,,,22,11,,http://productimportexport.
|
1 |
+
parent_sku,sku,post_title,post_excerpt,post_content,regular_price,sale_price,weight,Images,tax:product_type,tax:product_cat,tax:product_tag,meta:attribute_pa_color,attribute:pa_care-instructions,attribute_data:pa_care-instructions,attribute:pa_color,attribute_data:pa_color,attribute_default:pa_color,attribute:pa_fabric,attribute_data:pa_fabric,attribute:pa_fitting-type,attribute_data:pa_fitting-type
|
2 |
,A11,Samsung Galaxy Ace Duos,"-5 MP Primary Camera
|
3 |
-3.5 inch Capacitive Touchscreen
|
4 |
-Wi-Fi Enabled
|
5 |
+
","Having a much vaunted reputation of being one of the world’s leading budget smartphone makers, the Samsung Galaxy Ace Duos S6802 does quite well to maintain Samsung’s authority in the current market. The device comes in a bar shape and has a sleek look to it. The Ace Duos S6802 is a Smart Dual Active SIM, (GSM + GSM) device with both the inserted SIM cards being active at the same time. If you are on a call on sim 1 and you get a call on sim 2, the call would be diverted to sim 1 and the display would show it as call waiting.The same will be apply for both the Sims. So that we cannot miss out any calls on sim 1 and sim 2. This Samsung phone is run on the Android v2.3 (Gingerbread) OS with a snappy processor speed of 832 MHz. To assure the smooth running of apps, the device comes with an adequate 512 MB of RAM.",29.99,11.52,0.5,http://productimportexport.webtoffee.com/public_html/wp-includes/images/products/hikeforce-mobile.jpg|http://productimportexport.webtoffee.com/public_html/wp-includes/images/products/hikeforce-mobile-2.jpg,simple,Mobile Phone,Smart Phone,,,,,,,,,,
|
6 |
+
,A12,Formal shoe,Formal shoe leather made,"Formal shoe leather made , black color",10,8,0.5,,simple,Shoes,Foot Wears,,,,,,,,,,
|
7 |
+
,A13,LED TV,LED TV 20 inches,LED TV 20 inches by samsung,30,29,1,http://productimportexport.webtoffee.com/public_html/wp-includes/images/products/hikeforce-model-tv.jpg,simple,Tele Vision,Electronics,,,,,,,,,,
|
8 |
+
,A14,Refrigerator,Double door Refrigerator,Double door Refrigerator with auto power saving,35,32,2,http://productimportexport.webtoffee.com/public_html/wp-includes/images/products/hikeforce-model-fridge.jpg,simple,Refrigerator,Electronics,,,,,,,,,,
|
9 |
+
,A15,Washing machine,Washing machine with remote control,Washing machine with remote controle and much more options,20,18,2,http://productimportexport.webtoffee.com/public_html/wp-includes/images/products/hikeforce-model-wm.jpg,simple,washing Machine,Electronics,,,,,,,,,,
|
10 |
+
,B11,Men's Cotton T-Shirt,The images represent actual product though color of the image and product may slightly differ.,Strut on the streets in comfort adorning this slim-fit T-Shirt from the house of Tinted. This unique creation is made using rayon that will highlight your torso. Work hard and play hard as you party through the night in this utterly comfortable T-Shirt.,10,,1,http://productimportexport.webtoffee.com/public_html/wp-includes/images/products/hikeforce-men-t-shirt-red.png,variable,Clothing & Accessories > Men > Tops & Tees > T-Shirts,T-Shirts,,Wash dark colors seperately,2|1|0,Blue|Red,3|0|1,red,Cotton,0|1|0,Regular Fit,1|1|0
|
11 |
+
B11,B11V2,,,,24,12,,http://productimportexport.webtoffee.com/public_html/wp-includes/images/products/hikeforce-men-t-shirt-red.png,,,,red,,,,,,,,,
|
12 |
+
B11,B11V1,,,,22,11,,http://productimportexport.webtoffee.com/public_html/wp-includes/images/products/hikeforce-men-t-shirt-blue.png,,,,blue,,,,,,,,,
|
images/wf-ajax-loader.gif
CHANGED
File without changes
|
images/wf-failed.png
CHANGED
File without changes
|
images/wf-import.png
CHANGED
File without changes
|
images/wf-notice.png
CHANGED
File without changes
|
images/wf-success.png
CHANGED
File without changes
|
includes/class-wf-prodimpexpcsv-admin-screen.php
CHANGED
@@ -1,131 +1,131 @@
|
|
1 |
-
<?php
|
2 |
-
if (!defined('ABSPATH')) {
|
3 |
-
exit;
|
4 |
-
}
|
5 |
-
|
6 |
-
class WF_ProdImpExpCsv_Admin_Screen {
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Constructor
|
10 |
-
*/
|
11 |
-
public function __construct() {
|
12 |
-
|
13 |
-
add_action('admin_menu', array($this, 'admin_menu'));
|
14 |
-
add_action('admin_print_styles', array($this, 'admin_scripts'));
|
15 |
-
add_action('admin_notices', array($this, 'admin_notices'));
|
16 |
-
|
17 |
-
add_action('in_admin_header', array($this, 'render_review_text'), 1);
|
18 |
-
add_action('wp_ajax_review_rated', array($this, 'review_rated'));
|
19 |
-
}
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Notices in admin
|
23 |
-
*/
|
24 |
-
public function admin_notices() {
|
25 |
-
if (!function_exists('mb_detect_encoding')) {
|
26 |
-
echo '<div class="error"><p>' . __('Product CSV Import Export requires the function <code>mb_detect_encoding</code> to import and export CSV files. Please ask your hosting provider to enable this function.', 'wf_csv_import_export') . '</p></div>';
|
27 |
-
}
|
28 |
-
}
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Admin Menu
|
32 |
-
*/
|
33 |
-
public function admin_menu() {
|
34 |
-
$page1 = add_submenu_page('edit.php?post_type=product', __('Product Im-Ex', 'wf_csv_import_export'), __('Product Im-Ex', 'wf_csv_import_export'), apply_filters('woocommerce_csv_product_role', 'manage_woocommerce'), 'wf_woocommerce_csv_im_ex', array($this, 'output'));
|
35 |
-
$page = add_submenu_page('woocommerce', __('Product Import-Export', 'wf_csv_import_export'), __('Product Import-Export', 'wf_csv_import_export'), apply_filters('woocommerce_csv_product_role', 'manage_woocommerce'), 'wf_woocommerce_csv_im_ex', array($this, 'output'));
|
36 |
-
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Admin Scripts
|
41 |
-
*/
|
42 |
-
public function admin_scripts() {
|
43 |
-
wp_enqueue_style('woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css');
|
44 |
-
wp_enqueue_style('woocommerce-product-csv-importer', plugins_url(basename(plugin_dir_path(WF_ProdImpExpCsv_FILE)) . '/styles/wf-style.css', basename(__FILE__)), '', '1.4.4', 'screen');
|
45 |
-
}
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Admin Screen output
|
49 |
-
*/
|
50 |
-
public function output() {
|
51 |
-
|
52 |
-
$tab = '';
|
53 |
-
if (!empty($_GET['tab'])) {
|
54 |
-
if ($_GET['tab'] == 'help') {
|
55 |
-
$tab = 'help';
|
56 |
-
}
|
57 |
-
}
|
58 |
-
|
59 |
-
include( 'views/html-wf-admin-screen.php' );
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Admin Page for exporting
|
64 |
-
*/
|
65 |
-
public function admin_export_page() {
|
66 |
-
$post_columns = include( 'exporter/data/data-wf-post-columns.php' );
|
67 |
-
include( 'views/export/html-wf-export-products.php' );
|
68 |
-
}
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Admin Page for help
|
72 |
-
*/
|
73 |
-
public function admin_help_page() {
|
74 |
-
include('views/html-wf-help-guide.php');
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Change the admin header text on WooCommerce admin pages.
|
79 |
-
*
|
80 |
-
* @since 1.4.3
|
81 |
-
* @param string $header_text
|
82 |
-
* @return string
|
83 |
-
*/
|
84 |
-
public function render_review_text($header_text) {
|
85 |
-
|
86 |
-
if (strtotime(get_option('xa_pipe_plugin_installed_date')) < strtotime('-7 days')) {
|
87 |
-
|
88 |
-
if (!current_user_can('manage_woocommerce') || !function_exists('wc_get_screen_ids')) {
|
89 |
-
return $header_text;
|
90 |
-
}
|
91 |
-
|
92 |
-
$current_screen = get_current_screen();
|
93 |
-
|
94 |
-
$xa_pages = array('product_page_wf_woocommerce_csv_im_ex');
|
95 |
-
|
96 |
-
if (isset($current_screen->id) && apply_filters('xa_display_admin_footer_text', in_array($current_screen->id, $xa_pages))) {
|
97 |
-
|
98 |
-
if (!get_option('xa_pipe_plugin_review_rated')) {
|
99 |
-
$header_text = sprintf(
|
100 |
-
__('<div class="updated"><p>You have been using %1$s for a while. If you like the plugin please leave us a %2$s review!<p></div>', 'wf_csv_import_export'), sprintf('<strong>%s</strong>', esc_html__('Product Import Export for WooCommerce', 'wf_csv_import_export')), '<a href="https://wordpress.org/support/plugin/product-import-export-for-woo/reviews?rate=5#new-post" target="_blank" class="xa-pipe-rating-link" data-reviewed="' . esc_attr__('Thanks for the review.', 'wf_csv_import_export') . '">★★★★★</a>'
|
101 |
-
);
|
102 |
-
wc_enqueue_js("
|
103 |
-
jQuery( 'a.xa-pipe-rating-link' ).click( function() {
|
104 |
-
jQuery.post( '" . admin_url("admin-ajax.php") . "', { action: 'review_rated' } );
|
105 |
-
jQuery( this ).parent().text( jQuery( this ).data( 'reviewed' ) );
|
106 |
-
});
|
107 |
-
");
|
108 |
-
} else {
|
109 |
-
$header_text = '';
|
110 |
-
}
|
111 |
-
}
|
112 |
-
|
113 |
-
echo $header_text;
|
114 |
-
}
|
115 |
-
}
|
116 |
-
|
117 |
-
/**
|
118 |
-
* Fired when clicking the rating header.
|
119 |
-
*/
|
120 |
-
public function review_rated() {
|
121 |
-
|
122 |
-
if (!current_user_can('manage_woocommerce')) {
|
123 |
-
wp_die(-1);
|
124 |
-
}
|
125 |
-
update_option('xa_pipe_plugin_review_rated', 1);
|
126 |
-
wp_die();
|
127 |
-
}
|
128 |
-
|
129 |
-
}
|
130 |
-
|
131 |
new WF_ProdImpExpCsv_Admin_Screen();
|
1 |
+
<?php
|
2 |
+
if (!defined('ABSPATH')) {
|
3 |
+
exit;
|
4 |
+
}
|
5 |
+
|
6 |
+
class WF_ProdImpExpCsv_Admin_Screen {
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Constructor
|
10 |
+
*/
|
11 |
+
public function __construct() {
|
12 |
+
|
13 |
+
add_action('admin_menu', array($this, 'admin_menu'));
|
14 |
+
add_action('admin_print_styles', array($this, 'admin_scripts'));
|
15 |
+
add_action('admin_notices', array($this, 'admin_notices'));
|
16 |
+
|
17 |
+
add_action('in_admin_header', array($this, 'render_review_text'), 1);
|
18 |
+
add_action('wp_ajax_review_rated', array($this, 'review_rated'));
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Notices in admin
|
23 |
+
*/
|
24 |
+
public function admin_notices() {
|
25 |
+
if (!function_exists('mb_detect_encoding')) {
|
26 |
+
echo '<div class="error"><p>' . __('Product CSV Import Export requires the function <code>mb_detect_encoding</code> to import and export CSV files. Please ask your hosting provider to enable this function.', 'wf_csv_import_export') . '</p></div>';
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Admin Menu
|
32 |
+
*/
|
33 |
+
public function admin_menu() {
|
34 |
+
$page1 = add_submenu_page('edit.php?post_type=product', __('Product Im-Ex', 'wf_csv_import_export'), __('Product Im-Ex', 'wf_csv_import_export'), apply_filters('woocommerce_csv_product_role', 'manage_woocommerce'), 'wf_woocommerce_csv_im_ex', array($this, 'output'));
|
35 |
+
$page = add_submenu_page('woocommerce', __('Product Import-Export', 'wf_csv_import_export'), __('Product Import-Export', 'wf_csv_import_export'), apply_filters('woocommerce_csv_product_role', 'manage_woocommerce'), 'wf_woocommerce_csv_im_ex', array($this, 'output'));
|
36 |
+
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Admin Scripts
|
41 |
+
*/
|
42 |
+
public function admin_scripts() {
|
43 |
+
wp_enqueue_style('woocommerce_admin_styles', WC()->plugin_url() . '/assets/css/admin.css');
|
44 |
+
wp_enqueue_style('woocommerce-product-csv-importer', plugins_url(basename(plugin_dir_path(WF_ProdImpExpCsv_FILE)) . '/styles/wf-style.css', basename(__FILE__)), '', '1.4.4', 'screen');
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Admin Screen output
|
49 |
+
*/
|
50 |
+
public function output() {
|
51 |
+
|
52 |
+
$tab = '';
|
53 |
+
if (!empty($_GET['tab'])) {
|
54 |
+
if ($_GET['tab'] == 'help') {
|
55 |
+
$tab = 'help';
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
include( 'views/html-wf-admin-screen.php' );
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Admin Page for exporting
|
64 |
+
*/
|
65 |
+
public function admin_export_page() {
|
66 |
+
$post_columns = include( 'exporter/data/data-wf-post-columns.php' );
|
67 |
+
include( 'views/export/html-wf-export-products.php' );
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Admin Page for help
|
72 |
+
*/
|
73 |
+
public function admin_help_page() {
|
74 |
+
include('views/html-wf-help-guide.php');
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Change the admin header text on WooCommerce admin pages.
|
79 |
+
*
|
80 |
+
* @since 1.4.3
|
81 |
+
* @param string $header_text
|
82 |
+
* @return string
|
83 |
+
*/
|
84 |
+
public function render_review_text($header_text) {
|
85 |
+
|
86 |
+
if (strtotime(get_option('xa_pipe_plugin_installed_date')) < strtotime('-7 days')) {
|
87 |
+
|
88 |
+
if (!current_user_can('manage_woocommerce') || !function_exists('wc_get_screen_ids')) {
|
89 |
+
return $header_text;
|
90 |
+
}
|
91 |
+
|
92 |
+
$current_screen = get_current_screen();
|
93 |
+
|
94 |
+
$xa_pages = array('product_page_wf_woocommerce_csv_im_ex');
|
95 |
+
|
96 |
+
if (isset($current_screen->id) && apply_filters('xa_display_admin_footer_text', in_array($current_screen->id, $xa_pages))) {
|
97 |
+
|
98 |
+
if (!get_option('xa_pipe_plugin_review_rated')) {
|
99 |
+
$header_text = sprintf(
|
100 |
+
__('<div class="updated"><p>You have been using %1$s for a while. If you like the plugin please leave us a %2$s review!<p></div>', 'wf_csv_import_export'), sprintf('<strong>%s</strong>', esc_html__('Product Import Export for WooCommerce', 'wf_csv_import_export')), '<a href="https://wordpress.org/support/plugin/product-import-export-for-woo/reviews?rate=5#new-post" target="_blank" class="xa-pipe-rating-link" data-reviewed="' . esc_attr__('Thanks for the review.', 'wf_csv_import_export') . '">★★★★★</a>'
|
101 |
+
);
|
102 |
+
wc_enqueue_js("
|
103 |
+
jQuery( 'a.xa-pipe-rating-link' ).click( function() {
|
104 |
+
jQuery.post( '" . admin_url("admin-ajax.php") . "', { action: 'review_rated' } );
|
105 |
+
jQuery( this ).parent().text( jQuery( this ).data( 'reviewed' ) );
|
106 |
+
});
|
107 |
+
");
|
108 |
+
} else {
|
109 |
+
$header_text = '';
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
echo $header_text;
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Fired when clicking the rating header.
|
119 |
+
*/
|
120 |
+
public function review_rated() {
|
121 |
+
|
122 |
+
if (!current_user_can('manage_woocommerce')) {
|
123 |
+
wp_die(-1);
|
124 |
+
}
|
125 |
+
update_option('xa_pipe_plugin_review_rated', 1);
|
126 |
+
wp_die();
|
127 |
+
}
|
128 |
+
|
129 |
+
}
|
130 |
+
|
131 |
new WF_ProdImpExpCsv_Admin_Screen();
|
includes/class-wf-prodimpexpcsv-ajax-handler.php
CHANGED
@@ -1,69 +1,69 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
-
exit;
|
4 |
-
}
|
5 |
-
|
6 |
-
class WF_ProdImpExpCsv_AJAX_Handler {
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Constructor
|
10 |
-
*/
|
11 |
-
public function __construct() {
|
12 |
-
add_action( 'wp_ajax_woocommerce_csv_import_request', array( $this, 'csv_import_request' ) );
|
13 |
-
add_action( 'wp_ajax_woocommerce_csv_import_regenerate_thumbnail', array( $this, 'regenerate_thumbnail' ) );
|
14 |
-
}
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Ajax event for importing a CSV
|
18 |
-
*/
|
19 |
-
public function csv_import_request() {
|
20 |
-
define( 'WP_LOAD_IMPORTERS', true );
|
21 |
-
WF_ProdImpExpCsv_Importer::product_importer();
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* From regenerate thumbnails plugin
|
26 |
-
*/
|
27 |
-
public function regenerate_thumbnail() {
|
28 |
-
@error_reporting( 0 ); // Don't break the JSON result
|
29 |
-
|
30 |
-
header( 'Content-type: application/json' );
|
31 |
-
|
32 |
-
$id = (int) $_REQUEST['id'];
|
33 |
-
$image = get_post( $id );
|
34 |
-
|
35 |
-
if ( ! $image || 'attachment' != $image->post_type || 'image/' != substr( $image->post_mime_type, 0, 6 ) )
|
36 |
-
die( json_encode( array( 'error' => sprintf( __( 'Failed resize: %s is an invalid image ID.', 'wf_csv_import_export' ), esc_html( $_REQUEST['id'] ) ) ) ) );
|
37 |
-
|
38 |
-
if ( ! current_user_can( 'manage_woocommerce' ) )
|
39 |
-
$this->die_json_error_msg( $image->ID, __( "Your user account doesn't have permission to resize images", 'wf_csv_import_export' ) );
|
40 |
-
|
41 |
-
$fullsizepath = get_attached_file( $image->ID );
|
42 |
-
|
43 |
-
if ( false === $fullsizepath || ! file_exists( $fullsizepath ) )
|
44 |
-
$this->die_json_error_msg( $image->ID, sprintf( __( 'The originally uploaded image file cannot be found at %s', 'wf_csv_import_export' ), '<code>' . esc_html( $fullsizepath ) . '</code>' ) );
|
45 |
-
|
46 |
-
@set_time_limit( 900 ); // 5 minutes per image should be PLENTY
|
47 |
-
|
48 |
-
$metadata = wp_generate_attachment_metadata( $image->ID, $fullsizepath );
|
49 |
-
|
50 |
-
if ( is_wp_error( $metadata ) )
|
51 |
-
$this->die_json_error_msg( $image->ID, $metadata->get_error_message() );
|
52 |
-
if ( empty( $metadata ) )
|
53 |
-
$this->die_json_error_msg( $image->ID, __( 'Unknown failure reason.', 'wf_csv_import_export' ) );
|
54 |
-
|
55 |
-
// If this fails, then it just means that nothing was changed (old value == new value)
|
56 |
-
wp_update_attachment_metadata( $image->ID, $metadata );
|
57 |
-
|
58 |
-
die( json_encode( array( 'success' => sprintf( __( '"%1$s" (ID %2$s) was successfully resized in %3$s seconds.', 'wf_csv_import_export' ), esc_html( get_the_title( $image->ID ) ), $image->ID, timer_stop() ) ) ) );
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Die with a JSON formatted error message
|
63 |
-
*/
|
64 |
-
public function die_json_error_msg( $id, $message ) {
|
65 |
-
die( json_encode( array( 'error' => sprintf( __( '"%1$s" (ID %2$s) failed to resize. The error message was: %3$s', 'regenerate-thumbnails' ), esc_html( get_the_title( $id ) ), $id, $message ) ) ) );
|
66 |
-
}
|
67 |
-
}
|
68 |
-
|
69 |
new WF_ProdImpExpCsv_AJAX_Handler();
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
+
exit;
|
4 |
+
}
|
5 |
+
|
6 |
+
class WF_ProdImpExpCsv_AJAX_Handler {
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Constructor
|
10 |
+
*/
|
11 |
+
public function __construct() {
|
12 |
+
add_action( 'wp_ajax_woocommerce_csv_import_request', array( $this, 'csv_import_request' ) );
|
13 |
+
add_action( 'wp_ajax_woocommerce_csv_import_regenerate_thumbnail', array( $this, 'regenerate_thumbnail' ) );
|
14 |
+
}
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Ajax event for importing a CSV
|
18 |
+
*/
|
19 |
+
public function csv_import_request() {
|
20 |
+
define( 'WP_LOAD_IMPORTERS', true );
|
21 |
+
WF_ProdImpExpCsv_Importer::product_importer();
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* From regenerate thumbnails plugin
|
26 |
+
*/
|
27 |
+
public function regenerate_thumbnail() {
|
28 |
+
@error_reporting( 0 ); // Don't break the JSON result
|
29 |
+
|
30 |
+
header( 'Content-type: application/json' );
|
31 |
+
|
32 |
+
$id = (int) $_REQUEST['id'];
|
33 |
+
$image = get_post( $id );
|
34 |
+
|
35 |
+
if ( ! $image || 'attachment' != $image->post_type || 'image/' != substr( $image->post_mime_type, 0, 6 ) )
|
36 |
+
die( json_encode( array( 'error' => sprintf( __( 'Failed resize: %s is an invalid image ID.', 'wf_csv_import_export' ), esc_html( $_REQUEST['id'] ) ) ) ) );
|
37 |
+
|
38 |
+
if ( ! current_user_can( 'manage_woocommerce' ) )
|
39 |
+
$this->die_json_error_msg( $image->ID, __( "Your user account doesn't have permission to resize images", 'wf_csv_import_export' ) );
|
40 |
+
|
41 |
+
$fullsizepath = get_attached_file( $image->ID );
|
42 |
+
|
43 |
+
if ( false === $fullsizepath || ! file_exists( $fullsizepath ) )
|
44 |
+
$this->die_json_error_msg( $image->ID, sprintf( __( 'The originally uploaded image file cannot be found at %s', 'wf_csv_import_export' ), '<code>' . esc_html( $fullsizepath ) . '</code>' ) );
|
45 |
+
|
46 |
+
@set_time_limit( 900 ); // 5 minutes per image should be PLENTY
|
47 |
+
|
48 |
+
$metadata = wp_generate_attachment_metadata( $image->ID, $fullsizepath );
|
49 |
+
|
50 |
+
if ( is_wp_error( $metadata ) )
|
51 |
+
$this->die_json_error_msg( $image->ID, $metadata->get_error_message() );
|
52 |
+
if ( empty( $metadata ) )
|
53 |
+
$this->die_json_error_msg( $image->ID, __( 'Unknown failure reason.', 'wf_csv_import_export' ) );
|
54 |
+
|
55 |
+
// If this fails, then it just means that nothing was changed (old value == new value)
|
56 |
+
wp_update_attachment_metadata( $image->ID, $metadata );
|
57 |
+
|
58 |
+
die( json_encode( array( 'success' => sprintf( __( '"%1$s" (ID %2$s) was successfully resized in %3$s seconds.', 'wf_csv_import_export' ), esc_html( get_the_title( $image->ID ) ), $image->ID, timer_stop() ) ) ) );
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Die with a JSON formatted error message
|
63 |
+
*/
|
64 |
+
public function die_json_error_msg( $id, $message ) {
|
65 |
+
die( json_encode( array( 'error' => sprintf( __( '"%1$s" (ID %2$s) failed to resize. The error message was: %3$s', 'regenerate-thumbnails' ), esc_html( get_the_title( $id ) ), $id, $message ) ) ) );
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
new WF_ProdImpExpCsv_AJAX_Handler();
|
includes/class-wf-prodimpexpcsv-system-status-tools.php
CHANGED
@@ -1,103 +1,103 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
-
exit;
|
4 |
-
}
|
5 |
-
|
6 |
-
class WF_ProdImpExpCsv_System_Status_Tools {
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Constructor
|
10 |
-
*/
|
11 |
-
public function __construct() {
|
12 |
-
add_filter( 'woocommerce_debug_tools', array( $this, 'tools' ) );
|
13 |
-
}
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Tools we add to WC
|
17 |
-
* @param array $tools
|
18 |
-
* @return array
|
19 |
-
*/
|
20 |
-
public function tools( $tools ) {
|
21 |
-
$tools['delete_products'] = array(
|
22 |
-
'name' => __( 'Delete Products','wf_csv_import_export'),
|
23 |
-
'button' => __( 'Delete ALL products','wf_csv_import_export' ),
|
24 |
-
'desc' => __( 'This tool will delete all products allowing you to start fresh.', 'wf_csv_import_export' ),
|
25 |
-
'callback' => array( $this, 'delete_products' )
|
26 |
-
);
|
27 |
-
$tools['delete_variations'] = array(
|
28 |
-
'name' => __( 'Delete Variations','wf_csv_import_export'),
|
29 |
-
'button' => __( 'Delete ALL variations','wf_csv_import_export' ),
|
30 |
-
'desc' => __( 'This tool will delete all variations allowing you to start fresh.', 'wf_csv_import_export' ),
|
31 |
-
'callback' => array( $this, 'delete_variations' )
|
32 |
-
);
|
33 |
-
$tools['delete_orphaned_variations'] = array(
|
34 |
-
'name' => __( 'Delete Orphans','wf_csv_import_export'),
|
35 |
-
'button' => __( 'Delete orphaned variations','wf_csv_import_export' ),
|
36 |
-
'desc' => __( 'This tool will delete variations which have no parent.', 'wf_csv_import_export' ),
|
37 |
-
'callback' => array( $this, 'delete_orphaned_variations' )
|
38 |
-
);
|
39 |
-
return $tools;
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Delete products
|
44 |
-
*/
|
45 |
-
public function delete_products() {
|
46 |
-
global $wpdb;
|
47 |
-
|
48 |
-
// Delete products
|
49 |
-
$result = absint( $wpdb->delete( $wpdb->posts, array( 'post_type' => 'product' ) ) );
|
50 |
-
$result2 = absint( $wpdb->delete( $wpdb->posts, array( 'post_type' => 'product_variation' ) ) );
|
51 |
-
|
52 |
-
// Delete meta and term relationships with no post
|
53 |
-
$wpdb->query( "DELETE pm
|
54 |
-
FROM {$wpdb->postmeta} pm
|
55 |
-
LEFT JOIN {$wpdb->posts} wp ON wp.ID = pm.post_id
|
56 |
-
WHERE wp.ID IS NULL" );
|
57 |
-
$wpdb->query( "DELETE tr
|
58 |
-
FROM {$wpdb->term_relationships} tr
|
59 |
-
LEFT JOIN {$wpdb->posts} wp ON wp.ID = tr.object_id
|
60 |
-
WHERE wp.ID IS NULL" );
|
61 |
-
|
62 |
-
echo '<div class="updated"><p>' . sprintf( __( '%d Products Deleted', 'wf_csv_import_export' ), ( $result + $result2 ) ) . '</p></div>';
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Delete variations
|
67 |
-
*/
|
68 |
-
public function delete_variations() {
|
69 |
-
global $wpdb;
|
70 |
-
|
71 |
-
// Delete products
|
72 |
-
$result = absint( $wpdb->delete( $wpdb->posts, array( 'post_type' => 'product_variation' ) ) );
|
73 |
-
|
74 |
-
// Delete meta and term relationships with no post
|
75 |
-
$wpdb->query( "DELETE pm
|
76 |
-
FROM {$wpdb->postmeta} pm
|
77 |
-
LEFT JOIN {$wpdb->posts} wp ON wp.ID = pm.post_id
|
78 |
-
WHERE wp.ID IS NULL" );
|
79 |
-
$wpdb->query( "DELETE tr
|
80 |
-
FROM {$wpdb->term_relationships} tr
|
81 |
-
LEFT JOIN {$wpdb->posts} wp ON wp.ID = tr.object_id
|
82 |
-
WHERE wp.ID IS NULL" );
|
83 |
-
|
84 |
-
echo '<div class="updated"><p>' . sprintf( __( '%d Variations Deleted', 'wf_csv_import_export' ), $result ) . '</p></div>';
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Delete orphans
|
89 |
-
*/
|
90 |
-
public function delete_orphaned_variations() {
|
91 |
-
global $wpdb;
|
92 |
-
|
93 |
-
// Delete meta and term relationships with no post
|
94 |
-
$result = absint( $wpdb->query( "DELETE products
|
95 |
-
FROM {$wpdb->posts} products
|
96 |
-
LEFT JOIN {$wpdb->posts} wp ON wp.ID = products.post_parent
|
97 |
-
WHERE wp.ID IS NULL AND products.post_type = 'product_variation';" ) );
|
98 |
-
|
99 |
-
echo '<div class="updated"><p>' . sprintf( __( '%d Variations Deleted', 'wf_csv_import_export' ), $result ) . '</p></div>';
|
100 |
-
}
|
101 |
-
}
|
102 |
-
|
103 |
new WF_ProdImpExpCsv_System_Status_Tools();
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
+
exit;
|
4 |
+
}
|
5 |
+
|
6 |
+
class WF_ProdImpExpCsv_System_Status_Tools {
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Constructor
|
10 |
+
*/
|
11 |
+
public function __construct() {
|
12 |
+
add_filter( 'woocommerce_debug_tools', array( $this, 'tools' ) );
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Tools we add to WC
|
17 |
+
* @param array $tools
|
18 |
+
* @return array
|
19 |
+
*/
|
20 |
+
public function tools( $tools ) {
|
21 |
+
$tools['delete_products'] = array(
|
22 |
+
'name' => __( 'Delete Products','wf_csv_import_export'),
|
23 |
+
'button' => __( 'Delete ALL products','wf_csv_import_export' ),
|
24 |
+
'desc' => __( 'This tool will delete all products allowing you to start fresh.', 'wf_csv_import_export' ),
|
25 |
+
'callback' => array( $this, 'delete_products' )
|
26 |
+
);
|
27 |
+
$tools['delete_variations'] = array(
|
28 |
+
'name' => __( 'Delete Variations','wf_csv_import_export'),
|
29 |
+
'button' => __( 'Delete ALL variations','wf_csv_import_export' ),
|
30 |
+
'desc' => __( 'This tool will delete all variations allowing you to start fresh.', 'wf_csv_import_export' ),
|
31 |
+
'callback' => array( $this, 'delete_variations' )
|
32 |
+
);
|
33 |
+
$tools['delete_orphaned_variations'] = array(
|
34 |
+
'name' => __( 'Delete Orphans','wf_csv_import_export'),
|
35 |
+
'button' => __( 'Delete orphaned variations','wf_csv_import_export' ),
|
36 |
+
'desc' => __( 'This tool will delete variations which have no parent.', 'wf_csv_import_export' ),
|
37 |
+
'callback' => array( $this, 'delete_orphaned_variations' )
|
38 |
+
);
|
39 |
+
return $tools;
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Delete products
|
44 |
+
*/
|
45 |
+
public function delete_products() {
|
46 |
+
global $wpdb;
|
47 |
+
|
48 |
+
// Delete products
|
49 |
+
$result = absint( $wpdb->delete( $wpdb->posts, array( 'post_type' => 'product' ) ) );
|
50 |
+
$result2 = absint( $wpdb->delete( $wpdb->posts, array( 'post_type' => 'product_variation' ) ) );
|
51 |
+
|
52 |
+
// Delete meta and term relationships with no post
|
53 |
+
$wpdb->query( "DELETE pm
|
54 |
+
FROM {$wpdb->postmeta} pm
|
55 |
+
LEFT JOIN {$wpdb->posts} wp ON wp.ID = pm.post_id
|
56 |
+
WHERE wp.ID IS NULL" );
|
57 |
+
$wpdb->query( "DELETE tr
|
58 |
+
FROM {$wpdb->term_relationships} tr
|
59 |
+
LEFT JOIN {$wpdb->posts} wp ON wp.ID = tr.object_id
|
60 |
+
WHERE wp.ID IS NULL" );
|
61 |
+
|
62 |
+
echo '<div class="updated"><p>' . sprintf( __( '%d Products Deleted', 'wf_csv_import_export' ), ( $result + $result2 ) ) . '</p></div>';
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Delete variations
|
67 |
+
*/
|
68 |
+
public function delete_variations() {
|
69 |
+
global $wpdb;
|
70 |
+
|
71 |
+
// Delete products
|
72 |
+
$result = absint( $wpdb->delete( $wpdb->posts, array( 'post_type' => 'product_variation' ) ) );
|
73 |
+
|
74 |
+
// Delete meta and term relationships with no post
|
75 |
+
$wpdb->query( "DELETE pm
|
76 |
+
FROM {$wpdb->postmeta} pm
|
77 |
+
LEFT JOIN {$wpdb->posts} wp ON wp.ID = pm.post_id
|
78 |
+
WHERE wp.ID IS NULL" );
|
79 |
+
$wpdb->query( "DELETE tr
|
80 |
+
FROM {$wpdb->term_relationships} tr
|
81 |
+
LEFT JOIN {$wpdb->posts} wp ON wp.ID = tr.object_id
|
82 |
+
WHERE wp.ID IS NULL" );
|
83 |
+
|
84 |
+
echo '<div class="updated"><p>' . sprintf( __( '%d Variations Deleted', 'wf_csv_import_export' ), $result ) . '</p></div>';
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Delete orphans
|
89 |
+
*/
|
90 |
+
public function delete_orphaned_variations() {
|
91 |
+
global $wpdb;
|
92 |
+
|
93 |
+
// Delete meta and term relationships with no post
|
94 |
+
$result = absint( $wpdb->query( "DELETE products
|
95 |
+
FROM {$wpdb->posts} products
|
96 |
+
LEFT JOIN {$wpdb->posts} wp ON wp.ID = products.post_parent
|
97 |
+
WHERE wp.ID IS NULL AND products.post_type = 'product_variation';" ) );
|
98 |
+
|
99 |
+
echo '<div class="updated"><p>' . sprintf( __( '%d Variations Deleted', 'wf_csv_import_export' ), $result ) . '</p></div>';
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
new WF_ProdImpExpCsv_System_Status_Tools();
|
includes/exporter/class-wf-prodimpexpcsv-exporter.php
CHANGED
@@ -1,527 +1,527 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
-
exit;
|
4 |
-
}
|
5 |
-
|
6 |
-
class WF_ProdImpExpCsv_Exporter {
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Product Exporter Tool
|
10 |
-
*/
|
11 |
-
public static function do_export( $post_type = 'product' ) {
|
12 |
-
global $wpdb;
|
13 |
-
|
14 |
-
$export_limit = ! empty( $_POST['limit'] ) ? intval( $_POST['limit'] ) : 999999999;
|
15 |
-
$export_count = 0;
|
16 |
-
$limit = 100;
|
17 |
-
$current_offset = ! empty( $_POST['offset'] ) ? intval( $_POST['offset'] ) : 0;
|
18 |
-
$csv_columns = include( 'data/data-wf-post-columns.php' );
|
19 |
-
$user_columns_name = ! empty( $_POST['columns_name'] ) ? $_POST['columns_name'] : $csv_columns;
|
20 |
-
$product_taxonomies = get_object_taxonomies( 'product', 'name' );
|
21 |
-
$export_columns = ! empty( $_POST['columns'] ) ? $_POST['columns'] : '';
|
22 |
-
$include_hidden_meta = ! empty( $_POST['include_hidden_meta'] ) ? true : false;
|
23 |
-
$product_limit = ! empty( $_POST['product_limit'] ) ? sanitize_text_field( $_POST['product_limit'] ) : '';
|
24 |
-
$exclude_hidden_meta_columns = include( 'data/data-wf-hidden-meta-columns.php' );
|
25 |
-
|
26 |
-
if ( $limit > $export_limit )
|
27 |
-
$limit = $export_limit;
|
28 |
-
|
29 |
-
$wpdb->hide_errors();
|
30 |
-
@set_time_limit(0);
|
31 |
-
if ( function_exists( 'apache_setenv' ) )
|
32 |
-
@apache_setenv( 'no-gzip', 1 );
|
33 |
-
@ini_set('zlib.output_compression', 0);
|
34 |
-
@ob_clean();
|
35 |
-
|
36 |
-
|
37 |
-
header( 'Content-Type: text/csv; charset=UTF-8' );
|
38 |
-
header( 'Content-Disposition: attachment; filename=woocommerce-product-export.csv' );
|
39 |
-
header( 'Pragma: no-cache' );
|
40 |
-
header( 'Expires: 0' );
|
41 |
-
|
42 |
-
$fp = fopen('php://output', 'w');
|
43 |
-
|
44 |
-
|
45 |
-
// Headers
|
46 |
-
$all_meta_keys = self::get_all_metakeys( 'product' );
|
47 |
-
$found_attributes = self::get_all_product_attributes( 'product' );
|
48 |
-
|
49 |
-
// Loop products and load meta data
|
50 |
-
$found_product_meta = array();
|
51 |
-
// Some of the values may not be usable (e.g. arrays of arrays) but the worse
|
52 |
-
// that can happen is we get an empty column.
|
53 |
-
foreach ( $all_meta_keys as $meta ) {
|
54 |
-
if ( ! $meta ) continue;
|
55 |
-
if ( ! $include_hidden_meta && ! in_array( $meta, array_keys( $csv_columns ) ) && substr( (string)$meta, 0, 1 ) == '_' )
|
56 |
-
continue;
|
57 |
-
if ( $include_hidden_meta && ( in_array( $meta, $exclude_hidden_meta_columns ) || in_array( $meta, array_keys( $csv_columns ) ) ) )
|
58 |
-
continue;
|
59 |
-
$found_product_meta[] = $meta;
|
60 |
-
}
|
61 |
-
|
62 |
-
$found_product_meta = array_diff( $found_product_meta, array_keys( $csv_columns ) );
|
63 |
-
|
64 |
-
// Variable to hold the CSV data we're exporting
|
65 |
-
$row = array();
|
66 |
-
|
67 |
-
// Export header rows
|
68 |
-
foreach ( $csv_columns as $column => $value ) {
|
69 |
-
|
70 |
-
$temp_head = esc_attr( $user_columns_name[$column] );
|
71 |
-
if (strpos($temp_head, 'yoast') === false) {
|
72 |
-
$temp_head = ltrim($temp_head, '_');
|
73 |
-
}
|
74 |
-
if ( ! $export_columns || in_array( $column, $export_columns ) ) $row[] = $temp_head;
|
75 |
-
}
|
76 |
-
|
77 |
-
// Handle special fields like taxonomies
|
78 |
-
if ( ! $export_columns || in_array( 'images', $export_columns ) ) {
|
79 |
-
$row[] = 'images';
|
80 |
-
}
|
81 |
-
|
82 |
-
if ( ! $export_columns || in_array( 'file_paths', $export_columns ) ) {
|
83 |
-
if ( function_exists( 'wc_get_filename_from_url' ) ) {
|
84 |
-
$row[] = 'downloadable_files';
|
85 |
-
} else {
|
86 |
-
$row[] = 'file_paths';
|
87 |
-
}
|
88 |
-
}
|
89 |
-
|
90 |
-
if ( ! $export_columns || in_array( 'taxonomies', $export_columns ) ) {
|
91 |
-
foreach ( $product_taxonomies as $taxonomy ) {
|
92 |
-
if ( strstr( $taxonomy->name, 'pa_' ) ) continue; // Skip attributes
|
93 |
-
|
94 |
-
$row[] = 'tax:' . self::format_data( $taxonomy->name );
|
95 |
-
}
|
96 |
-
}
|
97 |
-
|
98 |
-
if ( ! $export_columns || in_array( 'meta', $export_columns ) ) {
|
99 |
-
foreach ( $found_product_meta as $product_meta ) {
|
100 |
-
$row[] = 'meta:' . self::format_data( $product_meta );
|
101 |
-
}
|
102 |
-
}
|
103 |
-
|
104 |
-
if ( ! $export_columns || in_array( 'attributes', $export_columns ) ) {
|
105 |
-
foreach ( $found_attributes as $attribute ) {
|
106 |
-
$row[] = 'attribute:' . self::format_data( $attribute );
|
107 |
-
$row[] = 'attribute_data:' . self::format_data( $attribute );
|
108 |
-
$row[] = 'attribute_default:' . self::format_data( $attribute );
|
109 |
-
}
|
110 |
-
}
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
// WF: Adding product permalink.
|
115 |
-
if ( ! $export_columns || in_array( 'product_page_url', $export_columns ) ) {
|
116 |
-
$row[] = 'Product Page URL';
|
117 |
-
}
|
118 |
-
|
119 |
-
$row = array_map( 'WF_ProdImpExpCsv_Exporter::wrap_column', $row );
|
120 |
-
fwrite( $fp, implode( ',', $row ) . "\n" );
|
121 |
-
unset( $row );
|
122 |
-
|
123 |
-
while ( $export_count < $export_limit ) {
|
124 |
-
|
125 |
-
$product_args = apply_filters( 'woocommerce_csv_product_export_args', array(
|
126 |
-
'numberposts' => $limit,
|
127 |
-
'post_status' => array( 'publish', 'pending', 'private', 'draft' ),
|
128 |
-
'post_type' => array('product'),
|
129 |
-
'orderby' => 'ID',
|
130 |
-
'suppress_filters' => false,
|
131 |
-
'order' => 'ASC',
|
132 |
-
'offset' => $current_offset
|
133 |
-
) );
|
134 |
-
|
135 |
-
|
136 |
-
if ( $product_limit ) {
|
137 |
-
$parent_ids = array_map( 'intval', explode( ',', $product_limit ) );
|
138 |
-
$child_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_parent IN (" . implode( ',', $parent_ids ) . ");" );
|
139 |
-
$product_args['post__in'] = $child_ids;
|
140 |
-
}
|
141 |
-
|
142 |
-
$products = get_posts( $product_args );
|
143 |
-
if ( ! $products || is_wp_error( $products ) )
|
144 |
-
break;
|
145 |
-
|
146 |
-
// Loop products
|
147 |
-
foreach ( $products as $product ) {
|
148 |
-
if($product->post_parent == 0) $product->post_parent = '';
|
149 |
-
$row = array();
|
150 |
-
|
151 |
-
// Pre-process data
|
152 |
-
$meta_data = get_post_custom( $product->ID );
|
153 |
-
|
154 |
-
$product->meta = new stdClass;
|
155 |
-
$product->attributes = new stdClass;
|
156 |
-
|
157 |
-
// Meta data
|
158 |
-
foreach ( $meta_data as $meta => $value ) {
|
159 |
-
if ( ! $meta ) {
|
160 |
-
continue;
|
161 |
-
}
|
162 |
-
if ( ! $include_hidden_meta && ! in_array( $meta, array_keys( $csv_columns ) ) && substr( $meta, 0, 1 ) == '_' ) {
|
163 |
-
continue;
|
164 |
-
}
|
165 |
-
if ( $include_hidden_meta && in_array( $meta, $exclude_hidden_meta_columns ) ) {
|
166 |
-
continue;
|
167 |
-
}
|
168 |
-
|
169 |
-
$meta_value = maybe_unserialize( maybe_unserialize( $value[0] ) );
|
170 |
-
|
171 |
-
if ( is_array( $meta_value ) ) {
|
172 |
-
$meta_value = json_encode( $meta_value );
|
173 |
-
}
|
174 |
-
|
175 |
-
$product->meta->$meta = self::format_export_meta( $meta_value, $meta );
|
176 |
-
}
|
177 |
-
|
178 |
-
// Product attributes
|
179 |
-
if ( isset( $meta_data['_product_attributes'][0] ) ) {
|
180 |
-
|
181 |
-
$attributes = maybe_unserialize( maybe_unserialize( $meta_data['_product_attributes'][0] ) );
|
182 |
-
|
183 |
-
if ( ! empty( $attributes ) && is_array( $attributes ) ) {
|
184 |
-
foreach ( $attributes as $key => $attribute ) {
|
185 |
-
if ( ! $key ) {
|
186 |
-
continue;
|
187 |
-
}
|
188 |
-
|
189 |
-
if ( $attribute['is_taxonomy'] == 1 ) {
|
190 |
-
$terms = wp_get_post_terms( $product->ID, $key, array("fields" => "names") );
|
191 |
-
if ( ! is_wp_error( $terms ) ) {
|
192 |
-
$attribute_value = implode( '|', $terms );
|
193 |
-
} else {
|
194 |
-
$attribute_value = '';
|
195 |
-
}
|
196 |
-
} else {
|
197 |
-
if ( empty( $attribute['name'] ) ) {
|
198 |
-
continue;
|
199 |
-
}
|
200 |
-
$key = $attribute['name'];
|
201 |
-
$attribute_value = $attribute['value'];
|
202 |
-
}
|
203 |
-
|
204 |
-
if ( ! isset( $attribute['position'] ) ) {
|
205 |
-
$attribute['position'] = 0;
|
206 |
-
}
|
207 |
-
if ( ! isset( $attribute['is_visible'] ) ) {
|
208 |
-
$attribute['is_visible'] = 0;
|
209 |
-
}
|
210 |
-
if ( ! isset( $attribute['is_variation'] ) ) {
|
211 |
-
$attribute['is_variation'] = 0;
|
212 |
-
}
|
213 |
-
|
214 |
-
$attribute_data = $attribute['position'] . '|' . $attribute['is_visible'] . '|' . $attribute['is_variation'];
|
215 |
-
$_default_attributes = isset( $meta_data['_default_attributes'][0] ) ? maybe_unserialize( maybe_unserialize( $meta_data['_default_attributes'][0] ) ) : '';
|
216 |
-
|
217 |
-
if ( is_array( $_default_attributes ) ) {
|
218 |
-
$_default_attribute = isset( $_default_attributes[ $key ] ) ? $_default_attributes[ $key ] : '';
|
219 |
-
} else {
|
220 |
-
$_default_attribute = '';
|
221 |
-
}
|
222 |
-
|
223 |
-
$product->attributes->$key = array(
|
224 |
-
'value' => $attribute_value,
|
225 |
-
'data' => $attribute_data,
|
226 |
-
'default' => $_default_attribute
|
227 |
-
);
|
228 |
-
}
|
229 |
-
}
|
230 |
-
}
|
231 |
-
|
232 |
-
// GPF
|
233 |
-
if ( isset( $meta_data['_woocommerce_gpf_data'][0] ) ) {
|
234 |
-
$product->gpf_data = $meta_data['_woocommerce_gpf_data'][0];
|
235 |
-
}
|
236 |
-
|
237 |
-
// Get column values
|
238 |
-
foreach ( $csv_columns as $column => $value ) {
|
239 |
-
if ( ! $export_columns || in_array( $column, $export_columns ) ) {
|
240 |
-
|
241 |
-
if ($column == '_regular_price' && empty( $product->meta->$column ) ) {
|
242 |
-
$column = '_price';
|
243 |
-
}
|
244 |
-
|
245 |
-
if ( isset( $product->meta->$column ) ) {
|
246 |
-
$row[] = self::format_data( $product->meta->$column );
|
247 |
-
} elseif ( isset( $product->$column ) && ! is_array( $product->$column ) ) {
|
248 |
-
if ( $column === 'post_title' ) {
|
249 |
-
$row[] = sanitize_text_field( $product->$column );
|
250 |
-
} else {
|
251 |
-
$row[] = self::format_data( $product->$column );
|
252 |
-
}
|
253 |
-
} else {
|
254 |
-
$row[] = '';
|
255 |
-
}
|
256 |
-
}
|
257 |
-
}
|
258 |
-
|
259 |
-
// Export images/gallery
|
260 |
-
if ( ! $export_columns || in_array( 'images', $export_columns ) ) {
|
261 |
-
|
262 |
-
$image_file_names = array();
|
263 |
-
|
264 |
-
// Featured image
|
265 |
-
if ( ( $featured_image_id = get_post_thumbnail_id( $product->ID ) ) && ( $image = wp_get_attachment_image_src( $featured_image_id, 'full' ) ) ) {
|
266 |
-
$image_file_names[] = current( $image );
|
267 |
-
}
|
268 |
-
|
269 |
-
// Images
|
270 |
-
$images = isset( $meta_data['_product_image_gallery'][0] ) ? explode( ',', maybe_unserialize( maybe_unserialize( $meta_data['_product_image_gallery'][0] ) ) ) : false;
|
271 |
-
$results = array();
|
272 |
-
|
273 |
-
if ( $images ) {
|
274 |
-
foreach ( $images as $image_id ) {
|
275 |
-
if ( $featured_image_id == $image_id ) {
|
276 |
-
continue;
|
277 |
-
}
|
278 |
-
$image = wp_get_attachment_image_src( $image_id, 'full' );
|
279 |
-
if ( $image ) {
|
280 |
-
$image_file_names[] = current( $image );
|
281 |
-
}
|
282 |
-
}
|
283 |
-
}
|
284 |
-
|
285 |
-
$row[] = implode( ' | ', $image_file_names );
|
286 |
-
|
287 |
-
}
|
288 |
-
|
289 |
-
// Downloadable files
|
290 |
-
if ( ! $export_columns || in_array( 'file_paths', $export_columns ) ) {
|
291 |
-
if ( ! function_exists( 'wc_get_filename_from_url' ) ) {
|
292 |
-
$file_paths = maybe_unserialize( maybe_unserialize( $meta_data['_file_paths'][0] ) );
|
293 |
-
$file_paths_to_export = array();
|
294 |
-
|
295 |
-
if ( $file_paths ) {
|
296 |
-
foreach ( $file_paths as $file_path ) {
|
297 |
-
$file_paths_to_export[] = $file_path;
|
298 |
-
}
|
299 |
-
}
|
300 |
-
|
301 |
-
$file_paths_to_export = implode( ' | ', $file_paths_to_export );
|
302 |
-
$row[] = self::format_data( $file_paths_to_export );
|
303 |
-
} elseif ( isset( $meta_data['_downloadable_files'][0] ) ) {
|
304 |
-
$file_paths = maybe_unserialize( maybe_unserialize( $meta_data['_downloadable_files'][0] ) );
|
305 |
-
$file_paths_to_export = array();
|
306 |
-
|
307 |
-
if ( $file_paths ) {
|
308 |
-
foreach ( $file_paths as $file_path ) {
|
309 |
-
$file_paths_to_export[] = ( ! empty( $file_path['name'] ) ? $file_path['name'] : wc_get_filename_from_url( $file_path['file'] ) ) . '::' . $file_path['file'];
|
310 |
-
}
|
311 |
-
}
|
312 |
-
$file_paths_to_export = implode( ' | ', $file_paths_to_export );
|
313 |
-
$row[] = self::format_data( $file_paths_to_export );
|
314 |
-
} else {
|
315 |
-
$row[] = '';
|
316 |
-
}
|
317 |
-
}
|
318 |
-
|
319 |
-
// Export taxonomies
|
320 |
-
if ( ! $export_columns || in_array( 'taxonomies', $export_columns ) ) {
|
321 |
-
foreach ( $product_taxonomies as $taxonomy ) {
|
322 |
-
if ( strstr( $taxonomy->name, 'pa_' ) ) continue; // Skip attributes
|
323 |
-
|
324 |
-
if ( is_taxonomy_hierarchical( $taxonomy->name ) ) {
|
325 |
-
$terms = wp_get_post_terms( $product->ID, $taxonomy->name, array( "fields" => "all" ) );
|
326 |
-
$formatted_terms = array();
|
327 |
-
|
328 |
-
foreach ( $terms as $term ) {
|
329 |
-
$ancestors = array_reverse( get_ancestors( $term->term_id, $taxonomy->name ) );
|
330 |
-
$formatted_term = array();
|
331 |
-
|
332 |
-
foreach ( $ancestors as $ancestor )
|
333 |
-
$formatted_term[] = get_term( $ancestor, $taxonomy->name )->name;
|
334 |
-
|
335 |
-
$formatted_term[] = $term->name;
|
336 |
-
|
337 |
-
$formatted_terms[] = implode( ' > ', $formatted_term );
|
338 |
-
}
|
339 |
-
|
340 |
-
$row[] = self::format_data( implode( '|', $formatted_terms ) );
|
341 |
-
} else {
|
342 |
-
$terms = wp_get_post_terms( $product->ID, $taxonomy->name, array( "fields" => "names" ) );
|
343 |
-
|
344 |
-
$row[] = self::format_data( implode( '|', $terms ) );
|
345 |
-
}
|
346 |
-
}
|
347 |
-
}
|
348 |
-
|
349 |
-
// Export meta data
|
350 |
-
if ( ! $export_columns || in_array( 'meta', $export_columns ) ) {
|
351 |
-
foreach ( $found_product_meta as $product_meta ) {
|
352 |
-
if ( isset( $product->meta->$product_meta ) ) {
|
353 |
-
$row[] = self::format_data( $product->meta->$product_meta );
|
354 |
-
} else {
|
355 |
-
$row[] = '';
|
356 |
-
}
|
357 |
-
}
|
358 |
-
}
|
359 |
-
|
360 |
-
// Find and export attributes
|
361 |
-
if ( ! $export_columns || in_array( 'attributes', $export_columns ) ) {
|
362 |
-
foreach ( $found_attributes as $attribute ) {
|
363 |
-
if ( isset( $product->attributes ) && isset( $product->attributes->$attribute ) ) {
|
364 |
-
$values = $product->attributes->$attribute;
|
365 |
-
$row[] = self::format_data( $values['value'] );
|
366 |
-
$row[] = self::format_data( $values['data'] );
|
367 |
-
$row[] = self::format_data( $values['default'] );
|
368 |
-
} else {
|
369 |
-
$row[] = '';
|
370 |
-
$row[] = '';
|
371 |
-
$row[] = '';
|
372 |
-
}
|
373 |
-
}
|
374 |
-
}
|
375 |
-
|
376 |
-
// Export GPF
|
377 |
-
if ( function_exists( 'woocommerce_gpf_install' ) && ( ! $export_columns || in_array( 'gpf', $export_columns ) ) ) {
|
378 |
-
|
379 |
-
$gpf_data = empty( $product->gpf_data ) ? '' : maybe_unserialize( $product->gpf_data );
|
380 |
-
|
381 |
-
$row[] = empty( $gpf_data['availability'] ) ? '' : $gpf_data['availability'];
|
382 |
-
$row[] = empty( $gpf_data['condition'] ) ? '' : $gpf_data['condition'];
|
383 |
-
$row[] = empty( $gpf_data['brand'] ) ? '' : $gpf_data['brand'];
|
384 |
-
$row[] = empty( $gpf_data['product_type'] ) ? '' : $gpf_data['product_type'];
|
385 |
-
$row[] = empty( $gpf_data['google_product_category'] ) ? '' : $gpf_data['google_product_category'];
|
386 |
-
$row[] = empty( $gpf_data['gtin'] ) ? '' : $gpf_data['gtin'];
|
387 |
-
$row[] = empty( $gpf_data['mpn'] ) ? '' : $gpf_data['mpn'];
|
388 |
-
$row[] = empty( $gpf_data['gender'] ) ? '' : $gpf_data['gender'];
|
389 |
-
$row[] = empty( $gpf_data['age_group'] ) ? '' : $gpf_data['age_group'];
|
390 |
-
$row[] = empty( $gpf_data['color'] ) ? '' : $gpf_data['color'];
|
391 |
-
$row[] = empty( $gpf_data['size'] ) ? '' : $gpf_data['size'];
|
392 |
-
$row[] = empty( $gpf_data['adwords_grouping'] ) ? '' : $gpf_data['adwords_grouping'];
|
393 |
-
$row[] = empty( $gpf_data['adwords_labels'] ) ? '' : $gpf_data['adwords_labels'];
|
394 |
-
}
|
395 |
-
|
396 |
-
// WF: Adding product permalink.
|
397 |
-
if ( ! $export_columns || in_array( 'product_page_url', $export_columns ) ) {
|
398 |
-
$product_page_url = '';
|
399 |
-
if ( $product->ID ) {
|
400 |
-
$product_page_url = get_permalink( $product->ID );
|
401 |
-
}
|
402 |
-
if ( $product->post_parent ) {
|
403 |
-
$product_page_url = get_permalink( $product->post_parent );
|
404 |
-
}
|
405 |
-
|
406 |
-
$row[] = $product_page_url;
|
407 |
-
}
|
408 |
-
|
409 |
-
// Add to csv
|
410 |
-
$row = array_map( 'WF_ProdImpExpCsv_Exporter::wrap_column', $row );
|
411 |
-
fwrite( $fp, implode( ',', $row ) . "\n" );
|
412 |
-
unset( $row );
|
413 |
-
|
414 |
-
}
|
415 |
-
$current_offset += $limit;
|
416 |
-
$export_count += $limit;
|
417 |
-
unset( $products );
|
418 |
-
}
|
419 |
-
|
420 |
-
fclose( $fp );
|
421 |
-
exit;
|
422 |
-
}
|
423 |
-
|
424 |
-
/**
|
425 |
-
* Format the data if required
|
426 |
-
* @param string $meta_value
|
427 |
-
* @param string $meta name of meta key
|
428 |
-
* @return string
|
429 |
-
*/
|
430 |
-
public static function format_export_meta( $meta_value, $meta ) {
|
431 |
-
switch ( $meta ) {
|
432 |
-
case '_sale_price_dates_from' :
|
433 |
-
case '_sale_price_dates_to' :
|
434 |
-
return $meta_value ? date( 'Y-m-d', $meta_value ) : '';
|
435 |
-
break;
|
436 |
-
case '_upsell_ids' :
|
437 |
-
case '_crosssell_ids' :
|
438 |
-
return implode( '|', array_filter( (array) json_decode( $meta_value ) ) );
|
439 |
-
break;
|
440 |
-
default :
|
441 |
-
return $meta_value;
|
442 |
-
break;
|
443 |
-
}
|
444 |
-
}
|
445 |
-
|
446 |
-
public static function format_data( $data ) {
|
447 |
-
$enc = mb_detect_encoding( $data, 'UTF-8, ISO-8859-1', true );
|
448 |
-
$data = ( $enc == 'UTF-8' ) ? $data : utf8_encode( $data );
|
449 |
-
return $data;
|
450 |
-
}
|
451 |
-
|
452 |
-
/**
|
453 |
-
* Wrap a column in quotes for the CSV
|
454 |
-
* @param string data to wrap
|
455 |
-
* @return string wrapped data
|
456 |
-
*/
|
457 |
-
public static function wrap_column( $data ) {
|
458 |
-
return '"' . str_replace( '"', '""', $data ) . '"';
|
459 |
-
}
|
460 |
-
|
461 |
-
/**
|
462 |
-
* Get a list of all the meta keys for a post type. This includes all public, private,
|
463 |
-
* used, no-longer used etc. They will be sorted once fetched.
|
464 |
-
*/
|
465 |
-
public static function get_all_metakeys( $post_type = 'product' ) {
|
466 |
-
global $wpdb;
|
467 |
-
|
468 |
-
$meta = $wpdb->get_col( $wpdb->prepare(
|
469 |
-
"SELECT DISTINCT pm.meta_key
|
470 |
-
FROM {$wpdb->postmeta} AS pm
|
471 |
-
LEFT JOIN {$wpdb->posts} AS p ON p.ID = pm.post_id
|
472 |
-
WHERE p.post_type = %s
|
473 |
-
AND p.post_status IN ( 'publish', 'pending', 'private', 'draft' )",
|
474 |
-
$post_type
|
475 |
-
) );
|
476 |
-
|
477 |
-
sort( $meta );
|
478 |
-
|
479 |
-
return $meta;
|
480 |
-
}
|
481 |
-
|
482 |
-
/**
|
483 |
-
* Get a list of all the product attributes for a post type.
|
484 |
-
* These require a bit more digging into the values.
|
485 |
-
*/
|
486 |
-
public static function get_all_product_attributes( $post_type = 'product' ) {
|
487 |
-
global $wpdb;
|
488 |
-
|
489 |
-
$results = $wpdb->get_col( $wpdb->prepare(
|
490 |
-
"SELECT DISTINCT pm.meta_value
|
491 |
-
FROM {$wpdb->postmeta} AS pm
|
492 |
-
LEFT JOIN {$wpdb->posts} AS p ON p.ID = pm.post_id
|
493 |
-
WHERE p.post_type = %s
|
494 |
-
AND p.post_status IN ( 'publish', 'pending', 'private', 'draft' )
|
495 |
-
AND pm.meta_key = '_product_attributes'",
|
496 |
-
$post_type
|
497 |
-
) );
|
498 |
-
|
499 |
-
// Go through each result, and look at the attribute keys within them.
|
500 |
-
$result = array();
|
501 |
-
|
502 |
-
if ( ! empty( $results ) ) {
|
503 |
-
foreach( $results as $_product_attributes ) {
|
504 |
-
$attributes = maybe_unserialize( maybe_unserialize( $_product_attributes ) );
|
505 |
-
if ( ! empty( $attributes ) && is_array( $attributes ) ) {
|
506 |
-
foreach( $attributes as $key => $attribute ) {
|
507 |
-
if ( ! $key ) {
|
508 |
-
continue;
|
509 |
-
}
|
510 |
-
if ( ! strstr( $key, 'pa_' ) ) {
|
511 |
-
if ( empty( $attribute['name'] ) ) {
|
512 |
-
continue;
|
513 |
-
}
|
514 |
-
$key = $attribute['name'];
|
515 |
-
}
|
516 |
-
|
517 |
-
$result[ $key ] = $key;
|
518 |
-
}
|
519 |
-
}
|
520 |
-
}
|
521 |
-
}
|
522 |
-
|
523 |
-
sort( $result );
|
524 |
-
|
525 |
-
return $result;
|
526 |
-
}
|
527 |
-
}
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
+
exit;
|
4 |
+
}
|
5 |
+
|
6 |
+
class WF_ProdImpExpCsv_Exporter {
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Product Exporter Tool
|
10 |
+
*/
|
11 |
+
public static function do_export( $post_type = 'product' ) {
|
12 |
+
global $wpdb;
|
13 |
+
|
14 |
+
$export_limit = ! empty( $_POST['limit'] ) ? intval( $_POST['limit'] ) : 999999999;
|
15 |
+
$export_count = 0;
|
16 |
+
$limit = 100;
|
17 |
+
$current_offset = ! empty( $_POST['offset'] ) ? intval( $_POST['offset'] ) : 0;
|
18 |
+
$csv_columns = include( 'data/data-wf-post-columns.php' );
|
19 |
+
$user_columns_name = ! empty( $_POST['columns_name'] ) ? $_POST['columns_name'] : $csv_columns;
|
20 |
+
$product_taxonomies = get_object_taxonomies( 'product', 'name' );
|
21 |
+
$export_columns = ! empty( $_POST['columns'] ) ? $_POST['columns'] : '';
|
22 |
+
$include_hidden_meta = ! empty( $_POST['include_hidden_meta'] ) ? true : false;
|
23 |
+
$product_limit = ! empty( $_POST['product_limit'] ) ? sanitize_text_field( $_POST['product_limit'] ) : '';
|
24 |
+
$exclude_hidden_meta_columns = include( 'data/data-wf-hidden-meta-columns.php' );
|
25 |
+
|
26 |
+
if ( $limit > $export_limit )
|
27 |
+
$limit = $export_limit;
|
28 |
+
|
29 |
+
$wpdb->hide_errors();
|
30 |
+
@set_time_limit(0);
|
31 |
+
if ( function_exists( 'apache_setenv' ) )
|
32 |
+
@apache_setenv( 'no-gzip', 1 );
|
33 |
+
@ini_set('zlib.output_compression', 0);
|
34 |
+
@ob_clean();
|
35 |
+
|
36 |
+
|
37 |
+
header( 'Content-Type: text/csv; charset=UTF-8' );
|
38 |
+
header( 'Content-Disposition: attachment; filename=woocommerce-product-export.csv' );
|
39 |
+
header( 'Pragma: no-cache' );
|
40 |
+
header( 'Expires: 0' );
|
41 |
+
|
42 |
+
$fp = fopen('php://output', 'w');
|
43 |
+
|
44 |
+
|
45 |
+
// Headers
|
46 |
+
$all_meta_keys = self::get_all_metakeys( 'product' );
|
47 |
+
$found_attributes = self::get_all_product_attributes( 'product' );
|
48 |
+
|
49 |
+
// Loop products and load meta data
|
50 |
+
$found_product_meta = array();
|
51 |
+
// Some of the values may not be usable (e.g. arrays of arrays) but the worse
|
52 |
+
// that can happen is we get an empty column.
|
53 |
+
foreach ( $all_meta_keys as $meta ) {
|
54 |
+
if ( ! $meta ) continue;
|
55 |
+
if ( ! $include_hidden_meta && ! in_array( $meta, array_keys( $csv_columns ) ) && substr( (string)$meta, 0, 1 ) == '_' )
|
56 |
+
continue;
|
57 |
+
if ( $include_hidden_meta && ( in_array( $meta, $exclude_hidden_meta_columns ) || in_array( $meta, array_keys( $csv_columns ) ) ) )
|
58 |
+
continue;
|
59 |
+
$found_product_meta[] = $meta;
|
60 |
+
}
|
61 |
+
|
62 |
+
$found_product_meta = array_diff( $found_product_meta, array_keys( $csv_columns ) );
|
63 |
+
|
64 |
+
// Variable to hold the CSV data we're exporting
|
65 |
+
$row = array();
|
66 |
+
|
67 |
+
// Export header rows
|
68 |
+
foreach ( $csv_columns as $column => $value ) {
|
69 |
+
|
70 |
+
$temp_head = esc_attr( $user_columns_name[$column] );
|
71 |
+
if (strpos($temp_head, 'yoast') === false) {
|
72 |
+
$temp_head = ltrim($temp_head, '_');
|
73 |
+
}
|
74 |
+
if ( ! $export_columns || in_array( $column, $export_columns ) ) $row[] = $temp_head;
|
75 |
+
}
|
76 |
+
|
77 |
+
// Handle special fields like taxonomies
|
78 |
+
if ( ! $export_columns || in_array( 'images', $export_columns ) ) {
|
79 |
+
$row[] = 'images';
|
80 |
+
}
|
81 |
+
|
82 |
+
if ( ! $export_columns || in_array( 'file_paths', $export_columns ) ) {
|
83 |
+
if ( function_exists( 'wc_get_filename_from_url' ) ) {
|
84 |
+
$row[] = 'downloadable_files';
|
85 |
+
} else {
|
86 |
+
$row[] = 'file_paths';
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
if ( ! $export_columns || in_array( 'taxonomies', $export_columns ) ) {
|
91 |
+
foreach ( $product_taxonomies as $taxonomy ) {
|
92 |
+
if ( strstr( $taxonomy->name, 'pa_' ) ) continue; // Skip attributes
|
93 |
+
|
94 |
+
$row[] = 'tax:' . self::format_data( $taxonomy->name );
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
if ( ! $export_columns || in_array( 'meta', $export_columns ) ) {
|
99 |
+
foreach ( $found_product_meta as $product_meta ) {
|
100 |
+
$row[] = 'meta:' . self::format_data( $product_meta );
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
if ( ! $export_columns || in_array( 'attributes', $export_columns ) ) {
|
105 |
+
foreach ( $found_attributes as $attribute ) {
|
106 |
+
$row[] = 'attribute:' . self::format_data( $attribute );
|
107 |
+
$row[] = 'attribute_data:' . self::format_data( $attribute );
|
108 |
+
$row[] = 'attribute_default:' . self::format_data( $attribute );
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
|
113 |
+
|
114 |
+
// WF: Adding product permalink.
|
115 |
+
if ( ! $export_columns || in_array( 'product_page_url', $export_columns ) ) {
|
116 |
+
$row[] = 'Product Page URL';
|
117 |
+
}
|
118 |
+
|
119 |
+
$row = array_map( 'WF_ProdImpExpCsv_Exporter::wrap_column', $row );
|
120 |
+
fwrite( $fp, implode( ',', $row ) . "\n" );
|
121 |
+
unset( $row );
|
122 |
+
|
123 |
+
while ( $export_count < $export_limit ) {
|
124 |
+
|
125 |
+
$product_args = apply_filters( 'woocommerce_csv_product_export_args', array(
|
126 |
+
'numberposts' => $limit,
|
127 |
+
'post_status' => array( 'publish', 'pending', 'private', 'draft' ),
|
128 |
+
'post_type' => array('product'),
|
129 |
+
'orderby' => 'ID',
|
130 |
+
'suppress_filters' => false,
|
131 |
+
'order' => 'ASC',
|
132 |
+
'offset' => $current_offset
|
133 |
+
) );
|
134 |
+
|
135 |
+
|
136 |
+
if ( $product_limit ) {
|
137 |
+
$parent_ids = array_map( 'intval', explode( ',', $product_limit ) );
|
138 |
+
$child_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_parent IN (" . implode( ',', $parent_ids ) . ");" );
|
139 |
+
$product_args['post__in'] = $child_ids;
|
140 |
+
}
|
141 |
+
|
142 |
+
$products = get_posts( $product_args );
|
143 |
+
if ( ! $products || is_wp_error( $products ) )
|
144 |
+
break;
|
145 |
+
|
146 |
+
// Loop products
|
147 |
+
foreach ( $products as $product ) {
|
148 |
+
if($product->post_parent == 0) $product->post_parent = '';
|
149 |
+
$row = array();
|
150 |
+
|
151 |
+
// Pre-process data
|
152 |
+
$meta_data = get_post_custom( $product->ID );
|
153 |
+
|
154 |
+
$product->meta = new stdClass;
|
155 |
+
$product->attributes = new stdClass;
|
156 |
+
|
157 |
+
// Meta data
|
158 |
+
foreach ( $meta_data as $meta => $value ) {
|
159 |
+
if ( ! $meta ) {
|
160 |
+
continue;
|
161 |
+
}
|
162 |
+
if ( ! $include_hidden_meta && ! in_array( $meta, array_keys( $csv_columns ) ) && substr( $meta, 0, 1 ) == '_' ) {
|
163 |
+
continue;
|
164 |
+
}
|
165 |
+
if ( $include_hidden_meta && in_array( $meta, $exclude_hidden_meta_columns ) ) {
|
166 |
+
continue;
|
167 |
+
}
|
168 |
+
|
169 |
+
$meta_value = maybe_unserialize( maybe_unserialize( $value[0] ) );
|
170 |
+
|
171 |
+
if ( is_array( $meta_value ) ) {
|
172 |
+
$meta_value = json_encode( $meta_value );
|
173 |
+
}
|
174 |
+
|
175 |
+
$product->meta->$meta = self::format_export_meta( $meta_value, $meta );
|
176 |
+
}
|
177 |
+
|
178 |
+
// Product attributes
|
179 |
+
if ( isset( $meta_data['_product_attributes'][0] ) ) {
|
180 |
+
|
181 |
+
$attributes = maybe_unserialize( maybe_unserialize( $meta_data['_product_attributes'][0] ) );
|
182 |
+
|
183 |
+
if ( ! empty( $attributes ) && is_array( $attributes ) ) {
|
184 |
+
foreach ( $attributes as $key => $attribute ) {
|
185 |
+
if ( ! $key ) {
|
186 |
+
continue;
|
187 |
+
}
|
188 |
+
|
189 |
+
if ( $attribute['is_taxonomy'] == 1 ) {
|
190 |
+
$terms = wp_get_post_terms( $product->ID, $key, array("fields" => "names") );
|
191 |
+
if ( ! is_wp_error( $terms ) ) {
|
192 |
+
$attribute_value = implode( '|', $terms );
|
193 |
+
} else {
|
194 |
+
$attribute_value = '';
|
195 |
+
}
|
196 |
+
} else {
|
197 |
+
if ( empty( $attribute['name'] ) ) {
|
198 |
+
continue;
|
199 |
+
}
|
200 |
+
$key = $attribute['name'];
|
201 |
+
$attribute_value = $attribute['value'];
|
202 |
+
}
|
203 |
+
|
204 |
+
if ( ! isset( $attribute['position'] ) ) {
|
205 |
+
$attribute['position'] = 0;
|
206 |
+
}
|
207 |
+
if ( ! isset( $attribute['is_visible'] ) ) {
|
208 |
+
$attribute['is_visible'] = 0;
|
209 |
+
}
|
210 |
+
if ( ! isset( $attribute['is_variation'] ) ) {
|
211 |
+
$attribute['is_variation'] = 0;
|
212 |
+
}
|
213 |
+
|
214 |
+
$attribute_data = $attribute['position'] . '|' . $attribute['is_visible'] . '|' . $attribute['is_variation'];
|
215 |
+
$_default_attributes = isset( $meta_data['_default_attributes'][0] ) ? maybe_unserialize( maybe_unserialize( $meta_data['_default_attributes'][0] ) ) : '';
|
216 |
+
|
217 |
+
if ( is_array( $_default_attributes ) ) {
|
218 |
+
$_default_attribute = isset( $_default_attributes[ $key ] ) ? $_default_attributes[ $key ] : '';
|
219 |
+
} else {
|
220 |
+
$_default_attribute = '';
|
221 |
+
}
|
222 |
+
|
223 |
+
$product->attributes->$key = array(
|
224 |
+
'value' => $attribute_value,
|
225 |
+
'data' => $attribute_data,
|
226 |
+
'default' => $_default_attribute
|
227 |
+
);
|
228 |
+
}
|
229 |
+
}
|
230 |
+
}
|
231 |
+
|
232 |
+
// GPF
|
233 |
+
if ( isset( $meta_data['_woocommerce_gpf_data'][0] ) ) {
|
234 |
+
$product->gpf_data = $meta_data['_woocommerce_gpf_data'][0];
|
235 |
+
}
|
236 |
+
|
237 |
+
// Get column values
|
238 |
+
foreach ( $csv_columns as $column => $value ) {
|
239 |
+
if ( ! $export_columns || in_array( $column, $export_columns ) ) {
|
240 |
+
|
241 |
+
if ($column == '_regular_price' && empty( $product->meta->$column ) ) {
|
242 |
+
$column = '_price';
|
243 |
+
}
|
244 |
+
|
245 |
+
if ( isset( $product->meta->$column ) ) {
|
246 |
+
$row[] = self::format_data( $product->meta->$column );
|
247 |
+
} elseif ( isset( $product->$column ) && ! is_array( $product->$column ) ) {
|
248 |
+
if ( $column === 'post_title' ) {
|
249 |
+
$row[] = sanitize_text_field( $product->$column );
|
250 |
+
} else {
|
251 |
+
$row[] = self::format_data( $product->$column );
|
252 |
+
}
|
253 |
+
} else {
|
254 |
+
$row[] = '';
|
255 |
+
}
|
256 |
+
}
|
257 |
+
}
|
258 |
+
|
259 |
+
// Export images/gallery
|
260 |
+
if ( ! $export_columns || in_array( 'images', $export_columns ) ) {
|
261 |
+
|
262 |
+
$image_file_names = array();
|
263 |
+
|
264 |
+
// Featured image
|
265 |
+
if ( ( $featured_image_id = get_post_thumbnail_id( $product->ID ) ) && ( $image = wp_get_attachment_image_src( $featured_image_id, 'full' ) ) ) {
|
266 |
+
$image_file_names[] = current( $image );
|
267 |
+
}
|
268 |
+
|
269 |
+
// Images
|
270 |
+
$images = isset( $meta_data['_product_image_gallery'][0] ) ? explode( ',', maybe_unserialize( maybe_unserialize( $meta_data['_product_image_gallery'][0] ) ) ) : false;
|
271 |
+
$results = array();
|
272 |
+
|
273 |
+
if ( $images ) {
|
274 |
+
foreach ( $images as $image_id ) {
|
275 |
+
if ( $featured_image_id == $image_id ) {
|
276 |
+
continue;
|
277 |
+
}
|
278 |
+
$image = wp_get_attachment_image_src( $image_id, 'full' );
|
279 |
+
if ( $image ) {
|
280 |
+
$image_file_names[] = current( $image );
|
281 |
+
}
|
282 |
+
}
|
283 |
+
}
|
284 |
+
|
285 |
+
$row[] = implode( ' | ', $image_file_names );
|
286 |
+
|
287 |
+
}
|
288 |
+
|
289 |
+
// Downloadable files
|
290 |
+
if ( ! $export_columns || in_array( 'file_paths', $export_columns ) ) {
|
291 |
+
if ( ! function_exists( 'wc_get_filename_from_url' ) ) {
|
292 |
+
$file_paths = maybe_unserialize( maybe_unserialize( $meta_data['_file_paths'][0] ) );
|
293 |
+
$file_paths_to_export = array();
|
294 |
+
|
295 |
+
if ( $file_paths ) {
|
296 |
+
foreach ( $file_paths as $file_path ) {
|
297 |
+
$file_paths_to_export[] = $file_path;
|
298 |
+
}
|
299 |
+
}
|
300 |
+
|
301 |
+
$file_paths_to_export = implode( ' | ', $file_paths_to_export );
|
302 |
+
$row[] = self::format_data( $file_paths_to_export );
|
303 |
+
} elseif ( isset( $meta_data['_downloadable_files'][0] ) ) {
|
304 |
+
$file_paths = maybe_unserialize( maybe_unserialize( $meta_data['_downloadable_files'][0] ) );
|
305 |
+
$file_paths_to_export = array();
|
306 |
+
|
307 |
+
if ( $file_paths ) {
|
308 |
+
foreach ( $file_paths as $file_path ) {
|
309 |
+
$file_paths_to_export[] = ( ! empty( $file_path['name'] ) ? $file_path['name'] : wc_get_filename_from_url( $file_path['file'] ) ) . '::' . $file_path['file'];
|
310 |
+
}
|
311 |
+
}
|
312 |
+
$file_paths_to_export = implode( ' | ', $file_paths_to_export );
|
313 |
+
$row[] = self::format_data( $file_paths_to_export );
|
314 |
+
} else {
|
315 |
+
$row[] = '';
|
316 |
+
}
|
317 |
+
}
|
318 |
+
|
319 |
+
// Export taxonomies
|
320 |
+
if ( ! $export_columns || in_array( 'taxonomies', $export_columns ) ) {
|
321 |
+
foreach ( $product_taxonomies as $taxonomy ) {
|
322 |
+
if ( strstr( $taxonomy->name, 'pa_' ) ) continue; // Skip attributes
|
323 |
+
|
324 |
+
if ( is_taxonomy_hierarchical( $taxonomy->name ) ) {
|
325 |
+
$terms = wp_get_post_terms( $product->ID, $taxonomy->name, array( "fields" => "all" ) );
|
326 |
+
$formatted_terms = array();
|
327 |
+
|
328 |
+
foreach ( $terms as $term ) {
|
329 |
+
$ancestors = array_reverse( get_ancestors( $term->term_id, $taxonomy->name ) );
|
330 |
+
$formatted_term = array();
|
331 |
+
|
332 |
+
foreach ( $ancestors as $ancestor )
|
333 |
+
$formatted_term[] = get_term( $ancestor, $taxonomy->name )->name;
|
334 |
+
|
335 |
+
$formatted_term[] = $term->name;
|
336 |
+
|
337 |
+
$formatted_terms[] = implode( ' > ', $formatted_term );
|
338 |
+
}
|
339 |
+
|
340 |
+
$row[] = self::format_data( implode( '|', $formatted_terms ) );
|
341 |
+
} else {
|
342 |
+
$terms = wp_get_post_terms( $product->ID, $taxonomy->name, array( "fields" => "names" ) );
|
343 |
+
|
344 |
+
$row[] = self::format_data( implode( '|', $terms ) );
|
345 |
+
}
|
346 |
+
}
|
347 |
+
}
|
348 |
+
|
349 |
+
// Export meta data
|
350 |
+
if ( ! $export_columns || in_array( 'meta', $export_columns ) ) {
|
351 |
+
foreach ( $found_product_meta as $product_meta ) {
|
352 |
+
if ( isset( $product->meta->$product_meta ) ) {
|
353 |
+
$row[] = self::format_data( $product->meta->$product_meta );
|
354 |
+
} else {
|
355 |
+
$row[] = '';
|
356 |
+
}
|
357 |
+
}
|
358 |
+
}
|
359 |
+
|
360 |
+
// Find and export attributes
|
361 |
+
if ( ! $export_columns || in_array( 'attributes', $export_columns ) ) {
|
362 |
+
foreach ( $found_attributes as $attribute ) {
|
363 |
+
if ( isset( $product->attributes ) && isset( $product->attributes->$attribute ) ) {
|
364 |
+
$values = $product->attributes->$attribute;
|
365 |
+
$row[] = self::format_data( $values['value'] );
|
366 |
+
$row[] = self::format_data( $values['data'] );
|
367 |
+
$row[] = self::format_data( $values['default'] );
|
368 |
+
} else {
|
369 |
+
$row[] = '';
|
370 |
+
$row[] = '';
|
371 |
+
$row[] = '';
|
372 |
+
}
|
373 |
+
}
|
374 |
+
}
|
375 |
+
|
376 |
+
// Export GPF
|
377 |
+
if ( function_exists( 'woocommerce_gpf_install' ) && ( ! $export_columns || in_array( 'gpf', $export_columns ) ) ) {
|
378 |
+
|
379 |
+
$gpf_data = empty( $product->gpf_data ) ? '' : maybe_unserialize( $product->gpf_data );
|
380 |
+
|
381 |
+
$row[] = empty( $gpf_data['availability'] ) ? '' : $gpf_data['availability'];
|
382 |
+
$row[] = empty( $gpf_data['condition'] ) ? '' : $gpf_data['condition'];
|
383 |
+
$row[] = empty( $gpf_data['brand'] ) ? '' : $gpf_data['brand'];
|
384 |
+
$row[] = empty( $gpf_data['product_type'] ) ? '' : $gpf_data['product_type'];
|
385 |
+
$row[] = empty( $gpf_data['google_product_category'] ) ? '' : $gpf_data['google_product_category'];
|
386 |
+
$row[] = empty( $gpf_data['gtin'] ) ? '' : $gpf_data['gtin'];
|
387 |
+
$row[] = empty( $gpf_data['mpn'] ) ? '' : $gpf_data['mpn'];
|
388 |
+
$row[] = empty( $gpf_data['gender'] ) ? '' : $gpf_data['gender'];
|
389 |
+
$row[] = empty( $gpf_data['age_group'] ) ? '' : $gpf_data['age_group'];
|
390 |
+
$row[] = empty( $gpf_data['color'] ) ? '' : $gpf_data['color'];
|
391 |
+
$row[] = empty( $gpf_data['size'] ) ? '' : $gpf_data['size'];
|
392 |
+
$row[] = empty( $gpf_data['adwords_grouping'] ) ? '' : $gpf_data['adwords_grouping'];
|
393 |
+
$row[] = empty( $gpf_data['adwords_labels'] ) ? '' : $gpf_data['adwords_labels'];
|
394 |
+
}
|
395 |
+
|
396 |
+
// WF: Adding product permalink.
|
397 |
+
if ( ! $export_columns || in_array( 'product_page_url', $export_columns ) ) {
|
398 |
+
$product_page_url = '';
|
399 |
+
if ( $product->ID ) {
|
400 |
+
$product_page_url = get_permalink( $product->ID );
|
401 |
+
}
|
402 |
+
if ( $product->post_parent ) {
|
403 |
+
$product_page_url = get_permalink( $product->post_parent );
|
404 |
+
}
|
405 |
+
|
406 |
+
$row[] = $product_page_url;
|
407 |
+
}
|
408 |
+
|
409 |
+
// Add to csv
|
410 |
+
$row = array_map( 'WF_ProdImpExpCsv_Exporter::wrap_column', $row );
|
411 |
+
fwrite( $fp, implode( ',', $row ) . "\n" );
|
412 |
+
unset( $row );
|
413 |
+
|
414 |
+
}
|
415 |
+
$current_offset += $limit;
|
416 |
+
$export_count += $limit;
|
417 |
+
unset( $products );
|
418 |
+
}
|
419 |
+
|
420 |
+
fclose( $fp );
|
421 |
+
exit;
|
422 |
+
}
|
423 |
+
|
424 |
+
/**
|
425 |
+
* Format the data if required
|
426 |
+
* @param string $meta_value
|
427 |
+
* @param string $meta name of meta key
|
428 |
+
* @return string
|
429 |
+
*/
|
430 |
+
public static function format_export_meta( $meta_value, $meta ) {
|
431 |
+
switch ( $meta ) {
|
432 |
+
case '_sale_price_dates_from' :
|
433 |
+
case '_sale_price_dates_to' :
|
434 |
+
return $meta_value ? date( 'Y-m-d', $meta_value ) : '';
|
435 |
+
break;
|
436 |
+
case '_upsell_ids' :
|
437 |
+
case '_crosssell_ids' :
|
438 |
+
return implode( '|', array_filter( (array) json_decode( $meta_value ) ) );
|
439 |
+
break;
|
440 |
+
default :
|
441 |
+
return $meta_value;
|
442 |
+
break;
|
443 |
+
}
|
444 |
+
}
|
445 |
+
|
446 |
+
public static function format_data( $data ) {
|
447 |
+
$enc = mb_detect_encoding( $data, 'UTF-8, ISO-8859-1', true );
|
448 |
+
$data = ( $enc == 'UTF-8' ) ? $data : utf8_encode( $data );
|
449 |
+
return $data;
|
450 |
+
}
|
451 |
+
|
452 |
+
/**
|
453 |
+
* Wrap a column in quotes for the CSV
|
454 |
+
* @param string data to wrap
|
455 |
+
* @return string wrapped data
|
456 |
+
*/
|
457 |
+
public static function wrap_column( $data ) {
|
458 |
+
return '"' . str_replace( '"', '""', $data ) . '"';
|
459 |
+
}
|
460 |
+
|
461 |
+
/**
|
462 |
+
* Get a list of all the meta keys for a post type. This includes all public, private,
|
463 |
+
* used, no-longer used etc. They will be sorted once fetched.
|
464 |
+
*/
|
465 |
+
public static function get_all_metakeys( $post_type = 'product' ) {
|
466 |
+
global $wpdb;
|
467 |
+
|
468 |
+
$meta = $wpdb->get_col( $wpdb->prepare(
|
469 |
+
"SELECT DISTINCT pm.meta_key
|
470 |
+
FROM {$wpdb->postmeta} AS pm
|
471 |
+
LEFT JOIN {$wpdb->posts} AS p ON p.ID = pm.post_id
|
472 |
+
WHERE p.post_type = %s
|
473 |
+
AND p.post_status IN ( 'publish', 'pending', 'private', 'draft' )",
|
474 |
+
$post_type
|
475 |
+
) );
|
476 |
+
|
477 |
+
sort( $meta );
|
478 |
+
|
479 |
+
return $meta;
|
480 |
+
}
|
481 |
+
|
482 |
+
/**
|
483 |
+
* Get a list of all the product attributes for a post type.
|
484 |
+
* These require a bit more digging into the values.
|
485 |
+
*/
|
486 |
+
public static function get_all_product_attributes( $post_type = 'product' ) {
|
487 |
+
global $wpdb;
|
488 |
+
|
489 |
+
$results = $wpdb->get_col( $wpdb->prepare(
|
490 |
+
"SELECT DISTINCT pm.meta_value
|
491 |
+
FROM {$wpdb->postmeta} AS pm
|
492 |
+
LEFT JOIN {$wpdb->posts} AS p ON p.ID = pm.post_id
|
493 |
+
WHERE p.post_type = %s
|
494 |
+
AND p.post_status IN ( 'publish', 'pending', 'private', 'draft' )
|
495 |
+
AND pm.meta_key = '_product_attributes'",
|
496 |
+
$post_type
|
497 |
+
) );
|
498 |
+
|
499 |
+
// Go through each result, and look at the attribute keys within them.
|
500 |
+
$result = array();
|
501 |
+
|
502 |
+
if ( ! empty( $results ) ) {
|
503 |
+
foreach( $results as $_product_attributes ) {
|
504 |
+
$attributes = maybe_unserialize( maybe_unserialize( $_product_attributes ) );
|
505 |
+
if ( ! empty( $attributes ) && is_array( $attributes ) ) {
|
506 |
+
foreach( $attributes as $key => $attribute ) {
|
507 |
+
if ( ! $key ) {
|
508 |
+
continue;
|
509 |
+
}
|
510 |
+
if ( ! strstr( $key, 'pa_' ) ) {
|
511 |
+
if ( empty( $attribute['name'] ) ) {
|
512 |
+
continue;
|
513 |
+
}
|
514 |
+
$key = $attribute['name'];
|
515 |
+
}
|
516 |
+
|
517 |
+
$result[ $key ] = $key;
|
518 |
+
}
|
519 |
+
}
|
520 |
+
}
|
521 |
+
}
|
522 |
+
|
523 |
+
sort( $result );
|
524 |
+
|
525 |
+
return $result;
|
526 |
+
}
|
527 |
+
}
|
includes/exporter/data/data-wf-hidden-meta-columns.php
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// Exclude columns handled specifically
|
4 |
-
return array(
|
5 |
-
'_product_attributes',
|
6 |
-
'_file_paths',
|
7 |
-
'_woocommerce_gpf_data',
|
8 |
-
'_price',
|
9 |
-
'_default_attributes',
|
10 |
-
'_edit_last',
|
11 |
-
'_edit_lock',
|
12 |
-
'_wp_old_slug',
|
13 |
-
'_product_image_gallery',
|
14 |
-
'_max_variation_price',
|
15 |
-
'_max_variation_regular_price',
|
16 |
-
'_max_variation_sale_price',
|
17 |
-
'_min_variation_price',
|
18 |
-
'_min_variation_regular_price',
|
19 |
-
'_min_variation_sale_price',
|
20 |
);
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Exclude columns handled specifically
|
4 |
+
return array(
|
5 |
+
'_product_attributes',
|
6 |
+
'_file_paths',
|
7 |
+
'_woocommerce_gpf_data',
|
8 |
+
'_price',
|
9 |
+
'_default_attributes',
|
10 |
+
'_edit_last',
|
11 |
+
'_edit_lock',
|
12 |
+
'_wp_old_slug',
|
13 |
+
'_product_image_gallery',
|
14 |
+
'_max_variation_price',
|
15 |
+
'_max_variation_regular_price',
|
16 |
+
'_max_variation_sale_price',
|
17 |
+
'_min_variation_price',
|
18 |
+
'_min_variation_regular_price',
|
19 |
+
'_min_variation_sale_price',
|
20 |
);
|
includes/exporter/data/data-wf-post-columns.php
CHANGED
@@ -1,51 +1,51 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
-
exit;
|
4 |
-
}
|
5 |
-
|
6 |
-
return apply_filters('woocommerce_csv_product_post_columns', array(
|
7 |
-
'post_title' => 'post_title',
|
8 |
-
'post_name' => 'post_name',
|
9 |
-
'ID' => 'ID',
|
10 |
-
'post_excerpt' => 'post_excerpt',
|
11 |
-
'post_content' => 'post_content',
|
12 |
-
'post_status' => 'post_status',
|
13 |
-
'menu_order' => 'menu_order',
|
14 |
-
'post_date' => 'post_date',
|
15 |
-
'post_author' => 'post_author',
|
16 |
-
'comment_status' => 'comment_status',
|
17 |
-
|
18 |
-
// Meta
|
19 |
-
'_sku' => 'sku',
|
20 |
-
'_downloadable' => 'downloadable',
|
21 |
-
'_virtual' => 'virtual',
|
22 |
-
'_stock' => 'stock',
|
23 |
-
'_regular_price' => 'regular_price',
|
24 |
-
'_sale_price' => 'sale_price',
|
25 |
-
'_weight' => 'weight',
|
26 |
-
'_length' => 'length',
|
27 |
-
'_width' => 'width',
|
28 |
-
'_height' => 'height',
|
29 |
-
'_tax_class' => 'tax_class',
|
30 |
-
|
31 |
-
'_visibility' => 'visibility',
|
32 |
-
'_stock_status' => 'stock_status',
|
33 |
-
'_backorders' => 'backorders',
|
34 |
-
'_manage_stock' => 'manage_stock',
|
35 |
-
'_tax_status' => 'tax_status',
|
36 |
-
'_upsell_ids' => 'upsell_ids',
|
37 |
-
'_crosssell_ids' => 'crosssell_ids',
|
38 |
-
'_featured' => 'featured',
|
39 |
-
|
40 |
-
'_sale_price_dates_from' => 'sale_price_dates_from',
|
41 |
-
'_sale_price_dates_to' => 'sale_price_dates_to',
|
42 |
-
|
43 |
-
// Downloadable products
|
44 |
-
'_download_limit' => 'download_limit',
|
45 |
-
'_download_expiry' => 'download_expiry',
|
46 |
-
|
47 |
-
// Virtual products
|
48 |
-
'_product_url' => 'product_url',
|
49 |
-
'_button_text' => 'button_text',
|
50 |
-
|
51 |
) );
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
+
exit;
|
4 |
+
}
|
5 |
+
|
6 |
+
return apply_filters('woocommerce_csv_product_post_columns', array(
|
7 |
+
'post_title' => 'post_title',
|
8 |
+
'post_name' => 'post_name',
|
9 |
+
'ID' => 'ID',
|
10 |
+
'post_excerpt' => 'post_excerpt',
|
11 |
+
'post_content' => 'post_content',
|
12 |
+
'post_status' => 'post_status',
|
13 |
+
'menu_order' => 'menu_order',
|
14 |
+
'post_date' => 'post_date',
|
15 |
+
'post_author' => 'post_author',
|
16 |
+
'comment_status' => 'comment_status',
|
17 |
+
|
18 |
+
// Meta
|
19 |
+
'_sku' => 'sku',
|
20 |
+
'_downloadable' => 'downloadable',
|
21 |
+
'_virtual' => 'virtual',
|
22 |
+
'_stock' => 'stock',
|
23 |
+
'_regular_price' => 'regular_price',
|
24 |
+
'_sale_price' => 'sale_price',
|
25 |
+
'_weight' => 'weight',
|
26 |
+
'_length' => 'length',
|
27 |
+
'_width' => 'width',
|
28 |
+
'_height' => 'height',
|
29 |
+
'_tax_class' => 'tax_class',
|
30 |
+
|
31 |
+
'_visibility' => 'visibility',
|
32 |
+
'_stock_status' => 'stock_status',
|
33 |
+
'_backorders' => 'backorders',
|
34 |
+
'_manage_stock' => 'manage_stock',
|
35 |
+
'_tax_status' => 'tax_status',
|
36 |
+
'_upsell_ids' => 'upsell_ids',
|
37 |
+
'_crosssell_ids' => 'crosssell_ids',
|
38 |
+
'_featured' => 'featured',
|
39 |
+
|
40 |
+
'_sale_price_dates_from' => 'sale_price_dates_from',
|
41 |
+
'_sale_price_dates_to' => 'sale_price_dates_to',
|
42 |
+
|
43 |
+
// Downloadable products
|
44 |
+
'_download_limit' => 'download_limit',
|
45 |
+
'_download_expiry' => 'download_expiry',
|
46 |
+
|
47 |
+
// Virtual products
|
48 |
+
'_product_url' => 'product_url',
|
49 |
+
'_button_text' => 'button_text',
|
50 |
+
|
51 |
) );
|
includes/importer/class-wf-csv-parser.php
CHANGED
@@ -1,853 +1,853 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* WooCommerce CSV Importer class for managing parsing of CSV files.
|
4 |
-
*/
|
5 |
-
class WF_CSV_Parser {
|
6 |
-
|
7 |
-
var $row;
|
8 |
-
var $post_type;
|
9 |
-
var $reserved_fields; // Fields we map/handle (not custom fields)
|
10 |
-
var $post_defaults; // Default post data
|
11 |
-
var $postmeta_defaults; // default post meta
|
12 |
-
var $postmeta_allowed; // post meta validation
|
13 |
-
var $allowed_product_types; // Allowed product types
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Constructor
|
17 |
-
*/
|
18 |
-
public function __construct( $post_type = 'product' ) {
|
19 |
-
|
20 |
-
$this->post_type = $post_type;
|
21 |
-
$this->reserved_fields = include( 'data/data-wf-reserved-fields.php' );
|
22 |
-
$this->post_defaults = include( 'data/data-wf-post-defaults.php' );
|
23 |
-
$this->postmeta_defaults = include( 'data/data-wf-postmeta-defaults.php' );
|
24 |
-
$this->postmeta_allowed = include( 'data/data-wf-postmeta-allowed.php' );
|
25 |
-
|
26 |
-
$simple_term = get_term_by( 'slug', 'simple', 'product_type' );
|
27 |
-
$variable_term = get_term_by( 'slug', 'variable', 'product_type' );
|
28 |
-
$grouped_term = get_term_by( 'slug', 'grouped', 'product_type' );
|
29 |
-
$external_term = get_term_by( 'slug', 'external', 'product_type' );
|
30 |
-
|
31 |
-
$this->allowed_product_types = array(
|
32 |
-
'simple' => $simple_term->term_id,
|
33 |
-
'variable' => $variable_term->term_id,
|
34 |
-
'grouped' => $grouped_term->term_id,
|
35 |
-
'external' => $external_term->term_id
|
36 |
-
);
|
37 |
-
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Format data from the csv file
|
42 |
-
* @param string $data
|
43 |
-
* @param string $enc
|
44 |
-
* @return string
|
45 |
-
*/
|
46 |
-
public function format_data_from_csv( $data, $enc ) {
|
47 |
-
return ( $enc == 'UTF-8' ) ? $data : utf8_encode( $data );
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Parse the data
|
52 |
-
* @param string $file [description]
|
53 |
-
* @param string $delimiter [description]
|
54 |
-
* @param array $mapping [description]
|
55 |
-
* @param integer $start_pos [description]
|
56 |
-
* @param integer $end_pos [description]
|
57 |
-
* @return array
|
58 |
-
*/
|
59 |
-
public function parse_data( $file, $delimiter, $mapping, $start_pos = 0, $end_pos = null, $eval_field ) {
|
60 |
-
// Set locale
|
61 |
-
$enc = mb_detect_encoding( $file, 'UTF-8, ISO-8859-1', true );
|
62 |
-
if ( $enc )
|
63 |
-
setlocale( LC_ALL, 'en_US.' . $enc );
|
64 |
-
@ini_set( 'auto_detect_line_endings', true );
|
65 |
-
|
66 |
-
$parsed_data = array();
|
67 |
-
$raw_headers = array();
|
68 |
-
|
69 |
-
// Put all CSV data into an associative array
|
70 |
-
if ( ( $handle = fopen( $file, "r" ) ) !== FALSE ) {
|
71 |
-
|
72 |
-
$header = fgetcsv( $handle, 0, $delimiter );
|
73 |
-
if ( $start_pos != 0 )
|
74 |
-
fseek( $handle, $start_pos );
|
75 |
-
|
76 |
-
while ( ( $postmeta = fgetcsv( $handle, 0, $delimiter ) ) !== FALSE ) {
|
77 |
-
$row = array();
|
78 |
-
|
79 |
-
foreach ( $header as $key => $heading ) {
|
80 |
-
// Heading is the lowercase version of the column name
|
81 |
-
$s_heading = strtolower( $heading );
|
82 |
-
|
83 |
-
// Check if this heading is being mapped to a different field
|
84 |
-
if ( isset( $mapping[$s_heading] ) ) {
|
85 |
-
if ( $mapping[$s_heading] == 'import_as_meta' ) {
|
86 |
-
|
87 |
-
$s_heading = 'meta:' . $s_heading;
|
88 |
-
|
89 |
-
} elseif ( $mapping[$s_heading] == 'import_as_images' ) {
|
90 |
-
|
91 |
-
$s_heading = 'images';
|
92 |
-
|
93 |
-
} else {
|
94 |
-
$s_heading = esc_attr( $mapping[$s_heading] );
|
95 |
-
}
|
96 |
-
}
|
97 |
-
if( !empty($mapping) )
|
98 |
-
{
|
99 |
-
foreach ($mapping as $mkey => $mvalue) {
|
100 |
-
if(trim($mvalue) === trim($heading)){
|
101 |
-
$s_heading = $mkey;
|
102 |
-
}
|
103 |
-
}
|
104 |
-
}
|
105 |
-
|
106 |
-
if ( $s_heading == '' )
|
107 |
-
continue;
|
108 |
-
|
109 |
-
// Add the heading to the parsed data
|
110 |
-
$row[$s_heading] = ( isset( $postmeta[$key] ) ) ? $this->format_data_from_csv( $postmeta[$key], $enc ) : '';
|
111 |
-
|
112 |
-
if(!empty($eval_field[strtolower( $heading )]))
|
113 |
-
$row[$s_heading] = $this->evaluate_field($row[$s_heading], $eval_field[strtolower( $heading )]);
|
114 |
-
|
115 |
-
// Raw Headers stores the actual column name in the CSV
|
116 |
-
$raw_headers[ $s_heading ] = $heading;
|
117 |
-
}
|
118 |
-
$parsed_data[] = $row;
|
119 |
-
|
120 |
-
unset( $postmeta, $row );
|
121 |
-
|
122 |
-
$position = ftell( $handle );
|
123 |
-
|
124 |
-
if ( $end_pos && $position >= $end_pos )
|
125 |
-
break;
|
126 |
-
}
|
127 |
-
fclose( $handle );
|
128 |
-
}
|
129 |
-
return array( $parsed_data, $raw_headers, $position );
|
130 |
-
}
|
131 |
-
|
132 |
-
private function evaluate_field($value, $evaluation_field){
|
133 |
-
|
134 |
-
$processed_value = $value;
|
135 |
-
if(!empty($evaluation_field)){
|
136 |
-
$operator = substr($evaluation_field, 0, 1);
|
137 |
-
if(in_array($operator, array('=', '+', '-', '*', '/', '&'))){
|
138 |
-
$eval_val = substr($evaluation_field, 1);
|
139 |
-
|
140 |
-
switch($operator){
|
141 |
-
case '=':
|
142 |
-
$processed_value = trim($eval_val);
|
143 |
-
break;
|
144 |
-
case '+':
|
145 |
-
$processed_value = $value + $eval_val;
|
146 |
-
break;
|
147 |
-
case '-':
|
148 |
-
$processed_value = $value - $eval_val;
|
149 |
-
break;
|
150 |
-
case '*':
|
151 |
-
$processed_value = $value * $eval_val;
|
152 |
-
break;
|
153 |
-
case '/':
|
154 |
-
$processed_value = $value / $eval_val;
|
155 |
-
break;
|
156 |
-
case '&':
|
157 |
-
if (strpos($eval_val, '[VAL]') !== false) {
|
158 |
-
$processed_value = str_replace('[VAL]',$value,$eval_val);
|
159 |
-
}
|
160 |
-
else{
|
161 |
-
$processed_value = $value . $eval_val;
|
162 |
-
}
|
163 |
-
break;
|
164 |
-
}
|
165 |
-
}
|
166 |
-
}
|
167 |
-
return $processed_value;
|
168 |
-
}
|
169 |
-
|
170 |
-
/**
|
171 |
-
* Parse product
|
172 |
-
* @param array $item
|
173 |
-
* @param integer $merge_empty_cells
|
174 |
-
* @return array
|
175 |
-
*/
|
176 |
-
public function parse_product( $item, $merge_empty_cells = 0 ) {
|
177 |
-
|
178 |
-
global $WF_CSV_Product_Import, $wpdb;
|
179 |
-
$this->row++;
|
180 |
-
|
181 |
-
$terms_array = $postmeta = $product = array();
|
182 |
-
$attributes = $default_attributes = $gpf_data = null;
|
183 |
-
|
184 |
-
// Merging
|
185 |
-
$merging = ( ! empty( $_GET['merge'] ) && $_GET['merge'] ) ? 1 : 0;
|
186 |
-
//if($item['post_parent']!== '' && $item['parent_sku'] !== ''){
|
187 |
-
|
188 |
-
$this->post_defaults['post_type'] = 'product';
|
189 |
-
$this->post_type = 'product';
|
190 |
-
// Post ID field mapping
|
191 |
-
$post_id = ( ! empty( $item['id'] ) ) ? $item['id'] : 0;
|
192 |
-
$post_id = ( ! empty( $item['post_id'] ) ) ? $item['post_id'] : $post_id;
|
193 |
-
if ( $merging ) {
|
194 |
-
|
195 |
-
$product['merging'] = true;
|
196 |
-
|
197 |
-
|
198 |
-
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __('> Row %s - preparing for merge.', 'wf_csv_import_export'), $this->row ) );
|
199 |
-
|
200 |
-
// Required fields
|
201 |
-
if ( ! $post_id && empty( $item['sku'] ) ) {
|
202 |
-
|
203 |
-
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', __( '> > Cannot merge without id or sku. Importing instead.', 'wf_csv_import_export') );
|
204 |
-
|
205 |
-
$merging = false;
|
206 |
-
} else {
|
207 |
-
|
208 |
-
// Check product exists
|
209 |
-
if ( ! $post_id ) {
|
210 |
-
// Check product to merge exists
|
211 |
-
$db_query = $wpdb->prepare("
|
212 |
-
SELECT $wpdb->posts.ID
|
213 |
-
FROM $wpdb->posts
|
214 |
-
LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id)
|
215 |
-
WHERE $wpdb->posts.post_type = 'product'
|
216 |
-
AND $wpdb->posts.post_status IN ( 'publish', 'private', 'draft', 'pending', 'future' )
|
217 |
-
AND $wpdb->postmeta.meta_key = '_sku' AND $wpdb->postmeta.meta_value = '%s'
|
218 |
-
", $item['sku']);
|
219 |
-
$found_product_id = $wpdb->get_var($db_query);
|
220 |
-
if ( ! $found_product_id ) {
|
221 |
-
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf(__( '> > Skipped. Cannot find product with sku %s. Importing instead.', 'wf_csv_import_export'), $item['sku']) );
|
222 |
-
$merging = false;
|
223 |
-
|
224 |
-
} else {
|
225 |
-
|
226 |
-
$post_id = $found_product_id;
|
227 |
-
|
228 |
-
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf(__( '> > Found product with ID %s.', 'wf_csv_import_export'), $post_id) );
|
229 |
-
|
230 |
-
}
|
231 |
-
}
|
232 |
-
|
233 |
-
}
|
234 |
-
}
|
235 |
-
|
236 |
-
if ( ! $merging ) {
|
237 |
-
|
238 |
-
$product['merging'] = false;
|
239 |
-
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __('> Row %s - preparing for import.', 'wf_csv_import_export'), $this->row ) );
|
240 |
-
|
241 |
-
// Required fields
|
242 |
-
if ( isset($item['post_parent']) && $item['post_parent']=== '' && $item['post_title']=== '') {
|
243 |
-
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', __( '> > Skipped. No post_title set for new product.', 'wf_csv_import_export') );
|
244 |
-
return new WP_Error( 'parse-error', __( 'No post_title set for new product.', 'wf_csv_import_export' ) );
|
245 |
-
}
|
246 |
-
if ( !empty($item['post_parent']) && $item['post_parent']!== '' && $item['post_parent']!== null && $item['parent_sku'] === '' ) {
|
247 |
-
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', __( '> > Skipped. No parent set for new variation product.', 'wf_csv_import_export') );
|
248 |
-
//return new WP_Error( 'parse-error', __( 'No post_title set for new product.', 'wf_csv_import_export' ) );
|
249 |
-
return new WP_Error( 'parse-error', __( 'No parent set for new variation product.', 'wf_csv_import_export' ) );
|
250 |
-
}
|
251 |
-
|
252 |
-
}
|
253 |
-
|
254 |
-
$product['post_id'] = $post_id;
|
255 |
-
|
256 |
-
|
257 |
-
// Get post fields
|
258 |
-
foreach ( $this->post_defaults as $column => $default ) {
|
259 |
-
if ( isset( $item[ $column ] ) ) $product[ $column ] = $item[ $column ];
|
260 |
-
}
|
261 |
-
|
262 |
-
// Get custom fields
|
263 |
-
foreach ( $this->postmeta_defaults as $column => $default ) {
|
264 |
-
if ( isset( $item[$column] ) )
|
265 |
-
$postmeta[$column] = (string) $item[$column];
|
266 |
-
elseif ( isset( $item['_' . $column] ) )
|
267 |
-
$postmeta[$column] = (string) $item['_' . $column];
|
268 |
-
|
269 |
-
// Check custom fields are valid
|
270 |
-
if ( isset( $postmeta[$column] ) && isset( $this->postmeta_allowed[$column] ) && ! in_array( $postmeta[$column], $this->postmeta_allowed[$column] ) ) {
|
271 |
-
$postmeta[$column] = $this->postmeta_defaults[$column];
|
272 |
-
}
|
273 |
-
}
|
274 |
-
|
275 |
-
if ( ! $merging ) {
|
276 |
-
// Merge post meta with defaults
|
277 |
-
$product = wp_parse_args( $product, $this->post_defaults );
|
278 |
-
$postmeta = wp_parse_args( $postmeta, $this->postmeta_defaults );
|
279 |
-
}
|
280 |
-
|
281 |
-
// Handle special meta fields
|
282 |
-
// price
|
283 |
-
if ( $merging ) {
|
284 |
-
if ( ! isset( $postmeta['regular_price'] ) )
|
285 |
-
$postmeta['regular_price'] = get_post_meta( $post_id, '_regular_price', true );
|
286 |
-
$postmeta['regular_price'] = $this->hf_currency_formatter($postmeta['regular_price']);
|
287 |
-
if ( ! isset( $postmeta['sale_price'] ) )
|
288 |
-
$postmeta['sale_price'] = get_post_meta( $post_id, '_sale_price', true );
|
289 |
-
$postmeta['sale_price'] = $this->hf_currency_formatter($postmeta['sale_price']);
|
290 |
-
}
|
291 |
-
|
292 |
-
if ( isset( $postmeta['regular_price'] ) && isset( $postmeta['sale_price'] ) && $postmeta['sale_price'] !== '' ) {
|
293 |
-
$postmeta['sale_price'] = $this->hf_currency_formatter($postmeta['sale_price']);
|
294 |
-
$postmeta['regular_price'] = $this->hf_currency_formatter($postmeta['regular_price']);
|
295 |
-
$price = min( $postmeta['sale_price'], $postmeta['regular_price']);
|
296 |
-
$postmeta['price'] = $price;
|
297 |
-
} elseif ( isset( $postmeta['regular_price'] ) ) {
|
298 |
-
$postmeta['price'] = $this->hf_currency_formatter($postmeta['regular_price']);
|
299 |
-
}
|
300 |
-
|
301 |
-
// Reset dynamically generated meta
|
302 |
-
if ( !isset($item['post_parent']) ) {
|
303 |
-
$postmeta['min_variation_price'] = $postmeta['max_variation_price'] = $postmeta['min_variation_regular_price'] =$postmeta['max_variation_regular_price'] = $postmeta['min_variation_sale_price'] = $postmeta['max_variation_sale_price'] = '';
|
304 |
-
}
|
305 |
-
|
306 |
-
// upsells
|
307 |
-
if ( isset( $postmeta['upsell_ids'] ) && ! is_array( $postmeta['upsell_ids'] ) ) {
|
308 |
-
$ids = array_filter( array_map( 'trim', explode( '|', $postmeta['upsell_ids'] ) ) );
|
309 |
-
$postmeta['upsell_ids'] = $ids;
|
310 |
-
}
|
311 |
-
|
312 |
-
// crosssells
|
313 |
-
if ( isset( $postmeta['crosssell_ids'] ) && ! is_array( $postmeta['crosssell_ids'] ) ) {
|
314 |
-
$ids = array_filter( array_map( 'trim', explode( '|', $postmeta['crosssell_ids'] ) ) );
|
315 |
-
$postmeta['crosssell_ids'] = $ids;
|
316 |
-
}
|
317 |
-
|
318 |
-
// Sale dates
|
319 |
-
if ( isset( $postmeta['sale_price_dates_from'] ) ) {
|
320 |
-
$postmeta['sale_price_dates_from'] = empty( $postmeta['sale_price_dates_from'] ) ? '' : strtotime( $postmeta['sale_price_dates_from'] );
|
321 |
-
}
|
322 |
-
|
323 |
-
if ( isset( $postmeta['sale_price_dates_to'] ) ) {
|
324 |
-
$postmeta['sale_price_dates_to'] = empty( $postmeta['sale_price_dates_to'] ) ? '' : strtotime( $postmeta['sale_price_dates_to'] );
|
325 |
-
}
|
326 |
-
|
327 |
-
// Relative stock updates
|
328 |
-
if ( $merging ) {
|
329 |
-
if ( isset( $postmeta['stock'] ) ) {
|
330 |
-
|
331 |
-
$postmeta['stock'] = trim( $postmeta['stock'] );
|
332 |
-
|
333 |
-
$mode = substr( $postmeta['stock'], 0, 3 );
|
334 |
-
|
335 |
-
if ( $mode == '(+)' ) {
|
336 |
-
$old_stock = absint( get_post_meta( $post_id, '_stock', true ) );
|
337 |
-
$amount = absint( substr( $postmeta['stock'], 3 ) );
|
338 |
-
$new_stock = $old_stock + $amount;
|
339 |
-
$postmeta['stock'] = $new_stock;
|
340 |
-
}
|
341 |
-
|
342 |
-
if ( $mode == '(-)' ) {
|
343 |
-
$old_stock = absint( get_post_meta( $post_id, '_stock', true ) );
|
344 |
-
$amount = absint( substr( $postmeta['stock'], 3 ) );
|
345 |
-
$new_stock = $old_stock - $amount;
|
346 |
-
$postmeta['stock'] = $new_stock;
|
347 |
-
}
|
348 |
-
}
|
349 |
-
}
|
350 |
-
|
351 |
-
// Format post status
|
352 |
-
if ( ! empty( $product['post_status'] ) ) {
|
353 |
-
$product['post_status'] = strtolower( $product['post_status'] );
|
354 |
-
|
355 |
-
if ( empty($item['post_parent']) ) {
|
356 |
-
if ( ! in_array( $product['post_status'], array( 'publish', 'private', 'draft', 'pending', 'future', 'inherit', 'trash' ) ) ) {
|
357 |
-
$product['post_status'] = 'publish';
|
358 |
-
}
|
359 |
-
} else {
|
360 |
-
if ( ! in_array( $product['post_status'], array( 'private', 'publish' ) ) ) {
|
361 |
-
$product['post_status'] = 'publish';
|
362 |
-
}
|
363 |
-
}
|
364 |
-
}
|
365 |
-
|
366 |
-
// Put set core product postmeta into product array
|
367 |
-
foreach ( $postmeta as $key => $value ) {
|
368 |
-
$product['postmeta'][] = array( 'key' => '_' . esc_attr($key), 'value' => $value );
|
369 |
-
}
|
370 |
-
|
371 |
-
/**
|
372 |
-
* Handle other columns
|
373 |
-
*/
|
374 |
-
foreach ( $item as $key => $value ) {
|
375 |
-
|
376 |
-
if ( empty($item['post_parent']) && ! $merge_empty_cells && $value == "" )
|
377 |
-
continue;
|
378 |
-
|
379 |
-
/**
|
380 |
-
* File path handling
|
381 |
-
*/
|
382 |
-
if ( $key == 'file_paths' || $key == 'downloadable_files' ) {
|
383 |
-
|
384 |
-
$file_paths = explode( '|', $value );
|
385 |
-
$_file_paths = array();
|
386 |
-
foreach ( $file_paths as $file_path ) {
|
387 |
-
// 2.1
|
388 |
-
if ( function_exists( 'wc_get_filename_from_url' ) ) {
|
389 |
-
$file_path = array_map( 'trim', explode( '::', $file_path ) );
|
390 |
-
if ( sizeof( $file_path ) === 2 ) {
|
391 |
-
$file_name = $file_path[0];
|
392 |
-
$file_path = $file_path[1];
|
393 |
-
} else {
|
394 |
-
$file_name = wc_get_filename_from_url( $file_path[0] );
|
395 |
-
$file_path = $file_path[0];
|
396 |
-
}
|
397 |
-
$_file_paths[ md5( $file_path ) ] = array(
|
398 |
-
'name' => $file_name,
|
399 |
-
'file' => $file_path
|
400 |
-
);
|
401 |
-
} else {
|
402 |
-
$file_path = trim( $file_path );
|
403 |
-
$_file_paths[ md5( $file_path ) ] = $file_path;
|
404 |
-
}
|
405 |
-
}
|
406 |
-
$value = $_file_paths;
|
407 |
-
|
408 |
-
$product['postmeta'][] = array( 'key' => '_' . esc_attr( $key ), 'value' => $value );
|
409 |
-
}
|
410 |
-
|
411 |
-
elseif ( strstr( $key, 'tax:' ) ) {
|
412 |
-
|
413 |
-
// Get taxonomy
|
414 |
-
$taxonomy = trim( str_replace( 'tax:', '', $key ) );
|
415 |
-
|
416 |
-
// Exists?
|
417 |
-
if ( ! taxonomy_exists( $taxonomy ) ) {
|
418 |
-
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __('> > Skipping taxonomy "%s" - it does not exist.', 'wf_csv_import_export'), $taxonomy ) );
|
419 |
-
continue;
|
420 |
-
}
|
421 |
-
|
422 |
-
// Product type check
|
423 |
-
if ( $taxonomy == 'product_type' ) {
|
424 |
-
$term = strtolower( $value );
|
425 |
-
|
426 |
-
if ( ! array_key_exists( $term, $this->allowed_product_types ) ) {
|
427 |
-
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __('> > > Product type "%s" not allowed - using simple.', 'wf_csv_import_export'), $term ) );
|
428 |
-
$term_id = $this->allowed_product_types['simple'];
|
429 |
-
} else {
|
430 |
-
$term_id = $this->allowed_product_types[ $term ];
|
431 |
-
}
|
432 |
-
|
433 |
-
// Add to array
|
434 |
-
$terms_array[] = array(
|
435 |
-
'taxonomy' => $taxonomy,
|
436 |
-
'terms' => array( $term_id )
|
437 |
-
);
|
438 |
-
|
439 |
-
continue;
|
440 |
-
}
|
441 |
-
|
442 |
-
// Get terms - ID => parent
|
443 |
-
$terms = array();
|
444 |
-
$raw_terms = explode( '|', $value );
|
445 |
-
$raw_terms = array_map( 'trim', $raw_terms );
|
446 |
-
|
447 |
-
// Handle term hierachy (>)
|
448 |
-
foreach ( $raw_terms as $raw_term ) {
|
449 |
-
|
450 |
-
if ( strstr( $raw_term, '>' ) ) {
|
451 |
-
|
452 |
-
$raw_term = explode( '>', $raw_term );
|
453 |
-
$raw_term = array_map( 'trim', $raw_term );
|
454 |
-
|
455 |
-
if(WC()->version < '2.7.0')
|
456 |
-
{
|
457 |
-
$raw_term = array_map( 'wp_specialchars', $raw_term );
|
458 |
-
$raw_term = array_filter( $raw_term );
|
459 |
-
|
460 |
-
}
|
461 |
-
else
|
462 |
-
{
|
463 |
-
$raw_term = array_map( 'esc_html', $raw_term );
|
464 |
-
$raw_term = array_filter( $raw_term );
|
465 |
-
|
466 |
-
}
|
467 |
-
|
468 |
-
$parent = 0;
|
469 |
-
$loop = 0;
|
470 |
-
|
471 |
-
foreach ( $raw_term as $term ) {
|
472 |
-
$loop ++;
|
473 |
-
$term_id = '';
|
474 |
-
|
475 |
-
if ( isset( $this->inserted_terms[ $taxonomy ][ $parent ][ $term ] ) ) {
|
476 |
-
$term_id = $this->inserted_terms[ $taxonomy ][ $parent ][ $term ];
|
477 |
-
} elseif ( $term ) {
|
478 |
-
|
479 |
-
/**
|
480 |
-
* Check term existance
|
481 |
-
*/
|
482 |
-
$term_may_exist = term_exists( $term, $taxonomy, absint( $parent ) );
|
483 |
-
|
484 |
-
$WF_CSV_Product_Import->hf_log_data_change( 'CSV-Import', sprintf( __( '> > (' . __LINE__ . ') Term %s (%s) exists? %s', 'wf_csv_import_export' ), sanitize_text_field( $term ), esc_html( $taxonomy ), $term_may_exist ? print_r( $term_may_exist, true ) : '-' ) );
|
485 |
-
|
486 |
-
if ( is_array( $term_may_exist ) ) {
|
487 |
-
$possible_term = get_term( $term_may_exist['term_id'], 'product_cat' );
|
488 |
-
|
489 |
-
if ( $possible_term->parent == $parent ) {
|
490 |
-
$term_id = $term_may_exist['term_id'];
|
491 |
-
}
|
492 |
-
}
|
493 |
-
|
494 |
-
if ( ! $term_id ) {
|
495 |
-
|
496 |
-
// Create appropriate slug
|
497 |
-
$slug = array();
|
498 |
-
|
499 |
-
for ( $i = 0; $i < $loop; $i ++ )
|
500 |
-
$slug[] = $raw_term[ $i ];
|
501 |
-
|
502 |
-
$slug = sanitize_title( implode( '-', $slug ) );
|
503 |
-
|
504 |
-
$t = wp_insert_term( $term, $taxonomy, array( 'parent' => $parent, 'slug' => $slug ) );
|
505 |
-
|
506 |
-
if ( ! is_wp_error( $t ) ) {
|
507 |
-
$term_id = $t['term_id'];
|
508 |
-
} else {
|
509 |
-
$WF_CSV_Product_Import->hf_log_data_change( 'CSV-Import', sprintf( __( '> > (' . __LINE__ . ') Failed to import term %s, parent %s - %s', 'wf_csv_import_export' ), sanitize_text_field( $term ), sanitize_text_field( $parent ), sanitize_text_field( $taxonomy ) ) );
|
510 |
-
break;
|
511 |
-
}
|
512 |
-
}
|
513 |
-
|
514 |
-
$this->inserted_terms[$taxonomy][$parent][$term] = $term_id;
|
515 |
-
|
516 |
-
}
|
517 |
-
|
518 |
-
if ( ! $term_id )
|
519 |
-
break;
|
520 |
-
|
521 |
-
// Add to product terms, ready to set if this is the final term
|
522 |
-
if ( sizeof( $raw_term ) == $loop )
|
523 |
-
$terms[] = $term_id;
|
524 |
-
|
525 |
-
$parent = $term_id;
|
526 |
-
}
|
527 |
-
|
528 |
-
} else {
|
529 |
-
|
530 |
-
$term_id = '';
|
531 |
-
$raw_term = (WC()->version < '2.7.0') ? wp_specialchars( $raw_term ) : esc_html( $raw_term );
|
532 |
-
|
533 |
-
if ( isset( $this->inserted_terms[$taxonomy][0][$raw_term] ) ) {
|
534 |
-
|
535 |
-
$term_id = $this->inserted_terms[$taxonomy][0][$raw_term];
|
536 |
-
|
537 |
-
} elseif ( $raw_term ) {
|
538 |
-
|
539 |
-
// Check term existance
|
540 |
-
$term_exists = term_exists( $raw_term, $taxonomy, 0 );
|
541 |
-
$term_id = is_array( $term_exists ) ? $term_exists['term_id'] : 0;
|
542 |
-
|
543 |
-
if ( ! $term_id ) {
|
544 |
-
$t = wp_insert_term( trim( $raw_term ), $taxonomy, array( 'parent' => 0 ) );
|
545 |
-
|
546 |
-
if ( ! is_wp_error( $t ) ) {
|
547 |
-
$term_id = $t['term_id'];
|
548 |
-
} else {
|
549 |
-
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __( '> > Failed to import term %s %s', 'wf_csv_import_export' ), esc_html($raw_term), esc_html($taxonomy) ) );
|
550 |
-
break;
|
551 |
-
}
|
552 |
-
}
|
553 |
-
|
554 |
-
$this->inserted_terms[$taxonomy][0][$raw_term] = $term_id;
|
555 |
-
|
556 |
-
}
|
557 |
-
|
558 |
-
// Store terms for later insertion
|
559 |
-
if ( $term_id )
|
560 |
-
$terms[] = $term_id;
|
561 |
-
|
562 |
-
}
|
563 |
-
|
564 |
-
}
|
565 |
-
|
566 |
-
// Any defined?
|
567 |
-
if ( sizeof( $terms ) == 0 )
|
568 |
-
continue;
|
569 |
-
|
570 |
-
// Add to array
|
571 |
-
$terms_array[] = array(
|
572 |
-
'taxonomy' => $taxonomy,
|
573 |
-
'terms' => $terms
|
574 |
-
);
|
575 |
-
}
|
576 |
-
|
577 |
-
/**
|
578 |
-
* Handle Attributes
|
579 |
-
*/
|
580 |
-
elseif ( strstr( $key, 'attribute:' ) ) {
|
581 |
-
|
582 |
-
$attribute_key = sanitize_title( trim( str_replace( 'attribute:', '', $key ) ) );
|
583 |
-
$attribute_name = str_replace( 'attribute:', '', $WF_CSV_Product_Import->raw_headers[ $key ] );
|
584 |
-
|
585 |
-
if ( ! $attribute_key )
|
586 |
-
continue;
|
587 |
-
|
588 |
-
// Taxonomy
|
589 |
-
if ( substr( $attribute_key, 0, 3 ) == 'pa_' ) {
|
590 |
-
|
591 |
-
$taxonomy = $attribute_key;
|
592 |
-
|
593 |
-
// Exists?
|
594 |
-
if ( ! taxonomy_exists( $taxonomy ) ) {
|
595 |
-
|
596 |
-
$nicename = strtolower( sanitize_title( str_replace( 'pa_', '', $taxonomy ) ) );
|
597 |
-
|
598 |
-
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __('> > Attribute taxonomy "%s" does not exist. Adding it. Nicename: %s', 'wf_csv_import_export'), $taxonomy, $nicename ) );
|
599 |
-
|
600 |
-
$exists_in_db = $wpdb->get_var( "SELECT attribute_id FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies WHERE attribute_name = '" . $nicename . "';" );
|
601 |
-
|
602 |
-
if ( ! $exists_in_db ) {
|
603 |
-
// Create the taxonomy
|
604 |
-
$wpdb->insert( $wpdb->prefix . "woocommerce_attribute_taxonomies", array( 'attribute_name' => $nicename, 'attribute_label' => $nicename, 'attribute_type' => 'select', 'attribute_orderby' => 'menu_order' ) );
|
605 |
-
} else {
|
606 |
-
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __('> > Attribute taxonomy %s already exists in DB.', 'wf_csv_import_export'), $taxonomy ) );
|
607 |
-
}
|
608 |
-
|
609 |
-
// Register the taxonomy now so that the import works!
|
610 |
-
register_taxonomy( $taxonomy,
|
611 |
-
array( 'product', 'product_variation' ),
|
612 |
-
array(
|
613 |
-
'hierarchical' => true,
|
614 |
-
'show_ui' => false,
|
615 |
-
'query_var' => true,
|
616 |
-
'rewrite' => false,
|
617 |
-
)
|
618 |
-
);
|
619 |
-
}
|
620 |
-
|
621 |
-
// Get terms
|
622 |
-
$terms = array();
|
623 |
-
$raw_terms = explode( '|', $value );
|
624 |
-
if(WC()->version < '2.7.0')
|
625 |
-
{
|
626 |
-
$raw_terms = array_map( 'wp_specialchars', $raw_terms );
|
627 |
-
$raw_terms = array_map( 'trim', $raw_terms );
|
628 |
-
|
629 |
-
}else{
|
630 |
-
|
631 |
-
$raw_terms = array_map( 'esc_html', $raw_terms );
|
632 |
-
$raw_terms = array_map( 'trim', $raw_terms );
|
633 |
-
|
634 |
-
}
|
635 |
-
|
636 |
-
if ( sizeof( $raw_terms ) > 0 ) {
|
637 |
-
|
638 |
-
foreach ( $raw_terms as $raw_term ) {
|
639 |
-
|
640 |
-
if ( empty( $raw_term ) && 0 != $raw_term ) {
|
641 |
-
continue;
|
642 |
-
}
|
643 |
-
|
644 |
-
// Check term existance
|
645 |
-
$term_exists = term_exists( $raw_term, $taxonomy, 0 );
|
646 |
-
$term_id = is_array( $term_exists ) ? $term_exists['term_id'] : 0;
|
647 |
-
|
648 |
-
if ( ! $term_id ) {
|
649 |
-
$t = wp_insert_term( trim( $raw_term ), $taxonomy );
|
650 |
-
|
651 |
-
if ( ! is_wp_error( $t ) ) {
|
652 |
-
$term_id = $t['term_id'];
|
653 |
-
|
654 |
-
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __( '> > Inserted Raw Term %s ID = %s', 'wf_csv_import_export' ), esc_html( $raw_term ), $term_id ) );
|
655 |
-
} else {
|
656 |
-
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __( '> > Failed to import term %s %s', 'wf_csv_import_export' ), esc_html($raw_term), esc_html($taxonomy) ) );
|
657 |
-
break;
|
658 |
-
}
|
659 |
-
} else {
|
660 |
-
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __( '> > Raw Term %s ID = %s', 'wf_csv_import_export' ), esc_html( $raw_term ), $term_id ) );
|
661 |
-
}
|
662 |
-
|
663 |
-
if ( $term_id ) {
|
664 |
-
$terms[] = $term_id;
|
665 |
-
}
|
666 |
-
}
|
667 |
-
|
668 |
-
}
|
669 |
-
|
670 |
-
// Add to array
|
671 |
-
$terms_array[] = array(
|
672 |
-
'taxonomy' => $taxonomy,
|
673 |
-
'terms' => $terms
|
674 |
-
);
|
675 |
-
|
676 |
-
// Ensure we have original attributes
|
677 |
-
if ( is_null( $attributes ) && $merging ) {
|
678 |
-
$attributes = array_filter( (array) maybe_unserialize( get_post_meta( $post_id, '_product_attributes', true ) ) );
|
679 |
-
} elseif ( is_null( $attributes ) ) {
|
680 |
-
$attributes = array();
|
681 |
-
}
|
682 |
-
|
683 |
-
// Set attribute
|
684 |
-
if ( ! isset( $attributes[$taxonomy] ) )
|
685 |
-
$attributes[$taxonomy] = array();
|
686 |
-
|
687 |
-
$attributes[$taxonomy]['name'] = $taxonomy;
|
688 |
-
$attributes[$taxonomy]['value'] = null;
|
689 |
-
$attributes[$taxonomy]['is_taxonomy'] = 1;
|
690 |
-
|
691 |
-
if ( ! isset( $attributes[$taxonomy]['position'] ) )
|
692 |
-
$attributes[$taxonomy]['position'] = 0;
|
693 |
-
if ( ! isset( $attributes[$taxonomy]['is_visible'] ) )
|
694 |
-
$attributes[$taxonomy]['is_visible'] = 1;
|
695 |
-
if ( ! isset( $attributes[$taxonomy]['is_variation'] ) )
|
696 |
-
$attributes[$taxonomy]['is_variation'] = 0;
|
697 |
-
|
698 |
-
} else {
|
699 |
-
|
700 |
-
if ( ! $value || ! $attribute_key ) continue;
|
701 |
-
|
702 |
-
// Set attribute
|
703 |
-
if ( ! isset( $attributes[$attribute_key] ) )
|
704 |
-
$attributes[$attribute_key] = array();
|
705 |
-
|
706 |
-
$attributes[$attribute_key]['name'] = $attribute_name;
|
707 |
-
$attributes[$attribute_key]['value'] = $value;
|
708 |
-
$attributes[$attribute_key]['is_taxonomy'] = 0;
|
709 |
-
|
710 |
-
if ( ! isset( $attributes[$attribute_key]['position'] ) )
|
711 |
-
$attributes[$attribute_key]['position'] = 0;
|
712 |
-
if ( ! isset( $attributes[$attribute_key]['is_visible'] ) )
|
713 |
-
$attributes[$attribute_key]['is_visible'] = 1;
|
714 |
-
if ( ! isset( $attributes[$attribute_key]['is_variation'] ) )
|
715 |
-
$attributes[$attribute_key]['is_variation'] = 0;
|
716 |
-
}
|
717 |
-
|
718 |
-
}
|
719 |
-
|
720 |
-
/**
|
721 |
-
* Handle Attributes Data - position|is_visible|is_variation
|
722 |
-
*/
|
723 |
-
elseif ( strstr( $key, 'attribute_data:' ) ) {
|
724 |
-
|
725 |
-
$attribute_key = sanitize_title( trim( str_replace( 'attribute_data:', '', $key ) ) );
|
726 |
-
|
727 |
-
if ( ! $attribute_key ) {
|
728 |
-
continue;
|
729 |
-
}
|
730 |
-
|
731 |
-
$values = explode( '|', $value );
|
732 |
-
$position = isset( $values[0] ) ? (int) $values[0] : 0;
|
733 |
-
$visible = isset( $values[1] ) ? (int) $values[1] : 1;
|
734 |
-
$variation = isset( $values[2] ) ? (int) $values[2] : 0;
|
735 |
-
|
736 |
-
// Ensure we have original attributes
|
737 |
-
if ( ! isset( $attributes[ $attribute_key ] ) ) {
|
738 |
-
if ( $merging ) {
|
739 |
-
$existing_attributes = array_filter( (array) maybe_unserialize( get_post_meta( $post_id, '_product_attributes', true ) ) );
|
740 |
-
$attributes[ $attribute_key ] = isset( $existing_attributes[ $attribute_key ] ) ? $existing_attributes[ $attribute_key ] : array();
|
741 |
-
} else {
|
742 |
-
$attributes[ $attribute_key ] = array();
|
743 |
-
}
|
744 |
-
}
|
745 |
-
|
746 |
-
$attributes[ $attribute_key ]['position'] = $position;
|
747 |
-
$attributes[ $attribute_key ]['is_visible'] = $visible;
|
748 |
-
$attributes[ $attribute_key ]['is_variation'] = $variation;
|
749 |
-
}
|
750 |
-
|
751 |
-
/**
|
752 |
-
* Handle Attributes Default Values
|
753 |
-
*/
|
754 |
-
elseif ( strstr( $key, 'attribute_default:' ) ) {
|
755 |
-
|
756 |
-
$attribute_key = sanitize_title( trim( str_replace( 'attribute_default:', '', $key ) ) );
|
757 |
-
|
758 |
-
if ( ! $attribute_key ) continue;
|
759 |
-
|
760 |
-
// Ensure we have original attributes
|
761 |
-
if ( is_null( $default_attributes ) && $merging ) {
|
762 |
-
$default_attributes = array_filter( (array) maybe_unserialize( get_post_meta( $post_id, '_default_attributes', true ) ) );
|
763 |
-
} elseif ( is_null( $default_attributes ) ) {
|
764 |
-
$default_attributes = array();
|
765 |
-
}
|
766 |
-
|
767 |
-
$default_attributes[ $attribute_key ] = $value;
|
768 |
-
}
|
769 |
-
|
770 |
-
/**
|
771 |
-
* Handle gpf: google product feed columns
|
772 |
-
*/
|
773 |
-
elseif ( strstr( $key, 'gpf:' ) ) {
|
774 |
-
|
775 |
-
$gpf_key = trim( str_replace( 'gpf:', '', $key ) );
|
776 |
-
|
777 |
-
// Get original values
|
778 |
-
if ( is_null( $gpf_data ) && $merging ) {
|
779 |
-
$gpf_data = array_filter( (array) maybe_unserialize( get_post_meta( $post_id, '_woocommerce_gpf_data', true ) ) );
|
780 |
-
} elseif ( is_null( $gpf_data ) ) {
|
781 |
-
$gpf_data = array(
|
782 |
-
'availability' => '',
|
783 |
-
'condition' => '',
|
784 |
-
'brand' => '',
|
785 |
-
'product_type' => '',
|
786 |
-
'google_product_category' => '',
|
787 |
-
'gtin' => '',
|
788 |
-
'mpn' => '',
|
789 |
-
'gender' => '',
|
790 |
-
'age_group' => '',
|
791 |
-
'color' => '',
|
792 |
-
'size' => ''
|
793 |
-
);
|
794 |
-
}
|
795 |
-
|
796 |
-
$gpf_data[$gpf_key] = $value;
|
797 |
-
|
798 |
-
}
|
799 |
-
|
800 |
-
/**
|
801 |
-
* Handle upsell SKUs which we cannot assign until we get IDs later on
|
802 |
-
*/
|
803 |
-
elseif ( strstr( $key, 'upsell_skus' ) ) {
|
804 |
-
if ( $value ) {
|
805 |
-
$skus = array_filter( array_map( 'trim', explode( '|', $value ) ) );
|
806 |
-
$product['upsell_skus'] = $skus;
|
807 |
-
}
|
808 |
-
}
|
809 |
-
|
810 |
-
/**
|
811 |
-
* Handle crosssells SKUs which we cannot assign until we get IDs later on
|
812 |
-
*/
|
813 |
-
elseif ( strstr( $key, 'crosssell_skus' ) ) {
|
814 |
-
if ( $value ) {
|
815 |
-
$skus = array_filter( array_map( 'trim', explode( '|', $value ) ) );
|
816 |
-
$product['crosssell_skus'] = $skus;
|
817 |
-
}
|
818 |
-
}
|
819 |
-
|
820 |
-
}
|
821 |
-
|
822 |
-
// Remove empty attribues
|
823 |
-
if(!empty($attributes))
|
824 |
-
foreach ( $attributes as $key => $value ) {
|
825 |
-
if ( ! isset($value['name']) ) unset( $attributes[$key] );
|
826 |
-
}
|
827 |
-
|
828 |
-
/**
|
829 |
-
* Handle images
|
830 |
-
*/
|
831 |
-
if ( ! empty( $item['images'] ) ) {
|
832 |
-
$images = array_map( 'trim', explode( '|', $item['images'] ) );
|
833 |
-
} else {
|
834 |
-
$images = '';
|
835 |
-
}
|
836 |
-
|
837 |
-
$product['postmeta'][] = array( 'key' => '_default_attributes', 'value' => $default_attributes );
|
838 |
-
$product['attributes'] = $attributes;
|
839 |
-
$product['gpf_data'] = $gpf_data;
|
840 |
-
$product['images'] = $images;
|
841 |
-
$product['terms'] = $terms_array;
|
842 |
-
$product['sku'] = ( ! empty( $item['sku'] ) ) ? $item['sku'] : '';
|
843 |
-
$product['post_title'] = ( ! empty( $item['post_title'] ) ) ? $item['post_title'] : '';
|
844 |
-
$product['post_type'] = $this->post_type;
|
845 |
-
unset( $item, $terms_array, $postmeta, $attributes, $gpf_data, $images );
|
846 |
-
return $product;
|
847 |
-
}
|
848 |
-
public function hf_currency_formatter($price){
|
849 |
-
|
850 |
-
$decimal_seperator = wc_get_price_decimal_separator();
|
851 |
-
return preg_replace("[^0-9\\'.$decimal_seperator.']", "", $price);
|
852 |
-
}
|
853 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WooCommerce CSV Importer class for managing parsing of CSV files.
|
4 |
+
*/
|
5 |
+
class WF_CSV_Parser {
|
6 |
+
|
7 |
+
var $row;
|
8 |
+
var $post_type;
|
9 |
+
var $reserved_fields; // Fields we map/handle (not custom fields)
|
10 |
+
var $post_defaults; // Default post data
|
11 |
+
var $postmeta_defaults; // default post meta
|
12 |
+
var $postmeta_allowed; // post meta validation
|
13 |
+
var $allowed_product_types; // Allowed product types
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Constructor
|
17 |
+
*/
|
18 |
+
public function __construct( $post_type = 'product' ) {
|
19 |
+
|
20 |
+
$this->post_type = $post_type;
|
21 |
+
$this->reserved_fields = include( 'data/data-wf-reserved-fields.php' );
|
22 |
+
$this->post_defaults = include( 'data/data-wf-post-defaults.php' );
|
23 |
+
$this->postmeta_defaults = include( 'data/data-wf-postmeta-defaults.php' );
|
24 |
+
$this->postmeta_allowed = include( 'data/data-wf-postmeta-allowed.php' );
|
25 |
+
|
26 |
+
$simple_term = get_term_by( 'slug', 'simple', 'product_type' );
|
27 |
+
$variable_term = get_term_by( 'slug', 'variable', 'product_type' );
|
28 |
+
$grouped_term = get_term_by( 'slug', 'grouped', 'product_type' );
|
29 |
+
$external_term = get_term_by( 'slug', 'external', 'product_type' );
|
30 |
+
|
31 |
+
$this->allowed_product_types = array(
|
32 |
+
'simple' => $simple_term->term_id,
|
33 |
+
'variable' => $variable_term->term_id,
|
34 |
+
'grouped' => $grouped_term->term_id,
|
35 |
+
'external' => $external_term->term_id
|
36 |
+
);
|
37 |
+
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Format data from the csv file
|
42 |
+
* @param string $data
|
43 |
+
* @param string $enc
|
44 |
+
* @return string
|
45 |
+
*/
|
46 |
+
public function format_data_from_csv( $data, $enc ) {
|
47 |
+
return ( $enc == 'UTF-8' ) ? $data : utf8_encode( $data );
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Parse the data
|
52 |
+
* @param string $file [description]
|
53 |
+
* @param string $delimiter [description]
|
54 |
+
* @param array $mapping [description]
|
55 |
+
* @param integer $start_pos [description]
|
56 |
+
* @param integer $end_pos [description]
|
57 |
+
* @return array
|
58 |
+
*/
|
59 |
+
public function parse_data( $file, $delimiter, $mapping, $start_pos = 0, $end_pos = null, $eval_field ) {
|
60 |
+
// Set locale
|
61 |
+
$enc = mb_detect_encoding( $file, 'UTF-8, ISO-8859-1', true );
|
62 |
+
if ( $enc )
|
63 |
+
setlocale( LC_ALL, 'en_US.' . $enc );
|
64 |
+
@ini_set( 'auto_detect_line_endings', true );
|
65 |
+
|
66 |
+
$parsed_data = array();
|
67 |
+
$raw_headers = array();
|
68 |
+
|
69 |
+
// Put all CSV data into an associative array
|
70 |
+
if ( ( $handle = fopen( $file, "r" ) ) !== FALSE ) {
|
71 |
+
|
72 |
+
$header = fgetcsv( $handle, 0, $delimiter );
|
73 |
+
if ( $start_pos != 0 )
|
74 |
+
fseek( $handle, $start_pos );
|
75 |
+
|
76 |
+
while ( ( $postmeta = fgetcsv( $handle, 0, $delimiter ) ) !== FALSE ) {
|
77 |
+
$row = array();
|
78 |
+
|
79 |
+
foreach ( $header as $key => $heading ) {
|
80 |
+
// Heading is the lowercase version of the column name
|
81 |
+
$s_heading = strtolower( $heading );
|
82 |
+
|
83 |
+
// Check if this heading is being mapped to a different field
|
84 |
+
if ( isset( $mapping[$s_heading] ) ) {
|
85 |
+
if ( $mapping[$s_heading] == 'import_as_meta' ) {
|
86 |
+
|
87 |
+
$s_heading = 'meta:' . $s_heading;
|
88 |
+
|
89 |
+
} elseif ( $mapping[$s_heading] == 'import_as_images' ) {
|
90 |
+
|
91 |
+
$s_heading = 'images';
|
92 |
+
|
93 |
+
} else {
|
94 |
+
$s_heading = esc_attr( $mapping[$s_heading] );
|
95 |
+
}
|
96 |
+
}
|
97 |
+
if( !empty($mapping) )
|
98 |
+
{
|
99 |
+
foreach ($mapping as $mkey => $mvalue) {
|
100 |
+
if(trim($mvalue) === trim($heading)){
|
101 |
+
$s_heading = $mkey;
|
102 |
+
}
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
if ( $s_heading == '' )
|
107 |
+
continue;
|
108 |
+
|
109 |
+
// Add the heading to the parsed data
|
110 |
+
$row[$s_heading] = ( isset( $postmeta[$key] ) ) ? $this->format_data_from_csv( $postmeta[$key], $enc ) : '';
|
111 |
+
|
112 |
+
if(!empty($eval_field[strtolower( $heading )]))
|
113 |
+
$row[$s_heading] = $this->evaluate_field($row[$s_heading], $eval_field[strtolower( $heading )]);
|
114 |
+
|
115 |
+
// Raw Headers stores the actual column name in the CSV
|
116 |
+
$raw_headers[ $s_heading ] = $heading;
|
117 |
+
}
|
118 |
+
$parsed_data[] = $row;
|
119 |
+
|
120 |
+
unset( $postmeta, $row );
|
121 |
+
|
122 |
+
$position = ftell( $handle );
|
123 |
+
|
124 |
+
if ( $end_pos && $position >= $end_pos )
|
125 |
+
break;
|
126 |
+
}
|
127 |
+
fclose( $handle );
|
128 |
+
}
|
129 |
+
return array( $parsed_data, $raw_headers, $position );
|
130 |
+
}
|
131 |
+
|
132 |
+
private function evaluate_field($value, $evaluation_field){
|
133 |
+
|
134 |
+
$processed_value = $value;
|
135 |
+
if(!empty($evaluation_field)){
|
136 |
+
$operator = substr($evaluation_field, 0, 1);
|
137 |
+
if(in_array($operator, array('=', '+', '-', '*', '/', '&'))){
|
138 |
+
$eval_val = substr($evaluation_field, 1);
|
139 |
+
|
140 |
+
switch($operator){
|
141 |
+
case '=':
|
142 |
+
$processed_value = trim($eval_val);
|
143 |
+
break;
|
144 |
+
case '+':
|
145 |
+
$processed_value = $value + $eval_val;
|
146 |
+
break;
|
147 |
+
case '-':
|
148 |
+
$processed_value = $value - $eval_val;
|
149 |
+
break;
|
150 |
+
case '*':
|
151 |
+
$processed_value = $value * $eval_val;
|
152 |
+
break;
|
153 |
+
case '/':
|
154 |
+
$processed_value = $value / $eval_val;
|
155 |
+
break;
|
156 |
+
case '&':
|
157 |
+
if (strpos($eval_val, '[VAL]') !== false) {
|
158 |
+
$processed_value = str_replace('[VAL]',$value,$eval_val);
|
159 |
+
}
|
160 |
+
else{
|
161 |
+
$processed_value = $value . $eval_val;
|
162 |
+
}
|
163 |
+
break;
|
164 |
+
}
|
165 |
+
}
|
166 |
+
}
|
167 |
+
return $processed_value;
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Parse product
|
172 |
+
* @param array $item
|
173 |
+
* @param integer $merge_empty_cells
|
174 |
+
* @return array
|
175 |
+
*/
|
176 |
+
public function parse_product( $item, $merge_empty_cells = 0 ) {
|
177 |
+
|
178 |
+
global $WF_CSV_Product_Import, $wpdb;
|
179 |
+
$this->row++;
|
180 |
+
|
181 |
+
$terms_array = $postmeta = $product = array();
|
182 |
+
$attributes = $default_attributes = $gpf_data = null;
|
183 |
+
|
184 |
+
// Merging
|
185 |
+
$merging = ( ! empty( $_GET['merge'] ) && $_GET['merge'] ) ? 1 : 0;
|
186 |
+
//if($item['post_parent']!== '' && $item['parent_sku'] !== ''){
|
187 |
+
|
188 |
+
$this->post_defaults['post_type'] = 'product';
|
189 |
+
$this->post_type = 'product';
|
190 |
+
// Post ID field mapping
|
191 |
+
$post_id = ( ! empty( $item['id'] ) ) ? $item['id'] : 0;
|
192 |
+
$post_id = ( ! empty( $item['post_id'] ) ) ? $item['post_id'] : $post_id;
|
193 |
+
if ( $merging ) {
|
194 |
+
|
195 |
+
$product['merging'] = true;
|
196 |
+
|
197 |
+
|
198 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __('> Row %s - preparing for merge.', 'wf_csv_import_export'), $this->row ) );
|
199 |
+
|
200 |
+
// Required fields
|
201 |
+
if ( ! $post_id && empty( $item['sku'] ) ) {
|
202 |
+
|
203 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', __( '> > Cannot merge without id or sku. Importing instead.', 'wf_csv_import_export') );
|
204 |
+
|
205 |
+
$merging = false;
|
206 |
+
} else {
|
207 |
+
|
208 |
+
// Check product exists
|
209 |
+
if ( ! $post_id ) {
|
210 |
+
// Check product to merge exists
|
211 |
+
$db_query = $wpdb->prepare("
|
212 |
+
SELECT $wpdb->posts.ID
|
213 |
+
FROM $wpdb->posts
|
214 |
+
LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id)
|
215 |
+
WHERE $wpdb->posts.post_type = 'product'
|
216 |
+
AND $wpdb->posts.post_status IN ( 'publish', 'private', 'draft', 'pending', 'future' )
|
217 |
+
AND $wpdb->postmeta.meta_key = '_sku' AND $wpdb->postmeta.meta_value = '%s'
|
218 |
+
", $item['sku']);
|
219 |
+
$found_product_id = $wpdb->get_var($db_query);
|
220 |
+
if ( ! $found_product_id ) {
|
221 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf(__( '> > Skipped. Cannot find product with sku %s. Importing instead.', 'wf_csv_import_export'), $item['sku']) );
|
222 |
+
$merging = false;
|
223 |
+
|
224 |
+
} else {
|
225 |
+
|
226 |
+
$post_id = $found_product_id;
|
227 |
+
|
228 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf(__( '> > Found product with ID %s.', 'wf_csv_import_export'), $post_id) );
|
229 |
+
|
230 |
+
}
|
231 |
+
}
|
232 |
+
|
233 |
+
}
|
234 |
+
}
|
235 |
+
|
236 |
+
if ( ! $merging ) {
|
237 |
+
|
238 |
+
$product['merging'] = false;
|
239 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __('> Row %s - preparing for import.', 'wf_csv_import_export'), $this->row ) );
|
240 |
+
|
241 |
+
// Required fields
|
242 |
+
if ( isset($item['post_parent']) && $item['post_parent']=== '' && $item['post_title']=== '') {
|
243 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', __( '> > Skipped. No post_title set for new product.', 'wf_csv_import_export') );
|
244 |
+
return new WP_Error( 'parse-error', __( 'No post_title set for new product.', 'wf_csv_import_export' ) );
|
245 |
+
}
|
246 |
+
if ( !empty($item['post_parent']) && $item['post_parent']!== '' && $item['post_parent']!== null && $item['parent_sku'] === '' ) {
|
247 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', __( '> > Skipped. No parent set for new variation product.', 'wf_csv_import_export') );
|
248 |
+
//return new WP_Error( 'parse-error', __( 'No post_title set for new product.', 'wf_csv_import_export' ) );
|
249 |
+
return new WP_Error( 'parse-error', __( 'No parent set for new variation product.', 'wf_csv_import_export' ) );
|
250 |
+
}
|
251 |
+
|
252 |
+
}
|
253 |
+
|
254 |
+
$product['post_id'] = $post_id;
|
255 |
+
|
256 |
+
|
257 |
+
// Get post fields
|
258 |
+
foreach ( $this->post_defaults as $column => $default ) {
|
259 |
+
if ( isset( $item[ $column ] ) ) $product[ $column ] = $item[ $column ];
|
260 |
+
}
|
261 |
+
|
262 |
+
// Get custom fields
|
263 |
+
foreach ( $this->postmeta_defaults as $column => $default ) {
|
264 |
+
if ( isset( $item[$column] ) )
|
265 |
+
$postmeta[$column] = (string) $item[$column];
|
266 |
+
elseif ( isset( $item['_' . $column] ) )
|
267 |
+
$postmeta[$column] = (string) $item['_' . $column];
|
268 |
+
|
269 |
+
// Check custom fields are valid
|
270 |
+
if ( isset( $postmeta[$column] ) && isset( $this->postmeta_allowed[$column] ) && ! in_array( $postmeta[$column], $this->postmeta_allowed[$column] ) ) {
|
271 |
+
$postmeta[$column] = $this->postmeta_defaults[$column];
|
272 |
+
}
|
273 |
+
}
|
274 |
+
|
275 |
+
if ( ! $merging ) {
|
276 |
+
// Merge post meta with defaults
|
277 |
+
$product = wp_parse_args( $product, $this->post_defaults );
|
278 |
+
$postmeta = wp_parse_args( $postmeta, $this->postmeta_defaults );
|
279 |
+
}
|
280 |
+
|
281 |
+
// Handle special meta fields
|
282 |
+
// price
|
283 |
+
if ( $merging ) {
|
284 |
+
if ( ! isset( $postmeta['regular_price'] ) )
|
285 |
+
$postmeta['regular_price'] = get_post_meta( $post_id, '_regular_price', true );
|
286 |
+
$postmeta['regular_price'] = $this->hf_currency_formatter($postmeta['regular_price']);
|
287 |
+
if ( ! isset( $postmeta['sale_price'] ) )
|
288 |
+
$postmeta['sale_price'] = get_post_meta( $post_id, '_sale_price', true );
|
289 |
+
$postmeta['sale_price'] = $this->hf_currency_formatter($postmeta['sale_price']);
|
290 |
+
}
|
291 |
+
|
292 |
+
if ( isset( $postmeta['regular_price'] ) && isset( $postmeta['sale_price'] ) && $postmeta['sale_price'] !== '' ) {
|
293 |
+
$postmeta['sale_price'] = $this->hf_currency_formatter($postmeta['sale_price']);
|
294 |
+
$postmeta['regular_price'] = $this->hf_currency_formatter($postmeta['regular_price']);
|
295 |
+
$price = min( $postmeta['sale_price'], $postmeta['regular_price']);
|
296 |
+
$postmeta['price'] = $price;
|
297 |
+
} elseif ( isset( $postmeta['regular_price'] ) ) {
|
298 |
+
$postmeta['price'] = $this->hf_currency_formatter($postmeta['regular_price']);
|
299 |
+
}
|
300 |
+
|
301 |
+
// Reset dynamically generated meta
|
302 |
+
if ( !isset($item['post_parent']) ) {
|
303 |
+
$postmeta['min_variation_price'] = $postmeta['max_variation_price'] = $postmeta['min_variation_regular_price'] =$postmeta['max_variation_regular_price'] = $postmeta['min_variation_sale_price'] = $postmeta['max_variation_sale_price'] = '';
|
304 |
+
}
|
305 |
+
|
306 |
+
// upsells
|
307 |
+
if ( isset( $postmeta['upsell_ids'] ) && ! is_array( $postmeta['upsell_ids'] ) ) {
|
308 |
+
$ids = array_filter( array_map( 'trim', explode( '|', $postmeta['upsell_ids'] ) ) );
|
309 |
+
$postmeta['upsell_ids'] = $ids;
|
310 |
+
}
|
311 |
+
|
312 |
+
// crosssells
|
313 |
+
if ( isset( $postmeta['crosssell_ids'] ) && ! is_array( $postmeta['crosssell_ids'] ) ) {
|
314 |
+
$ids = array_filter( array_map( 'trim', explode( '|', $postmeta['crosssell_ids'] ) ) );
|
315 |
+
$postmeta['crosssell_ids'] = $ids;
|
316 |
+
}
|
317 |
+
|
318 |
+
// Sale dates
|
319 |
+
if ( isset( $postmeta['sale_price_dates_from'] ) ) {
|
320 |
+
$postmeta['sale_price_dates_from'] = empty( $postmeta['sale_price_dates_from'] ) ? '' : strtotime( $postmeta['sale_price_dates_from'] );
|
321 |
+
}
|
322 |
+
|
323 |
+
if ( isset( $postmeta['sale_price_dates_to'] ) ) {
|
324 |
+
$postmeta['sale_price_dates_to'] = empty( $postmeta['sale_price_dates_to'] ) ? '' : strtotime( $postmeta['sale_price_dates_to'] );
|
325 |
+
}
|
326 |
+
|
327 |
+
// Relative stock updates
|
328 |
+
if ( $merging ) {
|
329 |
+
if ( isset( $postmeta['stock'] ) ) {
|
330 |
+
|
331 |
+
$postmeta['stock'] = trim( $postmeta['stock'] );
|
332 |
+
|
333 |
+
$mode = substr( $postmeta['stock'], 0, 3 );
|
334 |
+
|
335 |
+
if ( $mode == '(+)' ) {
|
336 |
+
$old_stock = absint( get_post_meta( $post_id, '_stock', true ) );
|
337 |
+
$amount = absint( substr( $postmeta['stock'], 3 ) );
|
338 |
+
$new_stock = $old_stock + $amount;
|
339 |
+
$postmeta['stock'] = $new_stock;
|
340 |
+
}
|
341 |
+
|
342 |
+
if ( $mode == '(-)' ) {
|
343 |
+
$old_stock = absint( get_post_meta( $post_id, '_stock', true ) );
|
344 |
+
$amount = absint( substr( $postmeta['stock'], 3 ) );
|
345 |
+
$new_stock = $old_stock - $amount;
|
346 |
+
$postmeta['stock'] = $new_stock;
|
347 |
+
}
|
348 |
+
}
|
349 |
+
}
|
350 |
+
|
351 |
+
// Format post status
|
352 |
+
if ( ! empty( $product['post_status'] ) ) {
|
353 |
+
$product['post_status'] = strtolower( $product['post_status'] );
|
354 |
+
|
355 |
+
if ( empty($item['post_parent']) ) {
|
356 |
+
if ( ! in_array( $product['post_status'], array( 'publish', 'private', 'draft', 'pending', 'future', 'inherit', 'trash' ) ) ) {
|
357 |
+
$product['post_status'] = 'publish';
|
358 |
+
}
|
359 |
+
} else {
|
360 |
+
if ( ! in_array( $product['post_status'], array( 'private', 'publish' ) ) ) {
|
361 |
+
$product['post_status'] = 'publish';
|
362 |
+
}
|
363 |
+
}
|
364 |
+
}
|
365 |
+
|
366 |
+
// Put set core product postmeta into product array
|
367 |
+
foreach ( $postmeta as $key => $value ) {
|
368 |
+
$product['postmeta'][] = array( 'key' => '_' . esc_attr($key), 'value' => $value );
|
369 |
+
}
|
370 |
+
|
371 |
+
/**
|
372 |
+
* Handle other columns
|
373 |
+
*/
|
374 |
+
foreach ( $item as $key => $value ) {
|
375 |
+
|
376 |
+
if ( empty($item['post_parent']) && ! $merge_empty_cells && $value == "" )
|
377 |
+
continue;
|
378 |
+
|
379 |
+
/**
|
380 |
+
* File path handling
|
381 |
+
*/
|
382 |
+
if ( $key == 'file_paths' || $key == 'downloadable_files' ) {
|
383 |
+
|
384 |
+
$file_paths = explode( '|', $value );
|
385 |
+
$_file_paths = array();
|
386 |
+
foreach ( $file_paths as $file_path ) {
|
387 |
+
// 2.1
|
388 |
+
if ( function_exists( 'wc_get_filename_from_url' ) ) {
|
389 |
+
$file_path = array_map( 'trim', explode( '::', $file_path ) );
|
390 |
+
if ( sizeof( $file_path ) === 2 ) {
|
391 |
+
$file_name = $file_path[0];
|
392 |
+
$file_path = $file_path[1];
|
393 |
+
} else {
|
394 |
+
$file_name = wc_get_filename_from_url( $file_path[0] );
|
395 |
+
$file_path = $file_path[0];
|
396 |
+
}
|
397 |
+
$_file_paths[ md5( $file_path ) ] = array(
|
398 |
+
'name' => $file_name,
|
399 |
+
'file' => $file_path
|
400 |
+
);
|
401 |
+
} else {
|
402 |
+
$file_path = trim( $file_path );
|
403 |
+
$_file_paths[ md5( $file_path ) ] = $file_path;
|
404 |
+
}
|
405 |
+
}
|
406 |
+
$value = $_file_paths;
|
407 |
+
|
408 |
+
$product['postmeta'][] = array( 'key' => '_' . esc_attr( $key ), 'value' => $value );
|
409 |
+
}
|
410 |
+
|
411 |
+
elseif ( strstr( $key, 'tax:' ) ) {
|
412 |
+
|
413 |
+
// Get taxonomy
|
414 |
+
$taxonomy = trim( str_replace( 'tax:', '', $key ) );
|
415 |
+
|
416 |
+
// Exists?
|
417 |
+
if ( ! taxonomy_exists( $taxonomy ) ) {
|
418 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __('> > Skipping taxonomy "%s" - it does not exist.', 'wf_csv_import_export'), $taxonomy ) );
|
419 |
+
continue;
|
420 |
+
}
|
421 |
+
|
422 |
+
// Product type check
|
423 |
+
if ( $taxonomy == 'product_type' ) {
|
424 |
+
$term = strtolower( $value );
|
425 |
+
|
426 |
+
if ( ! array_key_exists( $term, $this->allowed_product_types ) ) {
|
427 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __('> > > Product type "%s" not allowed - using simple.', 'wf_csv_import_export'), $term ) );
|
428 |
+
$term_id = $this->allowed_product_types['simple'];
|
429 |
+
} else {
|
430 |
+
$term_id = $this->allowed_product_types[ $term ];
|
431 |
+
}
|
432 |
+
|
433 |
+
// Add to array
|
434 |
+
$terms_array[] = array(
|
435 |
+
'taxonomy' => $taxonomy,
|
436 |
+
'terms' => array( $term_id )
|
437 |
+
);
|
438 |
+
|
439 |
+
continue;
|
440 |
+
}
|
441 |
+
|
442 |
+
// Get terms - ID => parent
|
443 |
+
$terms = array();
|
444 |
+
$raw_terms = explode( '|', $value );
|
445 |
+
$raw_terms = array_map( 'trim', $raw_terms );
|
446 |
+
|
447 |
+
// Handle term hierachy (>)
|
448 |
+
foreach ( $raw_terms as $raw_term ) {
|
449 |
+
|
450 |
+
if ( strstr( $raw_term, '>' ) ) {
|
451 |
+
|
452 |
+
$raw_term = explode( '>', $raw_term );
|
453 |
+
$raw_term = array_map( 'trim', $raw_term );
|
454 |
+
|
455 |
+
if(WC()->version < '2.7.0')
|
456 |
+
{
|
457 |
+
$raw_term = array_map( 'wp_specialchars', $raw_term );
|
458 |
+
$raw_term = array_filter( $raw_term );
|
459 |
+
|
460 |
+
}
|
461 |
+
else
|
462 |
+
{
|
463 |
+
$raw_term = array_map( 'esc_html', $raw_term );
|
464 |
+
$raw_term = array_filter( $raw_term );
|
465 |
+
|
466 |
+
}
|
467 |
+
|
468 |
+
$parent = 0;
|
469 |
+
$loop = 0;
|
470 |
+
|
471 |
+
foreach ( $raw_term as $term ) {
|
472 |
+
$loop ++;
|
473 |
+
$term_id = '';
|
474 |
+
|
475 |
+
if ( isset( $this->inserted_terms[ $taxonomy ][ $parent ][ $term ] ) ) {
|
476 |
+
$term_id = $this->inserted_terms[ $taxonomy ][ $parent ][ $term ];
|
477 |
+
} elseif ( $term ) {
|
478 |
+
|
479 |
+
/**
|
480 |
+
* Check term existance
|
481 |
+
*/
|
482 |
+
$term_may_exist = term_exists( $term, $taxonomy, absint( $parent ) );
|
483 |
+
|
484 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'CSV-Import', sprintf( __( '> > (' . __LINE__ . ') Term %s (%s) exists? %s', 'wf_csv_import_export' ), sanitize_text_field( $term ), esc_html( $taxonomy ), $term_may_exist ? print_r( $term_may_exist, true ) : '-' ) );
|
485 |
+
|
486 |
+
if ( is_array( $term_may_exist ) ) {
|
487 |
+
$possible_term = get_term( $term_may_exist['term_id'], 'product_cat' );
|
488 |
+
|
489 |
+
if ( $possible_term->parent == $parent ) {
|
490 |
+
$term_id = $term_may_exist['term_id'];
|
491 |
+
}
|
492 |
+
}
|
493 |
+
|
494 |
+
if ( ! $term_id ) {
|
495 |
+
|
496 |
+
// Create appropriate slug
|
497 |
+
$slug = array();
|
498 |
+
|
499 |
+
for ( $i = 0; $i < $loop; $i ++ )
|
500 |
+
$slug[] = $raw_term[ $i ];
|
501 |
+
|
502 |
+
$slug = sanitize_title( implode( '-', $slug ) );
|
503 |
+
|
504 |
+
$t = wp_insert_term( $term, $taxonomy, array( 'parent' => $parent, 'slug' => $slug ) );
|
505 |
+
|
506 |
+
if ( ! is_wp_error( $t ) ) {
|
507 |
+
$term_id = $t['term_id'];
|
508 |
+
} else {
|
509 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'CSV-Import', sprintf( __( '> > (' . __LINE__ . ') Failed to import term %s, parent %s - %s', 'wf_csv_import_export' ), sanitize_text_field( $term ), sanitize_text_field( $parent ), sanitize_text_field( $taxonomy ) ) );
|
510 |
+
break;
|
511 |
+
}
|
512 |
+
}
|
513 |
+
|
514 |
+
$this->inserted_terms[$taxonomy][$parent][$term] = $term_id;
|
515 |
+
|
516 |
+
}
|
517 |
+
|
518 |
+
if ( ! $term_id )
|
519 |
+
break;
|
520 |
+
|
521 |
+
// Add to product terms, ready to set if this is the final term
|
522 |
+
if ( sizeof( $raw_term ) == $loop )
|
523 |
+
$terms[] = $term_id;
|
524 |
+
|
525 |
+
$parent = $term_id;
|
526 |
+
}
|
527 |
+
|
528 |
+
} else {
|
529 |
+
|
530 |
+
$term_id = '';
|
531 |
+
$raw_term = (WC()->version < '2.7.0') ? wp_specialchars( $raw_term ) : esc_html( $raw_term );
|
532 |
+
|
533 |
+
if ( isset( $this->inserted_terms[$taxonomy][0][$raw_term] ) ) {
|
534 |
+
|
535 |
+
$term_id = $this->inserted_terms[$taxonomy][0][$raw_term];
|
536 |
+
|
537 |
+
} elseif ( $raw_term ) {
|
538 |
+
|
539 |
+
// Check term existance
|
540 |
+
$term_exists = term_exists( $raw_term, $taxonomy, 0 );
|
541 |
+
$term_id = is_array( $term_exists ) ? $term_exists['term_id'] : 0;
|
542 |
+
|
543 |
+
if ( ! $term_id ) {
|
544 |
+
$t = wp_insert_term( trim( $raw_term ), $taxonomy, array( 'parent' => 0 ) );
|
545 |
+
|
546 |
+
if ( ! is_wp_error( $t ) ) {
|
547 |
+
$term_id = $t['term_id'];
|
548 |
+
} else {
|
549 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __( '> > Failed to import term %s %s', 'wf_csv_import_export' ), esc_html($raw_term), esc_html($taxonomy) ) );
|
550 |
+
break;
|
551 |
+
}
|
552 |
+
}
|
553 |
+
|
554 |
+
$this->inserted_terms[$taxonomy][0][$raw_term] = $term_id;
|
555 |
+
|
556 |
+
}
|
557 |
+
|
558 |
+
// Store terms for later insertion
|
559 |
+
if ( $term_id )
|
560 |
+
$terms[] = $term_id;
|
561 |
+
|
562 |
+
}
|
563 |
+
|
564 |
+
}
|
565 |
+
|
566 |
+
// Any defined?
|
567 |
+
if ( sizeof( $terms ) == 0 )
|
568 |
+
continue;
|
569 |
+
|
570 |
+
// Add to array
|
571 |
+
$terms_array[] = array(
|
572 |
+
'taxonomy' => $taxonomy,
|
573 |
+
'terms' => $terms
|
574 |
+
);
|
575 |
+
}
|
576 |
+
|
577 |
+
/**
|
578 |
+
* Handle Attributes
|
579 |
+
*/
|
580 |
+
elseif ( strstr( $key, 'attribute:' ) ) {
|
581 |
+
|
582 |
+
$attribute_key = sanitize_title( trim( str_replace( 'attribute:', '', $key ) ) );
|
583 |
+
$attribute_name = str_replace( 'attribute:', '', $WF_CSV_Product_Import->raw_headers[ $key ] );
|
584 |
+
|
585 |
+
if ( ! $attribute_key )
|
586 |
+
continue;
|
587 |
+
|
588 |
+
// Taxonomy
|
589 |
+
if ( substr( $attribute_key, 0, 3 ) == 'pa_' ) {
|
590 |
+
|
591 |
+
$taxonomy = $attribute_key;
|
592 |
+
|
593 |
+
// Exists?
|
594 |
+
if ( ! taxonomy_exists( $taxonomy ) ) {
|
595 |
+
|
596 |
+
$nicename = strtolower( sanitize_title( str_replace( 'pa_', '', $taxonomy ) ) );
|
597 |
+
|
598 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __('> > Attribute taxonomy "%s" does not exist. Adding it. Nicename: %s', 'wf_csv_import_export'), $taxonomy, $nicename ) );
|
599 |
+
|
600 |
+
$exists_in_db = $wpdb->get_var( "SELECT attribute_id FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies WHERE attribute_name = '" . $nicename . "';" );
|
601 |
+
|
602 |
+
if ( ! $exists_in_db ) {
|
603 |
+
// Create the taxonomy
|
604 |
+
$wpdb->insert( $wpdb->prefix . "woocommerce_attribute_taxonomies", array( 'attribute_name' => $nicename, 'attribute_label' => $nicename, 'attribute_type' => 'select', 'attribute_orderby' => 'menu_order' ) );
|
605 |
+
} else {
|
606 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __('> > Attribute taxonomy %s already exists in DB.', 'wf_csv_import_export'), $taxonomy ) );
|
607 |
+
}
|
608 |
+
|
609 |
+
// Register the taxonomy now so that the import works!
|
610 |
+
register_taxonomy( $taxonomy,
|
611 |
+
array( 'product', 'product_variation' ),
|
612 |
+
array(
|
613 |
+
'hierarchical' => true,
|
614 |
+
'show_ui' => false,
|
615 |
+
'query_var' => true,
|
616 |
+
'rewrite' => false,
|
617 |
+
)
|
618 |
+
);
|
619 |
+
}
|
620 |
+
|
621 |
+
// Get terms
|
622 |
+
$terms = array();
|
623 |
+
$raw_terms = explode( '|', $value );
|
624 |
+
if(WC()->version < '2.7.0')
|
625 |
+
{
|
626 |
+
$raw_terms = array_map( 'wp_specialchars', $raw_terms );
|
627 |
+
$raw_terms = array_map( 'trim', $raw_terms );
|
628 |
+
|
629 |
+
}else{
|
630 |
+
|
631 |
+
$raw_terms = array_map( 'esc_html', $raw_terms );
|
632 |
+
$raw_terms = array_map( 'trim', $raw_terms );
|
633 |
+
|
634 |
+
}
|
635 |
+
|
636 |
+
if ( sizeof( $raw_terms ) > 0 ) {
|
637 |
+
|
638 |
+
foreach ( $raw_terms as $raw_term ) {
|
639 |
+
|
640 |
+
if ( empty( $raw_term ) && 0 != $raw_term ) {
|
641 |
+
continue;
|
642 |
+
}
|
643 |
+
|
644 |
+
// Check term existance
|
645 |
+
$term_exists = term_exists( $raw_term, $taxonomy, 0 );
|
646 |
+
$term_id = is_array( $term_exists ) ? $term_exists['term_id'] : 0;
|
647 |
+
|
648 |
+
if ( ! $term_id ) {
|
649 |
+
$t = wp_insert_term( trim( $raw_term ), $taxonomy );
|
650 |
+
|
651 |
+
if ( ! is_wp_error( $t ) ) {
|
652 |
+
$term_id = $t['term_id'];
|
653 |
+
|
654 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __( '> > Inserted Raw Term %s ID = %s', 'wf_csv_import_export' ), esc_html( $raw_term ), $term_id ) );
|
655 |
+
} else {
|
656 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __( '> > Failed to import term %s %s', 'wf_csv_import_export' ), esc_html($raw_term), esc_html($taxonomy) ) );
|
657 |
+
break;
|
658 |
+
}
|
659 |
+
} else {
|
660 |
+
$WF_CSV_Product_Import->hf_log_data_change( 'csv-import', sprintf( __( '> > Raw Term %s ID = %s', 'wf_csv_import_export' ), esc_html( $raw_term ), $term_id ) );
|
661 |
+
}
|
662 |
+
|
663 |
+
if ( $term_id ) {
|
664 |
+
$terms[] = $term_id;
|
665 |
+
}
|
666 |
+
}
|
667 |
+
|
668 |
+
}
|
669 |
+
|
670 |
+
// Add to array
|
671 |
+
$terms_array[] = array(
|
672 |
+
'taxonomy' => $taxonomy,
|
673 |
+
'terms' => $terms
|
674 |
+
);
|
675 |
+
|
676 |
+
// Ensure we have original attributes
|
677 |
+
if ( is_null( $attributes ) && $merging ) {
|
678 |
+
$attributes = array_filter( (array) maybe_unserialize( get_post_meta( $post_id, '_product_attributes', true ) ) );
|
679 |
+
} elseif ( is_null( $attributes ) ) {
|
680 |
+
$attributes = array();
|
681 |
+
}
|
682 |
+
|
683 |
+
// Set attribute
|
684 |
+
if ( ! isset( $attributes[$taxonomy] ) )
|
685 |
+
$attributes[$taxonomy] = array();
|
686 |
+
|
687 |
+
$attributes[$taxonomy]['name'] = $taxonomy;
|
688 |
+
$attributes[$taxonomy]['value'] = null;
|
689 |
+
$attributes[$taxonomy]['is_taxonomy'] = 1;
|
690 |
+
|
691 |
+
if ( ! isset( $attributes[$taxonomy]['position'] ) )
|
692 |
+
$attributes[$taxonomy]['position'] = 0;
|
693 |
+
if ( ! isset( $attributes[$taxonomy]['is_visible'] ) )
|
694 |
+
$attributes[$taxonomy]['is_visible'] = 1;
|
695 |
+
if ( ! isset( $attributes[$taxonomy]['is_variation'] ) )
|
696 |
+
$attributes[$taxonomy]['is_variation'] = 0;
|
697 |
+
|
698 |
+
} else {
|
699 |
+
|
700 |
+
if ( ! $value || ! $attribute_key ) continue;
|
701 |
+
|
702 |
+
// Set attribute
|
703 |
+
if ( ! isset( $attributes[$attribute_key] ) )
|
704 |
+
$attributes[$attribute_key] = array();
|
705 |
+
|
706 |
+
$attributes[$attribute_key]['name'] = $attribute_name;
|
707 |
+
$attributes[$attribute_key]['value'] = $value;
|
708 |
+
$attributes[$attribute_key]['is_taxonomy'] = 0;
|
709 |
+
|
710 |
+
if ( ! isset( $attributes[$attribute_key]['position'] ) )
|
711 |
+
$attributes[$attribute_key]['position'] = 0;
|
712 |
+
if ( ! isset( $attributes[$attribute_key]['is_visible'] ) )
|
713 |
+
$attributes[$attribute_key]['is_visible'] = 1;
|
714 |
+
if ( ! isset( $attributes[$attribute_key]['is_variation'] ) )
|
715 |
+
$attributes[$attribute_key]['is_variation'] = 0;
|
716 |
+
}
|
717 |
+
|
718 |
+
}
|
719 |
+
|
720 |
+
/**
|
721 |
+
* Handle Attributes Data - position|is_visible|is_variation
|
722 |
+
*/
|
723 |
+
elseif ( strstr( $key, 'attribute_data:' ) ) {
|
724 |
+
|
725 |
+
$attribute_key = sanitize_title( trim( str_replace( 'attribute_data:', '', $key ) ) );
|
726 |
+
|
727 |
+
if ( ! $attribute_key ) {
|
728 |
+
continue;
|
729 |
+
}
|
730 |
+
|
731 |
+
$values = explode( '|', $value );
|
732 |
+
$position = isset( $values[0] ) ? (int) $values[0] : 0;
|
733 |
+
$visible = isset( $values[1] ) ? (int) $values[1] : 1;
|
734 |
+
$variation = isset( $values[2] ) ? (int) $values[2] : 0;
|
735 |
+
|
736 |
+
// Ensure we have original attributes
|
737 |
+
if ( ! isset( $attributes[ $attribute_key ] ) ) {
|
738 |
+
if ( $merging ) {
|
739 |
+
$existing_attributes = array_filter( (array) maybe_unserialize( get_post_meta( $post_id, '_product_attributes', true ) ) );
|
740 |
+
$attributes[ $attribute_key ] = isset( $existing_attributes[ $attribute_key ] ) ? $existing_attributes[ $attribute_key ] : array();
|
741 |
+
} else {
|
742 |
+
$attributes[ $attribute_key ] = array();
|
743 |
+
}
|
744 |
+
}
|
745 |
+
|
746 |
+
$attributes[ $attribute_key ]['position'] = $position;
|
747 |
+
$attributes[ $attribute_key ]['is_visible'] = $visible;
|
748 |
+
$attributes[ $attribute_key ]['is_variation'] = $variation;
|
749 |
+
}
|
750 |
+
|
751 |
+
/**
|
752 |
+
* Handle Attributes Default Values
|
753 |
+
*/
|
754 |
+
elseif ( strstr( $key, 'attribute_default:' ) ) {
|
755 |
+
|
756 |
+
$attribute_key = sanitize_title( trim( str_replace( 'attribute_default:', '', $key ) ) );
|
757 |
+
|
758 |
+
if ( ! $attribute_key ) continue;
|
759 |
+
|
760 |
+
// Ensure we have original attributes
|
761 |
+
if ( is_null( $default_attributes ) && $merging ) {
|
762 |
+
$default_attributes = array_filter( (array) maybe_unserialize( get_post_meta( $post_id, '_default_attributes', true ) ) );
|
763 |
+
} elseif ( is_null( $default_attributes ) ) {
|
764 |
+
$default_attributes = array();
|
765 |
+
}
|
766 |
+
|
767 |
+
$default_attributes[ $attribute_key ] = $value;
|
768 |
+
}
|
769 |
+
|
770 |
+
/**
|
771 |
+
* Handle gpf: google product feed columns
|
772 |
+
*/
|
773 |
+
elseif ( strstr( $key, 'gpf:' ) ) {
|
774 |
+
|
775 |
+
$gpf_key = trim( str_replace( 'gpf:', '', $key ) );
|
776 |
+
|
777 |
+
// Get original values
|
778 |
+
if ( is_null( $gpf_data ) && $merging ) {
|
779 |
+
$gpf_data = array_filter( (array) maybe_unserialize( get_post_meta( $post_id, '_woocommerce_gpf_data', true ) ) );
|
780 |
+
} elseif ( is_null( $gpf_data ) ) {
|
781 |
+
$gpf_data = array(
|
782 |
+
'availability' => '',
|
783 |
+
'condition' => '',
|
784 |
+
'brand' => '',
|
785 |
+
'product_type' => '',
|
786 |
+
'google_product_category' => '',
|
787 |
+
'gtin' => '',
|
788 |
+
'mpn' => '',
|
789 |
+
'gender' => '',
|
790 |
+
'age_group' => '',
|
791 |
+
'color' => '',
|
792 |
+
'size' => ''
|
793 |
+
);
|
794 |
+
}
|
795 |
+
|
796 |
+
$gpf_data[$gpf_key] = $value;
|
797 |
+
|
798 |
+
}
|
799 |
+
|
800 |
+
/**
|
801 |
+
* Handle upsell SKUs which we cannot assign until we get IDs later on
|
802 |
+
*/
|
803 |
+
elseif ( strstr( $key, 'upsell_skus' ) ) {
|
804 |
+
if ( $value ) {
|
805 |
+
$skus = array_filter( array_map( 'trim', explode( '|', $value ) ) );
|
806 |
+
$product['upsell_skus'] = $skus;
|
807 |
+
}
|
808 |
+
}
|
809 |
+
|
810 |
+
/**
|
811 |
+
* Handle crosssells SKUs which we cannot assign until we get IDs later on
|
812 |
+
*/
|
813 |
+
elseif ( strstr( $key, 'crosssell_skus' ) ) {
|
814 |
+
if ( $value ) {
|
815 |
+
$skus = array_filter( array_map( 'trim', explode( '|', $value ) ) );
|
816 |
+
$product['crosssell_skus'] = $skus;
|
817 |
+
}
|
818 |
+
}
|
819 |
+
|
820 |
+
}
|
821 |
+
|
822 |
+
// Remove empty attribues
|
823 |
+
if(!empty($attributes))
|
824 |
+
foreach ( $attributes as $key => $value ) {
|
825 |
+
if ( ! isset($value['name']) ) unset( $attributes[$key] );
|
826 |
+
}
|
827 |
+
|
828 |
+
/**
|
829 |
+
* Handle images
|
830 |
+
*/
|
831 |
+
if ( ! empty( $item['images'] ) ) {
|
832 |
+
$images = array_map( 'trim', explode( '|', $item['images'] ) );
|
833 |
+
} else {
|
834 |
+
$images = '';
|
835 |
+
}
|
836 |
+
|
837 |
+
$product['postmeta'][] = array( 'key' => '_default_attributes', 'value' => $default_attributes );
|
838 |
+
$product['attributes'] = $attributes;
|
839 |
+
$product['gpf_data'] = $gpf_data;
|
840 |
+
$product['images'] = $images;
|
841 |
+
$product['terms'] = $terms_array;
|
842 |
+
$product['sku'] = ( ! empty( $item['sku'] ) ) ? $item['sku'] : '';
|
843 |
+
$product['post_title'] = ( ! empty( $item['post_title'] ) ) ? $item['post_title'] : '';
|
844 |
+
$product['post_type'] = $this->post_type;
|
845 |
+
unset( $item, $terms_array, $postmeta, $attributes, $gpf_data, $images );
|
846 |
+
return $product;
|
847 |
+
}
|
848 |
+
public function hf_currency_formatter($price){
|
849 |
+
|
850 |
+
$decimal_seperator = wc_get_price_decimal_separator();
|
851 |
+
return preg_replace("[^0-9\\'.$decimal_seperator.']", "", $price);
|
852 |
+
}
|
853 |
+
}
|
includes/importer/class-wf-prodimpexpcsv-importer.php
CHANGED
@@ -1,41 +1,41 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
-
exit;
|
4 |
-
}
|
5 |
-
|
6 |
-
class WF_ProdImpExpCsv_Importer {
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Product Exporter Tool
|
10 |
-
*/
|
11 |
-
public static function load_wp_importer() {
|
12 |
-
// Load Importer API
|
13 |
-
require_once ABSPATH . 'wp-admin/includes/import.php';
|
14 |
-
|
15 |
-
if ( ! class_exists( 'WP_Importer' ) ) {
|
16 |
-
$class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
|
17 |
-
if ( file_exists( $class_wp_importer ) ) {
|
18 |
-
require $class_wp_importer;
|
19 |
-
}
|
20 |
-
}
|
21 |
-
}
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Product Importer Tool
|
25 |
-
*/
|
26 |
-
public static function product_importer() {
|
27 |
-
if ( ! defined( 'WP_LOAD_IMPORTERS' ) ) {
|
28 |
-
return;
|
29 |
-
}
|
30 |
-
|
31 |
-
self::load_wp_importer();
|
32 |
-
|
33 |
-
// includes
|
34 |
-
require_once 'class-wf-prodimpexpcsv-product-import.php';
|
35 |
-
require_once 'class-wf-csv-parser.php';
|
36 |
-
|
37 |
-
// Dispatch
|
38 |
-
$GLOBALS['WF_CSV_Product_Import'] = new WF_ProdImpExpCsv_Product_Import();
|
39 |
-
$GLOBALS['WF_CSV_Product_Import'] ->dispatch();
|
40 |
-
}
|
41 |
}
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
+
exit;
|
4 |
+
}
|
5 |
+
|
6 |
+
class WF_ProdImpExpCsv_Importer {
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Product Exporter Tool
|
10 |
+
*/
|
11 |
+
public static function load_wp_importer() {
|
12 |
+
// Load Importer API
|
13 |
+
require_once ABSPATH . 'wp-admin/includes/import.php';
|
14 |
+
|
15 |
+
if ( ! class_exists( 'WP_Importer' ) ) {
|
16 |
+
$class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
|
17 |
+
if ( file_exists( $class_wp_importer ) ) {
|
18 |
+
require $class_wp_importer;
|
19 |
+
}
|
20 |
+
}
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Product Importer Tool
|
25 |
+
*/
|
26 |
+
public static function product_importer() {
|
27 |
+
if ( ! defined( 'WP_LOAD_IMPORTERS' ) ) {
|
28 |
+
return;
|
29 |
+
}
|
30 |
+
|
31 |
+
self::load_wp_importer();
|
32 |
+
|
33 |
+
// includes
|
34 |
+
require_once 'class-wf-prodimpexpcsv-product-import.php';
|
35 |
+
require_once 'class-wf-csv-parser.php';
|
36 |
+
|
37 |
+
// Dispatch
|
38 |
+
$GLOBALS['WF_CSV_Product_Import'] = new WF_ProdImpExpCsv_Product_Import();
|
39 |
+
$GLOBALS['WF_CSV_Product_Import'] ->dispatch();
|
40 |
+
}
|
41 |
}
|
includes/importer/class-wf-prodimpexpcsv-product-import.php
CHANGED
@@ -1,1488 +1,1564 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
-
exit;
|
4 |
-
}
|
5 |
-
/**
|
6 |
-
* WordPress Importer class for managing the import process of a CSV file
|
7 |
-
*
|
8 |
-
* @package WordPress
|
9 |
-
* @subpackage Importer
|
10 |
-
*/
|
11 |
-
if ( ! class_exists( 'WP_Importer' ) )
|
12 |
-
return;
|
13 |
-
|
14 |
-
class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
15 |
-
|
16 |
-
var $id;
|
17 |
-
var $file_url;
|
18 |
-
var $delimiter;
|
19 |
-
var $merge;
|
20 |
-
var $merge_empty_cells;
|
21 |
-
|
22 |
-
// mappings from old information to new
|
23 |
-
var $processed_terms = array();
|
24 |
-
var $processed_posts = array();
|
25 |
-
var $post_orphans = array();
|
26 |
-
var $attachments = array();
|
27 |
-
var $upsell_skus = array();
|
28 |
-
var $crosssell_skus = array();
|
29 |
-
|
30 |
-
// Results
|
31 |
-
var $import_results = array();
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Constructor
|
35 |
-
*/
|
36 |
-
public function __construct() {
|
37 |
-
|
38 |
-
if(WC()->version < '2.7.0'){
|
39 |
-
$this->log = new WC_Logger();
|
40 |
-
|
41 |
-
}else
|
42 |
-
{
|
43 |
-
$this->log = wc_get_logger();
|
44 |
-
|
45 |
-
}
|
46 |
-
|
47 |
-
$this->import_page = 'xa_woocommerce_csv';
|
48 |
-
$this->file_url_import_enabled = apply_filters( 'woocommerce_csv_product_file_url_import_enabled', true );
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* Registered callback function for the WordPress Importer
|
53 |
-
*
|
54 |
-
* Manages the three separate stages of the CSV import process
|
55 |
-
*/
|
56 |
-
public function dispatch() {
|
57 |
-
global $woocommerce, $wpdb;
|
58 |
-
|
59 |
-
if ( ! empty( $_POST['delimiter'] ) ) {
|
60 |
-
$this->delimiter = stripslashes( trim( $_POST['delimiter'] ) );
|
61 |
-
}else if ( ! empty( $_GET['delimiter'] ) ) {
|
62 |
-
$this->delimiter = stripslashes( trim( $_GET['delimiter'] ) );
|
63 |
-
}
|
64 |
-
|
65 |
-
if ( ! $this->delimiter )
|
66 |
-
$this->delimiter = ',';
|
67 |
-
|
68 |
-
if ( ! empty( $_POST['merge'] ) || ! empty( $_GET['merge'] ) ) {
|
69 |
-
$this->merge = 1;
|
70 |
-
} else{
|
71 |
-
$this->merge = 0;
|
72 |
-
}
|
73 |
-
|
74 |
-
if ( ! empty( $_POST['merge_empty_cells'] ) || ! empty( $_GET['merge_empty_cells'] ) ) {
|
75 |
-
$this->merge_empty_cells = 1;
|
76 |
-
} else{
|
77 |
-
$this->merge_empty_cells = 0;
|
78 |
-
}
|
79 |
-
|
80 |
-
$step = empty( $_GET['step'] ) ? 0 : (int) $_GET['step'];
|
81 |
-
|
82 |
-
switch ( $step ) {
|
83 |
-
case 0 :
|
84 |
-
$this->header();
|
85 |
-
$this->greet();
|
86 |
-
break;
|
87 |
-
case 1 :
|
88 |
-
$this->header();
|
89 |
-
|
90 |
-
check_admin_referer( 'import-upload' );
|
91 |
-
|
92 |
-
if(!empty($_GET['file_url']))
|
93 |
-
$this->file_url = esc_attr( $_GET['file_url'] );
|
94 |
-
if(!empty($_GET['file_id']))
|
95 |
-
$this->id = $_GET['file_id'] ;
|
96 |
-
|
97 |
-
if ( !empty($_GET['clearmapping']) || $this->handle_upload() )
|
98 |
-
$this->import_options();
|
99 |
-
else
|
100 |
-
_e( 'Error with handle_upload!', 'wf_csv_import_export' );
|
101 |
-
break;
|
102 |
-
case 2 :
|
103 |
-
$this->header();
|
104 |
-
|
105 |
-
check_admin_referer( 'import-woocommerce' );
|
106 |
-
|
107 |
-
$this->id = (int) $_POST['import_id'];
|
108 |
-
|
109 |
-
if ( $this->file_url_import_enabled )
|
110 |
-
$this->file_url = esc_attr( $_POST['import_url'] );
|
111 |
-
|
112 |
-
if ( $this->id )
|
113 |
-
$file = get_attached_file( $this->id );
|
114 |
-
else if ( $this->file_url_import_enabled )
|
115 |
-
$file = ABSPATH . $this->file_url;
|
116 |
-
|
117 |
-
$file = str_replace( "\\", "/", $file );
|
118 |
-
|
119 |
-
if ( $file ) {
|
120 |
-
?>
|
121 |
-
<table id="import-progress" class="widefat_importer widefat">
|
122 |
-
<thead>
|
123 |
-
<tr>
|
124 |
-
<th class="status"> </th>
|
125 |
-
<th class="row"><?php _e( 'Row', 'wf_csv_import_export' ); ?></th>
|
126 |
-
<th><?php _e( 'SKU', 'wf_csv_import_export' ); ?></th>
|
127 |
-
<th><?php _e( 'Product', 'wf_csv_import_export' ); ?></th>
|
128 |
-
<th class="reason"><?php _e( 'Status Msg', 'wf_csv_import_export' ); ?></th>
|
129 |
-
</tr>
|
130 |
-
</thead>
|
131 |
-
<tfoot>
|
132 |
-
<tr class="importer-loading">
|
133 |
-
<td colspan="5"></td>
|
134 |
-
</tr>
|
135 |
-
</tfoot>
|
136 |
-
<tbody></tbody>
|
137 |
-
</table>
|
138 |
-
<script type="text/javascript">
|
139 |
-
jQuery(document).ready(function($) {
|
140 |
-
|
141 |
-
if ( ! window.console ) { window.console = function(){}; }
|
142 |
-
|
143 |
-
var processed_terms = [];
|
144 |
-
var processed_posts = [];
|
145 |
-
var post_orphans = [];
|
146 |
-
var attachments = [];
|
147 |
-
var upsell_skus = [];
|
148 |
-
var crosssell_skus = [];
|
149 |
-
var i = 1;
|
150 |
-
var done_count = 0;
|
151 |
-
|
152 |
-
function import_rows( start_pos, end_pos ) {
|
153 |
-
|
154 |
-
var data = {
|
155 |
-
action: 'woocommerce_csv_import_request',
|
156 |
-
file: '<?php echo addslashes( $file ); ?>',
|
157 |
-
mapping: '<?php echo json_encode( $_POST['map_from'] ); ?>',
|
158 |
-
eval_field: '<?php echo stripslashes(json_encode(($_POST['eval_field']),JSON_HEX_APOS)) ?>',
|
159 |
-
delimiter: '<?php echo $this->delimiter; ?>',
|
160 |
-
merge_empty_cells: '<?php echo $this->merge_empty_cells; ?>',
|
161 |
-
merge: '<?php echo $this->merge; ?>',
|
162 |
-
start_pos: start_pos,
|
163 |
-
end_pos: end_pos,
|
164 |
-
};
|
165 |
-
data.eval_field = $.parseJSON(data.eval_field);
|
166 |
-
return $.ajax({
|
167 |
-
url: '<?php echo add_query_arg( array( 'import_page' => $this->import_page, 'step' => '3', 'merge' => ! empty( $_GET['merge'] ) ? '1' : '0' ), admin_url( 'admin-ajax.php' ) ); ?>',
|
168 |
-
data: data,
|
169 |
-
type: 'POST',
|
170 |
-
success: function( response ) {
|
171 |
-
//console.log( response );
|
172 |
-
if ( response ) {
|
173 |
-
|
174 |
-
try {
|
175 |
-
// Get the valid JSON only from the returned string
|
176 |
-
if ( response.indexOf("<!--WC_START-->") >= 0 )
|
177 |
-
response = response.split("<!--WC_START-->")[1]; // Strip off before after WC_START
|
178 |
-
|
179 |
-
if ( response.indexOf("<!--WC_END-->") >= 0 )
|
180 |
-
response = response.split("<!--WC_END-->")[0]; // Strip off anything after WC_END
|
181 |
-
|
182 |
-
// Parse
|
183 |
-
var results = $.parseJSON( response );
|
184 |
-
|
185 |
-
if ( results.error ) {
|
186 |
-
|
187 |
-
$('#import-progress tbody').append( '<tr id="row-' + i + '" class="error"><td class="status" colspan="5">' + results.error + '</td></tr>' );
|
188 |
-
|
189 |
-
i++;
|
190 |
-
|
191 |
-
} else if ( results.import_results && $( results.import_results ).size() > 0 ) {
|
192 |
-
|
193 |
-
$.each( results.processed_terms, function( index, value ) {
|
194 |
-
processed_terms.push( value );
|
195 |
-
});
|
196 |
-
|
197 |
-
$.each( results.processed_posts, function( index, value ) {
|
198 |
-
processed_posts.push( value );
|
199 |
-
});
|
200 |
-
|
201 |
-
$.each( results.post_orphans, function( index, value ) {
|
202 |
-
post_orphans.push( value );
|
203 |
-
});
|
204 |
-
|
205 |
-
$.each( results.attachments, function( index, value ) {
|
206 |
-
attachments.push( value );
|
207 |
-
});
|
208 |
-
|
209 |
-
upsell_skus = jQuery.extend( {}, upsell_skus, results.upsell_skus );
|
210 |
-
crosssell_skus = jQuery.extend( {}, crosssell_skus, results.crosssell_skus );
|
211 |
-
|
212 |
-
$( results.import_results ).each(function( index, row ) {
|
213 |
-
$('#import-progress tbody').append( '<tr id="row-' + i + '" class="' + row['status'] + '"><td><mark class="result" title="' + row['status'] + '">' + row['status'] + '</mark></td><td class="row">' + i + '</td><td>' + row['sku'] + '</td><td>' + row['post_id'] + ' - ' + row['post_title'] + '</td><td class="reason">' + row['reason'] + '</td></tr>' );
|
214 |
-
|
215 |
-
i++;
|
216 |
-
});
|
217 |
-
}
|
218 |
-
|
219 |
-
} catch(err) {}
|
220 |
-
|
221 |
-
} else {
|
222 |
-
$('#import-progress tbody').append( '<tr class="error"><td class="status" colspan="5">' + '<?php _e( 'AJAX Error', 'wf_csv_import_export' ); ?>' + '</td></tr>' );
|
223 |
-
}
|
224 |
-
|
225 |
-
var w = $(window);
|
226 |
-
var row = $( "#row-" + ( i - 1 ) );
|
227 |
-
|
228 |
-
if ( row.length ) {
|
229 |
-
w.scrollTop( row.offset().top - (w.height()/2) );
|
230 |
-
}
|
231 |
-
|
232 |
-
done_count++;
|
233 |
-
|
234 |
-
$('body').trigger( 'woocommerce_csv_import_request_complete' );
|
235 |
-
}
|
236 |
-
});
|
237 |
-
}
|
238 |
-
|
239 |
-
var rows = [];
|
240 |
-
|
241 |
-
<?php
|
242 |
-
$limit = apply_filters( 'woocommerce_csv_import_limit_per_request', 10 );
|
243 |
-
$enc = mb_detect_encoding( $file, 'UTF-8, ISO-8859-1', true );
|
244 |
-
if ( $enc )
|
245 |
-
setlocale( LC_ALL, 'en_US.' . $enc );
|
246 |
-
@ini_set( 'auto_detect_line_endings', true );
|
247 |
-
|
248 |
-
$count = 0;
|
249 |
-
$previous_position = 0;
|
250 |
-
$position = 0;
|
251 |
-
$import_count = 0;
|
252 |
-
|
253 |
-
// Get CSV positions
|
254 |
-
if ( ( $handle = fopen( $file, "r" ) ) !== FALSE ) {
|
255 |
-
|
256 |
-
while ( ( $postmeta = fgetcsv( $handle, 0, $this->delimiter ) ) !== FALSE ) {
|
257 |
-
$count++;
|
258 |
-
|
259 |
-
if ( $count >= $limit ) {
|
260 |
-
$previous_position = $position;
|
261 |
-
$position = ftell( $handle );
|
262 |
-
$count = 0;
|
263 |
-
$import_count ++;
|
264 |
-
|
265 |
-
// Import rows between $previous_position $position
|
266 |
-
?>rows.push( [ <?php echo $previous_position; ?>, <?php echo $position; ?> ] ); <?php
|
267 |
-
}
|
268 |
-
}
|
269 |
-
|
270 |
-
// Remainder
|
271 |
-
if ( $count > 0 ) {
|
272 |
-
?>rows.push( [ <?php echo $position; ?>, '' ] ); <?php
|
273 |
-
$import_count ++;
|
274 |
-
}
|
275 |
-
|
276 |
-
fclose( $handle );
|
277 |
-
}
|
278 |
-
?>
|
279 |
-
|
280 |
-
var data = rows.shift();
|
281 |
-
var regen_count = 0;
|
282 |
-
import_rows( data[0], data[1] );
|
283 |
-
|
284 |
-
$('body').on( 'woocommerce_csv_import_request_complete', function() {
|
285 |
-
if ( done_count == <?php echo $import_count; ?> ) {
|
286 |
-
|
287 |
-
if ( attachments.length ) {
|
288 |
-
|
289 |
-
$('#import-progress tbody').append( '<tr class="regenerating"><td colspan="5"><div class="progress"></div></td></tr>' );
|
290 |
-
|
291 |
-
index = 0;
|
292 |
-
|
293 |
-
$.each( attachments, function( i, value ) {
|
294 |
-
regenerate_thumbnail( value );
|
295 |
-
index ++;
|
296 |
-
if ( index == attachments.length ) {
|
297 |
-
import_done();
|
298 |
-
}
|
299 |
-
});
|
300 |
-
|
301 |
-
} else {
|
302 |
-
import_done();
|
303 |
-
}
|
304 |
-
|
305 |
-
} else {
|
306 |
-
// Call next request
|
307 |
-
data = rows.shift();
|
308 |
-
import_rows( data[0], data[1] );
|
309 |
-
}
|
310 |
-
} );
|
311 |
-
|
312 |
-
// Regenerate a specified image via AJAX
|
313 |
-
function regenerate_thumbnail( id ) {
|
314 |
-
$.ajax({
|
315 |
-
type: 'POST',
|
316 |
-
url: ajaxurl,
|
317 |
-
data: { action: "woocommerce_csv_import_regenerate_thumbnail", id: id },
|
318 |
-
success: function( response ) {
|
319 |
-
if ( response !== Object( response ) || ( typeof response.success === "undefined" && typeof response.error === "undefined" ) ) {
|
320 |
-
response = new Object;
|
321 |
-
response.success = false;
|
322 |
-
response.error = "<?php printf( esc_js( __( 'The resize request was abnormally terminated (ID %s). This is likely due to the image exceeding available memory or some other type of fatal error.', 'wf_csv_import_export' ) ), '" + id + "' ); ?>";
|
323 |
-
}
|
324 |
-
|
325 |
-
regen_count ++;
|
326 |
-
|
327 |
-
$('#import-progress tbody .regenerating .progress').css( 'width', ( ( regen_count / attachments.length ) * 100 ) + '%' ).html( regen_count + ' / ' + attachments.length + ' <?php echo esc_js( __( 'thumbnails regenerated', 'wf_csv_import_export' ) ); ?>' );
|
328 |
-
|
329 |
-
if ( ! response.success ) {
|
330 |
-
$('#import-progress tbody').append( '<tr><td colspan="5">' + response.error + '</td></tr>' );
|
331 |
-
}
|
332 |
-
},
|
333 |
-
error: function( response ) {
|
334 |
-
$('#import-progress tbody').append( '<tr><td colspan="5">' + response.error + '</td></tr>' );
|
335 |
-
}
|
336 |
-
});
|
337 |
-
}
|
338 |
-
|
339 |
-
function import_done() {
|
340 |
-
var data = {
|
341 |
-
action: 'woocommerce_csv_import_request',
|
342 |
-
file: '<?php echo $file; ?>',
|
343 |
-
processed_terms: processed_terms,
|
344 |
-
processed_posts: processed_posts,
|
345 |
-
post_orphans: post_orphans,
|
346 |
-
upsell_skus: upsell_skus,
|
347 |
-
crosssell_skus: crosssell_skus
|
348 |
-
};
|
349 |
-
|
350 |
-
$.ajax({
|
351 |
-
url: '<?php echo add_query_arg( array( 'import_page' => $this->import_page, 'step' => '4', 'merge' => ! empty( $_GET['merge'] ) ? 1 : 0 ), admin_url( 'admin-ajax.php' ) ); ?>',
|
352 |
-
data: data,
|
353 |
-
type: 'POST',
|
354 |
-
success: function( response ) {
|
355 |
-
console.log( response );
|
356 |
-
$('#import-progress tbody').append( '<tr class="complete"><td colspan="5">' + response + '</td></tr>' );
|
357 |
-
$('.importer-loading').hide();
|
358 |
-
}
|
359 |
-
});
|
360 |
-
}
|
361 |
-
});
|
362 |
-
</script>
|
363 |
-
<?php
|
364 |
-
} else {
|
365 |
-
echo '<p class="error">' . __( 'Error finding uploaded file!', 'wf_csv_import_export' ) . '</p>';
|
366 |
-
}
|
367 |
-
break;
|
368 |
-
case 3 :
|
369 |
-
// Check access - cannot use nonce here as it will expire after multiple requests
|
370 |
-
if ( ! current_user_can( 'manage_woocommerce' ) )
|
371 |
-
die();
|
372 |
-
|
373 |
-
add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );
|
374 |
-
|
375 |
-
if ( function_exists( 'gc_enable' ) )
|
376 |
-
gc_enable();
|
377 |
-
|
378 |
-
@set_time_limit(0);
|
379 |
-
@ob_flush();
|
380 |
-
@flush();
|
381 |
-
$wpdb->hide_errors();
|
382 |
-
|
383 |
-
$file = stripslashes( $_POST['file'] );
|
384 |
-
$mapping = json_decode( stripslashes( $_POST['mapping'] ), true );
|
385 |
-
$eval_field = $_POST['eval_field'];
|
386 |
-
$start_pos = isset( $_POST['start_pos'] ) ? absint( $_POST['start_pos'] ) : 0;
|
387 |
-
$end_pos = isset( $_POST['end_pos'] ) ? absint( $_POST['end_pos'] ) : '';
|
388 |
-
|
389 |
-
update_option( 'wf_prod_csv_imp_exp_mapping', array($mapping,$eval_field ));
|
390 |
-
|
391 |
-
$position = $this->import_start( $file, $mapping, $start_pos, $end_pos, $eval_field );
|
392 |
-
$this->import();
|
393 |
-
$this->import_end();
|
394 |
-
|
395 |
-
$results = array();
|
396 |
-
$results['import_results'] = $this->import_results;
|
397 |
-
$results['processed_terms'] = $this->processed_terms;
|
398 |
-
$results['processed_posts'] = $this->processed_posts;
|
399 |
-
$results['post_orphans'] = $this->post_orphans;
|
400 |
-
$results['attachments'] = $this->attachments;
|
401 |
-
$results['upsell_skus'] = $this->upsell_skus;
|
402 |
-
$results['crosssell_skus'] = $this->crosssell_skus;
|
403 |
-
|
404 |
-
echo "<!--WC_START-->";
|
405 |
-
echo json_encode( $results );
|
406 |
-
echo "<!--WC_END-->";
|
407 |
-
exit;
|
408 |
-
break;
|
409 |
-
case 4 :
|
410 |
-
// Check access - cannot use nonce here as it will expire after multiple requests
|
411 |
-
if ( ! current_user_can( 'manage_woocommerce' ) )
|
412 |
-
die();
|
413 |
-
|
414 |
-
add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );
|
415 |
-
|
416 |
-
if ( function_exists( 'gc_enable' ) )
|
417 |
-
gc_enable();
|
418 |
-
|
419 |
-
@set_time_limit(0);
|
420 |
-
@ob_flush();
|
421 |
-
@flush();
|
422 |
-
$wpdb->hide_errors();
|
423 |
-
|
424 |
-
$this->processed_terms = isset( $_POST['processed_terms'] ) ? $_POST['processed_terms'] : array();
|
425 |
-
$this->processed_posts = isset( $_POST['processed_posts']) ? $_POST['processed_posts'] : array();
|
426 |
-
$this->post_orphans = isset( $_POST['post_orphans']) ? $_POST['post_orphans'] : array();
|
427 |
-
$this->crosssell_skus = isset( $_POST['crosssell_skus']) ? array_filter( (array) $_POST['crosssell_skus'] ) : array();
|
428 |
-
$this->upsell_skus = isset( $_POST['upsell_skus']) ? array_filter( (array) $_POST['upsell_skus'] ) : array();
|
429 |
-
|
430 |
-
_e( 'Step 1...', 'wf_csv_import_export' ) . ' ';
|
431 |
-
|
432 |
-
wp_defer_term_counting( true );
|
433 |
-
wp_defer_comment_counting( true );
|
434 |
-
|
435 |
-
_e( 'Step 2...', 'wf_csv_import_export' ) . ' ';
|
436 |
-
|
437 |
-
echo 'Step 3...' . ' '; // Easter egg
|
438 |
-
|
439 |
-
// reset transients for products
|
440 |
-
if ( function_exists( 'wc_delete_product_transients' ) ) {
|
441 |
-
wc_delete_product_transients();
|
442 |
-
} else {
|
443 |
-
$woocommerce->clear_product_transients();
|
444 |
-
}
|
445 |
-
|
446 |
-
delete_transient( 'wc_attribute_taxonomies' );
|
447 |
-
|
448 |
-
$wpdb->query("DELETE FROM `$wpdb->options` WHERE `option_name` LIKE ('_transient_wc_product_type_%')");
|
449 |
-
|
450 |
-
_e( 'Finalizing...', 'wf_csv_import_export' ) . ' ';
|
451 |
-
|
452 |
-
$this->backfill_parents();
|
453 |
-
|
454 |
-
if ( ! empty( $this->upsell_skus ) ) {
|
455 |
-
|
456 |
-
_e( 'Linking upsells...', 'wf_csv_import_export' ) . ' ';
|
457 |
-
|
458 |
-
foreach ( $this->upsell_skus as $post_id => $skus ) {
|
459 |
-
$this->link_product_skus( 'upsell', $post_id, $skus );
|
460 |
-
}
|
461 |
-
}
|
462 |
-
|
463 |
-
if ( ! empty( $this->crosssell_skus ) ) {
|
464 |
-
|
465 |
-
_e( 'Linking crosssells...', 'wf_csv_import_export' ) . ' ';
|
466 |
-
|
467 |
-
foreach ( $this->crosssell_skus as $post_id => $skus ) {
|
468 |
-
$this->link_product_skus( 'crosssell', $post_id, $skus );
|
469 |
-
}
|
470 |
-
}
|
471 |
-
// SUCCESS
|
472 |
-
_e( 'Finished. Import complete.', 'wf_csv_import_export' );
|
473 |
-
|
474 |
-
$this->import_end();
|
475 |
-
exit;
|
476 |
-
break;
|
477 |
-
}
|
478 |
-
|
479 |
-
$this->footer();
|
480 |
-
}
|
481 |
-
|
482 |
-
/**
|
483 |
-
* format_data_from_csv
|
484 |
-
*/
|
485 |
-
public function format_data_from_csv( $data, $enc ) {
|
486 |
-
return ( $enc == 'UTF-8' ) ? $data : utf8_encode( $data );
|
487 |
-
}
|
488 |
-
|
489 |
-
/**
|
490 |
-
* Display pre-import options
|
491 |
-
*/
|
492 |
-
public function import_options() {
|
493 |
-
$j = 0;
|
494 |
-
|
495 |
-
if ( $this->id )
|
496 |
-
$file = get_attached_file( $this->id );
|
497 |
-
else if ( $this->file_url_import_enabled )
|
498 |
-
$file = ABSPATH . $this->file_url;
|
499 |
-
else
|
500 |
-
return;
|
501 |
-
|
502 |
-
// Set locale
|
503 |
-
$enc = mb_detect_encoding( $file, 'UTF-8, ISO-8859-1', true );
|
504 |
-
if ( $enc ) setlocale( LC_ALL, 'en_US.' . $enc );
|
505 |
-
@ini_set( 'auto_detect_line_endings', true );
|
506 |
-
|
507 |
-
// Get headers
|
508 |
-
if ( ( $handle = fopen( $file, "r" ) ) !== FALSE ) {
|
509 |
-
|
510 |
-
$row = $raw_headers = array();
|
511 |
-
$header = fgetcsv( $handle, 0, $this->delimiter );
|
512 |
-
|
513 |
-
while ( ( $postmeta = fgetcsv( $handle, 0, $this->delimiter ) ) !== FALSE ) {
|
514 |
-
foreach ( $header as $key => $heading ) {
|
515 |
-
if ( ! $heading ) continue;
|
516 |
-
$s_heading = strtolower( $heading );
|
517 |
-
$row[$s_heading] = ( isset( $postmeta[$key] ) ) ? $this->format_data_from_csv( $postmeta[$key], $enc ) : '';
|
518 |
-
$raw_headers[ $s_heading ] = $heading;
|
519 |
-
}
|
520 |
-
break;
|
521 |
-
}
|
522 |
-
fclose( $handle );
|
523 |
-
}
|
524 |
-
|
525 |
-
$mapping_from_db = get_option( 'wf_prod_csv_imp_exp_mapping');
|
526 |
-
$saved_mapping = null;
|
527 |
-
$saved_evaluation = null;
|
528 |
-
if($mapping_from_db && is_array($mapping_from_db) && count($mapping_from_db) == 2 && empty($_GET['clearmapping'])){
|
529 |
-
//if(count(array_intersect_key ( $mapping_from_db[0] , $row)) == count($mapping_from_db[0])){
|
530 |
-
$reset_action = 'admin.php?clearmapping=1&import=' . $this->import_page . '&step=1&merge=' . $this->merge . '&file_url=' . $this->file_url . '&delimiter=' . $this->delimiter . '&merge_empty_cells=' . $this->merge_empty_cells . '&file_id=' . $this->id . '';
|
531 |
-
$reset_action = esc_attr(wp_nonce_url($reset_action, 'import-upload'));
|
532 |
-
echo '<h3>' . __( 'Map to fields are pre-selected based on your last import. <a href="'.$reset_action.'">Click here</a> to clear saved mapping.', 'wf_csv_import_export' ) . '</h3>';
|
533 |
-
$saved_mapping = $mapping_from_db[0];
|
534 |
-
$saved_evaluation = $mapping_from_db[1];
|
535 |
-
//}
|
536 |
-
}
|
537 |
-
|
538 |
-
$attrs = self::get_all_product_attributes();
|
539 |
-
$attr_keys = array_values($attrs);
|
540 |
-
|
541 |
-
$attributes = array();
|
542 |
-
if(!empty($attr_keys) && !empty($attrs))
|
543 |
-
$attributes = array_combine($attr_keys , $attrs);
|
544 |
-
|
545 |
-
$product_ptaxonomies = get_object_taxonomies( 'product', 'name' );
|
546 |
-
$product_vtaxonomies = get_object_taxonomies( 'product_variation', 'name' );
|
547 |
-
$product_taxonomies = array_merge($product_ptaxonomies, $product_vtaxonomies);
|
548 |
-
$taxonomies = array_keys($product_taxonomies);
|
549 |
-
$new_keys = array_values($taxonomies);
|
550 |
-
$taxonomies = array_combine($new_keys , $taxonomies);
|
551 |
-
include( 'views/html-wf-import-options.php' );
|
552 |
-
}
|
553 |
-
|
554 |
-
/**
|
555 |
-
* The main controller for the actual import stage.
|
556 |
-
*/
|
557 |
-
public function import() {
|
558 |
-
global $woocommerce, $wpdb;
|
559 |
-
|
560 |
-
wp_suspend_cache_invalidation( true );
|
561 |
-
|
562 |
-
$this->hf_log_data_change( 'csv-import', '---' );
|
563 |
-
$this->hf_log_data_change( 'csv-import', __( 'Processing products.', 'wf_csv_import_export' ) );
|
564 |
-
foreach ( $this->parsed_data as $key => &$item ) {
|
565 |
-
|
566 |
-
$product = $this->parser->parse_product( $item, $this->merge_empty_cells );
|
567 |
-
if ( ! is_wp_error( $product ) )
|
568 |
-
$this->process_product( $product );
|
569 |
-
else
|
570 |
-
$this->add_import_result( 'failed', $product->get_error_message(), 'Not parsed', json_encode( $item ), '-' );
|
571 |
-
|
572 |
-
unset( $item, $product );
|
573 |
-
}
|
574 |
-
$this->hf_log_data_change( 'csv-import', __( 'Finished processing products.', 'wf_csv_import_export' ) );
|
575 |
-
wp_suspend_cache_invalidation( false );
|
576 |
-
}
|
577 |
-
|
578 |
-
/**
|
579 |
-
* Parses the CSV file and prepares us for the task of processing parsed data
|
580 |
-
*
|
581 |
-
* @param string $file Path to the CSV file for importing
|
582 |
-
*/
|
583 |
-
|
584 |
-
public function hf_log_data_change ($content = 'csv-import',$data='')
|
585 |
-
{
|
586 |
-
if (WC()->version < '2.7.0')
|
587 |
-
{
|
588 |
-
$this->log->add($content,$data);
|
589 |
-
}else
|
590 |
-
{
|
591 |
-
$context = array( 'source' => $content );
|
592 |
-
$this->log->log("debug", $data ,$context);
|
593 |
-
}
|
594 |
-
}
|
595 |
-
public function import_start( $file, $mapping, $start_pos, $end_pos, $eval_field ) {
|
596 |
-
|
597 |
-
if(WC()->version < '2.7.0'){
|
598 |
-
$memory = size_format( woocommerce_let_to_num( ini_get( 'memory_limit' ) ) );
|
599 |
-
$wp_memory = size_format( woocommerce_let_to_num( WP_MEMORY_LIMIT ) );
|
600 |
-
}else
|
601 |
-
{
|
602 |
-
$memory = size_format( wc_let_to_num( ini_get( 'memory_limit' ) ) );
|
603 |
-
$wp_memory = size_format( wc_let_to_num( WP_MEMORY_LIMIT ) );
|
604 |
-
|
605 |
-
}
|
606 |
-
$this->hf_log_data_change( 'csv-import', '---[ New Import ] PHP Memory: ' . $memory . ', WP Memory: ' . $wp_memory );
|
607 |
-
$this->hf_log_data_change( 'csv-import', __( 'Parsing products CSV.', 'wf_csv_import_export' ) );
|
608 |
-
|
609 |
-
$this->parser = new WF_CSV_Parser( 'product' );
|
610 |
-
|
611 |
-
list( $this->parsed_data, $this->raw_headers, $position ) = $this->parser->parse_data( $file, $this->delimiter, $mapping, $start_pos, $end_pos, $eval_field );
|
612 |
-
|
613 |
-
$this->hf_log_data_change( 'csv-import', __( 'Finished parsing products CSV.', 'wf_csv_import_export' ) );
|
614 |
-
|
615 |
-
unset( $import_data );
|
616 |
-
|
617 |
-
wp_defer_term_counting( true );
|
618 |
-
wp_defer_comment_counting( true );
|
619 |
-
|
620 |
-
return $position;
|
621 |
-
}
|
622 |
-
|
623 |
-
/**
|
624 |
-
* Performs post-import cleanup of files and the cache
|
625 |
-
*/
|
626 |
-
public function import_end() {
|
627 |
-
|
628 |
-
//wp_cache_flush(); Stops output in some hosting environments
|
629 |
-
foreach ( get_taxonomies() as $tax ) {
|
630 |
-
delete_option( "{$tax}_children" );
|
631 |
-
_get_term_hierarchy( $tax );
|
632 |
-
}
|
633 |
-
|
634 |
-
wp_defer_term_counting( false );
|
635 |
-
wp_defer_comment_counting( false );
|
636 |
-
|
637 |
-
do_action( 'import_end' );
|
638 |
-
}
|
639 |
-
|
640 |
-
/**
|
641 |
-
* Handles the CSV upload and initial parsing of the file to prepare for
|
642 |
-
* displaying author import options
|
643 |
-
*
|
644 |
-
* @return bool False if error uploading or invalid file, true otherwise
|
645 |
-
*/
|
646 |
-
public function handle_upload() {
|
647 |
-
if($this->handle_ftp()){
|
648 |
-
return true;
|
649 |
-
}
|
650 |
-
if ( empty( $_POST['file_url'] ) ) {
|
651 |
-
|
652 |
-
$file = wp_import_handle_upload();
|
653 |
-
|
654 |
-
if ( isset( $file['error'] ) ) {
|
655 |
-
echo '<p><strong>' . __( 'Sorry, there has been an error.', 'wf_csv_import_export' ) . '</strong><br />';
|
656 |
-
echo esc_html( $file['error'] ) . '</p>';
|
657 |
-
return false;
|
658 |
-
}
|
659 |
-
|
660 |
-
$this->id = (int) $file['id'];
|
661 |
-
return true;
|
662 |
-
|
663 |
-
} else {
|
664 |
-
|
665 |
-
if ( file_exists( ABSPATH . $_POST['file_url'] ) ) {
|
666 |
-
|
667 |
-
$this->file_url = esc_attr( $_POST['file_url'] );
|
668 |
-
return true;
|
669 |
-
|
670 |
-
} else {
|
671 |
-
|
672 |
-
echo '<p><strong>' . __( 'Sorry, there has been an error.', 'wf_csv_import_export' ) . '</strong></p>';
|
673 |
-
return false;
|
674 |
-
|
675 |
-
}
|
676 |
-
|
677 |
-
}
|
678 |
-
|
679 |
-
return false;
|
680 |
-
}
|
681 |
-
|
682 |
-
public function product_exists( $title, $sku = '', $post_name = '' ) {
|
683 |
-
global $wpdb;
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
if (
|
777 |
-
$
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
$
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
);
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
$
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
$
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
)
|
903 |
-
|
904 |
-
|
905 |
-
if (
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
}
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
$
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
$
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
$
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
$
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
//
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
$
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
$
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
$
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
$
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
public function
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
$
|
1430 |
-
|
1431 |
-
$
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
+
exit;
|
4 |
+
}
|
5 |
+
/**
|
6 |
+
* WordPress Importer class for managing the import process of a CSV file
|
7 |
+
*
|
8 |
+
* @package WordPress
|
9 |
+
* @subpackage Importer
|
10 |
+
*/
|
11 |
+
if ( ! class_exists( 'WP_Importer' ) )
|
12 |
+
return;
|
13 |
+
|
14 |
+
class WF_ProdImpExpCsv_Product_Import extends WP_Importer {
|
15 |
+
|
16 |
+
var $id;
|
17 |
+
var $file_url;
|
18 |
+
var $delimiter;
|
19 |
+
var $merge;
|
20 |
+
var $merge_empty_cells;
|
21 |
+
|
22 |
+
// mappings from old information to new
|
23 |
+
var $processed_terms = array();
|
24 |
+
var $processed_posts = array();
|
25 |
+
var $post_orphans = array();
|
26 |
+
var $attachments = array();
|
27 |
+
var $upsell_skus = array();
|
28 |
+
var $crosssell_skus = array();
|
29 |
+
|
30 |
+
// Results
|
31 |
+
var $import_results = array();
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Constructor
|
35 |
+
*/
|
36 |
+
public function __construct() {
|
37 |
+
|
38 |
+
if(WC()->version < '2.7.0'){
|
39 |
+
$this->log = new WC_Logger();
|
40 |
+
|
41 |
+
}else
|
42 |
+
{
|
43 |
+
$this->log = wc_get_logger();
|
44 |
+
|
45 |
+
}
|
46 |
+
|
47 |
+
$this->import_page = 'xa_woocommerce_csv';
|
48 |
+
$this->file_url_import_enabled = apply_filters( 'woocommerce_csv_product_file_url_import_enabled', true );
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Registered callback function for the WordPress Importer
|
53 |
+
*
|
54 |
+
* Manages the three separate stages of the CSV import process
|
55 |
+
*/
|
56 |
+
public function dispatch() {
|
57 |
+
global $woocommerce, $wpdb;
|
58 |
+
|
59 |
+
if ( ! empty( $_POST['delimiter'] ) ) {
|
60 |
+
$this->delimiter = stripslashes( trim( $_POST['delimiter'] ) );
|
61 |
+
}else if ( ! empty( $_GET['delimiter'] ) ) {
|
62 |
+
$this->delimiter = stripslashes( trim( $_GET['delimiter'] ) );
|
63 |
+
}
|
64 |
+
|
65 |
+
if ( ! $this->delimiter )
|
66 |
+
$this->delimiter = ',';
|
67 |
+
|
68 |
+
if ( ! empty( $_POST['merge'] ) || ! empty( $_GET['merge'] ) ) {
|
69 |
+
$this->merge = 1;
|
70 |
+
} else{
|
71 |
+
$this->merge = 0;
|
72 |
+
}
|
73 |
+
|
74 |
+
if ( ! empty( $_POST['merge_empty_cells'] ) || ! empty( $_GET['merge_empty_cells'] ) ) {
|
75 |
+
$this->merge_empty_cells = 1;
|
76 |
+
} else{
|
77 |
+
$this->merge_empty_cells = 0;
|
78 |
+
}
|
79 |
+
|
80 |
+
$step = empty( $_GET['step'] ) ? 0 : (int) $_GET['step'];
|
81 |
+
|
82 |
+
switch ( $step ) {
|
83 |
+
case 0 :
|
84 |
+
$this->header();
|
85 |
+
$this->greet();
|
86 |
+
break;
|
87 |
+
case 1 :
|
88 |
+
$this->header();
|
89 |
+
|
90 |
+
check_admin_referer( 'import-upload' );
|
91 |
+
|
92 |
+
if(!empty($_GET['file_url']))
|
93 |
+
$this->file_url = esc_attr( $_GET['file_url'] );
|
94 |
+
if(!empty($_GET['file_id']))
|
95 |
+
$this->id = $_GET['file_id'] ;
|
96 |
+
|
97 |
+
if ( !empty($_GET['clearmapping']) || $this->handle_upload() )
|
98 |
+
$this->import_options();
|
99 |
+
else
|
100 |
+
_e( 'Error with handle_upload!', 'wf_csv_import_export' );
|
101 |
+
break;
|
102 |
+
case 2 :
|
103 |
+
$this->header();
|
104 |
+
|
105 |
+
check_admin_referer( 'import-woocommerce' );
|
106 |
+
|
107 |
+
$this->id = (int) $_POST['import_id'];
|
108 |
+
|
109 |
+
if ( $this->file_url_import_enabled )
|
110 |
+
$this->file_url = esc_attr( $_POST['import_url'] );
|
111 |
+
|
112 |
+
if ( $this->id )
|
113 |
+
$file = get_attached_file( $this->id );
|
114 |
+
else if ( $this->file_url_import_enabled )
|
115 |
+
$file = ABSPATH . $this->file_url;
|
116 |
+
|
117 |
+
$file = str_replace( "\\", "/", $file );
|
118 |
+
|
119 |
+
if ( $file ) {
|
120 |
+
?>
|
121 |
+
<table id="import-progress" class="widefat_importer widefat">
|
122 |
+
<thead>
|
123 |
+
<tr>
|
124 |
+
<th class="status"> </th>
|
125 |
+
<th class="row"><?php _e( 'Row', 'wf_csv_import_export' ); ?></th>
|
126 |
+
<th><?php _e( 'SKU', 'wf_csv_import_export' ); ?></th>
|
127 |
+
<th><?php _e( 'Product', 'wf_csv_import_export' ); ?></th>
|
128 |
+
<th class="reason"><?php _e( 'Status Msg', 'wf_csv_import_export' ); ?></th>
|
129 |
+
</tr>
|
130 |
+
</thead>
|
131 |
+
<tfoot>
|
132 |
+
<tr class="importer-loading">
|
133 |
+
<td colspan="5"></td>
|
134 |
+
</tr>
|
135 |
+
</tfoot>
|
136 |
+
<tbody></tbody>
|
137 |
+
</table>
|
138 |
+
<script type="text/javascript">
|
139 |
+
jQuery(document).ready(function($) {
|
140 |
+
|
141 |
+
if ( ! window.console ) { window.console = function(){}; }
|
142 |
+
|
143 |
+
var processed_terms = [];
|
144 |
+
var processed_posts = [];
|
145 |
+
var post_orphans = [];
|
146 |
+
var attachments = [];
|
147 |
+
var upsell_skus = [];
|
148 |
+
var crosssell_skus = [];
|
149 |
+
var i = 1;
|
150 |
+
var done_count = 0;
|
151 |
+
|
152 |
+
function import_rows( start_pos, end_pos ) {
|
153 |
+
|
154 |
+
var data = {
|
155 |
+
action: 'woocommerce_csv_import_request',
|
156 |
+
file: '<?php echo addslashes( $file ); ?>',
|
157 |
+
mapping: '<?php echo json_encode( $_POST['map_from'] ); ?>',
|
158 |
+
eval_field: '<?php echo stripslashes(json_encode(($_POST['eval_field']),JSON_HEX_APOS)) ?>',
|
159 |
+
delimiter: '<?php echo $this->delimiter; ?>',
|
160 |
+
merge_empty_cells: '<?php echo $this->merge_empty_cells; ?>',
|
161 |
+
merge: '<?php echo $this->merge; ?>',
|
162 |
+
start_pos: start_pos,
|
163 |
+
end_pos: end_pos,
|
164 |
+
};
|
165 |
+
data.eval_field = $.parseJSON(data.eval_field);
|
166 |
+
return $.ajax({
|
167 |
+
url: '<?php echo add_query_arg( array( 'import_page' => $this->import_page, 'step' => '3', 'merge' => ! empty( $_GET['merge'] ) ? '1' : '0' ), admin_url( 'admin-ajax.php' ) ); ?>',
|
168 |
+
data: data,
|
169 |
+
type: 'POST',
|
170 |
+
success: function( response ) {
|
171 |
+
//console.log( response );
|
172 |
+
if ( response ) {
|
173 |
+
|
174 |
+
try {
|
175 |
+
// Get the valid JSON only from the returned string
|
176 |
+
if ( response.indexOf("<!--WC_START-->") >= 0 )
|
177 |
+
response = response.split("<!--WC_START-->")[1]; // Strip off before after WC_START
|
178 |
+
|
179 |
+
if ( response.indexOf("<!--WC_END-->") >= 0 )
|
180 |
+
response = response.split("<!--WC_END-->")[0]; // Strip off anything after WC_END
|
181 |
+
|
182 |
+
// Parse
|
183 |
+
var results = $.parseJSON( response );
|
184 |
+
|
185 |
+
if ( results.error ) {
|
186 |
+
|
187 |
+
$('#import-progress tbody').append( '<tr id="row-' + i + '" class="error"><td class="status" colspan="5">' + results.error + '</td></tr>' );
|
188 |
+
|
189 |
+
i++;
|
190 |
+
|
191 |
+
} else if ( results.import_results && $( results.import_results ).size() > 0 ) {
|
192 |
+
|
193 |
+
$.each( results.processed_terms, function( index, value ) {
|
194 |
+
processed_terms.push( value );
|
195 |
+
});
|
196 |
+
|
197 |
+
$.each( results.processed_posts, function( index, value ) {
|
198 |
+
processed_posts.push( value );
|
199 |
+
});
|
200 |
+
|
201 |
+
$.each( results.post_orphans, function( index, value ) {
|
202 |
+
post_orphans.push( value );
|
203 |
+
});
|
204 |
+
|
205 |
+
$.each( results.attachments, function( index, value ) {
|
206 |
+
attachments.push( value );
|
207 |
+
});
|
208 |
+
|
209 |
+
upsell_skus = jQuery.extend( {}, upsell_skus, results.upsell_skus );
|
210 |
+
crosssell_skus = jQuery.extend( {}, crosssell_skus, results.crosssell_skus );
|
211 |
+
|
212 |
+
$( results.import_results ).each(function( index, row ) {
|
213 |
+
$('#import-progress tbody').append( '<tr id="row-' + i + '" class="' + row['status'] + '"><td><mark class="result" title="' + row['status'] + '">' + row['status'] + '</mark></td><td class="row">' + i + '</td><td>' + row['sku'] + '</td><td>' + row['post_id'] + ' - ' + row['post_title'] + '</td><td class="reason">' + row['reason'] + '</td></tr>' );
|
214 |
+
|
215 |
+
i++;
|
216 |
+
});
|
217 |
+
}
|
218 |
+
|
219 |
+
} catch(err) {}
|
220 |
+
|
221 |
+
} else {
|
222 |
+
$('#import-progress tbody').append( '<tr class="error"><td class="status" colspan="5">' + '<?php _e( 'AJAX Error', 'wf_csv_import_export' ); ?>' + '</td></tr>' );
|
223 |
+
}
|
224 |
+
|
225 |
+
var w = $(window);
|
226 |
+
var row = $( "#row-" + ( i - 1 ) );
|
227 |
+
|
228 |
+
if ( row.length ) {
|
229 |
+
w.scrollTop( row.offset().top - (w.height()/2) );
|
230 |
+
}
|
231 |
+
|
232 |
+
done_count++;
|
233 |
+
|
234 |
+
$('body').trigger( 'woocommerce_csv_import_request_complete' );
|
235 |
+
}
|
236 |
+
});
|
237 |
+
}
|
238 |
+
|
239 |
+
var rows = [];
|
240 |
+
|
241 |
+
<?php
|
242 |
+
$limit = apply_filters( 'woocommerce_csv_import_limit_per_request', 10 );
|
243 |
+
$enc = mb_detect_encoding( $file, 'UTF-8, ISO-8859-1', true );
|
244 |
+
if ( $enc )
|
245 |
+
setlocale( LC_ALL, 'en_US.' . $enc );
|
246 |
+
@ini_set( 'auto_detect_line_endings', true );
|
247 |
+
|
248 |
+
$count = 0;
|
249 |
+
$previous_position = 0;
|
250 |
+
$position = 0;
|
251 |
+
$import_count = 0;
|
252 |
+
|
253 |
+
// Get CSV positions
|
254 |
+
if ( ( $handle = fopen( $file, "r" ) ) !== FALSE ) {
|
255 |
+
|
256 |
+
while ( ( $postmeta = fgetcsv( $handle, 0, $this->delimiter ) ) !== FALSE ) {
|
257 |
+
$count++;
|
258 |
+
|
259 |
+
if ( $count >= $limit ) {
|
260 |
+
$previous_position = $position;
|
261 |
+
$position = ftell( $handle );
|
262 |
+
$count = 0;
|
263 |
+
$import_count ++;
|
264 |
+
|
265 |
+
// Import rows between $previous_position $position
|
266 |
+
?>rows.push( [ <?php echo $previous_position; ?>, <?php echo $position; ?> ] ); <?php
|
267 |
+
}
|
268 |
+
}
|
269 |
+
|
270 |
+
// Remainder
|
271 |
+
if ( $count > 0 ) {
|
272 |
+
?>rows.push( [ <?php echo $position; ?>, '' ] ); <?php
|
273 |
+
$import_count ++;
|
274 |
+
}
|
275 |
+
|
276 |
+
fclose( $handle );
|
277 |
+
}
|
278 |
+
?>
|
279 |
+
|
280 |
+
var data = rows.shift();
|
281 |
+
var regen_count = 0;
|
282 |
+
import_rows( data[0], data[1] );
|
283 |
+
|
284 |
+
$('body').on( 'woocommerce_csv_import_request_complete', function() {
|
285 |
+
if ( done_count == <?php echo $import_count; ?> ) {
|
286 |
+
|
287 |
+
if ( attachments.length ) {
|
288 |
+
|
289 |
+
$('#import-progress tbody').append( '<tr class="regenerating"><td colspan="5"><div class="progress"></div></td></tr>' );
|
290 |
+
|
291 |
+
index = 0;
|
292 |
+
|
293 |
+
$.each( attachments, function( i, value ) {
|
294 |
+
regenerate_thumbnail( value );
|
295 |
+
index ++;
|
296 |
+
if ( index == attachments.length ) {
|
297 |
+
import_done();
|
298 |
+
}
|
299 |
+
});
|
300 |
+
|
301 |
+
} else {
|
302 |
+
import_done();
|
303 |
+
}
|
304 |
+
|
305 |
+
} else {
|
306 |
+
// Call next request
|
307 |
+
data = rows.shift();
|
308 |
+
import_rows( data[0], data[1] );
|
309 |
+
}
|
310 |
+
} );
|
311 |
+
|
312 |
+
// Regenerate a specified image via AJAX
|
313 |
+
function regenerate_thumbnail( id ) {
|
314 |
+
$.ajax({
|
315 |
+
type: 'POST',
|
316 |
+
url: ajaxurl,
|
317 |
+
data: { action: "woocommerce_csv_import_regenerate_thumbnail", id: id },
|
318 |
+
success: function( response ) {
|
319 |
+
if ( response !== Object( response ) || ( typeof response.success === "undefined" && typeof response.error === "undefined" ) ) {
|
320 |
+
response = new Object;
|
321 |
+
response.success = false;
|
322 |
+
response.error = "<?php printf( esc_js( __( 'The resize request was abnormally terminated (ID %s). This is likely due to the image exceeding available memory or some other type of fatal error.', 'wf_csv_import_export' ) ), '" + id + "' ); ?>";
|
323 |
+
}
|
324 |
+
|
325 |
+
regen_count ++;
|
326 |
+
|
327 |
+
$('#import-progress tbody .regenerating .progress').css( 'width', ( ( regen_count / attachments.length ) * 100 ) + '%' ).html( regen_count + ' / ' + attachments.length + ' <?php echo esc_js( __( 'thumbnails regenerated', 'wf_csv_import_export' ) ); ?>' );
|
328 |
+
|
329 |
+
if ( ! response.success ) {
|
330 |
+
$('#import-progress tbody').append( '<tr><td colspan="5">' + response.error + '</td></tr>' );
|
331 |
+
}
|
332 |
+
},
|
333 |
+
error: function( response ) {
|
334 |
+
$('#import-progress tbody').append( '<tr><td colspan="5">' + response.error + '</td></tr>' );
|
335 |
+
}
|
336 |
+
});
|
337 |
+
}
|
338 |
+
|
339 |
+
function import_done() {
|
340 |
+
var data = {
|
341 |
+
action: 'woocommerce_csv_import_request',
|
342 |
+
file: '<?php echo $file; ?>',
|
343 |
+
processed_terms: processed_terms,
|
344 |
+
processed_posts: processed_posts,
|
345 |
+
post_orphans: post_orphans,
|
346 |
+
upsell_skus: upsell_skus,
|
347 |
+
crosssell_skus: crosssell_skus
|
348 |
+
};
|
349 |
+
|
350 |
+
$.ajax({
|
351 |
+
url: '<?php echo add_query_arg( array( 'import_page' => $this->import_page, 'step' => '4', 'merge' => ! empty( $_GET['merge'] ) ? 1 : 0 ), admin_url( 'admin-ajax.php' ) ); ?>',
|
352 |
+
data: data,
|
353 |
+
type: 'POST',
|
354 |
+
success: function( response ) {
|
355 |
+
console.log( response );
|
356 |
+
$('#import-progress tbody').append( '<tr class="complete"><td colspan="5">' + response + '</td></tr>' );
|
357 |
+
$('.importer-loading').hide();
|
358 |
+
}
|
359 |
+
});
|
360 |
+
}
|
361 |
+
});
|
362 |
+
</script>
|
363 |
+
<?php
|
364 |
+
} else {
|
365 |
+
echo '<p class="error">' . __( 'Error finding uploaded file!', 'wf_csv_import_export' ) . '</p>';
|
366 |
+
}
|
367 |
+
break;
|
368 |
+
case 3 :
|
369 |
+
// Check access - cannot use nonce here as it will expire after multiple requests
|
370 |
+
if ( ! current_user_can( 'manage_woocommerce' ) )
|
371 |
+
die();
|
372 |
+
|
373 |
+
add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );
|
374 |
+
|
375 |
+
if ( function_exists( 'gc_enable' ) )
|
376 |
+
gc_enable();
|
377 |
+
|
378 |
+
@set_time_limit(0);
|
379 |
+
@ob_flush();
|
380 |
+
@flush();
|
381 |
+
$wpdb->hide_errors();
|
382 |
+
|
383 |
+
$file = stripslashes( $_POST['file'] );
|
384 |
+
$mapping = json_decode( stripslashes( $_POST['mapping'] ), true );
|
385 |
+
$eval_field = $_POST['eval_field'];
|
386 |
+
$start_pos = isset( $_POST['start_pos'] ) ? absint( $_POST['start_pos'] ) : 0;
|
387 |
+
$end_pos = isset( $_POST['end_pos'] ) ? absint( $_POST['end_pos'] ) : '';
|
388 |
+
|
389 |
+
update_option( 'wf_prod_csv_imp_exp_mapping', array($mapping,$eval_field ));
|
390 |
+
|
391 |
+
$position = $this->import_start( $file, $mapping, $start_pos, $end_pos, $eval_field );
|
392 |
+
$this->import();
|
393 |
+
$this->import_end();
|
394 |
+
|
395 |
+
$results = array();
|
396 |
+
$results['import_results'] = $this->import_results;
|
397 |
+
$results['processed_terms'] = $this->processed_terms;
|
398 |
+
$results['processed_posts'] = $this->processed_posts;
|
399 |
+
$results['post_orphans'] = $this->post_orphans;
|
400 |
+
$results['attachments'] = $this->attachments;
|
401 |
+
$results['upsell_skus'] = $this->upsell_skus;
|
402 |
+
$results['crosssell_skus'] = $this->crosssell_skus;
|
403 |
+
|
404 |
+
echo "<!--WC_START-->";
|
405 |
+
echo json_encode( $results );
|
406 |
+
echo "<!--WC_END-->";
|
407 |
+
exit;
|
408 |
+
break;
|
409 |
+
case 4 :
|
410 |
+
// Check access - cannot use nonce here as it will expire after multiple requests
|
411 |
+
if ( ! current_user_can( 'manage_woocommerce' ) )
|
412 |
+
die();
|
413 |
+
|
414 |
+
add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );
|
415 |
+
|
416 |
+
if ( function_exists( 'gc_enable' ) )
|
417 |
+
gc_enable();
|
418 |
+
|
419 |
+
@set_time_limit(0);
|
420 |
+
@ob_flush();
|
421 |
+
@flush();
|
422 |
+
$wpdb->hide_errors();
|
423 |
+
|
424 |
+
$this->processed_terms = isset( $_POST['processed_terms'] ) ? $_POST['processed_terms'] : array();
|
425 |
+
$this->processed_posts = isset( $_POST['processed_posts']) ? $_POST['processed_posts'] : array();
|
426 |
+
$this->post_orphans = isset( $_POST['post_orphans']) ? $_POST['post_orphans'] : array();
|
427 |
+
$this->crosssell_skus = isset( $_POST['crosssell_skus']) ? array_filter( (array) $_POST['crosssell_skus'] ) : array();
|
428 |
+
$this->upsell_skus = isset( $_POST['upsell_skus']) ? array_filter( (array) $_POST['upsell_skus'] ) : array();
|
429 |
+
|
430 |
+
_e( 'Step 1...', 'wf_csv_import_export' ) . ' ';
|
431 |
+
|
432 |
+
wp_defer_term_counting( true );
|
433 |
+
wp_defer_comment_counting( true );
|
434 |
+
|
435 |
+
_e( 'Step 2...', 'wf_csv_import_export' ) . ' ';
|
436 |
+
|
437 |
+
echo 'Step 3...' . ' '; // Easter egg
|
438 |
+
|
439 |
+
// reset transients for products
|
440 |
+
if ( function_exists( 'wc_delete_product_transients' ) ) {
|
441 |
+
wc_delete_product_transients();
|
442 |
+
} else {
|
443 |
+
$woocommerce->clear_product_transients();
|
444 |
+
}
|
445 |
+
|
446 |
+
delete_transient( 'wc_attribute_taxonomies' );
|
447 |
+
|
448 |
+
$wpdb->query("DELETE FROM `$wpdb->options` WHERE `option_name` LIKE ('_transient_wc_product_type_%')");
|
449 |
+
|
450 |
+
_e( 'Finalizing...', 'wf_csv_import_export' ) . ' ';
|
451 |
+
|
452 |
+
$this->backfill_parents();
|
453 |
+
|
454 |
+
if ( ! empty( $this->upsell_skus ) ) {
|
455 |
+
|
456 |
+
_e( 'Linking upsells...', 'wf_csv_import_export' ) . ' ';
|
457 |
+
|
458 |
+
foreach ( $this->upsell_skus as $post_id => $skus ) {
|
459 |
+
$this->link_product_skus( 'upsell', $post_id, $skus );
|
460 |
+
}
|
461 |
+
}
|
462 |
+
|
463 |
+
if ( ! empty( $this->crosssell_skus ) ) {
|
464 |
+
|
465 |
+
_e( 'Linking crosssells...', 'wf_csv_import_export' ) . ' ';
|
466 |
+
|
467 |
+
foreach ( $this->crosssell_skus as $post_id => $skus ) {
|
468 |
+
$this->link_product_skus( 'crosssell', $post_id, $skus );
|
469 |
+
}
|
470 |
+
}
|
471 |
+
// SUCCESS
|
472 |
+
_e( 'Finished. Import complete.', 'wf_csv_import_export' );
|
473 |
+
|
474 |
+
$this->import_end();
|
475 |
+
exit;
|
476 |
+
break;
|
477 |
+
}
|
478 |
+
|
479 |
+
$this->footer();
|
480 |
+
}
|
481 |
+
|
482 |
+
/**
|
483 |
+
* format_data_from_csv
|
484 |
+
*/
|
485 |
+
public function format_data_from_csv( $data, $enc ) {
|
486 |
+
return ( $enc == 'UTF-8' ) ? $data : utf8_encode( $data );
|
487 |
+
}
|
488 |
+
|
489 |
+
/**
|
490 |
+
* Display pre-import options
|
491 |
+
*/
|
492 |
+
public function import_options() {
|
493 |
+
$j = 0;
|
494 |
+
|
495 |
+
if ( $this->id )
|
496 |
+
$file = get_attached_file( $this->id );
|
497 |
+
else if ( $this->file_url_import_enabled )
|
498 |
+
$file = ABSPATH . $this->file_url;
|
499 |
+
else
|
500 |
+
return;
|
501 |
+
|
502 |
+
// Set locale
|
503 |
+
$enc = mb_detect_encoding( $file, 'UTF-8, ISO-8859-1', true );
|
504 |
+
if ( $enc ) setlocale( LC_ALL, 'en_US.' . $enc );
|
505 |
+
@ini_set( 'auto_detect_line_endings', true );
|
506 |
+
|
507 |
+
// Get headers
|
508 |
+
if ( ( $handle = fopen( $file, "r" ) ) !== FALSE ) {
|
509 |
+
|
510 |
+
$row = $raw_headers = array();
|
511 |
+
$header = fgetcsv( $handle, 0, $this->delimiter );
|
512 |
+
|
513 |
+
while ( ( $postmeta = fgetcsv( $handle, 0, $this->delimiter ) ) !== FALSE ) {
|
514 |
+
foreach ( $header as $key => $heading ) {
|
515 |
+
if ( ! $heading ) continue;
|
516 |
+
$s_heading = strtolower( $heading );
|
517 |
+
$row[$s_heading] = ( isset( $postmeta[$key] ) ) ? $this->format_data_from_csv( $postmeta[$key], $enc ) : '';
|
518 |
+
$raw_headers[ $s_heading ] = $heading;
|
519 |
+
}
|
520 |
+
break;
|
521 |
+
}
|
522 |
+
fclose( $handle );
|
523 |
+
}
|
524 |
+
|
525 |
+
$mapping_from_db = get_option( 'wf_prod_csv_imp_exp_mapping');
|
526 |
+
$saved_mapping = null;
|
527 |
+
$saved_evaluation = null;
|
528 |
+
if($mapping_from_db && is_array($mapping_from_db) && count($mapping_from_db) == 2 && empty($_GET['clearmapping'])){
|
529 |
+
//if(count(array_intersect_key ( $mapping_from_db[0] , $row)) == count($mapping_from_db[0])){
|
530 |
+
$reset_action = 'admin.php?clearmapping=1&import=' . $this->import_page . '&step=1&merge=' . $this->merge . '&file_url=' . $this->file_url . '&delimiter=' . $this->delimiter . '&merge_empty_cells=' . $this->merge_empty_cells . '&file_id=' . $this->id . '';
|
531 |
+
$reset_action = esc_attr(wp_nonce_url($reset_action, 'import-upload'));
|
532 |
+
echo '<h3>' . __( 'Map to fields are pre-selected based on your last import. <a href="'.$reset_action.'">Click here</a> to clear saved mapping.', 'wf_csv_import_export' ) . '</h3>';
|
533 |
+
$saved_mapping = $mapping_from_db[0];
|
534 |
+
$saved_evaluation = $mapping_from_db[1];
|
535 |
+
//}
|
536 |
+
}
|
537 |
+
|
538 |
+
$attrs = self::get_all_product_attributes();
|
539 |
+
$attr_keys = array_values($attrs);
|
540 |
+
|
541 |
+
$attributes = array();
|
542 |
+
if(!empty($attr_keys) && !empty($attrs))
|
543 |
+
$attributes = array_combine($attr_keys , $attrs);
|
544 |
+
|
545 |
+
$product_ptaxonomies = get_object_taxonomies( 'product', 'name' );
|
546 |
+
$product_vtaxonomies = get_object_taxonomies( 'product_variation', 'name' );
|
547 |
+
$product_taxonomies = array_merge($product_ptaxonomies, $product_vtaxonomies);
|
548 |
+
$taxonomies = array_keys($product_taxonomies);
|
549 |
+
$new_keys = array_values($taxonomies);
|
550 |
+
$taxonomies = array_combine($new_keys , $taxonomies);
|
551 |
+
include( 'views/html-wf-import-options.php' );
|
552 |
+
}
|
553 |
+
|
554 |
+
/**
|
555 |
+
* The main controller for the actual import stage.
|
556 |
+
*/
|
557 |
+
public function import() {
|
558 |
+
global $woocommerce, $wpdb;
|
559 |
+
|
560 |
+
wp_suspend_cache_invalidation( true );
|
561 |
+
|
562 |
+
$this->hf_log_data_change( 'csv-import', '---' );
|
563 |
+
$this->hf_log_data_change( 'csv-import', __( 'Processing products.', 'wf_csv_import_export' ) );
|
564 |
+
foreach ( $this->parsed_data as $key => &$item ) {
|
565 |
+
|
566 |
+
$product = $this->parser->parse_product( $item, $this->merge_empty_cells );
|
567 |
+
if ( ! is_wp_error( $product ) )
|
568 |
+
$this->process_product( $product );
|
569 |
+
else
|
570 |
+
$this->add_import_result( 'failed', $product->get_error_message(), 'Not parsed', json_encode( $item ), '-' );
|
571 |
+
|
572 |
+
unset( $item, $product );
|
573 |
+
}
|
574 |
+
$this->hf_log_data_change( 'csv-import', __( 'Finished processing products.', 'wf_csv_import_export' ) );
|
575 |
+
wp_suspend_cache_invalidation( false );
|
576 |
+
}
|
577 |
+
|
578 |
+
/**
|
579 |
+
* Parses the CSV file and prepares us for the task of processing parsed data
|
580 |
+
*
|
581 |
+
* @param string $file Path to the CSV file for importing
|
582 |
+
*/
|
583 |
+
|
584 |
+
public function hf_log_data_change ($content = 'csv-import',$data='')
|
585 |
+
{
|
586 |
+
if (WC()->version < '2.7.0')
|
587 |
+
{
|
588 |
+
$this->log->add($content,$data);
|
589 |
+
}else
|
590 |
+
{
|
591 |
+
$context = array( 'source' => $content );
|
592 |
+
$this->log->log("debug", $data ,$context);
|
593 |
+
}
|
594 |
+
}
|
595 |
+
public function import_start( $file, $mapping, $start_pos, $end_pos, $eval_field ) {
|
596 |
+
|
597 |
+
if(WC()->version < '2.7.0'){
|
598 |
+
$memory = size_format( woocommerce_let_to_num( ini_get( 'memory_limit' ) ) );
|
599 |
+
$wp_memory = size_format( woocommerce_let_to_num( WP_MEMORY_LIMIT ) );
|
600 |
+
}else
|
601 |
+
{
|
602 |
+
$memory = size_format( wc_let_to_num( ini_get( 'memory_limit' ) ) );
|
603 |
+
$wp_memory = size_format( wc_let_to_num( WP_MEMORY_LIMIT ) );
|
604 |
+
|
605 |
+
}
|
606 |
+
$this->hf_log_data_change( 'csv-import', '---[ New Import ] PHP Memory: ' . $memory . ', WP Memory: ' . $wp_memory );
|
607 |
+
$this->hf_log_data_change( 'csv-import', __( 'Parsing products CSV.', 'wf_csv_import_export' ) );
|
608 |
+
|
609 |
+
$this->parser = new WF_CSV_Parser( 'product' );
|
610 |
+
|
611 |
+
list( $this->parsed_data, $this->raw_headers, $position ) = $this->parser->parse_data( $file, $this->delimiter, $mapping, $start_pos, $end_pos, $eval_field );
|
612 |
+
|
613 |
+
$this->hf_log_data_change( 'csv-import', __( 'Finished parsing products CSV.', 'wf_csv_import_export' ) );
|
614 |
+
|
615 |
+
unset( $import_data );
|
616 |
+
|
617 |
+
wp_defer_term_counting( true );
|
618 |
+
wp_defer_comment_counting( true );
|
619 |
+
|
620 |
+
return $position;
|
621 |
+
}
|
622 |
+
|
623 |
+
/**
|
624 |
+
* Performs post-import cleanup of files and the cache
|
625 |
+
*/
|
626 |
+
public function import_end() {
|
627 |
+
|
628 |
+
//wp_cache_flush(); Stops output in some hosting environments
|
629 |
+
foreach ( get_taxonomies() as $tax ) {
|
630 |
+
delete_option( "{$tax}_children" );
|
631 |
+
_get_term_hierarchy( $tax );
|
632 |
+
}
|
633 |
+
|
634 |
+
wp_defer_term_counting( false );
|
635 |
+
wp_defer_comment_counting( false );
|
636 |
+
|
637 |
+
do_action( 'import_end' );
|
638 |
+
}
|
639 |
+
|
640 |
+
/**
|
641 |
+
* Handles the CSV upload and initial parsing of the file to prepare for
|
642 |
+
* displaying author import options
|
643 |
+
*
|
644 |
+
* @return bool False if error uploading or invalid file, true otherwise
|
645 |
+
*/
|
646 |
+
public function handle_upload() {
|
647 |
+
if($this->handle_ftp()){
|
648 |
+
return true;
|
649 |
+
}
|
650 |
+
if ( empty( $_POST['file_url'] ) ) {
|
651 |
+
|
652 |
+
$file = wp_import_handle_upload();
|
653 |
+
|
654 |
+
if ( isset( $file['error'] ) ) {
|
655 |
+
echo '<p><strong>' . __( 'Sorry, there has been an error.', 'wf_csv_import_export' ) . '</strong><br />';
|
656 |
+
echo esc_html( $file['error'] ) . '</p>';
|
657 |
+
return false;
|
658 |
+
}
|
659 |
+
|
660 |
+
$this->id = (int) $file['id'];
|
661 |
+
return true;
|
662 |
+
|
663 |
+
} else {
|
664 |
+
|
665 |
+
if ( file_exists( ABSPATH . $_POST['file_url'] ) ) {
|
666 |
+
|
667 |
+
$this->file_url = esc_attr( $_POST['file_url'] );
|
668 |
+
return true;
|
669 |
+
|
670 |
+
} else {
|
671 |
+
|
672 |
+
echo '<p><strong>' . __( 'Sorry, there has been an error.', 'wf_csv_import_export' ) . '</strong></p>';
|
673 |
+
return false;
|
674 |
+
|
675 |
+
}
|
676 |
+
|
677 |
+
}
|
678 |
+
|
679 |
+
return false;
|
680 |
+
}
|
681 |
+
|
682 |
+
public function product_exists( $title, $sku = '', $post_name = '' ) {
|
683 |
+
global $wpdb;
|
684 |
+
|
685 |
+
// Post Title Check
|
686 |
+
$post_title = stripslashes( sanitize_post_field( 'post_title', $title, 0, 'db' ) );
|
687 |
+
|
688 |
+
$query = "SELECT ID FROM $wpdb->posts WHERE post_type = 'product' AND post_status IN ( 'publish', 'private', 'draft', 'pending', 'future' )";
|
689 |
+
$args = array();
|
690 |
+
|
691 |
+
/*
|
692 |
+
* removed title check
|
693 |
+
if ( ! empty ( $title ) ) {
|
694 |
+
$query .= ' AND post_title = %s';
|
695 |
+
$args[] = $post_title;
|
696 |
+
}
|
697 |
+
|
698 |
+
|
699 |
+
if ( ! empty ( $post_name ) ) {
|
700 |
+
$query .= ' AND post_name = %s';
|
701 |
+
$args[] = $post_name;
|
702 |
+
}
|
703 |
+
|
704 |
+
*/
|
705 |
+
|
706 |
+
if ( ! empty ( $args ) ) {
|
707 |
+
$posts_that_exist = $wpdb->get_col( $wpdb->prepare( $query, $args ) );
|
708 |
+
|
709 |
+
if ( $posts_that_exist ) {
|
710 |
+
|
711 |
+
foreach( $posts_that_exist as $post_exists ) {
|
712 |
+
|
713 |
+
// Check unique SKU
|
714 |
+
$post_exists_sku = get_post_meta( $post_exists, '_sku', true );
|
715 |
+
|
716 |
+
if ( $sku == $post_exists_sku ) {
|
717 |
+
return true;
|
718 |
+
}
|
719 |
+
|
720 |
+
}
|
721 |
+
|
722 |
+
}
|
723 |
+
}
|
724 |
+
|
725 |
+
// Sku Check
|
726 |
+
if ( $sku ) {
|
727 |
+
|
728 |
+
$post_exists_sku = $wpdb->get_var( $wpdb->prepare( "
|
729 |
+
SELECT $wpdb->posts.ID
|
730 |
+
FROM $wpdb->posts
|
731 |
+
LEFT JOIN $wpdb->postmeta ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id )
|
732 |
+
WHERE $wpdb->posts.post_status IN ( 'publish', 'private', 'draft', 'pending', 'future' )
|
733 |
+
AND $wpdb->postmeta.meta_key = '_sku' AND $wpdb->postmeta.meta_value = '%s'
|
734 |
+
", $sku ) );
|
735 |
+
|
736 |
+
if ( $post_exists_sku ) {
|
737 |
+
return true;
|
738 |
+
}
|
739 |
+
}
|
740 |
+
|
741 |
+
return false;
|
742 |
+
}
|
743 |
+
|
744 |
+
|
745 |
+
public function wf_get_product_id_by_sku( $sku ) {
|
746 |
+
global $wpdb;
|
747 |
+
|
748 |
+
// phpcs:ignore WordPress.VIP.DirectDatabaseQuery.DirectQuery
|
749 |
+
$id = $wpdb->get_var(
|
750 |
+
$wpdb->prepare(
|
751 |
+
"SELECT posts.ID
|
752 |
+
FROM $wpdb->posts AS posts
|
753 |
+
LEFT JOIN $wpdb->postmeta AS postmeta ON ( posts.ID = postmeta.post_id )
|
754 |
+
WHERE posts.post_type IN ( 'product', 'product_variation' )
|
755 |
+
AND posts.post_status != 'trash'
|
756 |
+
AND postmeta.meta_key = '_sku'
|
757 |
+
AND postmeta.meta_value = %s
|
758 |
+
LIMIT 1",
|
759 |
+
$sku
|
760 |
+
)
|
761 |
+
);
|
762 |
+
|
763 |
+
return (int) apply_filters( 'wf_get_product_id_by_sku', $id, $sku );
|
764 |
+
}
|
765 |
+
|
766 |
+
/**
|
767 |
+
* Create new posts based on import information
|
768 |
+
*/
|
769 |
+
public function process_product( $post ) {
|
770 |
+
$processing_product_id = absint( $post['post_id'] );
|
771 |
+
$processing_product = get_post( $processing_product_id );
|
772 |
+
$processing_product_title = $processing_product ? $processing_product->post_title : '';
|
773 |
+
$processing_product_sku = $processing_product ? $processing_product->sku : '';
|
774 |
+
$merging = ! empty( $post['merging'] );
|
775 |
+
|
776 |
+
if ( ! empty( $post['post_title'] ) ) {
|
777 |
+
$processing_product_title = $post['post_title'];
|
778 |
+
}
|
779 |
+
|
780 |
+
if ( ! empty( $post['sku'] ) ) {
|
781 |
+
$processing_product_sku = $post['sku'];
|
782 |
+
}
|
783 |
+
|
784 |
+
if ( ! empty( $processing_product_id ) && isset( $this->processed_posts[ $processing_product_id ] ) ) {
|
785 |
+
$this->add_import_result( 'skipped', __( 'Product already processed', 'wf_csv_import_export' ), $processing_product_id, $processing_product_title, $processing_product_sku );
|
786 |
+
$this->hf_log_data_change( 'csv-import', __('> Post ID already processed. Skipping.', 'wf_csv_import_export'), true );
|
787 |
+
unset( $post );
|
788 |
+
return;
|
789 |
+
}
|
790 |
+
|
791 |
+
if ( ! empty ( $post['post_status'] ) && $post['post_status'] == 'auto-draft' ) {
|
792 |
+
$this->add_import_result( 'skipped', __( 'Skipping auto-draft', 'wf_csv_import_export' ), $processing_product_id, $processing_product_title, $processing_product_sku );
|
793 |
+
$this->hf_log_data_change( 'csv-import', __('> Skipping auto-draft.', 'wf_csv_import_export'), true );
|
794 |
+
unset( $post );
|
795 |
+
return;
|
796 |
+
}
|
797 |
+
// Check if post exists when importing
|
798 |
+
|
799 |
+
if ( ! $merging ) {
|
800 |
+
if ( $this->product_exists( $processing_product_title, $processing_product_sku, $post['post_name'] ) ) {
|
801 |
+
if(!$processing_product_id && empty($processing_product_sku)) {
|
802 |
+
// if no sku , no id and no merge + is product in db with same title -> just give message
|
803 |
+
$usr_msg = 'Product with same title already exist.';
|
804 |
+
}else{
|
805 |
+
$usr_msg = 'Product already exists.';
|
806 |
+
}
|
807 |
+
$this->add_import_result( 'skipped', __( $usr_msg, 'wf_csv_import_export' ), $processing_product_id, $processing_product_title, $processing_product_sku );
|
808 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __('> “%s”'.$usr_msg, 'wf_csv_import_export'), esc_html($processing_product_title) ), true );
|
809 |
+
unset( $post );
|
810 |
+
return;
|
811 |
+
}
|
812 |
+
|
813 |
+
if ( $processing_product_id && is_string( get_post_status( $processing_product_id ) ) ) {
|
814 |
+
$this->add_import_result( 'skipped', __( 'Importing post ID conflicts with an existing post ID', 'wf_csv_import_export' ), $processing_product_id, get_the_title( $processing_product_id ), '' );
|
815 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __('> “%s” ID already exists.', 'wf_csv_import_export'), esc_html( $processing_product_id ) ), true );
|
816 |
+
unset( $post );
|
817 |
+
return;
|
818 |
+
}
|
819 |
+
}
|
820 |
+
|
821 |
+
|
822 |
+
// if ( ! $merging ) {
|
823 |
+
// error_log('<pre>$this->wf_get_product_id_by_sku( $processing_product_sku ):-' . print_r($this->wf_get_product_id_by_sku( $processing_product_sku ), 1) . '</per>', 3, ABSPATH . "/wp-content/uploads/wc-logs/test-log.txt");
|
824 |
+
// if ( $this->wf_get_product_id_by_sku( $processing_product_sku ) ) {
|
825 |
+
//// $usr_msg = __( 'Product already exists.', 'wf_csv_import_export' );
|
826 |
+
//// $this->add_import_result( 'skipped',$usr_msg, $processing_product_id, $processing_product_title, $processing_product_sku );
|
827 |
+
//// $this->hf_log_data_change( 'csv-import', sprintf( __('> “%s” Product already exists.', 'wf_csv_import_export'), esc_html($processing_product_title) ), true );
|
828 |
+
//// unset( $post );
|
829 |
+
//// return;
|
830 |
+
//
|
831 |
+
// if(!$processing_product_id && empty($processing_product_sku)) {
|
832 |
+
// // if no sku , no id and no merge + is product in db with same title -> just give message
|
833 |
+
// $usr_msg = 'Product with same title already exist.';
|
834 |
+
// }else{
|
835 |
+
// $usr_msg = 'Product already exists.';
|
836 |
+
// }
|
837 |
+
// $this->add_import_result( 'skipped', __( $usr_msg, 'wf_csv_import_export' ), $processing_product_id, $processing_product_title, $processing_product_sku );
|
838 |
+
// $this->hf_log_data_change( 'csv-import', sprintf( __('> “%s”'.$usr_msg, 'wf_csv_import_export'), esc_html($processing_product_title) ), true );
|
839 |
+
// unset( $post );
|
840 |
+
// return;
|
841 |
+
// }
|
842 |
+
//
|
843 |
+
// if ( $processing_product_id && is_string( get_post_status( $processing_product_id ) ) ) {
|
844 |
+
// $this->add_import_result( 'skipped', __( 'Importing post ID conflicts with an existing post ID', 'wf_csv_import_export' ), $processing_product_id, get_the_title( $processing_product_id ), '' );
|
845 |
+
// $this->hf_log_data_change( 'csv-import', sprintf( __('> “%s” ID already exists.', 'wf_csv_import_export'), esc_html( $processing_product_id ) ), true );
|
846 |
+
// unset( $post );
|
847 |
+
// return;
|
848 |
+
// }
|
849 |
+
// }
|
850 |
+
// Check post type to avoid conflicts with IDs
|
851 |
+
$is_post_exist_in_db = get_post_type( $processing_product_id );
|
852 |
+
if ( $merging && $processing_product_id && !empty($is_post_exist_in_db) && ($is_post_exist_in_db !== $post['post_type'] )) {
|
853 |
+
$this->add_import_result( 'skipped', __( 'Post is not a product', 'wf_csv_import_export' ), $processing_product_id, $processing_product_title, $processing_product_sku );
|
854 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __('> “%s” is not a product.', 'wf_csv_import_export'), esc_html($processing_product_id) ), true );
|
855 |
+
unset( $post );
|
856 |
+
return;
|
857 |
+
}
|
858 |
+
|
859 |
+
if ( $merging && !empty($is_post_exist_in_db) ) {
|
860 |
+
|
861 |
+
// Only merge fields which are set
|
862 |
+
$post_id = $processing_product_id;
|
863 |
+
|
864 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __('> Merging post ID %s.', 'wf_csv_import_export'), $post_id ), true );
|
865 |
+
|
866 |
+
$postdata = array(
|
867 |
+
'ID' => $post_id
|
868 |
+
);
|
869 |
+
|
870 |
+
if ( $this->merge_empty_cells ) {
|
871 |
+
if ( isset( $post['post_content'] ) ) {
|
872 |
+
$postdata['post_content'] = $post['post_content'];
|
873 |
+
}
|
874 |
+
if ( isset( $post['post_excerpt'] ) ) {
|
875 |
+
$postdata['post_excerpt'] = $post['post_excerpt'];
|
876 |
+
}
|
877 |
+
if ( isset( $post['post_password'] ) ) {
|
878 |
+
$postdata['post_password'] = $post['post_password'];
|
879 |
+
}
|
880 |
+
if ( isset( $post['post_parent'] ) ) {
|
881 |
+
$postdata['post_parent'] = $post['post_parent'];
|
882 |
+
}
|
883 |
+
} else {
|
884 |
+
if ( ! empty( $post['post_content'] ) ) {
|
885 |
+
$postdata['post_content'] = $post['post_content'];
|
886 |
+
}
|
887 |
+
if ( ! empty( $post['post_excerpt'] ) ) {
|
888 |
+
$postdata['post_excerpt'] = $post['post_excerpt'];
|
889 |
+
}
|
890 |
+
if ( ! empty( $post['post_password'] ) ) {
|
891 |
+
$postdata['post_password'] = $post['post_password'];
|
892 |
+
}
|
893 |
+
if ( isset( $post['post_parent'] ) && $post['post_parent'] !== '' ) {
|
894 |
+
$postdata['post_parent'] = $post['post_parent'];
|
895 |
+
}
|
896 |
+
}
|
897 |
+
|
898 |
+
if ( ! empty( $post['post_title'] ) ) {
|
899 |
+
$postdata['post_title'] = $post['post_title'];
|
900 |
+
}
|
901 |
+
|
902 |
+
if ( ! empty( $post['post_author'] ) ) {
|
903 |
+
$postdata['post_author'] = absint( $post['post_author'] );
|
904 |
+
}
|
905 |
+
if ( ! empty( $post['post_date'] ) ) {
|
906 |
+
$postdata['post_date'] = date("Y-m-d H:i:s", strtotime( $post['post_date'] ) );
|
907 |
+
}
|
908 |
+
if ( ! empty( $post['post_date_gmt'] ) ) {
|
909 |
+
$postdata['post_date_gmt'] = date("Y-m-d H:i:s", strtotime( $post['post_date_gmt'] ) );
|
910 |
+
}
|
911 |
+
if ( ! empty( $post['post_name'] ) ) {
|
912 |
+
$postdata['post_name'] = $post['post_name'];
|
913 |
+
}
|
914 |
+
if ( ! empty( $post['post_status'] ) ) {
|
915 |
+
$postdata['post_status'] = $post['post_status'];
|
916 |
+
}
|
917 |
+
if ( ! empty( $post['menu_order'] ) ) {
|
918 |
+
$postdata['menu_order'] = $post['menu_order'];
|
919 |
+
}
|
920 |
+
if ( ! empty( $post['comment_status'] ) ) {
|
921 |
+
$postdata['comment_status'] = $post['comment_status'];
|
922 |
+
}
|
923 |
+
if ( sizeof( $postdata ) > 1 ) {
|
924 |
+
$result = wp_update_post( $postdata );
|
925 |
+
|
926 |
+
if ( ! $result ) {
|
927 |
+
$this->add_import_result( 'failed', __( 'Failed to update product', 'wf_csv_import_export' ), $post_id, $processing_product_title, $processing_product_sku );
|
928 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __('> Failed to update product %s', 'wf_csv_import_export'), $post_id ), true );
|
929 |
+
unset( $post );
|
930 |
+
return;
|
931 |
+
} else {
|
932 |
+
$this->hf_log_data_change( 'csv-import', __( '> Merged post data: ', 'wf_csv_import_export' ) . print_r( $postdata, true ) );
|
933 |
+
}
|
934 |
+
}
|
935 |
+
|
936 |
+
} else {
|
937 |
+
$merging = FALSE;
|
938 |
+
// Get parent
|
939 |
+
$post_parent = (isset($post['post_parent'])?$post['post_parent']:'');
|
940 |
+
|
941 |
+
if ( $post_parent !== "" ) {
|
942 |
+
$post_parent = absint( $post_parent );
|
943 |
+
|
944 |
+
if ( $post_parent > 0 ) {
|
945 |
+
// if we already know the parent, map it to the new local ID
|
946 |
+
if ( isset( $this->processed_posts[ $post_parent ] ) ) {
|
947 |
+
$post_parent = $this->processed_posts[ $post_parent ];
|
948 |
+
|
949 |
+
// otherwise record the parent for later
|
950 |
+
} else {
|
951 |
+
|
952 |
+
$this->post_orphans[ intval( $processing_product_id ) ] = $post_parent;
|
953 |
+
//$post_parent = 0;
|
954 |
+
|
955 |
+
}
|
956 |
+
|
957 |
+
}
|
958 |
+
}
|
959 |
+
|
960 |
+
// Insert product
|
961 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __('> Inserting %s', 'wf_csv_import_export'), esc_html( $processing_product_title ) ), true );
|
962 |
+
|
963 |
+
$postdata = array(
|
964 |
+
'import_id' => $processing_product_id,
|
965 |
+
'post_author' => isset($post['post_author']) ? absint( $post['post_author'] ) : get_current_user_id(),
|
966 |
+
'post_date' => isset( $post['post_date'] ) ? date( 'Y-m-d H:i:s', strtotime( $post['post_date'] )) : '',
|
967 |
+
'post_date_gmt' => isset( $post['post_date_gmt'] ) ? date( 'Y-m-d H:i:s', strtotime( $post['post_date_gmt'] )) : '',
|
968 |
+
'post_content' => isset($post['post_content'])?$post['post_content']:"",
|
969 |
+
'post_excerpt' => isset($post['post_excerpt'])?$post['post_excerpt']:'',
|
970 |
+
'post_title' => $processing_product_title,
|
971 |
+
'post_name' => isset( $post['post_name'] ) ? $post['post_name'] : sanitize_title( $processing_product_title ),
|
972 |
+
'post_status' => isset( $post['post_status'] ) ? $post['post_status'] : 'publish',
|
973 |
+
'post_parent' => $post_parent,
|
974 |
+
'menu_order' => isset($post['menu_order'])?$post['menu_order']:'',
|
975 |
+
'post_type' => isset($post['post_type'])?$post['post_type']:"",
|
976 |
+
'post_password' => isset($post['post_password'])?$post['post_password']:'',
|
977 |
+
'comment_status' => isset($post['comment_status'])?$post['comment_status']:'',
|
978 |
+
);
|
979 |
+
$post_id = wp_insert_post( $postdata, true );
|
980 |
+
|
981 |
+
if ( is_wp_error( $post_id ) ) {
|
982 |
+
|
983 |
+
$this->add_import_result( 'failed', __( 'Failed to import product', 'wf_csv_import_export' ), $processing_product_id, $processing_product_title, $processing_product_sku );
|
984 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __( 'Failed to import product “%s”', 'wf_csv_import_export' ), esc_html($processing_product_title) ) );
|
985 |
+
unset( $post );
|
986 |
+
return;
|
987 |
+
|
988 |
+
} else {
|
989 |
+
|
990 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __('> Inserted - post ID is %s.', 'wf_csv_import_export'), $post_id ) );
|
991 |
+
|
992 |
+
}
|
993 |
+
}
|
994 |
+
|
995 |
+
unset( $postdata );
|
996 |
+
|
997 |
+
// map pre-import ID to local ID
|
998 |
+
if ( empty( $processing_product_id ) ) {
|
999 |
+
$processing_product_id = (int) $post_id;
|
1000 |
+
}
|
1001 |
+
|
1002 |
+
$this->processed_posts[ intval( $processing_product_id ) ] = (int) $post_id;
|
1003 |
+
|
1004 |
+
// add categories, tags and other terms
|
1005 |
+
if ( ! empty( $post['terms'] ) && is_array( $post['terms'] ) ) {
|
1006 |
+
|
1007 |
+
$terms_to_set = array();
|
1008 |
+
|
1009 |
+
foreach ( $post['terms'] as $term_group ) {
|
1010 |
+
|
1011 |
+
$taxonomy = $term_group['taxonomy'];
|
1012 |
+
$terms = $term_group['terms'];
|
1013 |
+
|
1014 |
+
if ( ! $taxonomy || ! taxonomy_exists( $taxonomy ) ) {
|
1015 |
+
continue;
|
1016 |
+
}
|
1017 |
+
|
1018 |
+
if ( ! is_array( $terms ) ) {
|
1019 |
+
$terms = array( $terms );
|
1020 |
+
}
|
1021 |
+
|
1022 |
+
$terms_to_set[ $taxonomy ] = array();
|
1023 |
+
|
1024 |
+
foreach ( $terms as $term_id ) {
|
1025 |
+
|
1026 |
+
if ( ! $term_id ) continue;
|
1027 |
+
|
1028 |
+
$terms_to_set[ $taxonomy ][] = intval( $term_id );
|
1029 |
+
}
|
1030 |
+
|
1031 |
+
}
|
1032 |
+
|
1033 |
+
foreach ( $terms_to_set as $tax => $ids ) {
|
1034 |
+
$tt_ids = wp_set_post_terms( $post_id, $ids, $tax, false );
|
1035 |
+
}
|
1036 |
+
|
1037 |
+
unset( $post['terms'], $terms_to_set );
|
1038 |
+
}
|
1039 |
+
|
1040 |
+
// add/update post meta
|
1041 |
+
if ( ! empty( $post['postmeta'] ) && is_array( $post['postmeta'] ) ) {
|
1042 |
+
foreach ( $post['postmeta'] as $meta ) {
|
1043 |
+
$key = apply_filters( 'import_post_meta_key', $meta['key'] );
|
1044 |
+
|
1045 |
+
if ( $key ) {
|
1046 |
+
update_post_meta( $post_id, $key, maybe_unserialize( $meta['value'] ) );
|
1047 |
+
}
|
1048 |
+
|
1049 |
+
if ( $key == '_file_paths' ) {
|
1050 |
+
do_action( 'woocommerce_process_product_file_download_paths', $post_id, 0, maybe_unserialize( $meta['value'] ) );
|
1051 |
+
}
|
1052 |
+
|
1053 |
+
}
|
1054 |
+
|
1055 |
+
unset( $post['postmeta'] );
|
1056 |
+
}
|
1057 |
+
|
1058 |
+
// Import images and add to post
|
1059 |
+
if ( ! empty( $post['images'] ) && is_array($post['images']) ) {
|
1060 |
+
|
1061 |
+
$featured = true;
|
1062 |
+
$gallery_ids = array();
|
1063 |
+
|
1064 |
+
if ($merging) {
|
1065 |
+
|
1066 |
+
// Get basenames
|
1067 |
+
$image_basenames = array();
|
1068 |
+
|
1069 |
+
foreach( $post['images'] as $image )
|
1070 |
+
$image_basenames[] = basename( $image );
|
1071 |
+
|
1072 |
+
// Loop attachments already attached to the product
|
1073 |
+
$attachments = get_posts( 'post_parent=' . $post_id . '&post_type=attachment&fields=ids&post_mime_type=image&numberposts=-1' );
|
1074 |
+
|
1075 |
+
foreach ( $attachments as $attachment_key => $attachment ) {
|
1076 |
+
|
1077 |
+
$attachment_url = wp_get_attachment_url( $attachment );
|
1078 |
+
$attachment_basename = basename( $attachment_url );
|
1079 |
+
|
1080 |
+
// Don't import existing images
|
1081 |
+
if ( in_array( $attachment_url, $post['images'] ) || in_array( $attachment_basename, $image_basenames ) ) {
|
1082 |
+
|
1083 |
+
foreach( $post['images'] as $key => $image ) {
|
1084 |
+
|
1085 |
+
if ( $image == $attachment_url || basename( $image ) == $attachment_basename ) {
|
1086 |
+
unset( $post['images'][ $key ] );
|
1087 |
+
|
1088 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __( '> > Image exists - skipping %s', 'wf_csv_import_export' ), basename( $image ) ) );
|
1089 |
+
|
1090 |
+
if ( $key == 0 ) {
|
1091 |
+
update_post_meta( $post_id, '_thumbnail_id', $attachment );
|
1092 |
+
$featured = false;
|
1093 |
+
} else {
|
1094 |
+
$gallery_ids[ $key ] = $attachment;
|
1095 |
+
}
|
1096 |
+
}
|
1097 |
+
|
1098 |
+
}
|
1099 |
+
|
1100 |
+
} else {
|
1101 |
+
|
1102 |
+
// Detach image which is not being merged
|
1103 |
+
$attachment_post = array();
|
1104 |
+
$attachment_post['ID'] = $attachment;
|
1105 |
+
$attachment_post['post_parent'] = '';
|
1106 |
+
wp_update_post( $attachment_post );
|
1107 |
+
unset( $attachment_post );
|
1108 |
+
|
1109 |
+
}
|
1110 |
+
|
1111 |
+
}
|
1112 |
+
|
1113 |
+
unset( $attachments );
|
1114 |
+
}
|
1115 |
+
|
1116 |
+
if ( $post['images'] ) foreach ( $post['images'] as $image_key => $image ) {
|
1117 |
+
|
1118 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __( '> > Importing image "%s"', 'wf_csv_import_export' ), $image ) );
|
1119 |
+
|
1120 |
+
$filename = basename( $image );
|
1121 |
+
|
1122 |
+
$attachment = array(
|
1123 |
+
'post_title' => preg_replace( '/\.[^.]+$/', '', $processing_product_title . ' ' . ( $image_key + 1 ) ),
|
1124 |
+
'post_content' => '',
|
1125 |
+
'post_status' => 'inherit',
|
1126 |
+
'post_parent' => $post_id
|
1127 |
+
);
|
1128 |
+
|
1129 |
+
$attachment_id = $this->process_attachment( $attachment, $image, $post_id );
|
1130 |
+
|
1131 |
+
if ( ! is_wp_error( $attachment_id ) && $attachment_id ) {
|
1132 |
+
|
1133 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __( '> > Imported image "%s"', 'wf_csv_import_export' ), $image ) );
|
1134 |
+
|
1135 |
+
// Set alt
|
1136 |
+
update_post_meta( $attachment_id, '_wp_attachment_image_alt', $processing_product_title );
|
1137 |
+
|
1138 |
+
if ( $featured ) {
|
1139 |
+
update_post_meta( $post_id, '_thumbnail_id', $attachment_id );
|
1140 |
+
} else {
|
1141 |
+
$gallery_ids[ $image_key ] = $attachment_id;
|
1142 |
+
}
|
1143 |
+
|
1144 |
+
update_post_meta( $attachment_id, '_woocommerce_exclude_image', 0 );
|
1145 |
+
|
1146 |
+
$featured = false;
|
1147 |
+
} else {
|
1148 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __( '> > Error importing image "%s"', 'wf_csv_import_export' ), $image ) );
|
1149 |
+
$this->hf_log_data_change( 'csv-import', '> > ' . $attachment_id->get_error_message() );
|
1150 |
+
}
|
1151 |
+
|
1152 |
+
unset( $attachment, $attachment_id );
|
1153 |
+
}
|
1154 |
+
|
1155 |
+
$this->hf_log_data_change( 'csv-import', __( '> > Images set', 'wf_csv_import_export' ) );
|
1156 |
+
|
1157 |
+
ksort( $gallery_ids );
|
1158 |
+
|
1159 |
+
update_post_meta( $post_id, '_product_image_gallery', implode( ',', $gallery_ids ) );
|
1160 |
+
|
1161 |
+
unset( $post['images'], $featured, $gallery_ids );
|
1162 |
+
}
|
1163 |
+
|
1164 |
+
// Import attributes
|
1165 |
+
if ( ! empty( $post['attributes'] ) && is_array($post['attributes']) ) {
|
1166 |
+
|
1167 |
+
if ($merging) {
|
1168 |
+
$attributes = array_filter( (array) maybe_unserialize( get_post_meta( $post_id, '_product_attributes', true ) ) );
|
1169 |
+
$attributes = array_merge( $attributes, $post['attributes'] );
|
1170 |
+
} else {
|
1171 |
+
$attributes = $post['attributes'];
|
1172 |
+
}
|
1173 |
+
|
1174 |
+
// Sort attribute positions
|
1175 |
+
if ( ! function_exists( 'attributes_cmp' ) ) {
|
1176 |
+
function attributes_cmp( $a, $b ) {
|
1177 |
+
if ( $a['position'] == $b['position'] ) return 0;
|
1178 |
+
return ( $a['position'] < $b['position'] ) ? -1 : 1;
|
1179 |
+
}
|
1180 |
+
}
|
1181 |
+
uasort( $attributes, 'attributes_cmp' );
|
1182 |
+
|
1183 |
+
update_post_meta( $post_id, '_product_attributes', $attributes );
|
1184 |
+
|
1185 |
+
unset( $post['attributes'], $attributes );
|
1186 |
+
}
|
1187 |
+
|
1188 |
+
// Import GPF
|
1189 |
+
if ( ! empty( $post['gpf_data'] ) && is_array( $post['gpf_data'] ) ) {
|
1190 |
+
|
1191 |
+
update_post_meta( $post_id, '_woocommerce_gpf_data', $post['gpf_data'] );
|
1192 |
+
|
1193 |
+
unset( $post['gpf_data'] );
|
1194 |
+
}
|
1195 |
+
|
1196 |
+
if ( ! empty( $post['upsell_skus'] ) && is_array( $post['upsell_skus'] ) ) {
|
1197 |
+
$this->upsell_skus[ $post_id ] = $post['upsell_skus'];
|
1198 |
+
}
|
1199 |
+
|
1200 |
+
if ( ! empty( $post['crosssell_skus'] ) && is_array( $post['crosssell_skus'] ) ) {
|
1201 |
+
$this->crosssell_skus[ $post_id ] = $post['crosssell_skus'];
|
1202 |
+
}
|
1203 |
+
|
1204 |
+
add_post_meta( $post_id, 'total_sales', 0 );
|
1205 |
+
|
1206 |
+
if ( $merging ) {
|
1207 |
+
$this->add_import_result( 'merged', 'Merge successful', $post_id, $processing_product_title, $processing_product_sku );
|
1208 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __('> Finished merging post ID %s.', 'wf_csv_import_export'), $post_id ) );
|
1209 |
+
} else {
|
1210 |
+
$this->add_import_result( 'imported', 'Import successful', $post_id, $processing_product_title, $processing_product_sku );
|
1211 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __('> Finished importing post ID %s.', 'wf_csv_import_export'), $post_id ) );
|
1212 |
+
}
|
1213 |
+
|
1214 |
+
unset( $post );
|
1215 |
+
}
|
1216 |
+
|
1217 |
+
/**
|
1218 |
+
* Log a row's import status
|
1219 |
+
*/
|
1220 |
+
protected function add_import_result( $status, $reason, $post_id = '', $post_title = '', $sku = '' ) {
|
1221 |
+
$this->import_results[] = array(
|
1222 |
+
'post_title' => $post_title,
|
1223 |
+
'post_id' => $post_id,
|
1224 |
+
'sku' => $sku,
|
1225 |
+
'status' => $status,
|
1226 |
+
'reason' => $reason
|
1227 |
+
);
|
1228 |
+
}
|
1229 |
+
|
1230 |
+
/**
|
1231 |
+
* If fetching attachments is enabled then attempt to create a new attachment
|
1232 |
+
*
|
1233 |
+
* @param array $post Attachment post details from WXR
|
1234 |
+
* @param string $url URL to fetch attachment from
|
1235 |
+
* @return int|WP_Error Post ID on success, WP_Error otherwise
|
1236 |
+
*/
|
1237 |
+
public function process_attachment( $post, $url, $post_id ) {
|
1238 |
+
|
1239 |
+
$attachment_id = '';
|
1240 |
+
$attachment_url = '';
|
1241 |
+
$attachment_file = '';
|
1242 |
+
$upload_dir = wp_upload_dir();
|
1243 |
+
|
1244 |
+
// If same server, make it a path and move to upload directory
|
1245 |
+
/*if ( strstr( $url, $upload_dir['baseurl'] ) ) {
|
1246 |
+
|
1247 |
+
$url = str_replace( $upload_dir['baseurl'], $upload_dir['basedir'], $url );
|
1248 |
+
|
1249 |
+
} else*/
|
1250 |
+
if ( strstr( $url, site_url() ) ) {
|
1251 |
+
$abs_url = str_replace( trailingslashit( site_url() ), trailingslashit( ABSPATH ), urldecode($url) );
|
1252 |
+
$new_name = wp_unique_filename( $upload_dir['path'], basename( urldecode($url) ) );
|
1253 |
+
$new_url = trailingslashit( $upload_dir['path'] ) . $new_name;
|
1254 |
+
|
1255 |
+
if ( copy( $abs_url, $new_url ) ) {
|
1256 |
+
$url = basename( $new_url );
|
1257 |
+
}
|
1258 |
+
}
|
1259 |
+
|
1260 |
+
if ( ! strstr( $url, 'http' ) ) {
|
1261 |
+
|
1262 |
+
// Local file
|
1263 |
+
$attachment_file = trailingslashit( $upload_dir['basedir'] ) . 'product_images/' . $url;
|
1264 |
+
|
1265 |
+
// We have the path, check it exists
|
1266 |
+
if ( ! file_exists( $attachment_file ) )
|
1267 |
+
$attachment_file = trailingslashit( $upload_dir['path'] ) . $url;
|
1268 |
+
|
1269 |
+
// We have the path, check it exists
|
1270 |
+
if ( file_exists( $attachment_file ) ) {
|
1271 |
+
|
1272 |
+
$attachment_url = str_replace( trailingslashit( ABSPATH ), trailingslashit( site_url() ), $attachment_file );
|
1273 |
+
|
1274 |
+
if ( $info = wp_check_filetype( $attachment_file ) )
|
1275 |
+
$post['post_mime_type'] = $info['type'];
|
1276 |
+
else
|
1277 |
+
return new WP_Error( 'attachment_processing_error', __('Invalid file type', 'wordpress-importer') );
|
1278 |
+
|
1279 |
+
$post['guid'] = $attachment_url;
|
1280 |
+
|
1281 |
+
$attachment_id = wp_insert_attachment( $post, $attachment_file, $post_id );
|
1282 |
+
|
1283 |
+
} else {
|
1284 |
+
return new WP_Error( 'attachment_processing_error', __('Local image did not exist!', 'wordpress-importer') );
|
1285 |
+
}
|
1286 |
+
|
1287 |
+
} else {
|
1288 |
+
|
1289 |
+
// if the URL is absolute, but does not contain address, then upload it assuming base_site_url
|
1290 |
+
if ( preg_match( '|^/[\w\W]+$|', $url ) )
|
1291 |
+
$url = rtrim( site_url(), '/' ) . $url;
|
1292 |
+
|
1293 |
+
$upload = $this->fetch_remote_file( $url, $post );
|
1294 |
+
|
1295 |
+
if ( is_wp_error( $upload ) )
|
1296 |
+
return $upload;
|
1297 |
+
|
1298 |
+
if ( $info = wp_check_filetype( $upload['file'] ) )
|
1299 |
+
$post['post_mime_type'] = $info['type'];
|
1300 |
+
else
|
1301 |
+
return new WP_Error( 'attachment_processing_error', __('Invalid file type', 'wordpress-importer') );
|
1302 |
+
|
1303 |
+
$post['guid'] = $upload['url'];
|
1304 |
+
$attachment_file = $upload['file'];
|
1305 |
+
$attachment_url = $upload['url'];
|
1306 |
+
|
1307 |
+
// as per wp-admin/includes/upload.php
|
1308 |
+
$attachment_id = wp_insert_attachment( $post, $upload['file'], $post_id );
|
1309 |
+
|
1310 |
+
unset( $upload );
|
1311 |
+
}
|
1312 |
+
|
1313 |
+
if ( ! is_wp_error( $attachment_id ) && $attachment_id > 0 ) {
|
1314 |
+
$this->hf_log_data_change( 'csv-import', sprintf( __( '> > Inserted image attachment "%s"', 'wf_csv_import_export' ), $url ) );
|
1315 |
+
|
1316 |
+
$this->attachments[] = $attachment_id;
|
1317 |
+
}
|
1318 |
+
|
1319 |
+
return $attachment_id;
|
1320 |
+
}
|
1321 |
+
|
1322 |
+
/**
|
1323 |
+
* Attempt to download a remote file attachment
|
1324 |
+
*/
|
1325 |
+
public function fetch_remote_file( $url, $post ) {
|
1326 |
+
|
1327 |
+
// extract the file name and extension from the url
|
1328 |
+
$file_name = basename( current( explode( '?', $url ) ) );
|
1329 |
+
$wp_filetype = wp_check_filetype( $file_name, null );
|
1330 |
+
$parsed_url = @parse_url( $url );
|
1331 |
+
|
1332 |
+
// Check parsed URL
|
1333 |
+
if ( ! $parsed_url || ! is_array( $parsed_url ) )
|
1334 |
+
return new WP_Error( 'import_file_error', 'Invalid URL' );
|
1335 |
+
|
1336 |
+
// Ensure url is valid
|
1337 |
+
$url = str_replace( " ", '%20', $url );
|
1338 |
+
|
1339 |
+
// Get the file
|
1340 |
+
$response = wp_remote_get( $url, array(
|
1341 |
+
'timeout' => 10
|
1342 |
+
) );
|
1343 |
+
|
1344 |
+
if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) !== 200 )
|
1345 |
+
return new WP_Error( 'import_file_error', 'Error getting remote image' );
|
1346 |
+
|
1347 |
+
// Ensure we have a file name and type
|
1348 |
+
if ( ! $wp_filetype['type'] ) {
|
1349 |
+
|
1350 |
+
$headers = wp_remote_retrieve_headers( $response );
|
1351 |
+
|
1352 |
+
if ( isset( $headers['content-disposition'] ) && strstr( $headers['content-disposition'], 'filename=' ) ) {
|
1353 |
+
|
1354 |
+
$disposition = end( explode( 'filename=', $headers['content-disposition'] ) );
|
1355 |
+
$disposition = sanitize_file_name( $disposition );
|
1356 |
+
$file_name = $disposition;
|
1357 |
+
|
1358 |
+
} elseif ( isset( $headers['content-type'] ) && strstr( $headers['content-type'], 'image/' ) ) {
|
1359 |
+
|
1360 |
+
$file_name = 'image.' . str_replace( 'image/', '', $headers['content-type'] );
|
1361 |
+
|
1362 |
+
}
|
1363 |
+
|
1364 |
+
unset( $headers );
|
1365 |
+
}
|
1366 |
+
|
1367 |
+
// Upload the file
|
1368 |
+
$upload = wp_upload_bits( $file_name, '', wp_remote_retrieve_body( $response ) );
|
1369 |
+
|
1370 |
+
if ( $upload['error'] )
|
1371 |
+
return new WP_Error( 'upload_dir_error', $upload['error'] );
|
1372 |
+
|
1373 |
+
// Get filesize
|
1374 |
+
$filesize = filesize( $upload['file'] );
|
1375 |
+
|
1376 |
+
if ( 0 == $filesize ) {
|
1377 |
+
@unlink( $upload['file'] );
|
1378 |
+
unset( $upload );
|
1379 |
+
return new WP_Error( 'import_file_error', __('Zero size file downloaded', 'wf_csv_import_export') );
|
1380 |
+
}
|
1381 |
+
|
1382 |
+
unset( $response );
|
1383 |
+
|
1384 |
+
return $upload;
|
1385 |
+
}
|
1386 |
+
|
1387 |
+
/**
|
1388 |
+
* Decide what the maximum file size for downloaded attachments is.
|
1389 |
+
* Default is 0 (unlimited), can be filtered via import_attachment_size_limit
|
1390 |
+
*
|
1391 |
+
* @return int Maximum attachment file size to import
|
1392 |
+
*/
|
1393 |
+
public function max_attachment_size() {
|
1394 |
+
return apply_filters( 'import_attachment_size_limit', 0 );
|
1395 |
+
}
|
1396 |
+
|
1397 |
+
/**
|
1398 |
+
* Attempt to associate posts and menu items with previously missing parents
|
1399 |
+
*/
|
1400 |
+
public function backfill_parents() {
|
1401 |
+
global $wpdb;
|
1402 |
+
|
1403 |
+
// find parents for post orphans
|
1404 |
+
if ( ! empty( $this->post_orphans ) && is_array( $this->post_orphans ) )
|
1405 |
+
foreach ( $this->post_orphans as $child_id => $parent_id ) {
|
1406 |
+
$local_child_id = $local_parent_id = false;
|
1407 |
+
if ( isset( $this->processed_posts[$child_id] ) )
|
1408 |
+
$local_child_id = $this->processed_posts[$child_id];
|
1409 |
+
if ( isset( $this->processed_posts[$parent_id] ) )
|
1410 |
+
$local_parent_id = $this->processed_posts[$parent_id];
|
1411 |
+
|
1412 |
+
if ( $local_child_id && $local_parent_id )
|
1413 |
+
$wpdb->update( $wpdb->posts, array( 'post_parent' => $local_parent_id ), array( 'ID' => $local_child_id ), '%d', '%d' );
|
1414 |
+
}
|
1415 |
+
}
|
1416 |
+
|
1417 |
+
/**
|
1418 |
+
* Attempt to associate posts and menu items with previously missing parents
|
1419 |
+
*/
|
1420 |
+
public function link_product_skus( $type, $product_id, $skus ) {
|
1421 |
+
global $wpdb;
|
1422 |
+
|
1423 |
+
$ids = array();
|
1424 |
+
|
1425 |
+
foreach ( $skus as $sku ) {
|
1426 |
+
$ids[] = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_sku' AND meta_value = %s;", $sku ) );
|
1427 |
+
}
|
1428 |
+
|
1429 |
+
$ids = array_filter( $ids );
|
1430 |
+
|
1431 |
+
update_post_meta( $product_id, "_{$type}_ids", $ids );
|
1432 |
+
}
|
1433 |
+
|
1434 |
+
private function handle_ftp(){
|
1435 |
+
$enable_ftp_ie = !empty( $_POST['enable_ftp_ie'] ) ? true : false;
|
1436 |
+
if($enable_ftp_ie == false) return false;
|
1437 |
+
|
1438 |
+
$ftp_server = ! empty( $_POST['ftp_server'] ) ? $_POST['ftp_server'] : '';
|
1439 |
+
$ftp_server_path = ! empty( $_POST['ftp_server_path'] ) ? $_POST['ftp_server_path'] : '';
|
1440 |
+
$ftp_user = ! empty( $_POST['ftp_user'] ) ? $_POST['ftp_user'] : '';
|
1441 |
+
$ftp_password = ! empty( $_POST['ftp_password'] ) ? $_POST['ftp_password'] : '';
|
1442 |
+
$use_ftps = ! empty( $_POST['use_ftps'] ) ? true : false;
|
1443 |
+
|
1444 |
+
|
1445 |
+
$settings = array();
|
1446 |
+
$settings[ 'ftp_server' ] = $ftp_server;
|
1447 |
+
$settings[ 'ftp_user' ] = $ftp_user;
|
1448 |
+
$settings[ 'ftp_password' ] = $ftp_password;
|
1449 |
+
$settings[ 'use_ftps' ] = $use_ftps;
|
1450 |
+
$settings[ 'enable_ftp_ie' ] = $enable_ftp_ie;
|
1451 |
+
$settings[ 'ftp_server_path' ] = $ftp_server_path;
|
1452 |
+
|
1453 |
+
|
1454 |
+
$local_file = 'wp-content/plugins/product-csv-import-export-for-woocommerce/temp-import.csv';
|
1455 |
+
$server_file = $ftp_server_path;
|
1456 |
+
|
1457 |
+
update_option( 'wf_shipment_tracking_importer_ftp', $settings );
|
1458 |
+
|
1459 |
+
$ftp_conn = $use_ftps ? ftp_ssl_connect($ftp_server) : ftp_connect($ftp_server);
|
1460 |
+
$error_message = "";
|
1461 |
+
$success = false;
|
1462 |
+
if($ftp_conn == false){
|
1463 |
+
$error_message = "There is connection problem\n";
|
1464 |
+
}
|
1465 |
+
|
1466 |
+
if(empty($error_message)){
|
1467 |
+
if(ftp_login($ftp_conn, $ftp_user, $ftp_password) == false){
|
1468 |
+
$error_message = "Not able to login \n";
|
1469 |
+
}
|
1470 |
+
}
|
1471 |
+
if(empty($error_message)){
|
1472 |
+
|
1473 |
+
if (ftp_get($ftp_conn, ABSPATH.$local_file, $server_file, FTP_BINARY)) {
|
1474 |
+
$error_message = "";
|
1475 |
+
$success = true;
|
1476 |
+
} else {
|
1477 |
+
$error_message = "There was a problem\n";
|
1478 |
+
}
|
1479 |
+
}
|
1480 |
+
|
1481 |
+
ftp_close($ftp_conn);
|
1482 |
+
if($success){
|
1483 |
+
$this->file_url = $local_file;
|
1484 |
+
}else{
|
1485 |
+
die($error_message);
|
1486 |
+
}
|
1487 |
+
return true;
|
1488 |
+
}
|
1489 |
+
|
1490 |
+
// Display import page title
|
1491 |
+
public function header() {
|
1492 |
+
echo '<div class="pipe-import-wrap"><div class="icon32" id="icon-woocommerce-importer"><br></div>';
|
1493 |
+
}
|
1494 |
+
|
1495 |
+
// Close div.pipe-import-wrap
|
1496 |
+
public function footer() {
|
1497 |
+
echo '</div>';
|
1498 |
+
}
|
1499 |
+
|
1500 |
+
/**
|
1501 |
+
* Display introductory text and file upload form
|
1502 |
+
*/
|
1503 |
+
public function greet() {
|
1504 |
+
$action = 'admin.php?import=xa_woocommerce_csv&step=1';
|
1505 |
+
$bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
|
1506 |
+
$size = size_format( $bytes );
|
1507 |
+
$upload_dir = wp_upload_dir();
|
1508 |
+
|
1509 |
+
include( 'views/html-wf-import-greeting.php' );
|
1510 |
+
}
|
1511 |
+
|
1512 |
+
/**
|
1513 |
+
* Added to http_request_timeout filter to force timeout at 60 seconds during import
|
1514 |
+
* @return int 60
|
1515 |
+
*/
|
1516 |
+
public function bump_request_timeout( $val ) {
|
1517 |
+
return 60;
|
1518 |
+
}
|
1519 |
+
/**
|
1520 |
+
* Get a list of all the product attributes for a post type.
|
1521 |
+
* These require a bit more digging into the values.
|
1522 |
+
*/
|
1523 |
+
public static function get_all_product_attributes( $post_type = 'product' ) {
|
1524 |
+
global $wpdb;
|
1525 |
+
|
1526 |
+
$results = $wpdb->get_col( $wpdb->prepare(
|
1527 |
+
"SELECT DISTINCT pm.meta_value
|
1528 |
+
FROM {$wpdb->postmeta} AS pm
|
1529 |
+
LEFT JOIN {$wpdb->posts} AS p ON p.ID = pm.post_id
|
1530 |
+
WHERE p.post_type = %s
|
1531 |
+
AND p.post_status IN ( 'publish', 'pending', 'private', 'draft' )
|
1532 |
+
AND pm.meta_key = '_product_attributes'",
|
1533 |
+
$post_type
|
1534 |
+
) );
|
1535 |
+
|
1536 |
+
// Go through each result, and look at the attribute keys within them.
|
1537 |
+
$result = array();
|
1538 |
+
|
1539 |
+
if ( ! empty( $results ) ) {
|
1540 |
+
foreach( $results as $_product_attributes ) {
|
1541 |
+
$attributes = maybe_unserialize( maybe_unserialize( $_product_attributes ) );
|
1542 |
+
if ( ! empty( $attributes ) && is_array( $attributes ) ) {
|
1543 |
+
foreach( $attributes as $key => $attribute ) {
|
1544 |
+
if ( ! $key ) {
|
1545 |
+
continue;
|
1546 |
+
}
|
1547 |
+
if ( ! strstr( $key, 'pa_' ) ) {
|
1548 |
+
if ( empty( $attribute['name'] ) ) {
|
1549 |
+
continue;
|
1550 |
+
}
|
1551 |
+
$key = $attribute['name'];
|
1552 |
+
}
|
1553 |
+
|
1554 |
+
$result[ $key ] = $key;
|
1555 |
+
}
|
1556 |
+
}
|
1557 |
+
}
|
1558 |
+
}
|
1559 |
+
|
1560 |
+
sort( $result );
|
1561 |
+
|
1562 |
+
return $result;
|
1563 |
+
}
|
1564 |
+
}
|
includes/importer/data/data-wf-post-defaults.php
CHANGED
@@ -1,22 +1,22 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
-
exit;
|
4 |
-
}
|
5 |
-
|
6 |
-
// New post defaults
|
7 |
-
return array(
|
8 |
-
'post_type' => $this->post_type,
|
9 |
-
'menu_order' => '',
|
10 |
-
'postmeta' => array(),
|
11 |
-
'post_status' => 'publish',
|
12 |
-
'post_title' => '',
|
13 |
-
'post_name' => '',
|
14 |
-
'post_date' => '',
|
15 |
-
'post_date_gmt' => '',
|
16 |
-
'post_content' => '',
|
17 |
-
'post_excerpt' => '',
|
18 |
-
'post_parent' => '',
|
19 |
-
'post_password' => '',
|
20 |
-
'post_author' => '',
|
21 |
-
'comment_status'=> 'open'
|
22 |
);
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
+
exit;
|
4 |
+
}
|
5 |
+
|
6 |
+
// New post defaults
|
7 |
+
return array(
|
8 |
+
'post_type' => $this->post_type,
|
9 |
+
'menu_order' => '',
|
10 |
+
'postmeta' => array(),
|
11 |
+
'post_status' => 'publish',
|
12 |
+
'post_title' => '',
|
13 |
+
'post_name' => '',
|
14 |
+
'post_date' => '',
|
15 |
+
'post_date_gmt' => '',
|
16 |
+
'post_content' => '',
|
17 |
+
'post_excerpt' => '',
|
18 |
+
'post_parent' => '',
|
19 |
+
'post_password' => '',
|
20 |
+
'post_author' => '',
|
21 |
+
'comment_status'=> 'open'
|
22 |
);
|
includes/importer/data/data-wf-postmeta-allowed.php
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
-
exit;
|
4 |
-
}
|
5 |
-
|
6 |
-
// New postmeta allowed
|
7 |
-
return array(
|
8 |
-
'downloadable' => array( 'yes', 'no' ),
|
9 |
-
'virtual' => array( 'yes', 'no' ),
|
10 |
-
'visibility' => array( 'visible', 'catalog', 'search', 'hidden' ),
|
11 |
-
'stock_status' => array( 'instock', 'outofstock' ),
|
12 |
-
'backorders' => array( 'yes', 'no', 'notify' ),
|
13 |
-
'manage_stock' => array( 'yes', 'no' ),
|
14 |
-
'tax_status' => array( 'taxable', 'shipping', 'none' ),
|
15 |
-
'featured' => array( 'yes', 'no' ),
|
16 |
);
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
+
exit;
|
4 |
+
}
|
5 |
+
|
6 |
+
// New postmeta allowed
|
7 |
+
return array(
|
8 |
+
'downloadable' => array( 'yes', 'no' ),
|
9 |
+
'virtual' => array( 'yes', 'no' ),
|
10 |
+
'visibility' => array( 'visible', 'catalog', 'search', 'hidden' ),
|
11 |
+
'stock_status' => array( 'instock', 'outofstock' ),
|
12 |
+
'backorders' => array( 'yes', 'no', 'notify' ),
|
13 |
+
'manage_stock' => array( 'yes', 'no' ),
|
14 |
+
'tax_status' => array( 'taxable', 'shipping', 'none' ),
|
15 |
+
'featured' => array( 'yes', 'no' ),
|
16 |
);
|
includes/importer/data/data-wf-postmeta-defaults.php
CHANGED
@@ -1,44 +1,44 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
-
exit;
|
4 |
-
}
|
5 |
-
|
6 |
-
// New postmeta defaults
|
7 |
-
return apply_filters( 'woocommerce_csv_product_postmeta_defaults', array(
|
8 |
-
'sku' => '',
|
9 |
-
'downloadable' => 'no',
|
10 |
-
'virtual' => 'no',
|
11 |
-
'price' => '',
|
12 |
-
'visibility' => 'visible',
|
13 |
-
'stock' => 0,
|
14 |
-
'stock_status' => 'instock',
|
15 |
-
'backorders' => 'no',
|
16 |
-
'manage_stock' => 'no',
|
17 |
-
'sale_price' => '',
|
18 |
-
'regular_price' => '',
|
19 |
-
'weight' => '',
|
20 |
-
'length' => '',
|
21 |
-
'width' => '',
|
22 |
-
'height' => '',
|
23 |
-
'tax_status' => 'taxable',
|
24 |
-
'tax_class' => '',
|
25 |
-
'upsell_ids' => array(),
|
26 |
-
'crosssell_ids' => array(),
|
27 |
-
'upsell_skus' => array(),
|
28 |
-
'crosssell_skus' => array(),
|
29 |
-
'sale_price_dates_from' => '',
|
30 |
-
'sale_price_dates_to' => '',
|
31 |
-
'min_variation_price' => '',
|
32 |
-
'max_variation_price' => '',
|
33 |
-
'min_variation_regular_price' => '',
|
34 |
-
'max_variation_regular_price' => '',
|
35 |
-
'min_variation_sale_price' => '',
|
36 |
-
'max_variation_sale_price' => '',
|
37 |
-
'featured' => 'no',
|
38 |
-
'file_path' => '',
|
39 |
-
'file_paths' => '',
|
40 |
-
'download_limit' => '',
|
41 |
-
'download_expiry' => '',
|
42 |
-
'product_url' => '',
|
43 |
-
'button_text' => '',
|
44 |
) );
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
+
exit;
|
4 |
+
}
|
5 |
+
|
6 |
+
// New postmeta defaults
|
7 |
+
return apply_filters( 'woocommerce_csv_product_postmeta_defaults', array(
|
8 |
+
'sku' => '',
|
9 |
+
'downloadable' => 'no',
|
10 |
+
'virtual' => 'no',
|
11 |
+
'price' => '',
|
12 |
+
'visibility' => 'visible',
|
13 |
+
'stock' => 0,
|
14 |
+
'stock_status' => 'instock',
|
15 |
+
'backorders' => 'no',
|
16 |
+
'manage_stock' => 'no',
|
17 |
+
'sale_price' => '',
|
18 |
+
'regular_price' => '',
|
19 |
+
'weight' => '',
|
20 |
+
'length' => '',
|
21 |
+
'width' => '',
|
22 |
+
'height' => '',
|
23 |
+
'tax_status' => 'taxable',
|
24 |
+
'tax_class' => '',
|
25 |
+
'upsell_ids' => array(),
|
26 |
+
'crosssell_ids' => array(),
|
27 |
+
'upsell_skus' => array(),
|
28 |
+
'crosssell_skus' => array(),
|
29 |
+
'sale_price_dates_from' => '',
|
30 |
+
'sale_price_dates_to' => '',
|
31 |
+
'min_variation_price' => '',
|
32 |
+
'max_variation_price' => '',
|
33 |
+
'min_variation_regular_price' => '',
|
34 |
+
'max_variation_regular_price' => '',
|
35 |
+
'min_variation_sale_price' => '',
|
36 |
+
'max_variation_sale_price' => '',
|
37 |
+
'featured' => 'no',
|
38 |
+
'file_path' => '',
|
39 |
+
'file_paths' => '',
|
40 |
+
'download_limit' => '',
|
41 |
+
'download_expiry' => '',
|
42 |
+
'product_url' => '',
|
43 |
+
'button_text' => '',
|
44 |
) );
|
includes/importer/data/data-wf-reserved-fields-pair.php
CHANGED
@@ -1,51 +1,51 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// Reserved column names
|
4 |
-
return array(
|
5 |
-
'id' => 'Product ID | Product ID',
|
6 |
-
'post_title' => 'Product Title | Product Title. ie Name of the product ',
|
7 |
-
'post_name' => 'Product Permalink | Unique part of the product link',
|
8 |
-
'post_status' => 'Product Status | Product Status ( published , draft ...)',
|
9 |
-
'post_content' => 'Product Description | Description about the Product',
|
10 |
-
'post_excerpt' => 'Product Short Description | Short description about the Product',
|
11 |
-
'post_date' => 'Post Date | Product posted date',
|
12 |
-
//'post_date_gmt' => 'Post Date GMT | Tooltip data Status',
|
13 |
-
'sku' => 'Product SKU | Product SKU - This will unique and Product identifier',
|
14 |
-
'post_password' => 'Post Password | To Protect a post with password',
|
15 |
-
'post_author' => 'Prodcut Author | Prodcut Author ( 1 - Admin )',
|
16 |
-
'menu_order' => 'Menu Order | If menu enabled , menu order',
|
17 |
-
'comment_status' => 'Comment Status | Comment Status ( Open or Closed comments for this prodcut)',
|
18 |
-
'downloadable' => 'Type: Downloadable | Is Product is downloadable eg:- Book',
|
19 |
-
'virtual' => 'Type: Virtual | Is Product is virtual',
|
20 |
-
'visibility' => 'Visibility: Visibility | Visibility status ( hidden or visible)',
|
21 |
-
'featured' => 'Visibility: Featured | Featured Product',
|
22 |
-
'stock' => 'Inventory: Stock | Stock Quantity',
|
23 |
-
'stock_status' => 'Inventory: Stock Status | InStock or OutofStock',
|
24 |
-
'backorders' => 'Inventory: Backorders | Backorders',
|
25 |
-
'manage_stock' => 'Inventory: Manage Stock | 1 to enable 0 to disable',
|
26 |
-
'sale_price' => 'Price: Sale Price | Sale Price ',
|
27 |
-
'regular_price' => 'Price: Regular Price | Regular Price',
|
28 |
-
'sale_price_dates_from' => 'Sale Price Dates: From | Sale Price Dates effect from',
|
29 |
-
'sale_price_dates_to' => 'Sale Price Dates: To | Sale Price Dates effect to',
|
30 |
-
'weight' => 'Dimensions: Weight | Wight of product in LB , OZ , KG as of your woocommerce Unit',
|
31 |
-
'length' => 'Dimensions: length | Length',
|
32 |
-
'width' => 'Dimensions: width | Width',
|
33 |
-
'height' => 'Dimensions: height | Height',
|
34 |
-
'tax_status' => 'Tax: Tax Status | Taxable product or not',
|
35 |
-
'tax_class' => 'Tax: Tax Class | Tax class ( eg:- reduced rate)',
|
36 |
-
'upsell_ids' => 'Related Products: Upsell IDs | Upsell Product ids',
|
37 |
-
'crosssell_ids' => 'Related Products: Crosssell IDs | Crosssell Product ids',
|
38 |
-
'file_paths' => 'Downloads: File Paths (WC 2.0.x) | File Paths',
|
39 |
-
'downloadable_files' => 'Downloads: Downloadable Files (WC 2.1.x) | Downloadable Files',
|
40 |
-
'download_limit' => 'Downloads: Download Limit | Download Limit',
|
41 |
-
'download_expiry' => 'Downloads: Download Expiry | Download Expiry ',
|
42 |
-
'product_url' => 'External: Product URL | Product URL if the Product is external',
|
43 |
-
'button_text' => 'External: Button Text | Buy button text for Product , if the Product is external',
|
44 |
-
'images' => 'Images/Gallery | Image URLs seperated with |',
|
45 |
-
'tax:product_type' => 'Product Type | ( eg:- simple , variable)',
|
46 |
-
'tax:product_cat' => 'Product Categories | Product related categories',
|
47 |
-
'tax:product_tag' => 'Product Tags | Product related tags',
|
48 |
-
'tax:product_shipping_class' => 'Product Shipping Class | Allow you to group similar products for shipping',
|
49 |
-
|
50 |
-
|
51 |
-
);
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Reserved column names
|
4 |
+
return array(
|
5 |
+
'id' => 'Product ID | Product ID',
|
6 |
+
'post_title' => 'Product Title | Product Title. ie Name of the product ',
|
7 |
+
'post_name' => 'Product Permalink | Unique part of the product link',
|
8 |
+
'post_status' => 'Product Status | Product Status ( published , draft ...)',
|
9 |
+
'post_content' => 'Product Description | Description about the Product',
|
10 |
+
'post_excerpt' => 'Product Short Description | Short description about the Product',
|
11 |
+
'post_date' => 'Post Date | Product posted date',
|
12 |
+
//'post_date_gmt' => 'Post Date GMT | Tooltip data Status',
|
13 |
+
'sku' => 'Product SKU | Product SKU - This will unique and Product identifier',
|
14 |
+
'post_password' => 'Post Password | To Protect a post with password',
|
15 |
+
'post_author' => 'Prodcut Author | Prodcut Author ( 1 - Admin )',
|
16 |
+
'menu_order' => 'Menu Order | If menu enabled , menu order',
|
17 |
+
'comment_status' => 'Comment Status | Comment Status ( Open or Closed comments for this prodcut)',
|
18 |
+
'downloadable' => 'Type: Downloadable | Is Product is downloadable eg:- Book',
|
19 |
+
'virtual' => 'Type: Virtual | Is Product is virtual',
|
20 |
+
'visibility' => 'Visibility: Visibility | Visibility status ( hidden or visible)',
|
21 |
+
'featured' => 'Visibility: Featured | Featured Product',
|
22 |
+
'stock' => 'Inventory: Stock | Stock Quantity',
|
23 |
+
'stock_status' => 'Inventory: Stock Status | InStock or OutofStock',
|
24 |
+
'backorders' => 'Inventory: Backorders | Backorders',
|
25 |
+
'manage_stock' => 'Inventory: Manage Stock | 1 to enable 0 to disable',
|
26 |
+
'sale_price' => 'Price: Sale Price | Sale Price ',
|
27 |
+
'regular_price' => 'Price: Regular Price | Regular Price',
|
28 |
+
'sale_price_dates_from' => 'Sale Price Dates: From | Sale Price Dates effect from',
|
29 |
+
'sale_price_dates_to' => 'Sale Price Dates: To | Sale Price Dates effect to',
|
30 |
+
'weight' => 'Dimensions: Weight | Wight of product in LB , OZ , KG as of your woocommerce Unit',
|
31 |
+
'length' => 'Dimensions: length | Length',
|
32 |
+
'width' => 'Dimensions: width | Width',
|
33 |
+
'height' => 'Dimensions: height | Height',
|
34 |
+
'tax_status' => 'Tax: Tax Status | Taxable product or not',
|
35 |
+
'tax_class' => 'Tax: Tax Class | Tax class ( eg:- reduced rate)',
|
36 |
+
'upsell_ids' => 'Related Products: Upsell IDs | Upsell Product ids',
|
37 |
+
'crosssell_ids' => 'Related Products: Crosssell IDs | Crosssell Product ids',
|
38 |
+
'file_paths' => 'Downloads: File Paths (WC 2.0.x) | File Paths',
|
39 |
+
'downloadable_files' => 'Downloads: Downloadable Files (WC 2.1.x) | Downloadable Files',
|
40 |
+
'download_limit' => 'Downloads: Download Limit | Download Limit',
|
41 |
+
'download_expiry' => 'Downloads: Download Expiry | Download Expiry ',
|
42 |
+
'product_url' => 'External: Product URL | Product URL if the Product is external',
|
43 |
+
'button_text' => 'External: Button Text | Buy button text for Product , if the Product is external',
|
44 |
+
'images' => 'Images/Gallery | Image URLs seperated with |',
|
45 |
+
'tax:product_type' => 'Product Type | ( eg:- simple , variable)',
|
46 |
+
'tax:product_cat' => 'Product Categories | Product related categories',
|
47 |
+
'tax:product_tag' => 'Product Tags | Product related tags',
|
48 |
+
'tax:product_shipping_class' => 'Product Shipping Class | Allow you to group similar products for shipping',
|
49 |
+
|
50 |
+
|
51 |
+
);
|
includes/importer/data/data-wf-reserved-fields.php
CHANGED
@@ -1,60 +1,60 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// Reserved column names
|
4 |
-
return array(
|
5 |
-
'id',
|
6 |
-
'product_type',
|
7 |
-
'post_id',
|
8 |
-
'post_title',
|
9 |
-
'post_name',
|
10 |
-
'post_status',
|
11 |
-
'post_date',
|
12 |
-
'post_date_gmt',
|
13 |
-
'post_content',
|
14 |
-
'post_excerpt',
|
15 |
-
'post_parent',
|
16 |
-
'post_password',
|
17 |
-
'sku',
|
18 |
-
'post_type',
|
19 |
-
'post_author',
|
20 |
-
'menu_order',
|
21 |
-
'postmeta',
|
22 |
-
'comment_status',
|
23 |
-
'downloadable',
|
24 |
-
'virtual',
|
25 |
-
'visibility',
|
26 |
-
'stock',
|
27 |
-
'stock_status',
|
28 |
-
'backorders',
|
29 |
-
'manage_stock',
|
30 |
-
'price',
|
31 |
-
'sale_price',
|
32 |
-
'regular_price',
|
33 |
-
'weight',
|
34 |
-
'length',
|
35 |
-
'width',
|
36 |
-
'height',
|
37 |
-
'tax_status',
|
38 |
-
'tax_class',
|
39 |
-
'upsell_ids',
|
40 |
-
'crosssell_ids',
|
41 |
-
'upsell_skus',
|
42 |
-
'crosssell_skus',
|
43 |
-
'sale_price_dates_from',
|
44 |
-
'sale_price_dates_to',
|
45 |
-
'min_variation_price',
|
46 |
-
'max_variation_price',
|
47 |
-
'min_variation_regular_price',
|
48 |
-
'max_variation_regular_price',
|
49 |
-
'min_variation_sale_price',
|
50 |
-
'max_variation_sale_price',
|
51 |
-
'featured',
|
52 |
-
'file_path',
|
53 |
-
'file_paths',
|
54 |
-
'downloadable_files',
|
55 |
-
'download_limit',
|
56 |
-
'download_expiry',
|
57 |
-
'product_url',
|
58 |
-
'button_text',
|
59 |
-
'default_attributes'
|
60 |
);
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Reserved column names
|
4 |
+
return array(
|
5 |
+
'id',
|
6 |
+
'product_type',
|
7 |
+
'post_id',
|
8 |
+
'post_title',
|
9 |
+
'post_name',
|
10 |
+
'post_status',
|
11 |
+
'post_date',
|
12 |
+
'post_date_gmt',
|
13 |
+
'post_content',
|
14 |
+
'post_excerpt',
|
15 |
+
'post_parent',
|
16 |
+
'post_password',
|
17 |
+
'sku',
|
18 |
+
'post_type',
|
19 |
+
'post_author',
|
20 |
+
'menu_order',
|
21 |
+
'postmeta',
|
22 |
+
'comment_status',
|
23 |
+
'downloadable',
|
24 |
+
'virtual',
|
25 |
+
'visibility',
|
26 |
+
'stock',
|
27 |
+
'stock_status',
|
28 |
+
'backorders',
|
29 |
+
'manage_stock',
|
30 |
+
'price',
|
31 |
+
'sale_price',
|
32 |
+
'regular_price',
|
33 |
+
'weight',
|
34 |
+
'length',
|
35 |
+
'width',
|
36 |
+
'height',
|
37 |
+
'tax_status',
|
38 |
+
'tax_class',
|
39 |
+
'upsell_ids',
|
40 |
+
'crosssell_ids',
|
41 |
+
'upsell_skus',
|
42 |
+
'crosssell_skus',
|
43 |
+
'sale_price_dates_from',
|
44 |
+
'sale_price_dates_to',
|
45 |
+
'min_variation_price',
|
46 |
+
'max_variation_price',
|
47 |
+
'min_variation_regular_price',
|
48 |
+
'max_variation_regular_price',
|
49 |
+
'min_variation_sale_price',
|
50 |
+
'max_variation_sale_price',
|
51 |
+
'featured',
|
52 |
+
'file_path',
|
53 |
+
'file_paths',
|
54 |
+
'downloadable_files',
|
55 |
+
'download_limit',
|
56 |
+
'download_expiry',
|
57 |
+
'product_url',
|
58 |
+
'button_text',
|
59 |
+
'default_attributes'
|
60 |
);
|
includes/importer/views/html-wf-import-greeting.php
CHANGED
@@ -1,84 +1,84 @@
|
|
1 |
-
<?php
|
2 |
-
if (!defined('ABSPATH')) {
|
3 |
-
exit;
|
4 |
-
}
|
5 |
-
|
6 |
-
$ftp_server = '';
|
7 |
-
$ftp_user = '';
|
8 |
-
$ftp_password = '';
|
9 |
-
$use_ftps = '';
|
10 |
-
$enable_ftp_ie = '';
|
11 |
-
$ftp_server_path = '';
|
12 |
-
if (!empty($ftp_settings)) {
|
13 |
-
$ftp_server = $ftp_settings['ftp_server'];
|
14 |
-
$ftp_user = $ftp_settings['ftp_user'];
|
15 |
-
$ftp_password = $ftp_settings['ftp_password'];
|
16 |
-
$use_ftps = $ftp_settings['use_ftps'];
|
17 |
-
$enable_ftp_ie = $ftp_settings['enable_ftp_ie'];
|
18 |
-
$ftp_server_path = $ftp_settings['ftp_server_path'];
|
19 |
-
}
|
20 |
-
?>
|
21 |
-
<div class="woocommerce">
|
22 |
-
|
23 |
-
<h2 class="nav-tab-wrapper woo-nav-tab-wrapper">
|
24 |
-
<a href="<?php echo admin_url('admin.php?page=wf_woocommerce_csv_im_ex'); ?>" class="nav-tab"><?php _e('Product Export', 'wf_csv_import_export'); ?></a>
|
25 |
-
<a href="<?php echo admin_url('admin.php?import=xa_woocommerce_csv'); ?>" class="nav-tab nav-tab-active"><?php _e('Product Import', 'wf_csv_import_export'); ?></a>
|
26 |
-
<a href="<?php echo admin_url('admin.php?page=wf_woocommerce_csv_im_ex&tab=help'); ?>" class="nav-tab"><?php _e('Help', 'wf_csv_import_export'); ?></a>
|
27 |
-
<a href="https://www.xadapter.com/product/product-import-export-plugin-for-woocommerce/" target="_blank" class="nav-tab nav-tab-premium"><?php _e('Upgrade to Premium for More Features', 'wf_csv_import_export'); ?></a>
|
28 |
-
</h2>
|
29 |
-
|
30 |
-
<div class="pipe-main-box">
|
31 |
-
<div class="pipe-view bg-white p-20p">
|
32 |
-
<h3 class="title"><?php _e('Step 1: Import settings', 'wf_csv_import_export'); ?></h3>
|
33 |
-
<?php if (!empty($upload_dir['error'])) : ?>
|
34 |
-
<div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:', 'wf_csv_import_export'); ?></p>
|
35 |
-
<p><strong><?php echo $upload_dir['error']; ?></strong></p></div>
|
36 |
-
<?php else : ?>
|
37 |
-
<div class="tool-box">
|
38 |
-
<p><?php _e('You can import products (in CSV format) in to the shop using by uploading a CSV file.', 'wf_csv_import_export'); ?></p>
|
39 |
-
<form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo esc_attr(wp_nonce_url($action, 'import-upload')); ?>">
|
40 |
-
<table class="form-table">
|
41 |
-
<tbody>
|
42 |
-
<tr>
|
43 |
-
<th>
|
44 |
-
<label for="upload"><?php _e('Select a file from your computer', 'wf_csv_import_export'); ?></label>
|
45 |
-
</th>
|
46 |
-
<td>
|
47 |
-
<input type="file" id="upload" name="import" size="25" />
|
48 |
-
<input type="hidden" name="action" value="save" />
|
49 |
-
<input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" /><br/>
|
50 |
-
<small><?php _e('Please upload UTF-8 encoded CSV', 'wf_csv_import_export'); ?> -- <?php printf(__('Maximum size: %s', 'wf_csv_import_export'), $size); ?></small>
|
51 |
-
</td>
|
52 |
-
</tr>
|
53 |
-
<tr>
|
54 |
-
<th><label><?php _e('Update products if exists', 'wf_csv_import_export'); ?></label><br/></th>
|
55 |
-
<td>
|
56 |
-
<input type="checkbox" name="merge" id="merge">
|
57 |
-
<p><small><?php _e('Existing products are identified by their SKUs/IDs. If this option is not selected and if a product with same ID/SKU is found in the CSV, that product will not be imported.', 'wf_csv_import_export'); ?></small></p>
|
58 |
-
</td>
|
59 |
-
|
60 |
-
</tr>
|
61 |
-
<tr>
|
62 |
-
<th><label><?php _e('Delimiter', 'wf_csv_import_export'); ?></label><br/></th>
|
63 |
-
<td><input type="text" name="delimiter" placeholder="," size="2" /></td>
|
64 |
-
</tr>
|
65 |
-
<tr>
|
66 |
-
<th><label><?php _e('Merge empty cells', 'wf_csv_import_export'); ?></label><br/></th>
|
67 |
-
<td><input type="checkbox" name="merge_empty_cells" placeholder="," size="2" />
|
68 |
-
<p><small><?php _e('If this option is checked, empty attributes will be added to products with no value. You can leave this unchecked if you are not sure about this option.', 'wf_csv_import_export'); ?></small></p>
|
69 |
-
</td>
|
70 |
-
</tr>
|
71 |
-
</tbody>
|
72 |
-
</table>
|
73 |
-
<p class="submit">
|
74 |
-
<input type="submit" class="button button-primary" value="<?php esc_attr_e('Proceed to Import Mapping', 'wf_csv_import_export'); ?>" />
|
75 |
-
<p><span><i><?php _e('If you want to import from an FTP location or from a URL or to configure a scheduled import you may need to upgrade to premium version.', 'wf_csv_import_export'); ?></i></span></p>
|
76 |
-
</p>
|
77 |
-
</form>
|
78 |
-
<?php endif; ?>
|
79 |
-
</div>
|
80 |
-
</div>
|
81 |
-
<?php include(WF_ProdImpExpCsv_BASE . 'includes/views/market.php'); ?>
|
82 |
-
<div class="clearfix"></div>
|
83 |
-
</div>
|
84 |
</div>
|
1 |
+
<?php
|
2 |
+
if (!defined('ABSPATH')) {
|
3 |
+
exit;
|
4 |
+
}
|
5 |
+
|
6 |
+
$ftp_server = '';
|
7 |
+
$ftp_user = '';
|
8 |
+
$ftp_password = '';
|
9 |
+
$use_ftps = '';
|
10 |
+
$enable_ftp_ie = '';
|
11 |
+
$ftp_server_path = '';
|
12 |
+
if (!empty($ftp_settings)) {
|
13 |
+
$ftp_server = $ftp_settings['ftp_server'];
|
14 |
+
$ftp_user = $ftp_settings['ftp_user'];
|
15 |
+
$ftp_password = $ftp_settings['ftp_password'];
|
16 |
+
$use_ftps = $ftp_settings['use_ftps'];
|
17 |
+
$enable_ftp_ie = $ftp_settings['enable_ftp_ie'];
|
18 |
+
$ftp_server_path = $ftp_settings['ftp_server_path'];
|
19 |
+
}
|
20 |
+
?>
|
21 |
+
<div class="woocommerce">
|
22 |
+
|
23 |
+
<h2 class="nav-tab-wrapper woo-nav-tab-wrapper">
|
24 |
+
<a href="<?php echo admin_url('admin.php?page=wf_woocommerce_csv_im_ex'); ?>" class="nav-tab"><?php _e('Product Export', 'wf_csv_import_export'); ?></a>
|
25 |
+
<a href="<?php echo admin_url('admin.php?import=xa_woocommerce_csv'); ?>" class="nav-tab nav-tab-active"><?php _e('Product Import', 'wf_csv_import_export'); ?></a>
|
26 |
+
<a href="<?php echo admin_url('admin.php?page=wf_woocommerce_csv_im_ex&tab=help'); ?>" class="nav-tab"><?php _e('Help', 'wf_csv_import_export'); ?></a>
|
27 |
+
<a href="https://www.xadapter.com/product/product-import-export-plugin-for-woocommerce/" target="_blank" class="nav-tab nav-tab-premium"><?php _e('Upgrade to Premium for More Features', 'wf_csv_import_export'); ?></a>
|
28 |
+
</h2>
|
29 |
+
|
30 |
+
<div class="pipe-main-box">
|
31 |
+
<div class="pipe-view bg-white p-20p">
|
32 |
+
<h3 class="title"><?php _e('Step 1: Import settings', 'wf_csv_import_export'); ?></h3>
|
33 |
+
<?php if (!empty($upload_dir['error'])) : ?>
|
34 |
+
<div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:', 'wf_csv_import_export'); ?></p>
|
35 |
+
<p><strong><?php echo $upload_dir['error']; ?></strong></p></div>
|
36 |
+
<?php else : ?>
|
37 |
+
<div class="tool-box">
|
38 |
+
<p><?php _e('You can import products (in CSV format) in to the shop using by uploading a CSV file.', 'wf_csv_import_export'); ?></p>
|
39 |
+
<form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo esc_attr(wp_nonce_url($action, 'import-upload')); ?>">
|
40 |
+
<table class="form-table">
|
41 |
+
<tbody>
|
42 |
+
<tr>
|
43 |
+
<th>
|
44 |
+
<label for="upload"><?php _e('Select a file from your computer', 'wf_csv_import_export'); ?></label>
|
45 |
+
</th>
|
46 |
+
<td>
|
47 |
+
<input type="file" id="upload" name="import" size="25" />
|
48 |
+
<input type="hidden" name="action" value="save" />
|
49 |
+
<input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" /><br/>
|
50 |
+
<small><?php _e('Please upload UTF-8 encoded CSV', 'wf_csv_import_export'); ?> -- <?php printf(__('Maximum size: %s', 'wf_csv_import_export'), $size); ?></small>
|
51 |
+
</td>
|
52 |
+
</tr>
|
53 |
+
<tr>
|
54 |
+
<th><label><?php _e('Update products if exists', 'wf_csv_import_export'); ?></label><br/></th>
|
55 |
+
<td>
|
56 |
+
<input type="checkbox" name="merge" id="merge">
|
57 |
+
<p><small><?php _e('Existing products are identified by their SKUs/IDs. If this option is not selected and if a product with same ID/SKU is found in the CSV, that product will not be imported.', 'wf_csv_import_export'); ?></small></p>
|
58 |
+
</td>
|
59 |
+
|
60 |
+
</tr>
|
61 |
+
<tr>
|
62 |
+
<th><label><?php _e('Delimiter', 'wf_csv_import_export'); ?></label><br/></th>
|
63 |
+
<td><input type="text" name="delimiter" placeholder="," size="2" /></td>
|
64 |
+
</tr>
|
65 |
+
<tr>
|
66 |
+
<th><label><?php _e('Merge empty cells', 'wf_csv_import_export'); ?></label><br/></th>
|
67 |
+
<td><input type="checkbox" name="merge_empty_cells" placeholder="," size="2" />
|
68 |
+
<p><small><?php _e('If this option is checked, empty attributes will be added to products with no value. You can leave this unchecked if you are not sure about this option.', 'wf_csv_import_export'); ?></small></p>
|
69 |
+
</td>
|
70 |
+
</tr>
|
71 |
+
</tbody>
|
72 |
+
</table>
|
73 |
+
<p class="submit">
|
74 |
+
<input type="submit" class="button button-primary" value="<?php esc_attr_e('Proceed to Import Mapping', 'wf_csv_import_export'); ?>" />
|
75 |
+
<p><span><i><?php _e('If you want to import from an FTP location or from a URL or to configure a scheduled import you may need to upgrade to premium version.', 'wf_csv_import_export'); ?></i></span></p>
|
76 |
+
</p>
|
77 |
+
</form>
|
78 |
+
<?php endif; ?>
|
79 |
+
</div>
|
80 |
+
</div>
|
81 |
+
<?php include(WF_ProdImpExpCsv_BASE . 'includes/views/market.php'); ?>
|
82 |
+
<div class="clearfix"></div>
|
83 |
+
</div>
|
84 |
</div>
|
includes/importer/views/html-wf-import-options.php
CHANGED
@@ -1,131 +1,131 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
-
exit;
|
4 |
-
}
|
5 |
-
?>
|
6 |
-
<h2 class="nav-tab-wrapper woo-nav-tab-wrapper">
|
7 |
-
<a href="<?php echo admin_url('admin.php?page=wf_woocommerce_csv_im_ex'); ?>" class="nav-tab"><?php _e('Product Export', 'wf_csv_import_export'); ?></a>
|
8 |
-
<a href="<?php echo admin_url('admin.php?import=xa_woocommerce_csv'); ?>" class="nav-tab nav-tab-active"><?php _e('Product Import', 'wf_csv_import_export'); ?></a>
|
9 |
-
<a href="<?php echo admin_url('admin.php?page=wf_woocommerce_csv_im_ex&tab=help'); ?>" class="nav-tab"><?php _e('Help', 'wf_csv_import_export'); ?></a>
|
10 |
-
<a href="https://www.xadapter.com/product/product-import-export-plugin-for-woocommerce/" target="_blank" class="nav-tab nav-tab-premium"><?php _e('Upgrade to Premium for More Features', 'wf_csv_import_export'); ?></a>
|
11 |
-
</h2>
|
12 |
-
<div class="bg-white p-20p">
|
13 |
-
<form action="<?php echo admin_url('admin.php?import=' . $this->import_page . '&step=2&merge=' . $this->merge); ?>" method="post">
|
14 |
-
<?php wp_nonce_field('import-woocommerce'); ?>
|
15 |
-
<input type="hidden" name="import_id" value="<?php echo $this->id; ?>" />
|
16 |
-
<?php if ($this->file_url_import_enabled) : ?>
|
17 |
-
<input type="hidden" name="import_url" value="<?php echo $this->file_url; ?>" />
|
18 |
-
<?php endif; ?>
|
19 |
-
<h3><?php _e('Step 2: Import mapping', 'wf_csv_import_export'); ?></h3>
|
20 |
-
<p><?php _e('Here you can map your imported columns to product data fields.', 'wf_csv_import_export'); ?></p>
|
21 |
-
<table class="widefat widefat_importer">
|
22 |
-
<thead>
|
23 |
-
<tr>
|
24 |
-
<th><?php _e('Woocommerce product fields', 'wf_csv_import_export'); ?></th>
|
25 |
-
<th><?php _e('CSV column header(from imported file)', 'wf_csv_import_export'); ?></th>
|
26 |
-
<th><?php _e('Evaluation Field', 'wf_csv_import_export'); ?>
|
27 |
-
<?php $plugin_url = WC()->plugin_url(); ?>
|
28 |
-
<img class="help_tip" style="float:none;" data-tip="<?php _e('Assign constant value HikeFoce to post_author:</br>=HikeFoce</br>Add $5 to Price:sale_price:</br>+5</br>Reduce $5 to Price:sale_price:</br>-5</br>Multiple 1.05 to Price:sale_price:</br>*1.05</br>Divide Price:sale_price by 2:</br>/2</br>Append a value By HikeFoce to post_title:</br>&By HikeFoce</br>Prepend a value HikeFoce to post_title:</br>&HikeFoce [VAL].', 'wf_csv_import_export'); ?>" src="<?php echo $plugin_url; ?>/assets/images/help.png" height="20" width="20" />
|
29 |
-
</th>
|
30 |
-
</tr>
|
31 |
-
</thead>
|
32 |
-
<tbody>
|
33 |
-
<?php
|
34 |
-
$wpost_attributes = include( dirname(__FILE__) . '/../data/data-wf-reserved-fields-pair.php' );
|
35 |
-
|
36 |
-
$taxonomy_n_attributes_items = array();
|
37 |
-
foreach ($taxonomies as $taxonomy) {
|
38 |
-
if (substr($taxonomy, 0, 3) !== 'pa_')
|
39 |
-
$taxonomy_n_attributes_items['tax:' . $taxonomy] = 'tax:' . $taxonomy. '| Product Taxonomies';
|
40 |
-
}
|
41 |
-
foreach ($taxonomies as $taxonomy) {
|
42 |
-
if (substr($taxonomy, 0, 3) == 'pa_')
|
43 |
-
$taxonomy_n_attributes_items['attribute:' . $taxonomy] = 'attribute:' . $taxonomy. '| Taxonomy Attributes';
|
44 |
-
}
|
45 |
-
foreach ($attributes as $attr) {
|
46 |
-
$attr = sanitize_title($attr);
|
47 |
-
if (substr($attr, 0, 3) !== 'pa_')
|
48 |
-
$taxonomy_n_attributes_items['attribute:' . $attr] = 'attribute:' . $attr. '| Product Attributes';
|
49 |
-
$taxonomy_n_attributes_items['attribute_data:' . $attr] = 'attribute_data:' .$attr. '| Product Attributes Data';
|
50 |
-
$taxonomy_n_attributes_items['attribute_default:' . $attr] = 'attribute_default:' .$attr. '| Product Attributes default';
|
51 |
-
}
|
52 |
-
|
53 |
-
foreach ($raw_headers as $key => $column) {
|
54 |
-
if(!empty($taxonomy_n_attributes_items[$key]))
|
55 |
-
continue;
|
56 |
-
if (strstr($key, 'tax:')) {
|
57 |
-
$column = trim(str_replace('tax:', '', $key));
|
58 |
-
$taxonomy_n_attributes_items['tax:' . $column] = 'tax:' . $column . '| New Taxonomy:' . $column;
|
59 |
-
} elseif (strstr($key, 'meta:')) {
|
60 |
-
$column = trim(str_replace('meta:', '', $key));
|
61 |
-
$taxonomy_n_attributes_items['meta:' . $column] = 'meta:' . $column . '| Custom Field:' . $column;
|
62 |
-
} elseif (strstr($key, 'attribute:')) {
|
63 |
-
$column = trim(str_replace('attribute:', '', $key));
|
64 |
-
$taxonomy_n_attributes_items['attribute:' . $column] = 'attribute:' . $column . '| New Product Attribute:' . $column;
|
65 |
-
} elseif (strstr($key, 'attribute_data:')) {
|
66 |
-
$column = trim(str_replace('attribute_data:', '', $key));
|
67 |
-
$taxonomy_n_attributes_items['attribute_data:' . $column] = 'attribute_data:' . $column . '| New Product Attribute Data:' . $column;
|
68 |
-
} elseif (strstr($key, 'attribute_default:')) {
|
69 |
-
$column = trim(str_replace('attribute_default:', '', $key));
|
70 |
-
$taxonomy_n_attributes_items['attribute_default:' . $column] = 'attribute_default:' . $column . '| New Product Attribute default value:' . $column;
|
71 |
-
}
|
72 |
-
}
|
73 |
-
|
74 |
-
foreach ($taxonomy_n_attributes_items as $key => $value) {
|
75 |
-
if(!empty($wpost_attributes[$key]))
|
76 |
-
continue;
|
77 |
-
$wpost_attributes[$key] = $value;
|
78 |
-
}
|
79 |
-
|
80 |
-
foreach ($wpost_attributes as $key => $value) :
|
81 |
-
$sel_key = ($saved_mapping && isset($saved_mapping[$key])) ? $saved_mapping[$key] : $key;
|
82 |
-
$evaluation_value = ($saved_evaluation && isset($saved_evaluation[$key])) ? $saved_evaluation[$key] : '';
|
83 |
-
$evaluation_value = stripslashes($evaluation_value);
|
84 |
-
$values = explode('|',$value);
|
85 |
-
$value = $values[0];
|
86 |
-
$tool_tip = $values[1];
|
87 |
-
?>
|
88 |
-
<tr>
|
89 |
-
<td width="25%">
|
90 |
-
<img class="help_tip" style="float:none;" data-tip="<?php echo $tool_tip; ?>" src="<?php echo $plugin_url; ?>/assets/images/help.png" height="20" width="20" />
|
91 |
-
<select name="map_to[<?php echo $key; ?>]" disabled="true"
|
92 |
-
style=" -webkit-appearance: none;
|
93 |
-
-moz-appearance: none;
|
94 |
-
text-indent: 1px;
|
95 |
-
text-overflow: '';
|
96 |
-
background-color: #f1f1f1;
|
97 |
-
border: none;
|
98 |
-
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07) inset;
|
99 |
-
color: #32373c;
|
100 |
-
outline: 0 none;
|
101 |
-
transition: border-color 50ms ease-in-out 0s;">
|
102 |
-
<option value="<?php echo $key; ?>" <?php if ($key == $key) echo 'selected="selected"'; ?>><?php echo $value; ?></option>
|
103 |
-
</select>
|
104 |
-
</td>
|
105 |
-
<td width="25%">
|
106 |
-
<select name="map_from[<?php echo $key; ?>]">
|
107 |
-
<option value=""><?php _e('Do not import', 'wf_csv_import_export'); ?></option>
|
108 |
-
<?php
|
109 |
-
foreach ($row as $hkey => $hdr):
|
110 |
-
$hdr = strlen($hdr) > 50 ? substr(strip_tags($hdr), 0, 50) . "..." : $hdr;
|
111 |
-
?>
|
112 |
-
<option value="<?php echo $raw_headers[$hkey]; ?>" <?php selected(strtolower($sel_key), $hkey); ?>><?php echo $raw_headers[$hkey] . " : " . $hdr; ?></option>
|
113 |
-
<?php endforeach; ?>
|
114 |
-
</select>
|
115 |
-
<?php do_action('woocommerce_csv_product_data_mapping', $key); ?>
|
116 |
-
</td>
|
117 |
-
<td width="10%"><input type="text" name="eval_field[<?php echo $key; ?>]" value="<?php echo $evaluation_value; ?>" /></td>
|
118 |
-
</tr>
|
119 |
-
<?php endforeach; ?>
|
120 |
-
</tbody>
|
121 |
-
</table>
|
122 |
-
<p class="submit"><br/>
|
123 |
-
<span style="color:gray;"><i><?php _e('Time taken to Import the products depends on the time taken to fetch the images and the internet speed. If you have more than 1000 products we recommend doing the import in batches by splitting the CSV file. Please do not navigate away or close the window while the import is in progress.', 'wf_csv_import_export' ); ?></i></span>
|
124 |
-
<br/><br/>
|
125 |
-
<input type="submit" class="button button-primary" value="<?php esc_attr_e('Start Import', 'wf_csv_import_export'); ?>" />
|
126 |
-
<input type="hidden" name="delimiter" value="<?php echo $this->delimiter ?>" />
|
127 |
-
<input type="hidden" name="merge_empty_cells" value="<?php echo $this->merge_empty_cells ?>" />
|
128 |
-
<input type="hidden" name="merge" value="<?php echo $this->merge?>" />
|
129 |
-
</p>
|
130 |
-
</form>
|
131 |
</div>
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
+
exit;
|
4 |
+
}
|
5 |
+
?>
|
6 |
+
<h2 class="nav-tab-wrapper woo-nav-tab-wrapper">
|
7 |
+
<a href="<?php echo admin_url('admin.php?page=wf_woocommerce_csv_im_ex'); ?>" class="nav-tab"><?php _e('Product Export', 'wf_csv_import_export'); ?></a>
|
8 |
+
<a href="<?php echo admin_url('admin.php?import=xa_woocommerce_csv'); ?>" class="nav-tab nav-tab-active"><?php _e('Product Import', 'wf_csv_import_export'); ?></a>
|
9 |
+
<a href="<?php echo admin_url('admin.php?page=wf_woocommerce_csv_im_ex&tab=help'); ?>" class="nav-tab"><?php _e('Help', 'wf_csv_import_export'); ?></a>
|
10 |
+
<a href="https://www.xadapter.com/product/product-import-export-plugin-for-woocommerce/" target="_blank" class="nav-tab nav-tab-premium"><?php _e('Upgrade to Premium for More Features', 'wf_csv_import_export'); ?></a>
|
11 |
+
</h2>
|
12 |
+
<div class="bg-white p-20p">
|
13 |
+
<form action="<?php echo admin_url('admin.php?import=' . $this->import_page . '&step=2&merge=' . $this->merge); ?>" method="post">
|
14 |
+
<?php wp_nonce_field('import-woocommerce'); ?>
|
15 |
+
<input type="hidden" name="import_id" value="<?php echo $this->id; ?>" />
|
16 |
+
<?php if ($this->file_url_import_enabled) : ?>
|
17 |
+
<input type="hidden" name="import_url" value="<?php echo $this->file_url; ?>" />
|
18 |
+
<?php endif; ?>
|
19 |
+
<h3><?php _e('Step 2: Import mapping', 'wf_csv_import_export'); ?></h3>
|
20 |
+
<p><?php _e('Here you can map your imported columns to product data fields.', 'wf_csv_import_export'); ?></p>
|
21 |
+
<table class="widefat widefat_importer">
|
22 |
+
<thead>
|
23 |
+
<tr>
|
24 |
+
<th><?php _e('Woocommerce product fields', 'wf_csv_import_export'); ?></th>
|
25 |
+
<th><?php _e('CSV column header(from imported file)', 'wf_csv_import_export'); ?></th>
|
26 |
+
<th><?php _e('Evaluation Field', 'wf_csv_import_export'); ?>
|
27 |
+
<?php $plugin_url = WC()->plugin_url(); ?>
|
28 |
+
<img class="help_tip" style="float:none;" data-tip="<?php _e('Assign constant value HikeFoce to post_author:</br>=HikeFoce</br>Add $5 to Price:sale_price:</br>+5</br>Reduce $5 to Price:sale_price:</br>-5</br>Multiple 1.05 to Price:sale_price:</br>*1.05</br>Divide Price:sale_price by 2:</br>/2</br>Append a value By HikeFoce to post_title:</br>&By HikeFoce</br>Prepend a value HikeFoce to post_title:</br>&HikeFoce [VAL].', 'wf_csv_import_export'); ?>" src="<?php echo $plugin_url; ?>/assets/images/help.png" height="20" width="20" />
|
29 |
+
</th>
|
30 |
+
</tr>
|
31 |
+
</thead>
|
32 |
+
<tbody>
|
33 |
+
<?php
|
34 |
+
$wpost_attributes = include( dirname(__FILE__) . '/../data/data-wf-reserved-fields-pair.php' );
|
35 |
+
|
36 |
+
$taxonomy_n_attributes_items = array();
|
37 |
+
foreach ($taxonomies as $taxonomy) {
|
38 |
+
if (substr($taxonomy, 0, 3) !== 'pa_')
|
39 |
+
$taxonomy_n_attributes_items['tax:' . $taxonomy] = 'tax:' . $taxonomy. '| Product Taxonomies';
|
40 |
+
}
|
41 |
+
foreach ($taxonomies as $taxonomy) {
|
42 |
+
if (substr($taxonomy, 0, 3) == 'pa_')
|
43 |
+
$taxonomy_n_attributes_items['attribute:' . $taxonomy] = 'attribute:' . $taxonomy. '| Taxonomy Attributes';
|
44 |
+
}
|
45 |
+
foreach ($attributes as $attr) {
|
46 |
+
$attr = sanitize_title($attr);
|
47 |
+
if (substr($attr, 0, 3) !== 'pa_')
|
48 |
+
$taxonomy_n_attributes_items['attribute:' . $attr] = 'attribute:' . $attr. '| Product Attributes';
|
49 |
+
$taxonomy_n_attributes_items['attribute_data:' . $attr] = 'attribute_data:' .$attr. '| Product Attributes Data';
|
50 |
+
$taxonomy_n_attributes_items['attribute_default:' . $attr] = 'attribute_default:' .$attr. '| Product Attributes default';
|
51 |
+
}
|
52 |
+
|
53 |
+
foreach ($raw_headers as $key => $column) {
|
54 |
+
if(!empty($taxonomy_n_attributes_items[$key]))
|
55 |
+
continue;
|
56 |
+
if (strstr($key, 'tax:')) {
|
57 |
+
$column = trim(str_replace('tax:', '', $key));
|
58 |
+
$taxonomy_n_attributes_items['tax:' . $column] = 'tax:' . $column . '| New Taxonomy:' . $column;
|
59 |
+
} elseif (strstr($key, 'meta:')) {
|
60 |
+
$column = trim(str_replace('meta:', '', $key));
|
61 |
+
$taxonomy_n_attributes_items['meta:' . $column] = 'meta:' . $column . '| Custom Field:' . $column;
|
62 |
+
} elseif (strstr($key, 'attribute:')) {
|
63 |
+
$column = trim(str_replace('attribute:', '', $key));
|
64 |
+
$taxonomy_n_attributes_items['attribute:' . $column] = 'attribute:' . $column . '| New Product Attribute:' . $column;
|
65 |
+
} elseif (strstr($key, 'attribute_data:')) {
|
66 |
+
$column = trim(str_replace('attribute_data:', '', $key));
|
67 |
+
$taxonomy_n_attributes_items['attribute_data:' . $column] = 'attribute_data:' . $column . '| New Product Attribute Data:' . $column;
|
68 |
+
} elseif (strstr($key, 'attribute_default:')) {
|
69 |
+
$column = trim(str_replace('attribute_default:', '', $key));
|
70 |
+
$taxonomy_n_attributes_items['attribute_default:' . $column] = 'attribute_default:' . $column . '| New Product Attribute default value:' . $column;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
foreach ($taxonomy_n_attributes_items as $key => $value) {
|
75 |
+
if(!empty($wpost_attributes[$key]))
|
76 |
+
continue;
|
77 |
+
$wpost_attributes[$key] = $value;
|
78 |
+
}
|
79 |
+
|
80 |
+
foreach ($wpost_attributes as $key => $value) :
|
81 |
+
$sel_key = ($saved_mapping && isset($saved_mapping[$key])) ? $saved_mapping[$key] : $key;
|
82 |
+
$evaluation_value = ($saved_evaluation && isset($saved_evaluation[$key])) ? $saved_evaluation[$key] : '';
|
83 |
+
$evaluation_value = stripslashes($evaluation_value);
|
84 |
+
$values = explode('|',$value);
|
85 |
+
$value = $values[0];
|
86 |
+
$tool_tip = $values[1];
|
87 |
+
?>
|
88 |
+
<tr>
|
89 |
+
<td width="25%">
|
90 |
+
<img class="help_tip" style="float:none;" data-tip="<?php echo $tool_tip; ?>" src="<?php echo $plugin_url; ?>/assets/images/help.png" height="20" width="20" />
|
91 |
+
<select name="map_to[<?php echo $key; ?>]" disabled="true"
|
92 |
+
style=" -webkit-appearance: none;
|
93 |
+
-moz-appearance: none;
|
94 |
+
text-indent: 1px;
|
95 |
+
text-overflow: '';
|
96 |
+
background-color: #f1f1f1;
|
97 |
+
border: none;
|
98 |
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07) inset;
|
99 |
+
color: #32373c;
|
100 |
+
outline: 0 none;
|
101 |
+
transition: border-color 50ms ease-in-out 0s;">
|
102 |
+
<option value="<?php echo $key; ?>" <?php if ($key == $key) echo 'selected="selected"'; ?>><?php echo $value; ?></option>
|
103 |
+
</select>
|
104 |
+
</td>
|
105 |
+
<td width="25%">
|
106 |
+
<select name="map_from[<?php echo $key; ?>]">
|
107 |
+
<option value=""><?php _e('Do not import', 'wf_csv_import_export'); ?></option>
|
108 |
+
<?php
|
109 |
+
foreach ($row as $hkey => $hdr):
|
110 |
+
$hdr = strlen($hdr) > 50 ? substr(strip_tags($hdr), 0, 50) . "..." : $hdr;
|
111 |
+
?>
|
112 |
+
<option value="<?php echo $raw_headers[$hkey]; ?>" <?php selected(strtolower($sel_key), $hkey); ?>><?php echo $raw_headers[$hkey] . " : " . $hdr; ?></option>
|
113 |
+
<?php endforeach; ?>
|
114 |
+
</select>
|
115 |
+
<?php do_action('woocommerce_csv_product_data_mapping', $key); ?>
|
116 |
+
</td>
|
117 |
+
<td width="10%"><input type="text" name="eval_field[<?php echo $key; ?>]" value="<?php echo $evaluation_value; ?>" /></td>
|
118 |
+
</tr>
|
119 |
+
<?php endforeach; ?>
|
120 |
+
</tbody>
|
121 |
+
</table>
|
122 |
+
<p class="submit"><br/>
|
123 |
+
<span style="color:gray;"><i><?php _e('Time taken to Import the products depends on the time taken to fetch the images and the internet speed. If you have more than 1000 products we recommend doing the import in batches by splitting the CSV file. Please do not navigate away or close the window while the import is in progress.', 'wf_csv_import_export' ); ?></i></span>
|
124 |
+
<br/><br/>
|
125 |
+
<input type="submit" class="button button-primary" value="<?php esc_attr_e('Start Import', 'wf_csv_import_export'); ?>" />
|
126 |
+
<input type="hidden" name="delimiter" value="<?php echo $this->delimiter ?>" />
|
127 |
+
<input type="hidden" name="merge_empty_cells" value="<?php echo $this->merge_empty_cells ?>" />
|
128 |
+
<input type="hidden" name="merge" value="<?php echo $this->merge?>" />
|
129 |
+
</p>
|
130 |
+
</form>
|
131 |
</div>
|
includes/settings/class-wf-prodimpexpcsv-settings.php
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
-
exit;
|
4 |
-
}
|
5 |
-
|
6 |
-
class WF_ProdImpExpCsv_Settings {
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Product Exporter Tool
|
10 |
-
*/
|
11 |
-
public static function save_settings( ) {
|
12 |
-
global $wpdb;
|
13 |
-
|
14 |
-
//update_option( 'woocommerce_'.WF_PROD_IMP_EXP_ID.'_settings', $settings );
|
15 |
-
|
16 |
-
//echo ':'.$ftp_server.':'.$ftp_user.':'.$ftp_password.':'.$use_ftps; die();
|
17 |
-
//wp_redirect( admin_url( '/admin.php?page='.WF_WOOCOMMERCE_CSV_IM_EX.'&tab=settings' ) );
|
18 |
-
//exit;
|
19 |
-
}
|
20 |
-
}
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
+
exit;
|
4 |
+
}
|
5 |
+
|
6 |
+
class WF_ProdImpExpCsv_Settings {
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Product Exporter Tool
|
10 |
+
*/
|
11 |
+
public static function save_settings( ) {
|
12 |
+
global $wpdb;
|
13 |
+
|
14 |
+
//update_option( 'woocommerce_'.WF_PROD_IMP_EXP_ID.'_settings', $settings );
|
15 |
+
|
16 |
+
//echo ':'.$ftp_server.':'.$ftp_user.':'.$ftp_password.':'.$use_ftps; die();
|
17 |
+
//wp_redirect( admin_url( '/admin.php?page='.WF_WOOCOMMERCE_CSV_IM_EX.'&tab=settings' ) );
|
18 |
+
//exit;
|
19 |
+
}
|
20 |
+
}
|
includes/views/export/html-wf-export-products.php
CHANGED
@@ -1,101 +1,101 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
-
exit;
|
4 |
-
}
|
5 |
-
?>
|
6 |
-
<script>
|
7 |
-
jQuery(document).ready(function (a) {
|
8 |
-
"use strict";
|
9 |
-
// Listen for click on toggle checkbox
|
10 |
-
jQuery('#pselectall').live("click", function () {
|
11 |
-
// Iterate each checkbox
|
12 |
-
jQuery(':checkbox').each(function () {
|
13 |
-
this.checked = true;
|
14 |
-
});
|
15 |
-
});
|
16 |
-
jQuery('#punselectall').live("click", function () {
|
17 |
-
// Iterate each checkbox
|
18 |
-
jQuery(':checkbox').each(function () {
|
19 |
-
this.checked = false;
|
20 |
-
});
|
21 |
-
});
|
22 |
-
});
|
23 |
-
</script>
|
24 |
-
<div class="pipe-main-box">
|
25 |
-
<div class="tool-box bg-white p-20p pipe-view">
|
26 |
-
<h3 class="title" style="font-size: 1.3em !important;font-weight: 600;"><?php _e('Export Settings', 'wf_csv_import_export'); ?></h3>
|
27 |
-
<p><?php _e('Export and download your products in CSV file format. This file can be used to import products back into your WooCommerce store.', 'wf_csv_import_export'); ?></p>
|
28 |
-
<form action="<?php echo admin_url('admin.php?page=wf_woocommerce_csv_im_ex&action=export'); ?>" method="post">
|
29 |
-
<table class="form-table">
|
30 |
-
<tr>
|
31 |
-
<th>
|
32 |
-
<label for="v_offset"><?php _e('Offset', 'wf_csv_import_export'); ?></label>
|
33 |
-
</th>
|
34 |
-
<td>
|
35 |
-
<input type="text" name="offset" id="v_offset" placeholder="0" class="input-text" />
|
36 |
-
<p style="font-size: 12px"><?php _e('Number of products to skip before exporting. If the value is 0 no products are skipped. If value is 100, products from product id 101 will be exported.', 'wf_csv_import_export'); ?></p>
|
37 |
-
</td>
|
38 |
-
</tr>
|
39 |
-
<tr>
|
40 |
-
<th>
|
41 |
-
<label for="v_limit"><?php _e('Limit', 'wf_csv_import_export'); ?></label>
|
42 |
-
</th>
|
43 |
-
<td>
|
44 |
-
<input type="text" name="limit" id="v_limit" placeholder="<?php _e('Unlimited', 'wf_csv_import_export'); ?>" class="input-text" />
|
45 |
-
<p style="font-size: 12px"><?php _e('Number of products to export. If no value is given all products will be exported. This is useful if you have large number of products and want to export partial list of products.', 'wf_csv_import_export'); ?></p>
|
46 |
-
</td>
|
47 |
-
</tr>
|
48 |
-
<tr>
|
49 |
-
<th colspan="2">
|
50 |
-
<label for="v_columns"><?php _e('Columns', 'wf_csv_import_export'); ?></label>
|
51 |
-
<p style="font-size: 12px;font-weight:300;"><?php _e('Configure the Column Names of CSV file.', 'wf_csv_import_export'); ?></p>
|
52 |
-
</th>
|
53 |
-
<table id="datagrid">
|
54 |
-
<th style="text-align: left; padding:6px 25px !important; font-weight: normal !important;color:#000;">
|
55 |
-
<label for="v_columns"><?php _e('WooCommerce product field name', 'wf_csv_import_export'); ?></label>
|
56 |
-
</th>
|
57 |
-
<th style="text-align: left; padding:6px 25px !important; font-weight: normal !important;color:#000;">
|
58 |
-
<label for="v_columns_name"><?php _e('Column header name in the CSV file', 'wf_csv_import_export'); ?></label>
|
59 |
-
</th>
|
60 |
-
<!-- select all boxes -->
|
61 |
-
<tr>
|
62 |
-
<td style="padding: 10px;">
|
63 |
-
<a href="#" id="pselectall" onclick="return false;" ><?php _e('Select all', 'wf_csv_import_export'); ?></a> /
|
64 |
-
<a href="#" id="punselectall" onclick="return false;"><?php _e('Unselect all', 'wf_csv_import_export'); ?></a>
|
65 |
-
</td>
|
66 |
-
</tr>
|
67 |
-
<?php
|
68 |
-
$post_columns['images'] = 'Images (featured and gallery)';
|
69 |
-
$post_columns['file_paths'] = 'Downloadable file paths';
|
70 |
-
$post_columns['taxonomies'] = 'Taxonomies (cat/tags/shipping-class)';
|
71 |
-
$post_columns['attributes'] = 'Attributes';
|
72 |
-
?>
|
73 |
-
<?php foreach ($post_columns as $pkey => $pcolumn) {
|
74 |
-
?>
|
75 |
-
<tr>
|
76 |
-
<td>
|
77 |
-
<input name= "columns[<?php echo $pkey; ?>]" type="checkbox" value="<?php echo $pkey; ?>" checked>
|
78 |
-
<label for="columns[<?php echo $pkey; ?>]"><?php _e($pcolumn, 'wf_csv_import_export'); ?></label>
|
79 |
-
</td>
|
80 |
-
<td>
|
81 |
-
<?php
|
82 |
-
$tmpkey = $pkey;
|
83 |
-
if (strpos($pkey, 'yoast') === false) {
|
84 |
-
$tmpkey = ltrim($pkey, '_');
|
85 |
-
}
|
86 |
-
?>
|
87 |
-
<input type="text" name="columns_name[<?php echo $pkey; ?>]" value="<?php echo $tmpkey; ?>" class="input-text" />
|
88 |
-
</td>
|
89 |
-
</tr>
|
90 |
-
<?php } ?>
|
91 |
-
|
92 |
-
</table><br/>
|
93 |
-
</tr>
|
94 |
-
</table>
|
95 |
-
<p class="submit"><input type="submit" class="button button-primary" value="<?php _e('Export Products', 'wf_csv_import_export'); ?>" /></p>
|
96 |
-
<p><span><i><?php _e('With this version of the plugin you can export products (except variable products) in to a file. If you want to export to an FTP location (scheduled / manual ) you may need to upgrade to premium version.', 'wf_csv_import_export'); ?></i></span></p>
|
97 |
-
</form>
|
98 |
-
</div>
|
99 |
-
<?php include(WF_ProdImpExpCsv_BASE . 'includes/views/market.php'); ?>
|
100 |
-
<div class="clearfix"></div>
|
101 |
</div>
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
+
exit;
|
4 |
+
}
|
5 |
+
?>
|
6 |
+
<script>
|
7 |
+
jQuery(document).ready(function (a) {
|
8 |
+
"use strict";
|
9 |
+
// Listen for click on toggle checkbox
|
10 |
+
jQuery('#pselectall').live("click", function () {
|
11 |
+
// Iterate each checkbox
|
12 |
+
jQuery(':checkbox').each(function () {
|
13 |
+
this.checked = true;
|
14 |
+
});
|
15 |
+
});
|
16 |
+
jQuery('#punselectall').live("click", function () {
|
17 |
+
// Iterate each checkbox
|
18 |
+
jQuery(':checkbox').each(function () {
|
19 |
+
this.checked = false;
|
20 |
+
});
|
21 |
+
});
|
22 |
+
});
|
23 |
+
</script>
|
24 |
+
<div class="pipe-main-box">
|
25 |
+
<div class="tool-box bg-white p-20p pipe-view">
|
26 |
+
<h3 class="title" style="font-size: 1.3em !important;font-weight: 600;"><?php _e('Export Settings', 'wf_csv_import_export'); ?></h3>
|
27 |
+
<p><?php _e('Export and download your products in CSV file format. This file can be used to import products back into your WooCommerce store.', 'wf_csv_import_export'); ?></p>
|
28 |
+
<form action="<?php echo admin_url('admin.php?page=wf_woocommerce_csv_im_ex&action=export'); ?>" method="post">
|
29 |
+
<table class="form-table">
|
30 |
+
<tr>
|
31 |
+
<th>
|
32 |
+
<label for="v_offset"><?php _e('Offset', 'wf_csv_import_export'); ?></label>
|
33 |
+
</th>
|
34 |
+
<td>
|
35 |
+
<input type="text" name="offset" id="v_offset" placeholder="0" class="input-text" />
|
36 |
+
<p style="font-size: 12px"><?php _e('Number of products to skip before exporting. If the value is 0 no products are skipped. If value is 100, products from product id 101 will be exported.', 'wf_csv_import_export'); ?></p>
|
37 |
+
</td>
|
38 |
+
</tr>
|
39 |
+
<tr>
|
40 |
+
<th>
|
41 |
+
<label for="v_limit"><?php _e('Limit', 'wf_csv_import_export'); ?></label>
|
42 |
+
</th>
|
43 |
+
<td>
|
44 |
+
<input type="text" name="limit" id="v_limit" placeholder="<?php _e('Unlimited', 'wf_csv_import_export'); ?>" class="input-text" />
|
45 |
+
<p style="font-size: 12px"><?php _e('Number of products to export. If no value is given all products will be exported. This is useful if you have large number of products and want to export partial list of products.', 'wf_csv_import_export'); ?></p>
|
46 |
+
</td>
|
47 |
+
</tr>
|
48 |
+
<tr>
|
49 |
+
<th colspan="2">
|
50 |
+
<label for="v_columns"><?php _e('Columns', 'wf_csv_import_export'); ?></label>
|
51 |
+
<p style="font-size: 12px;font-weight:300;"><?php _e('Configure the Column Names of CSV file.', 'wf_csv_import_export'); ?></p>
|
52 |
+
</th>
|
53 |
+
<table id="datagrid">
|
54 |
+
<th style="text-align: left; padding:6px 25px !important; font-weight: normal !important;color:#000;">
|
55 |
+
<label for="v_columns"><?php _e('WooCommerce product field name', 'wf_csv_import_export'); ?></label>
|
56 |
+
</th>
|
57 |
+
<th style="text-align: left; padding:6px 25px !important; font-weight: normal !important;color:#000;">
|
58 |
+
<label for="v_columns_name"><?php _e('Column header name in the CSV file', 'wf_csv_import_export'); ?></label>
|
59 |
+
</th>
|
60 |
+
<!-- select all boxes -->
|
61 |
+
<tr>
|
62 |
+
<td style="padding: 10px;">
|
63 |
+
<a href="#" id="pselectall" onclick="return false;" ><?php _e('Select all', 'wf_csv_import_export'); ?></a> /
|
64 |
+
<a href="#" id="punselectall" onclick="return false;"><?php _e('Unselect all', 'wf_csv_import_export'); ?></a>
|
65 |
+
</td>
|
66 |
+
</tr>
|
67 |
+
<?php
|
68 |
+
$post_columns['images'] = 'Images (featured and gallery)';
|
69 |
+
$post_columns['file_paths'] = 'Downloadable file paths';
|
70 |
+
$post_columns['taxonomies'] = 'Taxonomies (cat/tags/shipping-class)';
|
71 |
+
$post_columns['attributes'] = 'Attributes';
|
72 |
+
?>
|
73 |
+
<?php foreach ($post_columns as $pkey => $pcolumn) {
|
74 |
+
?>
|
75 |
+
<tr>
|
76 |
+
<td>
|
77 |
+
<input name= "columns[<?php echo $pkey; ?>]" type="checkbox" value="<?php echo $pkey; ?>" checked>
|
78 |
+
<label for="columns[<?php echo $pkey; ?>]"><?php _e($pcolumn, 'wf_csv_import_export'); ?></label>
|
79 |
+
</td>
|
80 |
+
<td>
|
81 |
+
<?php
|
82 |
+
$tmpkey = $pkey;
|
83 |
+
if (strpos($pkey, 'yoast') === false) {
|
84 |
+
$tmpkey = ltrim($pkey, '_');
|
85 |
+
}
|
86 |
+
?>
|
87 |
+
<input type="text" name="columns_name[<?php echo $pkey; ?>]" value="<?php echo $tmpkey; ?>" class="input-text" />
|
88 |
+
</td>
|
89 |
+
</tr>
|
90 |
+
<?php } ?>
|
91 |
+
|
92 |
+
</table><br/>
|
93 |
+
</tr>
|
94 |
+
</table>
|
95 |
+
<p class="submit"><input type="submit" class="button button-primary" value="<?php _e('Export Products', 'wf_csv_import_export'); ?>" /></p>
|
96 |
+
<p><span><i><?php _e('With this version of the plugin you can export products (except variable products) in to a file. If you want to export to an FTP location (scheduled / manual ) you may need to upgrade to premium version.', 'wf_csv_import_export'); ?></i></span></p>
|
97 |
+
</form>
|
98 |
+
</div>
|
99 |
+
<?php include(WF_ProdImpExpCsv_BASE . 'includes/views/market.php'); ?>
|
100 |
+
<div class="clearfix"></div>
|
101 |
</div>
|
includes/views/html-wf-admin-screen.php
CHANGED
@@ -1,27 +1,27 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
-
exit;
|
4 |
-
}
|
5 |
-
?>
|
6 |
-
<div class="woocommerce">
|
7 |
-
<div class="icon32" id="icon-woocommerce-importer"><br></div>
|
8 |
-
<h2 class="nav-tab-wrapper woo-nav-tab-wrapper">
|
9 |
-
<a href="<?php echo admin_url('admin.php?page=wf_woocommerce_csv_im_ex'); ?>" class="nav-tab <?php echo ('help' != $tab) ? 'nav-tab-active' : ''; ?>"><?php _e('Product Export', 'wf_csv_import_export'); ?></a>
|
10 |
-
<a href="<?php echo admin_url('admin.php?import=xa_woocommerce_csv'); ?>" class="nav-tab"><?php _e('Product Import', 'wf_csv_import_export'); ?></a>
|
11 |
-
<a href="<?php echo admin_url('admin.php?page=wf_woocommerce_csv_im_ex&tab=help'); ?>" class="nav-tab <?php echo ('help' == $tab) ? 'nav-tab-active' : ''; ?>"><?php _e('Help', 'wf_csv_import_export'); ?></a>
|
12 |
-
<a href="https://www.xadapter.com/product/product-import-export-plugin-for-woocommerce/" target="_blank" class="nav-tab nav-tab-premium"><?php _e('Upgrade to Premium for More Features', 'wf_csv_import_export'); ?></a>
|
13 |
-
|
14 |
-
</h2>
|
15 |
-
<?php
|
16 |
-
switch ($tab) {
|
17 |
-
case "help" :
|
18 |
-
$this->admin_help_page();
|
19 |
-
break;
|
20 |
-
|
21 |
-
case "export":
|
22 |
-
default :
|
23 |
-
$this->admin_export_page();
|
24 |
-
break;
|
25 |
-
}
|
26 |
-
?>
|
27 |
</div>
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
+
exit;
|
4 |
+
}
|
5 |
+
?>
|
6 |
+
<div class="woocommerce">
|
7 |
+
<div class="icon32" id="icon-woocommerce-importer"><br></div>
|
8 |
+
<h2 class="nav-tab-wrapper woo-nav-tab-wrapper">
|
9 |
+
<a href="<?php echo admin_url('admin.php?page=wf_woocommerce_csv_im_ex'); ?>" class="nav-tab <?php echo ('help' != $tab) ? 'nav-tab-active' : ''; ?>"><?php _e('Product Export', 'wf_csv_import_export'); ?></a>
|
10 |
+
<a href="<?php echo admin_url('admin.php?import=xa_woocommerce_csv'); ?>" class="nav-tab"><?php _e('Product Import', 'wf_csv_import_export'); ?></a>
|
11 |
+
<a href="<?php echo admin_url('admin.php?page=wf_woocommerce_csv_im_ex&tab=help'); ?>" class="nav-tab <?php echo ('help' == $tab) ? 'nav-tab-active' : ''; ?>"><?php _e('Help', 'wf_csv_import_export'); ?></a>
|
12 |
+
<a href="https://www.xadapter.com/product/product-import-export-plugin-for-woocommerce/" target="_blank" class="nav-tab nav-tab-premium"><?php _e('Upgrade to Premium for More Features', 'wf_csv_import_export'); ?></a>
|
13 |
+
|
14 |
+
</h2>
|
15 |
+
<?php
|
16 |
+
switch ($tab) {
|
17 |
+
case "help" :
|
18 |
+
$this->admin_help_page();
|
19 |
+
break;
|
20 |
+
|
21 |
+
case "export":
|
22 |
+
default :
|
23 |
+
$this->admin_export_page();
|
24 |
+
break;
|
25 |
+
}
|
26 |
+
?>
|
27 |
</div>
|
includes/views/import/html-wf-import-products.php
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
-
|
2 |
-
<div class="tool-box">
|
3 |
-
<h3 class="title"><?php _e('Import Products in CSV Format:', 'wf_csv_import_export'); ?></h3>
|
4 |
-
<p><?php _e('Import products in CSV format ( works for simple products) from different sources', 'wf_csv_import_export'); ?></p>
|
5 |
-
<p class="submit">
|
6 |
-
<?php
|
7 |
-
$merge_url = admin_url('admin.php?import=woocommerce_csv&merge=1');
|
8 |
-
$import_url = admin_url('admin.php?import=woocommerce_csv');
|
9 |
-
?>
|
10 |
-
<a class="button button-primary" id="mylink" href="<?php echo admin_url('admin.php?import=woocommerce_csv'); ?>"><?php _e('Import Products', 'wf_csv_import_export'); ?></a>
|
11 |
-
|
12 |
-
<input type="checkbox" id="merge" value="0"><?php _e('Merge products if exists', 'wf_csv_import_export'); ?> <br>
|
13 |
-
</p>
|
14 |
-
</div>
|
15 |
-
<script type="text/javascript">
|
16 |
-
jQuery('#merge').click(function () {
|
17 |
-
if (this.checked) {
|
18 |
-
jQuery("#mylink").attr("href", '<?php echo $merge_url ?>');
|
19 |
-
} else {
|
20 |
-
jQuery("#mylink").attr("href", '<?php echo $import_url ?>');
|
21 |
-
}
|
22 |
-
});
|
23 |
</script>
|
1 |
+
|
2 |
+
<div class="tool-box">
|
3 |
+
<h3 class="title"><?php _e('Import Products in CSV Format:', 'wf_csv_import_export'); ?></h3>
|
4 |
+
<p><?php _e('Import products in CSV format ( works for simple products) from different sources', 'wf_csv_import_export'); ?></p>
|
5 |
+
<p class="submit">
|
6 |
+
<?php
|
7 |
+
$merge_url = admin_url('admin.php?import=woocommerce_csv&merge=1');
|
8 |
+
$import_url = admin_url('admin.php?import=woocommerce_csv');
|
9 |
+
?>
|
10 |
+
<a class="button button-primary" id="mylink" href="<?php echo admin_url('admin.php?import=woocommerce_csv'); ?>"><?php _e('Import Products', 'wf_csv_import_export'); ?></a>
|
11 |
+
|
12 |
+
<input type="checkbox" id="merge" value="0"><?php _e('Merge products if exists', 'wf_csv_import_export'); ?> <br>
|
13 |
+
</p>
|
14 |
+
</div>
|
15 |
+
<script type="text/javascript">
|
16 |
+
jQuery('#merge').click(function () {
|
17 |
+
if (this.checked) {
|
18 |
+
jQuery("#mylink").attr("href", '<?php echo $merge_url ?>');
|
19 |
+
} else {
|
20 |
+
jQuery("#mylink").attr("href", '<?php echo $import_url ?>');
|
21 |
+
}
|
22 |
+
});
|
23 |
</script>
|
includes/views/market.php
CHANGED
@@ -1,41 +1,41 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
-
exit;
|
4 |
-
}
|
5 |
-
?>
|
6 |
-
<div class="market-box table-box-main">
|
7 |
-
<div class="getting-started-video">
|
8 |
-
<h2><?php _e('Watch getting started video', 'wf_csv_import_export');?></h2>
|
9 |
-
<iframe src="https://www.youtube.com/embed/L-01qI1EZWE?rel=0&showinfo=0" frameborder="0" allowfullscreen="allowfullscreen" align="center"></iframe>
|
10 |
-
</div>
|
11 |
-
<div class="pipe-premium-features">
|
12 |
-
<center><a href="https://www.xadapter.com/product/product-import-export-plugin-for-woocommerce/" target="_blank" class="button button-primary button-go-pro"><?php _e('Upgrade to Premium Version', 'wf_csv_import_export'); ?></a></center>
|
13 |
-
<span>
|
14 |
-
<ul>
|
15 |
-
<li><?php _e('Export simple, group, external and variation products.', 'wf_csv_import_export');?></li>
|
16 |
-
<li><?php _e('Import simple, group, external and variation products.', 'wf_csv_import_export');?></li>
|
17 |
-
<li><?php _e('Export products by category.', 'wf_csv_import_export');?></li>
|
18 |
-
<li><?php _e('Various filter options for exporting products.', 'wf_csv_import_export');?> </li>
|
19 |
-
<li><?php _e('Map and transform fields while importing products.', 'wf_csv_import_export');?></li>
|
20 |
-
<li><?php _e('Change values while importing products using evaluation fields.', 'wf_csv_import_export');?></li>
|
21 |
-
<li><?php _e('Choice to update or skip existing imported products.', 'wf_csv_import_export');?></li>
|
22 |
-
<li><?php _e('WPML supported. French and German support out of the box.', 'wf_csv_import_export');?></li>
|
23 |
-
<li><?php _e('Import/Export file via FTP.', 'wf_csv_import_export');?></li>
|
24 |
-
<li><?php _e('Import from URL.', 'wf_csv_import_export');?></li>
|
25 |
-
<li><?php _e('Automatic scheduled import and export.', 'wf_csv_import_export');?></li>
|
26 |
-
<li><?php _e('Supports product reviews export and import.', 'wf_csv_import_export');?></li>
|
27 |
-
<li><?php _e('30 Days Money Back Guarantee.', 'wf_csv_import_export');?></li>
|
28 |
-
<li><?php _e('More frequent plugin updates.', 'wf_csv_import_export');?></li>
|
29 |
-
<li><?php _e('Excellent Support for setting it up!', 'wf_csv_import_export');?></li>
|
30 |
-
</ul>
|
31 |
-
</span>
|
32 |
-
<center>
|
33 |
-
<a href="http://productimportexport.webtoffee.com/" target="_blank" class="button button-doc-demo"><?php _e('Live Demo', 'wf_csv_import_export'); ?></a>
|
34 |
-
<a href="https://www.xadapter.com/category/product/product-import-export-plugin-for-woocommerce/" target="_blank" class="button button-doc-demo"><?php _e('Documentation', 'wf_csv_import_export'); ?></a></center>
|
35 |
-
</div>
|
36 |
-
<div class="pipe-review-widget">
|
37 |
-
<?php
|
38 |
-
echo sprintf(__('<div class=""><p><i>If you like the plugin please leave us a %1$s review!</i><p></div>', 'wf_csv_import_export'), '<a href="https://wordpress.org/support/plugin/product-import-export-for-woo/reviews?rate=5#new-post" target="_blank" class="xa-pipe-rating-link" data-reviewed="' . esc_attr__('Thanks for the review.', 'wf_csv_import_export') . '">★★★★★</a>');
|
39 |
-
?>
|
40 |
-
</div>
|
41 |
-
</div>
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
+
exit;
|
4 |
+
}
|
5 |
+
?>
|
6 |
+
<div class="market-box table-box-main">
|
7 |
+
<div class="getting-started-video">
|
8 |
+
<h2><?php _e('Watch getting started video', 'wf_csv_import_export');?></h2>
|
9 |
+
<iframe src="https://www.youtube.com/embed/L-01qI1EZWE?rel=0&showinfo=0" frameborder="0" allowfullscreen="allowfullscreen" align="center"></iframe>
|
10 |
+
</div>
|
11 |
+
<div class="pipe-premium-features">
|
12 |
+
<center><a href="https://www.xadapter.com/product/product-import-export-plugin-for-woocommerce/" target="_blank" class="button button-primary button-go-pro"><?php _e('Upgrade to Premium Version', 'wf_csv_import_export'); ?></a></center>
|
13 |
+
<span>
|
14 |
+
<ul>
|
15 |
+
<li><?php _e('Export simple, group, external and variation products.', 'wf_csv_import_export');?></li>
|
16 |
+
<li><?php _e('Import simple, group, external and variation products.', 'wf_csv_import_export');?></li>
|
17 |
+
<li><?php _e('Export products by category.', 'wf_csv_import_export');?></li>
|
18 |
+
<li><?php _e('Various filter options for exporting products.', 'wf_csv_import_export');?> </li>
|
19 |
+
<li><?php _e('Map and transform fields while importing products.', 'wf_csv_import_export');?></li>
|
20 |
+
<li><?php _e('Change values while importing products using evaluation fields.', 'wf_csv_import_export');?></li>
|
21 |
+
<li><?php _e('Choice to update or skip existing imported products.', 'wf_csv_import_export');?></li>
|
22 |
+
<li><?php _e('WPML supported. French and German support out of the box.', 'wf_csv_import_export');?></li>
|
23 |
+
<li><?php _e('Import/Export file via FTP.', 'wf_csv_import_export');?></li>
|
24 |
+
<li><?php _e('Import from URL.', 'wf_csv_import_export');?></li>
|
25 |
+
<li><?php _e('Automatic scheduled import and export.', 'wf_csv_import_export');?></li>
|
26 |
+
<li><?php _e('Supports product reviews export and import.', 'wf_csv_import_export');?></li>
|
27 |
+
<li><?php _e('30 Days Money Back Guarantee.', 'wf_csv_import_export');?></li>
|
28 |
+
<li><?php _e('More frequent plugin updates.', 'wf_csv_import_export');?></li>
|
29 |
+
<li><?php _e('Excellent Support for setting it up!', 'wf_csv_import_export');?></li>
|
30 |
+
</ul>
|
31 |
+
</span>
|
32 |
+
<center>
|
33 |
+
<a href="http://productimportexport.webtoffee.com/" target="_blank" class="button button-doc-demo"><?php _e('Live Demo', 'wf_csv_import_export'); ?></a>
|
34 |
+
<a href="https://www.xadapter.com/category/product/product-import-export-plugin-for-woocommerce/" target="_blank" class="button button-doc-demo"><?php _e('Documentation', 'wf_csv_import_export'); ?></a></center>
|
35 |
+
</div>
|
36 |
+
<div class="pipe-review-widget">
|
37 |
+
<?php
|
38 |
+
echo sprintf(__('<div class=""><p><i>If you like the plugin please leave us a %1$s review!</i><p></div>', 'wf_csv_import_export'), '<a href="https://wordpress.org/support/plugin/product-import-export-for-woo/reviews?rate=5#new-post" target="_blank" class="xa-pipe-rating-link" data-reviewed="' . esc_attr__('Thanks for the review.', 'wf_csv_import_export') . '">★★★★★</a>');
|
39 |
+
?>
|
40 |
+
</div>
|
41 |
+
</div>
|
license.txt
CHANGED
@@ -1,705 +1,705 @@
|
|
1 |
-
Product CSV Import Export For WooCommerce
|
2 |
-
|
3 |
-
Copyright 2018 by the contributors
|
4 |
-
|
5 |
-
This program is free software; you can redistribute it and/or modify
|
6 |
-
it under the terms of the GNU General Public License as published by
|
7 |
-
the Free Software Foundation; either version 3 of the License, or
|
8 |
-
(at your option) any later version.
|
9 |
-
|
10 |
-
This program is distributed in the hope that it will be useful,
|
11 |
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
-
GNU General Public License for more details.
|
14 |
-
|
15 |
-
You should have received a copy of the GNU General Public License
|
16 |
-
along with this program; if not, write to the Free Software
|
17 |
-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
18 |
-
|
19 |
-
This program incorporates work covered by the following copyright and
|
20 |
-
permission notices:
|
21 |
-
|
22 |
-
Product CSV Import Export For WooCommerce
|
23 |
-
Copyright: 2009-2018 XAdapter.
|
24 |
-
License: GNU General Public License v3.0
|
25 |
-
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
26 |
-
|
27 |
-
|
28 |
-
Product CSV Import Export For WooCommerce is released under the GPLv3
|
29 |
-
|
30 |
-
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
31 |
-
|
32 |
-
GNU GENERAL PUBLIC LICENSE
|
33 |
-
Version 3, 29 June 2007
|
34 |
-
|
35 |
-
Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
36 |
-
Everyone is permitted to copy and distribute verbatim copies
|
37 |
-
of this license document, but changing it is not allowed.
|
38 |
-
|
39 |
-
Preamble
|
40 |
-
|
41 |
-
The GNU General Public License is a free, copyleft license for
|
42 |
-
software and other kinds of works.
|
43 |
-
|
44 |
-
The licenses for most software and other practical works are designed
|
45 |
-
to take away your freedom to share and change the works. By contrast,
|
46 |
-
the GNU General Public License is intended to guarantee your freedom to
|
47 |
-
share and change all versions of a program--to make sure it remains free
|
48 |
-
software for all its users. We, the Free Software Foundation, use the
|
49 |
-
GNU General Public License for most of our software; it applies also to
|
50 |
-
any other work released this way by its authors. You can apply it to
|
51 |
-
your programs, too.
|
52 |
-
|
53 |
-
When we speak of free software, we are referring to freedom, not
|
54 |
-
price. Our General Public Licenses are designed to make sure that you
|
55 |
-
have the freedom to distribute copies of free software (and charge for
|
56 |
-
them if you wish), that you receive source code or can get it if you
|
57 |
-
want it, that you can change the software or use pieces of it in new
|
58 |
-
free programs, and that you know you can do these things.
|
59 |
-
|
60 |
-
To protect your rights, we need to prevent others from denying you
|
61 |
-
these rights or asking you to surrender the rights. Therefore, you have
|
62 |
-
certain responsibilities if you distribute copies of the software, or if
|
63 |
-
you modify it: responsibilities to respect the freedom of others.
|
64 |
-
|
65 |
-
For example, if you distribute copies of such a program, whether
|
66 |
-
gratis or for a fee, you must pass on to the recipients the same
|
67 |
-
freedoms that you received. You must make sure that they, too, receive
|
68 |
-
or can get the source code. And you must show them these terms so they
|
69 |
-
know their rights.
|
70 |
-
|
71 |
-
Developers that use the GNU GPL protect your rights with two steps:
|
72 |
-
(1) assert copyright on the software, and (2) offer you this License
|
73 |
-
giving you legal permission to copy, distribute and/or modify it.
|
74 |
-
|
75 |
-
For the developers' and authors' protection, the GPL clearly explains
|
76 |
-
that there is no warranty for this free software. For both users' and
|
77 |
-
authors' sake, the GPL requires that modified versions be marked as
|
78 |
-
changed, so that their problems will not be attributed erroneously to
|
79 |
-
authors of previous versions.
|
80 |
-
|
81 |
-
Some devices are designed to deny users access to install or run
|
82 |
-
modified versions of the software inside them, although the manufacturer
|
83 |
-
can do so. This is fundamentally incompatible with the aim of
|
84 |
-
protecting users' freedom to change the software. The systematic
|
85 |
-
pattern of such abuse occurs in the area of products for individuals to
|
86 |
-
use, which is precisely where it is most unacceptable. Therefore, we
|
87 |
-
have designed this version of the GPL to prohibit the practice for those
|
88 |
-
products. If such problems arise substantially in other domains, we
|
89 |
-
stand ready to extend this provision to those domains in future versions
|
90 |
-
of the GPL, as needed to protect the freedom of users.
|
91 |
-
|
92 |
-
Finally, every program is threatened constantly by software patents.
|
93 |
-
States should not allow patents to restrict development and use of
|
94 |
-
software on general-purpose computers, but in those that do, we wish to
|
95 |
-
avoid the special danger that patents applied to a free program could
|
96 |
-
make it effectively proprietary. To prevent this, the GPL assures that
|
97 |
-
patents cannot be used to render the program non-free.
|
98 |
-
|
99 |
-
The precise terms and conditions for copying, distribution and
|
100 |
-
modification follow.
|
101 |
-
|
102 |
-
TERMS AND CONDITIONS
|
103 |
-
|
104 |
-
0. Definitions.
|
105 |
-
|
106 |
-
"This License" refers to version 3 of the GNU General Public License.
|
107 |
-
|
108 |
-
"Copyright" also means copyright-like laws that apply to other kinds of
|
109 |
-
works, such as semiconductor masks.
|
110 |
-
|
111 |
-
"The Program" refers to any copyrightable work licensed under this
|
112 |
-
License. Each licensee is addressed as "you". "Licensees" and
|
113 |
-
"recipients" may be individuals or organizations.
|
114 |
-
|
115 |
-
To "modify" a work means to copy from or adapt all or part of the work
|
116 |
-
in a fashion requiring copyright permission, other than the making of an
|
117 |
-
exact copy. The resulting work is called a "modified version" of the
|
118 |
-
earlier work or a work "based on" the earlier work.
|
119 |
-
|
120 |
-
A "covered work" means either the unmodified Program or a work based
|
121 |
-
on the Program.
|
122 |
-
|
123 |
-
To "propagate" a work means to do anything with it that, without
|
124 |
-
permission, would make you directly or secondarily liable for
|
125 |
-
infringement under applicable copyright law, except executing it on a
|
126 |
-
computer or modifying a private copy. Propagation includes copying,
|
127 |
-
distribution (with or without modification), making available to the
|
128 |
-
public, and in some countries other activities as well.
|
129 |
-
|
130 |
-
To "convey" a work means any kind of propagation that enables other
|
131 |
-
parties to make or receive copies. Mere interaction with a user through
|
132 |
-
a computer network, with no transfer of a copy, is not conveying.
|
133 |
-
|
134 |
-
An interactive user interface displays "Appropriate Legal Notices"
|
135 |
-
to the extent that it includes a convenient and prominently visible
|
136 |
-
feature that (1) displays an appropriate copyright notice, and (2)
|
137 |
-
tells the user that there is no warranty for the work (except to the
|
138 |
-
extent that warranties are provided), that licensees may convey the
|
139 |
-
work under this License, and how to view a copy of this License. If
|
140 |
-
the interface presents a list of user commands or options, such as a
|
141 |
-
menu, a prominent item in the list meets this criterion.
|
142 |
-
|
143 |
-
1. Source Code.
|
144 |
-
|
145 |
-
The "source code" for a work means the preferred form of the work
|
146 |
-
for making modifications to it. "Object code" means any non-source
|
147 |
-
form of a work.
|
148 |
-
|
149 |
-
A "Standard Interface" means an interface that either is an official
|
150 |
-
standard defined by a recognized standards body, or, in the case of
|
151 |
-
interfaces specified for a particular programming language, one that
|
152 |
-
is widely used among developers working in that language.
|
153 |
-
|
154 |
-
The "System Libraries" of an executable work include anything, other
|
155 |
-
than the work as a whole, that (a) is included in the normal form of
|
156 |
-
packaging a Major Component, but which is not part of that Major
|
157 |
-
Component, and (b) serves only to enable use of the work with that
|
158 |
-
Major Component, or to implement a Standard Interface for which an
|
159 |
-
implementation is available to the public in source code form. A
|
160 |
-
"Major Component", in this context, means a major essential component
|
161 |
-
(kernel, window system, and so on) of the specific operating system
|
162 |
-
(if any) on which the executable work runs, or a compiler used to
|
163 |
-
produce the work, or an object code interpreter used to run it.
|
164 |
-
|
165 |
-
The "Corresponding Source" for a work in object code form means all
|
166 |
-
the source code needed to generate, install, and (for an executable
|
167 |
-
work) run the object code and to modify the work, including scripts to
|
168 |
-
control those activities. However, it does not include the work's
|
169 |
-
System Libraries, or general-purpose tools or generally available free
|
170 |
-
programs which are used unmodified in performing those activities but
|
171 |
-
which are not part of the work. For example, Corresponding Source
|
172 |
-
includes interface definition files associated with source files for
|
173 |
-
the work, and the source code for shared libraries and dynamically
|
174 |
-
linked subprograms that the work is specifically designed to require,
|
175 |
-
such as by intimate data communication or control flow between those
|
176 |
-
subprograms and other parts of the work.
|
177 |
-
|
178 |
-
The Corresponding Source need not include anything that users
|
179 |
-
can regenerate automatically from other parts of the Corresponding
|
180 |
-
Source.
|
181 |
-
|
182 |
-
The Corresponding Source for a work in source code form is that
|
183 |
-
same work.
|
184 |
-
|
185 |
-
2. Basic Permissions.
|
186 |
-
|
187 |
-
All rights granted under this License are granted for the term of
|
188 |
-
copyright on the Program, and are irrevocable provided the stated
|
189 |
-
conditions are met. This License explicitly affirms your unlimited
|
190 |
-
permission to run the unmodified Program. The output from running a
|
191 |
-
covered work is covered by this License only if the output, given its
|
192 |
-
content, constitutes a covered work. This License acknowledges your
|
193 |
-
rights of fair use or other equivalent, as provided by copyright law.
|
194 |
-
|
195 |
-
You may make, run and propagate covered works that you do not
|
196 |
-
convey, without conditions so long as your license otherwise remains
|
197 |
-
in force. You may convey covered works to others for the sole purpose
|
198 |
-
of having them make modifications exclusively for you, or provide you
|
199 |
-
with facilities for running those works, provided that you comply with
|
200 |
-
the terms of this License in conveying all material for which you do
|
201 |
-
not control copyright. Those thus making or running the covered works
|
202 |
-
for you must do so exclusively on your behalf, under your direction
|
203 |
-
and control, on terms that prohibit them from making any copies of
|
204 |
-
your copyrighted material outside their relationship with you.
|
205 |
-
|
206 |
-
Conveying under any other circumstances is permitted solely under
|
207 |
-
the conditions stated below. Sublicensing is not allowed; section 10
|
208 |
-
makes it unnecessary.
|
209 |
-
|
210 |
-
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
211 |
-
|
212 |
-
No covered work shall be deemed part of an effective technological
|
213 |
-
measure under any applicable law fulfilling obligations under article
|
214 |
-
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
215 |
-
similar laws prohibiting or restricting circumvention of such
|
216 |
-
measures.
|
217 |
-
|
218 |
-
When you convey a covered work, you waive any legal power to forbid
|
219 |
-
circumvention of technological measures to the extent such circumvention
|
220 |
-
is effected by exercising rights under this License with respect to
|
221 |
-
the covered work, and you disclaim any intention to limit operation or
|
222 |
-
modification of the work as a means of enforcing, against the work's
|
223 |
-
users, your or third parties' legal rights to forbid circumvention of
|
224 |
-
technological measures.
|
225 |
-
|
226 |
-
4. Conveying Verbatim Copies.
|
227 |
-
|
228 |
-
You may convey verbatim copies of the Program's source code as you
|
229 |
-
receive it, in any medium, provided that you conspicuously and
|
230 |
-
appropriately publish on each copy an appropriate copyright notice;
|
231 |
-
keep intact all notices stating that this License and any
|
232 |
-
non-permissive terms added in accord with section 7 apply to the code;
|
233 |
-
keep intact all notices of the absence of any warranty; and give all
|
234 |
-
recipients a copy of this License along with the Program.
|
235 |
-
|
236 |
-
You may charge any price or no price for each copy that you convey,
|
237 |
-
and you may offer support or warranty protection for a fee.
|
238 |
-
|
239 |
-
5. Conveying Modified Source Versions.
|
240 |
-
|
241 |
-
You may convey a work based on the Program, or the modifications to
|
242 |
-
produce it from the Program, in the form of source code under the
|
243 |
-
terms of section 4, provided that you also meet all of these conditions:
|
244 |
-
|
245 |
-
a) The work must carry prominent notices stating that you modified
|
246 |
-
it, and giving a relevant date.
|
247 |
-
|
248 |
-
b) The work must carry prominent notices stating that it is
|
249 |
-
released under this License and any conditions added under section
|
250 |
-
7. This requirement modifies the requirement in section 4 to
|
251 |
-
"keep intact all notices".
|
252 |
-
|
253 |
-
c) You must license the entire work, as a whole, under this
|
254 |
-
License to anyone who comes into possession of a copy. This
|
255 |
-
License will therefore apply, along with any applicable section 7
|
256 |
-
additional terms, to the whole of the work, and all its parts,
|
257 |
-
regardless of how they are packaged. This License gives no
|
258 |
-
permission to license the work in any other way, but it does not
|
259 |
-
invalidate such permission if you have separately received it.
|
260 |
-
|
261 |
-
d) If the work has interactive user interfaces, each must display
|
262 |
-
Appropriate Legal Notices; however, if the Program has interactive
|
263 |
-
interfaces that do not display Appropriate Legal Notices, your
|
264 |
-
work need not make them do so.
|
265 |
-
|
266 |
-
A compilation of a covered work with other separate and independent
|
267 |
-
works, which are not by their nature extensions of the covered work,
|
268 |
-
and which are not combined with it such as to form a larger program,
|
269 |
-
in or on a volume of a storage or distribution medium, is called an
|
270 |
-
"aggregate" if the compilation and its resulting copyright are not
|
271 |
-
used to limit the access or legal rights of the compilation's users
|
272 |
-
beyond what the individual works permit. Inclusion of a covered work
|
273 |
-
in an aggregate does not cause this License to apply to the other
|
274 |
-
parts of the aggregate.
|
275 |
-
|
276 |
-
6. Conveying Non-Source Forms.
|
277 |
-
|
278 |
-
You may convey a covered work in object code form under the terms
|
279 |
-
of sections 4 and 5, provided that you also convey the
|
280 |
-
machine-readable Corresponding Source under the terms of this License,
|
281 |
-
in one of these ways:
|
282 |
-
|
283 |
-
a) Convey the object code in, or embodied in, a physical product
|
284 |
-
(including a physical distribution medium), accompanied by the
|
285 |
-
Corresponding Source fixed on a durable physical medium
|
286 |
-
customarily used for software interchange.
|
287 |
-
|
288 |
-
b) Convey the object code in, or embodied in, a physical product
|
289 |
-
(including a physical distribution medium), accompanied by a
|
290 |
-
written offer, valid for at least three years and valid for as
|
291 |
-
long as you offer spare parts or customer support for that product
|
292 |
-
model, to give anyone who possesses the object code either (1) a
|
293 |
-
copy of the Corresponding Source for all the software in the
|
294 |
-
product that is covered by this License, on a durable physical
|
295 |
-
medium customarily used for software interchange, for a price no
|
296 |
-
more than your reasonable cost of physically performing this
|
297 |
-
conveying of source, or (2) access to copy the
|
298 |
-
Corresponding Source from a network server at no charge.
|
299 |
-
|
300 |
-
c) Convey individual copies of the object code with a copy of the
|
301 |
-
written offer to provide the Corresponding Source. This
|
302 |
-
alternative is allowed only occasionally and noncommercially, and
|
303 |
-
only if you received the object code with such an offer, in accord
|
304 |
-
with subsection 6b.
|
305 |
-
|
306 |
-
d) Convey the object code by offering access from a designated
|
307 |
-
place (gratis or for a charge), and offer equivalent access to the
|
308 |
-
Corresponding Source in the same way through the same place at no
|
309 |
-
further charge. You need not require recipients to copy the
|
310 |
-
Corresponding Source along with the object code. If the place to
|
311 |
-
copy the object code is a network server, the Corresponding Source
|
312 |
-
may be on a different server (operated by you or a third party)
|
313 |
-
that supports equivalent copying facilities, provided you maintain
|
314 |
-
clear directions next to the object code saying where to find the
|
315 |
-
Corresponding Source. Regardless of what server hosts the
|
316 |
-
Corresponding Source, you remain obligated to ensure that it is
|
317 |
-
available for as long as needed to satisfy these requirements.
|
318 |
-
|
319 |
-
e) Convey the object code using peer-to-peer transmission, provided
|
320 |
-
you inform other peers where the object code and Corresponding
|
321 |
-
Source of the work are being offered to the general public at no
|
322 |
-
charge under subsection 6d.
|
323 |
-
|
324 |
-
A separable portion of the object code, whose source code is excluded
|
325 |
-
from the Corresponding Source as a System Library, need not be
|
326 |
-
included in conveying the object code work.
|
327 |
-
|
328 |
-
A "User Product" is either (1) a "consumer product", which means any
|
329 |
-
tangible personal property which is normally used for personal, family,
|
330 |
-
or household purposes, or (2) anything designed or sold for incorporation
|
331 |
-
into a dwelling. In determining whether a product is a consumer product,
|
332 |
-
doubtful cases shall be resolved in favor of coverage. For a particular
|
333 |
-
product received by a particular user, "normally used" refers to a
|
334 |
-
typical or common use of that class of product, regardless of the status
|
335 |
-
of the particular user or of the way in which the particular user
|
336 |
-
actually uses, or expects or is expected to use, the product. A product
|
337 |
-
is a consumer product regardless of whether the product has substantial
|
338 |
-
commercial, industrial or non-consumer uses, unless such uses represent
|
339 |
-
the only significant mode of use of the product.
|
340 |
-
|
341 |
-
"Installation Information" for a User Product means any methods,
|
342 |
-
procedures, authorization keys, or other information required to install
|
343 |
-
and execute modified versions of a covered work in that User Product from
|
344 |
-
a modified version of its Corresponding Source. The information must
|
345 |
-
suffice to ensure that the continued functioning of the modified object
|
346 |
-
code is in no case prevented or interfered with solely because
|
347 |
-
modification has been made.
|
348 |
-
|
349 |
-
If you convey an object code work under this section in, or with, or
|
350 |
-
specifically for use in, a User Product, and the conveying occurs as
|
351 |
-
part of a transaction in which the right of possession and use of the
|
352 |
-
User Product is transferred to the recipient in perpetuity or for a
|
353 |
-
fixed term (regardless of how the transaction is characterized), the
|
354 |
-
Corresponding Source conveyed under this section must be accompanied
|
355 |
-
by the Installation Information. But this requirement does not apply
|
356 |
-
if neither you nor any third party retains the ability to install
|
357 |
-
modified object code on the User Product (for example, the work has
|
358 |
-
been installed in ROM).
|
359 |
-
|
360 |
-
The requirement to provide Installation Information does not include a
|
361 |
-
requirement to continue to provide support service, warranty, or updates
|
362 |
-
for a work that has been modified or installed by the recipient, or for
|
363 |
-
the User Product in which it has been modified or installed. Access to a
|
364 |
-
network may be denied when the modification itself materially and
|
365 |
-
adversely affects the operation of the network or violates the rules and
|
366 |
-
protocols for communication across the network.
|
367 |
-
|
368 |
-
Corresponding Source conveyed, and Installation Information provided,
|
369 |
-
in accord with this section must be in a format that is publicly
|
370 |
-
documented (and with an implementation available to the public in
|
371 |
-
source code form), and must require no special password or key for
|
372 |
-
unpacking, reading or copying.
|
373 |
-
|
374 |
-
7. Additional Terms.
|
375 |
-
|
376 |
-
"Additional permissions" are terms that supplement the terms of this
|
377 |
-
License by making exceptions from one or more of its conditions.
|
378 |
-
Additional permissions that are applicable to the entire Program shall
|
379 |
-
be treated as though they were included in this License, to the extent
|
380 |
-
that they are valid under applicable law. If additional permissions
|
381 |
-
apply only to part of the Program, that part may be used separately
|
382 |
-
under those permissions, but the entire Program remains governed by
|
383 |
-
this License without regard to the additional permissions.
|
384 |
-
|
385 |
-
When you convey a copy of a covered work, you may at your option
|
386 |
-
remove any additional permissions from that copy, or from any part of
|
387 |
-
it. (Additional permissions may be written to require their own
|
388 |
-
removal in certain cases when you modify the work.) You may place
|
389 |
-
additional permissions on material, added by you to a covered work,
|
390 |
-
for which you have or can give appropriate copyright permission.
|
391 |
-
|
392 |
-
Notwithstanding any other provision of this License, for material you
|
393 |
-
add to a covered work, you may (if authorized by the copyright holders of
|
394 |
-
that material) supplement the terms of this License with terms:
|
395 |
-
|
396 |
-
a) Disclaiming warranty or limiting liability differently from the
|
397 |
-
terms of sections 15 and 16 of this License; or
|
398 |
-
|
399 |
-
b) Requiring preservation of specified reasonable legal notices or
|
400 |
-
author attributions in that material or in the Appropriate Legal
|
401 |
-
Notices displayed by works containing it; or
|
402 |
-
|
403 |
-
c) Prohibiting misrepresentation of the origin of that material, or
|
404 |
-
requiring that modified versions of such material be marked in
|
405 |
-
reasonable ways as different from the original version; or
|
406 |
-
|
407 |
-
d) Limiting the use for publicity purposes of names of licensors or
|
408 |
-
authors of the material; or
|
409 |
-
|
410 |
-
e) Declining to grant rights under trademark law for use of some
|
411 |
-
trade names, trademarks, or service marks; or
|
412 |
-
|
413 |
-
f) Requiring indemnification of licensors and authors of that
|
414 |
-
material by anyone who conveys the material (or modified versions of
|
415 |
-
it) with contractual assumptions of liability to the recipient, for
|
416 |
-
any liability that these contractual assumptions directly impose on
|
417 |
-
those licensors and authors.
|
418 |
-
|
419 |
-
All other non-permissive additional terms are considered "further
|
420 |
-
restrictions" within the meaning of section 10. If the Program as you
|
421 |
-
received it, or any part of it, contains a notice stating that it is
|
422 |
-
governed by this License along with a term that is a further
|
423 |
-
restriction, you may remove that term. If a license document contains
|
424 |
-
a further restriction but permits relicensing or conveying under this
|
425 |
-
License, you may add to a covered work material governed by the terms
|
426 |
-
of that license document, provided that the further restriction does
|
427 |
-
not survive such relicensing or conveying.
|
428 |
-
|
429 |
-
If you add terms to a covered work in accord with this section, you
|
430 |
-
must place, in the relevant source files, a statement of the
|
431 |
-
additional terms that apply to those files, or a notice indicating
|
432 |
-
where to find the applicable terms.
|
433 |
-
|
434 |
-
Additional terms, permissive or non-permissive, may be stated in the
|
435 |
-
form of a separately written license, or stated as exceptions;
|
436 |
-
the above requirements apply either way.
|
437 |
-
|
438 |
-
8. Termination.
|
439 |
-
|
440 |
-
You may not propagate or modify a covered work except as expressly
|
441 |
-
provided under this License. Any attempt otherwise to propagate or
|
442 |
-
modify it is void, and will automatically terminate your rights under
|
443 |
-
this License (including any patent licenses granted under the third
|
444 |
-
paragraph of section 11).
|
445 |
-
|
446 |
-
However, if you cease all violation of this License, then your
|
447 |
-
license from a particular copyright holder is reinstated (a)
|
448 |
-
provisionally, unless and until the copyright holder explicitly and
|
449 |
-
finally terminates your license, and (b) permanently, if the copyright
|
450 |
-
holder fails to notify you of the violation by some reasonable means
|
451 |
-
prior to 60 days after the cessation.
|
452 |
-
|
453 |
-
Moreover, your license from a particular copyright holder is
|
454 |
-
reinstated permanently if the copyright holder notifies you of the
|
455 |
-
violation by some reasonable means, this is the first time you have
|
456 |
-
received notice of violation of this License (for any work) from that
|
457 |
-
copyright holder, and you cure the violation prior to 30 days after
|
458 |
-
your receipt of the notice.
|
459 |
-
|
460 |
-
Termination of your rights under this section does not terminate the
|
461 |
-
licenses of parties who have received copies or rights from you under
|
462 |
-
this License. If your rights have been terminated and not permanently
|
463 |
-
reinstated, you do not qualify to receive new licenses for the same
|
464 |
-
material under section 10.
|
465 |
-
|
466 |
-
9. Acceptance Not Required for Having Copies.
|
467 |
-
|
468 |
-
You are not required to accept this License in order to receive or
|
469 |
-
run a copy of the Program. Ancillary propagation of a covered work
|
470 |
-
occurring solely as a consequence of using peer-to-peer transmission
|
471 |
-
to receive a copy likewise does not require acceptance. However,
|
472 |
-
nothing other than this License grants you permission to propagate or
|
473 |
-
modify any covered work. These actions infringe copyright if you do
|
474 |
-
not accept this License. Therefore, by modifying or propagating a
|
475 |
-
covered work, you indicate your acceptance of this License to do so.
|
476 |
-
|
477 |
-
10. Automatic Licensing of Downstream Recipients.
|
478 |
-
|
479 |
-
Each time you convey a covered work, the recipient automatically
|
480 |
-
receives a license from the original licensors, to run, modify and
|
481 |
-
propagate that work, subject to this License. You are not responsible
|
482 |
-
for enforcing compliance by third parties with this License.
|
483 |
-
|
484 |
-
An "entity transaction" is a transaction transferring control of an
|
485 |
-
organization, or substantially all assets of one, or subdividing an
|
486 |
-
organization, or merging organizations. If propagation of a covered
|
487 |
-
work results from an entity transaction, each party to that
|
488 |
-
transaction who receives a copy of the work also receives whatever
|
489 |
-
licenses to the work the party's predecessor in interest had or could
|
490 |
-
give under the previous paragraph, plus a right to possession of the
|
491 |
-
Corresponding Source of the work from the predecessor in interest, if
|
492 |
-
the predecessor has it or can get it with reasonable efforts.
|
493 |
-
|
494 |
-
You may not impose any further restrictions on the exercise of the
|
495 |
-
rights granted or affirmed under this License. For example, you may
|
496 |
-
not impose a license fee, royalty, or other charge for exercise of
|
497 |
-
rights granted under this License, and you may not initiate litigation
|
498 |
-
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
499 |
-
any patent claim is infringed by making, using, selling, offering for
|
500 |
-
sale, or importing the Program or any portion of it.
|
501 |
-
|
502 |
-
11. Patents.
|
503 |
-
|
504 |
-
A "contributor" is a copyright holder who authorizes use under this
|
505 |
-
License of the Program or a work on which the Program is based. The
|
506 |
-
work thus licensed is called the contributor's "contributor version".
|
507 |
-
|
508 |
-
A contributor's "essential patent claims" are all patent claims
|
509 |
-
owned or controlled by the contributor, whether already acquired or
|
510 |
-
hereafter acquired, that would be infringed by some manner, permitted
|
511 |
-
by this License, of making, using, or selling its contributor version,
|
512 |
-
but do not include claims that would be infringed only as a
|
513 |
-
consequence of further modification of the contributor version. For
|
514 |
-
purposes of this definition, "control" includes the right to grant
|
515 |
-
patent sublicenses in a manner consistent with the requirements of
|
516 |
-
this License.
|
517 |
-
|
518 |
-
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
519 |
-
patent license under the contributor's essential patent claims, to
|
520 |
-
make, use, sell, offer for sale, import and otherwise run, modify and
|
521 |
-
propagate the contents of its contributor version.
|
522 |
-
|
523 |
-
In the following three paragraphs, a "patent license" is any express
|
524 |
-
agreement or commitment, however denominated, not to enforce a patent
|
525 |
-
(such as an express permission to practice a patent or covenant not to
|
526 |
-
sue for patent infringement). To "grant" such a patent license to a
|
527 |
-
party means to make such an agreement or commitment not to enforce a
|
528 |
-
patent against the party.
|
529 |
-
|
530 |
-
If you convey a covered work, knowingly relying on a patent license,
|
531 |
-
and the Corresponding Source of the work is not available for anyone
|
532 |
-
to copy, free of charge and under the terms of this License, through a
|
533 |
-
publicly available network server or other readily accessible means,
|
534 |
-
then you must either (1) cause the Corresponding Source to be so
|
535 |
-
available, or (2) arrange to deprive yourself of the benefit of the
|
536 |
-
patent license for this particular work, or (3) arrange, in a manner
|
537 |
-
consistent with the requirements of this License, to extend the patent
|
538 |
-
license to downstream recipients. "Knowingly relying" means you have
|
539 |
-
actual knowledge that, but for the patent license, your conveying the
|
540 |
-
covered work in a country, or your recipient's use of the covered work
|
541 |
-
in a country, would infringe one or more identifiable patents in that
|
542 |
-
country that you have reason to believe are valid.
|
543 |
-
|
544 |
-
If, pursuant to or in connection with a single transaction or
|
545 |
-
arrangement, you convey, or propagate by procuring conveyance of, a
|
546 |
-
covered work, and grant a patent license to some of the parties
|
547 |
-
receiving the covered work authorizing them to use, propagate, modify
|
548 |
-
or convey a specific copy of the covered work, then the patent license
|
549 |
-
you grant is automatically extended to all recipients of the covered
|
550 |
-
work and works based on it.
|
551 |
-
|
552 |
-
A patent license is "discriminatory" if it does not include within
|
553 |
-
the scope of its coverage, prohibits the exercise of, or is
|
554 |
-
conditioned on the non-exercise of one or more of the rights that are
|
555 |
-
specifically granted under this License. You may not convey a covered
|
556 |
-
work if you are a party to an arrangement with a third party that is
|
557 |
-
in the business of distributing software, under which you make payment
|
558 |
-
to the third party based on the extent of your activity of conveying
|
559 |
-
the work, and under which the third party grants, to any of the
|
560 |
-
parties who would receive the covered work from you, a discriminatory
|
561 |
-
patent license (a) in connection with copies of the covered work
|
562 |
-
conveyed by you (or copies made from those copies), or (b) primarily
|
563 |
-
for and in connection with specific products or compilations that
|
564 |
-
contain the covered work, unless you entered into that arrangement,
|
565 |
-
or that patent license was granted, prior to 28 March 2007.
|
566 |
-
|
567 |
-
Nothing in this License shall be construed as excluding or limiting
|
568 |
-
any implied license or other defenses to infringement that may
|
569 |
-
otherwise be available to you under applicable patent law.
|
570 |
-
|
571 |
-
12. No Surrender of Others' Freedom.
|
572 |
-
|
573 |
-
If conditions are imposed on you (whether by court order, agreement or
|
574 |
-
otherwise) that contradict the conditions of this License, they do not
|
575 |
-
excuse you from the conditions of this License. If you cannot convey a
|
576 |
-
covered work so as to satisfy simultaneously your obligations under this
|
577 |
-
License and any other pertinent obligations, then as a consequence you may
|
578 |
-
not convey it at all. For example, if you agree to terms that obligate you
|
579 |
-
to collect a royalty for further conveying from those to whom you convey
|
580 |
-
the Program, the only way you could satisfy both those terms and this
|
581 |
-
License would be to refrain entirely from conveying the Program.
|
582 |
-
|
583 |
-
13. Use with the GNU Affero General Public License.
|
584 |
-
|
585 |
-
Notwithstanding any other provision of this License, you have
|
586 |
-
permission to link or combine any covered work with a work licensed
|
587 |
-
under version 3 of the GNU Affero General Public License into a single
|
588 |
-
combined work, and to convey the resulting work. The terms of this
|
589 |
-
License will continue to apply to the part which is the covered work,
|
590 |
-
but the special requirements of the GNU Affero General Public License,
|
591 |
-
section 13, concerning interaction through a network will apply to the
|
592 |
-
combination as such.
|
593 |
-
|
594 |
-
14. Revised Versions of this License.
|
595 |
-
|
596 |
-
The Free Software Foundation may publish revised and/or new versions of
|
597 |
-
the GNU General Public License from time to time. Such new versions will
|
598 |
-
be similar in spirit to the present version, but may differ in detail to
|
599 |
-
address new problems or concerns.
|
600 |
-
|
601 |
-
Each version is given a distinguishing version number. If the
|
602 |
-
Program specifies that a certain numbered version of the GNU General
|
603 |
-
Public License "or any later version" applies to it, you have the
|
604 |
-
option of following the terms and conditions either of that numbered
|
605 |
-
version or of any later version published by the Free Software
|
606 |
-
Foundation. If the Program does not specify a version number of the
|
607 |
-
GNU General Public License, you may choose any version ever published
|
608 |
-
by the Free Software Foundation.
|
609 |
-
|
610 |
-
If the Program specifies that a proxy can decide which future
|
611 |
-
versions of the GNU General Public License can be used, that proxy's
|
612 |
-
public statement of acceptance of a version permanently authorizes you
|
613 |
-
to choose that version for the Program.
|
614 |
-
|
615 |
-
Later license versions may give you additional or different
|
616 |
-
permissions. However, no additional obligations are imposed on any
|
617 |
-
author or copyright holder as a result of your choosing to follow a
|
618 |
-
later version.
|
619 |
-
|
620 |
-
15. Disclaimer of Warranty.
|
621 |
-
|
622 |
-
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
623 |
-
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
624 |
-
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
625 |
-
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
626 |
-
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
627 |
-
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
628 |
-
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
629 |
-
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
630 |
-
|
631 |
-
16. Limitation of Liability.
|
632 |
-
|
633 |
-
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
634 |
-
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
635 |
-
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
636 |
-
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
637 |
-
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
638 |
-
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
639 |
-
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
640 |
-
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
641 |
-
SUCH DAMAGES.
|
642 |
-
|
643 |
-
17. Interpretation of Sections 15 and 16.
|
644 |
-
|
645 |
-
If the disclaimer of warranty and limitation of liability provided
|
646 |
-
above cannot be given local legal effect according to their terms,
|
647 |
-
reviewing courts shall apply local law that most closely approximates
|
648 |
-
an absolute waiver of all civil liability in connection with the
|
649 |
-
Program, unless a warranty or assumption of liability accompanies a
|
650 |
-
copy of the Program in return for a fee.
|
651 |
-
|
652 |
-
END OF TERMS AND CONDITIONS
|
653 |
-
|
654 |
-
How to Apply These Terms to Your New Programs
|
655 |
-
|
656 |
-
If you develop a new program, and you want it to be of the greatest
|
657 |
-
possible use to the public, the best way to achieve this is to make it
|
658 |
-
free software which everyone can redistribute and change under these terms.
|
659 |
-
|
660 |
-
To do so, attach the following notices to the program. It is safest
|
661 |
-
to attach them to the start of each source file to most effectively
|
662 |
-
state the exclusion of warranty; and each file should have at least
|
663 |
-
the "copyright" line and a pointer to where the full notice is found.
|
664 |
-
|
665 |
-
<one line to give the program's name and a brief idea of what it does.>
|
666 |
-
Copyright © <year> <name of author>
|
667 |
-
|
668 |
-
This program is free software: you can redistribute it and/or modify
|
669 |
-
it under the terms of the GNU General Public License as published by
|
670 |
-
the Free Software Foundation, either version 3 of the License, or
|
671 |
-
(at your option) any later version.
|
672 |
-
|
673 |
-
This program is distributed in the hope that it will be useful,
|
674 |
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
675 |
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
676 |
-
GNU General Public License for more details.
|
677 |
-
|
678 |
-
You should have received a copy of the GNU General Public License
|
679 |
-
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
680 |
-
|
681 |
-
Also add information on how to contact you by electronic and paper mail.
|
682 |
-
|
683 |
-
If the program does terminal interaction, make it output a short
|
684 |
-
notice like this when it starts in an interactive mode:
|
685 |
-
|
686 |
-
<program> Copyright © <year> <name of author>
|
687 |
-
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
688 |
-
This is free software, and you are welcome to redistribute it
|
689 |
-
under certain conditions; type `show c' for details.
|
690 |
-
|
691 |
-
The hypothetical commands `show w' and `show c' should show the appropriate
|
692 |
-
parts of the General Public License. Of course, your program's commands
|
693 |
-
might be different; for a GUI interface, you would use an "about box".
|
694 |
-
|
695 |
-
You should also get your employer (if you work as a programmer) or school,
|
696 |
-
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
697 |
-
For more information on this, and how to apply and follow the GNU GPL, see
|
698 |
-
<http://www.gnu.org/licenses/>.
|
699 |
-
|
700 |
-
The GNU General Public License does not permit incorporating your program
|
701 |
-
into proprietary programs. If your program is a subroutine library, you
|
702 |
-
may consider it more useful to permit linking proprietary applications with
|
703 |
-
the library. If this is what you want to do, use the GNU Lesser General
|
704 |
-
Public License instead of this License. But first, please read
|
705 |
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
1 |
+
Product CSV Import Export For WooCommerce
|
2 |
+
|
3 |
+
Copyright 2018 by the contributors
|
4 |
+
|
5 |
+
This program is free software; you can redistribute it and/or modify
|
6 |
+
it under the terms of the GNU General Public License as published by
|
7 |
+
the Free Software Foundation; either version 3 of the License, or
|
8 |
+
(at your option) any later version.
|
9 |
+
|
10 |
+
This program is distributed in the hope that it will be useful,
|
11 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
+
GNU General Public License for more details.
|
14 |
+
|
15 |
+
You should have received a copy of the GNU General Public License
|
16 |
+
along with this program; if not, write to the Free Software
|
17 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
18 |
+
|
19 |
+
This program incorporates work covered by the following copyright and
|
20 |
+
permission notices:
|
21 |
+
|
22 |
+
Product CSV Import Export For WooCommerce
|
23 |
+
Copyright: 2009-2018 XAdapter.
|
24 |
+
License: GNU General Public License v3.0
|
25 |
+
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
26 |
+
|
27 |
+
|
28 |
+
Product CSV Import Export For WooCommerce is released under the GPLv3
|
29 |
+
|
30 |
+
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
31 |
+
|
32 |
+
GNU GENERAL PUBLIC LICENSE
|
33 |
+
Version 3, 29 June 2007
|
34 |
+
|
35 |
+
Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
36 |
+
Everyone is permitted to copy and distribute verbatim copies
|
37 |
+
of this license document, but changing it is not allowed.
|
38 |
+
|
39 |
+
Preamble
|
40 |
+
|
41 |
+
The GNU General Public License is a free, copyleft license for
|
42 |
+
software and other kinds of works.
|
43 |
+
|
44 |
+
The licenses for most software and other practical works are designed
|
45 |
+
to take away your freedom to share and change the works. By contrast,
|
46 |
+
the GNU General Public License is intended to guarantee your freedom to
|
47 |
+
share and change all versions of a program--to make sure it remains free
|
48 |
+
software for all its users. We, the Free Software Foundation, use the
|
49 |
+
GNU General Public License for most of our software; it applies also to
|
50 |
+
any other work released this way by its authors. You can apply it to
|
51 |
+
your programs, too.
|
52 |
+
|
53 |
+
When we speak of free software, we are referring to freedom, not
|
54 |
+
price. Our General Public Licenses are designed to make sure that you
|
55 |
+
have the freedom to distribute copies of free software (and charge for
|
56 |
+
them if you wish), that you receive source code or can get it if you
|
57 |
+
want it, that you can change the software or use pieces of it in new
|
58 |
+
free programs, and that you know you can do these things.
|
59 |
+
|
60 |
+
To protect your rights, we need to prevent others from denying you
|
61 |
+
these rights or asking you to surrender the rights. Therefore, you have
|
62 |
+
certain responsibilities if you distribute copies of the software, or if
|
63 |
+
you modify it: responsibilities to respect the freedom of others.
|
64 |
+
|
65 |
+
For example, if you distribute copies of such a program, whether
|
66 |
+
gratis or for a fee, you must pass on to the recipients the same
|
67 |
+
freedoms that you received. You must make sure that they, too, receive
|
68 |
+
or can get the source code. And you must show them these terms so they
|
69 |
+
know their rights.
|
70 |
+
|
71 |
+
Developers that use the GNU GPL protect your rights with two steps:
|
72 |
+
(1) assert copyright on the software, and (2) offer you this License
|
73 |
+
giving you legal permission to copy, distribute and/or modify it.
|
74 |
+
|
75 |
+
For the developers' and authors' protection, the GPL clearly explains
|
76 |
+
that there is no warranty for this free software. For both users' and
|
77 |
+
authors' sake, the GPL requires that modified versions be marked as
|
78 |
+
changed, so that their problems will not be attributed erroneously to
|
79 |
+
authors of previous versions.
|
80 |
+
|
81 |
+
Some devices are designed to deny users access to install or run
|
82 |
+
modified versions of the software inside them, although the manufacturer
|
83 |
+
can do so. This is fundamentally incompatible with the aim of
|
84 |
+
protecting users' freedom to change the software. The systematic
|
85 |
+
pattern of such abuse occurs in the area of products for individuals to
|
86 |
+
use, which is precisely where it is most unacceptable. Therefore, we
|
87 |
+
have designed this version of the GPL to prohibit the practice for those
|
88 |
+
products. If such problems arise substantially in other domains, we
|
89 |
+
stand ready to extend this provision to those domains in future versions
|
90 |
+
of the GPL, as needed to protect the freedom of users.
|
91 |
+
|
92 |
+
Finally, every program is threatened constantly by software patents.
|
93 |
+
States should not allow patents to restrict development and use of
|
94 |
+
software on general-purpose computers, but in those that do, we wish to
|
95 |
+
avoid the special danger that patents applied to a free program could
|
96 |
+
make it effectively proprietary. To prevent this, the GPL assures that
|
97 |
+
patents cannot be used to render the program non-free.
|
98 |
+
|
99 |
+
The precise terms and conditions for copying, distribution and
|
100 |
+
modification follow.
|
101 |
+
|
102 |
+
TERMS AND CONDITIONS
|
103 |
+
|
104 |
+
0. Definitions.
|
105 |
+
|
106 |
+
"This License" refers to version 3 of the GNU General Public License.
|
107 |
+
|
108 |
+
"Copyright" also means copyright-like laws that apply to other kinds of
|
109 |
+
works, such as semiconductor masks.
|
110 |
+
|
111 |
+
"The Program" refers to any copyrightable work licensed under this
|
112 |
+
License. Each licensee is addressed as "you". "Licensees" and
|
113 |
+
"recipients" may be individuals or organizations.
|
114 |
+
|
115 |
+
To "modify" a work means to copy from or adapt all or part of the work
|
116 |
+
in a fashion requiring copyright permission, other than the making of an
|
117 |
+
exact copy. The resulting work is called a "modified version" of the
|
118 |
+
earlier work or a work "based on" the earlier work.
|
119 |
+
|
120 |
+
A "covered work" means either the unmodified Program or a work based
|
121 |
+
on the Program.
|
122 |
+
|
123 |
+
To "propagate" a work means to do anything with it that, without
|
124 |
+
permission, would make you directly or secondarily liable for
|
125 |
+
infringement under applicable copyright law, except executing it on a
|
126 |
+
computer or modifying a private copy. Propagation includes copying,
|
127 |
+
distribution (with or without modification), making available to the
|
128 |
+
public, and in some countries other activities as well.
|
129 |
+
|
130 |
+
To "convey" a work means any kind of propagation that enables other
|
131 |
+
parties to make or receive copies. Mere interaction with a user through
|
132 |
+
a computer network, with no transfer of a copy, is not conveying.
|
133 |
+
|
134 |
+
An interactive user interface displays "Appropriate Legal Notices"
|
135 |
+
to the extent that it includes a convenient and prominently visible
|
136 |
+
feature that (1) displays an appropriate copyright notice, and (2)
|
137 |
+
tells the user that there is no warranty for the work (except to the
|
138 |
+
extent that warranties are provided), that licensees may convey the
|
139 |
+
work under this License, and how to view a copy of this License. If
|
140 |
+
the interface presents a list of user commands or options, such as a
|
141 |
+
menu, a prominent item in the list meets this criterion.
|
142 |
+
|
143 |
+
1. Source Code.
|
144 |
+
|
145 |
+
The "source code" for a work means the preferred form of the work
|
146 |
+
for making modifications to it. "Object code" means any non-source
|
147 |
+
form of a work.
|
148 |
+
|
149 |
+
A "Standard Interface" means an interface that either is an official
|
150 |
+
standard defined by a recognized standards body, or, in the case of
|
151 |
+
interfaces specified for a particular programming language, one that
|
152 |
+
is widely used among developers working in that language.
|
153 |
+
|
154 |
+
The "System Libraries" of an executable work include anything, other
|
155 |
+
than the work as a whole, that (a) is included in the normal form of
|
156 |
+
packaging a Major Component, but which is not part of that Major
|
157 |
+
Component, and (b) serves only to enable use of the work with that
|
158 |
+
Major Component, or to implement a Standard Interface for which an
|
159 |
+
implementation is available to the public in source code form. A
|
160 |
+
"Major Component", in this context, means a major essential component
|
161 |
+
(kernel, window system, and so on) of the specific operating system
|
162 |
+
(if any) on which the executable work runs, or a compiler used to
|
163 |
+
produce the work, or an object code interpreter used to run it.
|
164 |
+
|
165 |
+
The "Corresponding Source" for a work in object code form means all
|
166 |
+
the source code needed to generate, install, and (for an executable
|
167 |
+
work) run the object code and to modify the work, including scripts to
|
168 |
+
control those activities. However, it does not include the work's
|
169 |
+
System Libraries, or general-purpose tools or generally available free
|
170 |
+
programs which are used unmodified in performing those activities but
|
171 |
+
which are not part of the work. For example, Corresponding Source
|
172 |
+
includes interface definition files associated with source files for
|
173 |
+
the work, and the source code for shared libraries and dynamically
|
174 |
+
linked subprograms that the work is specifically designed to require,
|
175 |
+
such as by intimate data communication or control flow between those
|
176 |
+
subprograms and other parts of the work.
|
177 |
+
|
178 |
+
The Corresponding Source need not include anything that users
|
179 |
+
can regenerate automatically from other parts of the Corresponding
|
180 |
+
Source.
|
181 |
+
|
182 |
+
The Corresponding Source for a work in source code form is that
|
183 |
+
same work.
|
184 |
+
|
185 |
+
2. Basic Permissions.
|
186 |
+
|
187 |
+
All rights granted under this License are granted for the term of
|
188 |
+
copyright on the Program, and are irrevocable provided the stated
|
189 |
+
conditions are met. This License explicitly affirms your unlimited
|
190 |
+
permission to run the unmodified Program. The output from running a
|
191 |
+
covered work is covered by this License only if the output, given its
|
192 |
+
content, constitutes a covered work. This License acknowledges your
|
193 |
+
rights of fair use or other equivalent, as provided by copyright law.
|
194 |
+
|
195 |
+
You may make, run and propagate covered works that you do not
|
196 |
+
convey, without conditions so long as your license otherwise remains
|
197 |
+
in force. You may convey covered works to others for the sole purpose
|
198 |
+
of having them make modifications exclusively for you, or provide you
|
199 |
+
with facilities for running those works, provided that you comply with
|
200 |
+
the terms of this License in conveying all material for which you do
|
201 |
+
not control copyright. Those thus making or running the covered works
|
202 |
+
for you must do so exclusively on your behalf, under your direction
|
203 |
+
and control, on terms that prohibit them from making any copies of
|
204 |
+
your copyrighted material outside their relationship with you.
|
205 |
+
|
206 |
+
Conveying under any other circumstances is permitted solely under
|
207 |
+
the conditions stated below. Sublicensing is not allowed; section 10
|
208 |
+
makes it unnecessary.
|
209 |
+
|
210 |
+
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
211 |
+
|
212 |
+
No covered work shall be deemed part of an effective technological
|
213 |
+
measure under any applicable law fulfilling obligations under article
|
214 |
+
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
215 |
+
similar laws prohibiting or restricting circumvention of such
|
216 |
+
measures.
|
217 |
+
|
218 |
+
When you convey a covered work, you waive any legal power to forbid
|
219 |
+
circumvention of technological measures to the extent such circumvention
|
220 |
+
is effected by exercising rights under this License with respect to
|
221 |
+
the covered work, and you disclaim any intention to limit operation or
|
222 |
+
modification of the work as a means of enforcing, against the work's
|
223 |
+
users, your or third parties' legal rights to forbid circumvention of
|
224 |
+
technological measures.
|
225 |
+
|
226 |
+
4. Conveying Verbatim Copies.
|
227 |
+
|
228 |
+
You may convey verbatim copies of the Program's source code as you
|
229 |
+
receive it, in any medium, provided that you conspicuously and
|
230 |
+
appropriately publish on each copy an appropriate copyright notice;
|
231 |
+
keep intact all notices stating that this License and any
|
232 |
+
non-permissive terms added in accord with section 7 apply to the code;
|
233 |
+
keep intact all notices of the absence of any warranty; and give all
|
234 |
+
recipients a copy of this License along with the Program.
|
235 |
+
|
236 |
+
You may charge any price or no price for each copy that you convey,
|
237 |
+
and you may offer support or warranty protection for a fee.
|
238 |
+
|
239 |
+
5. Conveying Modified Source Versions.
|
240 |
+
|
241 |
+
You may convey a work based on the Program, or the modifications to
|
242 |
+
produce it from the Program, in the form of source code under the
|
243 |
+
terms of section 4, provided that you also meet all of these conditions:
|
244 |
+
|
245 |
+
a) The work must carry prominent notices stating that you modified
|
246 |
+
it, and giving a relevant date.
|
247 |
+
|
248 |
+
b) The work must carry prominent notices stating that it is
|
249 |
+
released under this License and any conditions added under section
|
250 |
+
7. This requirement modifies the requirement in section 4 to
|
251 |
+
"keep intact all notices".
|
252 |
+
|
253 |
+
c) You must license the entire work, as a whole, under this
|
254 |
+
License to anyone who comes into possession of a copy. This
|
255 |
+
License will therefore apply, along with any applicable section 7
|
256 |
+
additional terms, to the whole of the work, and all its parts,
|
257 |
+
regardless of how they are packaged. This License gives no
|
258 |
+
permission to license the work in any other way, but it does not
|
259 |
+
invalidate such permission if you have separately received it.
|
260 |
+
|
261 |
+
d) If the work has interactive user interfaces, each must display
|
262 |
+
Appropriate Legal Notices; however, if the Program has interactive
|
263 |
+
interfaces that do not display Appropriate Legal Notices, your
|
264 |
+
work need not make them do so.
|
265 |
+
|
266 |
+
A compilation of a covered work with other separate and independent
|
267 |
+
works, which are not by their nature extensions of the covered work,
|
268 |
+
and which are not combined with it such as to form a larger program,
|
269 |
+
in or on a volume of a storage or distribution medium, is called an
|
270 |
+
"aggregate" if the compilation and its resulting copyright are not
|
271 |
+
used to limit the access or legal rights of the compilation's users
|
272 |
+
beyond what the individual works permit. Inclusion of a covered work
|
273 |
+
in an aggregate does not cause this License to apply to the other
|
274 |
+
parts of the aggregate.
|
275 |
+
|
276 |
+
6. Conveying Non-Source Forms.
|
277 |
+
|
278 |
+
You may convey a covered work in object code form under the terms
|
279 |
+
of sections 4 and 5, provided that you also convey the
|
280 |
+
machine-readable Corresponding Source under the terms of this License,
|
281 |
+
in one of these ways:
|
282 |
+
|
283 |
+
a) Convey the object code in, or embodied in, a physical product
|
284 |
+
(including a physical distribution medium), accompanied by the
|
285 |
+
Corresponding Source fixed on a durable physical medium
|
286 |
+
customarily used for software interchange.
|
287 |
+
|
288 |
+
b) Convey the object code in, or embodied in, a physical product
|
289 |
+
(including a physical distribution medium), accompanied by a
|
290 |
+
written offer, valid for at least three years and valid for as
|
291 |
+
long as you offer spare parts or customer support for that product
|
292 |
+
model, to give anyone who possesses the object code either (1) a
|
293 |
+
copy of the Corresponding Source for all the software in the
|
294 |
+
product that is covered by this License, on a durable physical
|
295 |
+
medium customarily used for software interchange, for a price no
|
296 |
+
more than your reasonable cost of physically performing this
|
297 |
+
conveying of source, or (2) access to copy the
|
298 |
+
Corresponding Source from a network server at no charge.
|
299 |
+
|
300 |
+
c) Convey individual copies of the object code with a copy of the
|
301 |
+
written offer to provide the Corresponding Source. This
|
302 |
+
alternative is allowed only occasionally and noncommercially, and
|
303 |
+
only if you received the object code with such an offer, in accord
|
304 |
+
with subsection 6b.
|
305 |
+
|
306 |
+
d) Convey the object code by offering access from a designated
|
307 |
+
place (gratis or for a charge), and offer equivalent access to the
|
308 |
+
Corresponding Source in the same way through the same place at no
|
309 |
+
further charge. You need not require recipients to copy the
|
310 |
+
Corresponding Source along with the object code. If the place to
|
311 |
+
copy the object code is a network server, the Corresponding Source
|
312 |
+
may be on a different server (operated by you or a third party)
|
313 |
+
that supports equivalent copying facilities, provided you maintain
|
314 |
+
clear directions next to the object code saying where to find the
|
315 |
+
Corresponding Source. Regardless of what server hosts the
|
316 |
+
Corresponding Source, you remain obligated to ensure that it is
|
317 |
+
available for as long as needed to satisfy these requirements.
|
318 |
+
|
319 |
+
e) Convey the object code using peer-to-peer transmission, provided
|
320 |
+
you inform other peers where the object code and Corresponding
|
321 |
+
Source of the work are being offered to the general public at no
|
322 |
+
charge under subsection 6d.
|
323 |
+
|
324 |
+
A separable portion of the object code, whose source code is excluded
|
325 |
+
from the Corresponding Source as a System Library, need not be
|
326 |
+
included in conveying the object code work.
|
327 |
+
|
328 |
+
A "User Product" is either (1) a "consumer product", which means any
|
329 |
+
tangible personal property which is normally used for personal, family,
|
330 |
+
or household purposes, or (2) anything designed or sold for incorporation
|
331 |
+
into a dwelling. In determining whether a product is a consumer product,
|
332 |
+
doubtful cases shall be resolved in favor of coverage. For a particular
|
333 |
+
product received by a particular user, "normally used" refers to a
|
334 |
+
typical or common use of that class of product, regardless of the status
|
335 |
+
of the particular user or of the way in which the particular user
|
336 |
+
actually uses, or expects or is expected to use, the product. A product
|
337 |
+
is a consumer product regardless of whether the product has substantial
|
338 |
+
commercial, industrial or non-consumer uses, unless such uses represent
|
339 |
+
the only significant mode of use of the product.
|
340 |
+
|
341 |
+
"Installation Information" for a User Product means any methods,
|
342 |
+
procedures, authorization keys, or other information required to install
|
343 |
+
and execute modified versions of a covered work in that User Product from
|
344 |
+
a modified version of its Corresponding Source. The information must
|
345 |
+
suffice to ensure that the continued functioning of the modified object
|
346 |
+
code is in no case prevented or interfered with solely because
|
347 |
+
modification has been made.
|
348 |
+
|
349 |
+
If you convey an object code work under this section in, or with, or
|
350 |
+
specifically for use in, a User Product, and the conveying occurs as
|
351 |
+
part of a transaction in which the right of possession and use of the
|
352 |
+
User Product is transferred to the recipient in perpetuity or for a
|
353 |
+
fixed term (regardless of how the transaction is characterized), the
|
354 |
+
Corresponding Source conveyed under this section must be accompanied
|
355 |
+
by the Installation Information. But this requirement does not apply
|
356 |
+
if neither you nor any third party retains the ability to install
|
357 |
+
modified object code on the User Product (for example, the work has
|
358 |
+
been installed in ROM).
|
359 |
+
|
360 |
+
The requirement to provide Installation Information does not include a
|
361 |
+
requirement to continue to provide support service, warranty, or updates
|
362 |
+
for a work that has been modified or installed by the recipient, or for
|
363 |
+
the User Product in which it has been modified or installed. Access to a
|
364 |
+
network may be denied when the modification itself materially and
|
365 |
+
adversely affects the operation of the network or violates the rules and
|
366 |
+
protocols for communication across the network.
|
367 |
+
|
368 |
+
Corresponding Source conveyed, and Installation Information provided,
|
369 |
+
in accord with this section must be in a format that is publicly
|
370 |
+
documented (and with an implementation available to the public in
|
371 |
+
source code form), and must require no special password or key for
|
372 |
+
unpacking, reading or copying.
|
373 |
+
|
374 |
+
7. Additional Terms.
|
375 |
+
|
376 |
+
"Additional permissions" are terms that supplement the terms of this
|
377 |
+
License by making exceptions from one or more of its conditions.
|
378 |
+
Additional permissions that are applicable to the entire Program shall
|
379 |
+
be treated as though they were included in this License, to the extent
|
380 |
+
that they are valid under applicable law. If additional permissions
|
381 |
+
apply only to part of the Program, that part may be used separately
|
382 |
+
under those permissions, but the entire Program remains governed by
|
383 |
+
this License without regard to the additional permissions.
|
384 |
+
|
385 |
+
When you convey a copy of a covered work, you may at your option
|
386 |
+
remove any additional permissions from that copy, or from any part of
|
387 |
+
it. (Additional permissions may be written to require their own
|
388 |
+
removal in certain cases when you modify the work.) You may place
|
389 |
+
additional permissions on material, added by you to a covered work,
|
390 |
+
for which you have or can give appropriate copyright permission.
|
391 |
+
|
392 |
+
Notwithstanding any other provision of this License, for material you
|
393 |
+
add to a covered work, you may (if authorized by the copyright holders of
|
394 |
+
that material) supplement the terms of this License with terms:
|
395 |
+
|
396 |
+
a) Disclaiming warranty or limiting liability differently from the
|
397 |
+
terms of sections 15 and 16 of this License; or
|
398 |
+
|
399 |
+
b) Requiring preservation of specified reasonable legal notices or
|
400 |
+
author attributions in that material or in the Appropriate Legal
|
401 |
+
Notices displayed by works containing it; or
|
402 |
+
|
403 |
+
c) Prohibiting misrepresentation of the origin of that material, or
|
404 |
+
requiring that modified versions of such material be marked in
|
405 |
+
reasonable ways as different from the original version; or
|
406 |
+
|
407 |
+
d) Limiting the use for publicity purposes of names of licensors or
|
408 |
+
authors of the material; or
|
409 |
+
|
410 |
+
e) Declining to grant rights under trademark law for use of some
|
411 |
+
trade names, trademarks, or service marks; or
|
412 |
+
|
413 |
+
f) Requiring indemnification of licensors and authors of that
|
414 |
+
material by anyone who conveys the material (or modified versions of
|
415 |
+
it) with contractual assumptions of liability to the recipient, for
|
416 |
+
any liability that these contractual assumptions directly impose on
|
417 |
+
those licensors and authors.
|
418 |
+
|
419 |
+
All other non-permissive additional terms are considered "further
|
420 |
+
restrictions" within the meaning of section 10. If the Program as you
|
421 |
+
received it, or any part of it, contains a notice stating that it is
|
422 |
+
governed by this License along with a term that is a further
|
423 |
+
restriction, you may remove that term. If a license document contains
|
424 |
+
a further restriction but permits relicensing or conveying under this
|
425 |
+
License, you may add to a covered work material governed by the terms
|
426 |
+
of that license document, provided that the further restriction does
|
427 |
+
not survive such relicensing or conveying.
|
428 |
+
|
429 |
+
If you add terms to a covered work in accord with this section, you
|
430 |
+
must place, in the relevant source files, a statement of the
|
431 |
+
additional terms that apply to those files, or a notice indicating
|
432 |
+
where to find the applicable terms.
|
433 |
+
|
434 |
+
Additional terms, permissive or non-permissive, may be stated in the
|
435 |
+
form of a separately written license, or stated as exceptions;
|
436 |
+
the above requirements apply either way.
|
437 |
+
|
438 |
+
8. Termination.
|
439 |
+
|
440 |
+
You may not propagate or modify a covered work except as expressly
|
441 |
+
provided under this License. Any attempt otherwise to propagate or
|
442 |
+
modify it is void, and will automatically terminate your rights under
|
443 |
+
this License (including any patent licenses granted under the third
|
444 |
+
paragraph of section 11).
|
445 |
+
|
446 |
+
However, if you cease all violation of this License, then your
|
447 |
+
license from a particular copyright holder is reinstated (a)
|
448 |
+
provisionally, unless and until the copyright holder explicitly and
|
449 |
+
finally terminates your license, and (b) permanently, if the copyright
|
450 |
+
holder fails to notify you of the violation by some reasonable means
|
451 |
+
prior to 60 days after the cessation.
|
452 |
+
|
453 |
+
Moreover, your license from a particular copyright holder is
|
454 |
+
reinstated permanently if the copyright holder notifies you of the
|
455 |
+
violation by some reasonable means, this is the first time you have
|
456 |
+
received notice of violation of this License (for any work) from that
|
457 |
+
copyright holder, and you cure the violation prior to 30 days after
|
458 |
+
your receipt of the notice.
|
459 |
+
|
460 |
+
Termination of your rights under this section does not terminate the
|
461 |
+
licenses of parties who have received copies or rights from you under
|
462 |
+
this License. If your rights have been terminated and not permanently
|
463 |
+
reinstated, you do not qualify to receive new licenses for the same
|
464 |
+
material under section 10.
|
465 |
+
|
466 |
+
9. Acceptance Not Required for Having Copies.
|
467 |
+
|
468 |
+
You are not required to accept this License in order to receive or
|
469 |
+
run a copy of the Program. Ancillary propagation of a covered work
|
470 |
+
occurring solely as a consequence of using peer-to-peer transmission
|
471 |
+
to receive a copy likewise does not require acceptance. However,
|
472 |
+
nothing other than this License grants you permission to propagate or
|
473 |
+
modify any covered work. These actions infringe copyright if you do
|
474 |
+
not accept this License. Therefore, by modifying or propagating a
|
475 |
+
covered work, you indicate your acceptance of this License to do so.
|
476 |
+
|
477 |
+
10. Automatic Licensing of Downstream Recipients.
|
478 |
+
|
479 |
+
Each time you convey a covered work, the recipient automatically
|
480 |
+
receives a license from the original licensors, to run, modify and
|
481 |
+
propagate that work, subject to this License. You are not responsible
|
482 |
+
for enforcing compliance by third parties with this License.
|
483 |
+
|
484 |
+
An "entity transaction" is a transaction transferring control of an
|
485 |
+
organization, or substantially all assets of one, or subdividing an
|
486 |
+
organization, or merging organizations. If propagation of a covered
|
487 |
+
work results from an entity transaction, each party to that
|
488 |
+
transaction who receives a copy of the work also receives whatever
|
489 |
+
licenses to the work the party's predecessor in interest had or could
|
490 |
+
give under the previous paragraph, plus a right to possession of the
|
491 |
+
Corresponding Source of the work from the predecessor in interest, if
|
492 |
+
the predecessor has it or can get it with reasonable efforts.
|
493 |
+
|
494 |
+
You may not impose any further restrictions on the exercise of the
|
495 |
+
rights granted or affirmed under this License. For example, you may
|
496 |
+
not impose a license fee, royalty, or other charge for exercise of
|
497 |
+
rights granted under this License, and you may not initiate litigation
|
498 |
+
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
499 |
+
any patent claim is infringed by making, using, selling, offering for
|
500 |
+
sale, or importing the Program or any portion of it.
|
501 |
+
|
502 |
+
11. Patents.
|
503 |
+
|
504 |
+
A "contributor" is a copyright holder who authorizes use under this
|
505 |
+
License of the Program or a work on which the Program is based. The
|
506 |
+
work thus licensed is called the contributor's "contributor version".
|
507 |
+
|
508 |
+
A contributor's "essential patent claims" are all patent claims
|
509 |
+
owned or controlled by the contributor, whether already acquired or
|
510 |
+
hereafter acquired, that would be infringed by some manner, permitted
|
511 |
+
by this License, of making, using, or selling its contributor version,
|
512 |
+
but do not include claims that would be infringed only as a
|
513 |
+
consequence of further modification of the contributor version. For
|
514 |
+
purposes of this definition, "control" includes the right to grant
|
515 |
+
patent sublicenses in a manner consistent with the requirements of
|
516 |
+
this License.
|
517 |
+
|
518 |
+
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
519 |
+
patent license under the contributor's essential patent claims, to
|
520 |
+
make, use, sell, offer for sale, import and otherwise run, modify and
|
521 |
+
propagate the contents of its contributor version.
|
522 |
+
|
523 |
+
In the following three paragraphs, a "patent license" is any express
|
524 |
+
agreement or commitment, however denominated, not to enforce a patent
|
525 |
+
(such as an express permission to practice a patent or covenant not to
|
526 |
+
sue for patent infringement). To "grant" such a patent license to a
|
527 |
+
party means to make such an agreement or commitment not to enforce a
|
528 |
+
patent against the party.
|
529 |
+
|
530 |
+
If you convey a covered work, knowingly relying on a patent license,
|
531 |
+
and the Corresponding Source of the work is not available for anyone
|
532 |
+
to copy, free of charge and under the terms of this License, through a
|
533 |
+
publicly available network server or other readily accessible means,
|
534 |
+
then you must either (1) cause the Corresponding Source to be so
|
535 |
+
available, or (2) arrange to deprive yourself of the benefit of the
|
536 |
+
patent license for this particular work, or (3) arrange, in a manner
|
537 |
+
consistent with the requirements of this License, to extend the patent
|
538 |
+
license to downstream recipients. "Knowingly relying" means you have
|
539 |
+
actual knowledge that, but for the patent license, your conveying the
|
540 |
+
covered work in a country, or your recipient's use of the covered work
|
541 |
+
in a country, would infringe one or more identifiable patents in that
|
542 |
+
country that you have reason to believe are valid.
|
543 |
+
|
544 |
+
If, pursuant to or in connection with a single transaction or
|
545 |
+
arrangement, you convey, or propagate by procuring conveyance of, a
|
546 |
+
covered work, and grant a patent license to some of the parties
|
547 |
+
receiving the covered work authorizing them to use, propagate, modify
|
548 |
+
or convey a specific copy of the covered work, then the patent license
|
549 |
+
you grant is automatically extended to all recipients of the covered
|
550 |
+
work and works based on it.
|
551 |
+
|
552 |
+
A patent license is "discriminatory" if it does not include within
|
553 |
+
the scope of its coverage, prohibits the exercise of, or is
|
554 |
+
conditioned on the non-exercise of one or more of the rights that are
|
555 |
+
specifically granted under this License. You may not convey a covered
|
556 |
+
work if you are a party to an arrangement with a third party that is
|
557 |
+
in the business of distributing software, under which you make payment
|
558 |
+
to the third party based on the extent of your activity of conveying
|
559 |
+
the work, and under which the third party grants, to any of the
|
560 |
+
parties who would receive the covered work from you, a discriminatory
|
561 |
+
patent license (a) in connection with copies of the covered work
|
562 |
+
conveyed by you (or copies made from those copies), or (b) primarily
|
563 |
+
for and in connection with specific products or compilations that
|
564 |
+
contain the covered work, unless you entered into that arrangement,
|
565 |
+
or that patent license was granted, prior to 28 March 2007.
|
566 |
+
|
567 |
+
Nothing in this License shall be construed as excluding or limiting
|
568 |
+
any implied license or other defenses to infringement that may
|
569 |
+
otherwise be available to you under applicable patent law.
|
570 |
+
|
571 |
+
12. No Surrender of Others' Freedom.
|
572 |
+
|
573 |
+
If conditions are imposed on you (whether by court order, agreement or
|
574 |
+
otherwise) that contradict the conditions of this License, they do not
|
575 |
+
excuse you from the conditions of this License. If you cannot convey a
|
576 |
+
covered work so as to satisfy simultaneously your obligations under this
|
577 |
+
License and any other pertinent obligations, then as a consequence you may
|
578 |
+
not convey it at all. For example, if you agree to terms that obligate you
|
579 |
+
to collect a royalty for further conveying from those to whom you convey
|
580 |
+
the Program, the only way you could satisfy both those terms and this
|
581 |
+
License would be to refrain entirely from conveying the Program.
|
582 |
+
|
583 |
+
13. Use with the GNU Affero General Public License.
|
584 |
+
|
585 |
+
Notwithstanding any other provision of this License, you have
|
586 |
+
permission to link or combine any covered work with a work licensed
|
587 |
+
under version 3 of the GNU Affero General Public License into a single
|
588 |
+
combined work, and to convey the resulting work. The terms of this
|
589 |
+
License will continue to apply to the part which is the covered work,
|
590 |
+
but the special requirements of the GNU Affero General Public License,
|
591 |
+
section 13, concerning interaction through a network will apply to the
|
592 |
+
combination as such.
|
593 |
+
|
594 |
+
14. Revised Versions of this License.
|
595 |
+
|
596 |
+
The Free Software Foundation may publish revised and/or new versions of
|
597 |
+
the GNU General Public License from time to time. Such new versions will
|
598 |
+
be similar in spirit to the present version, but may differ in detail to
|
599 |
+
address new problems or concerns.
|
600 |
+
|
601 |
+
Each version is given a distinguishing version number. If the
|
602 |
+
Program specifies that a certain numbered version of the GNU General
|
603 |
+
Public License "or any later version" applies to it, you have the
|
604 |
+
option of following the terms and conditions either of that numbered
|
605 |
+
version or of any later version published by the Free Software
|
606 |
+
Foundation. If the Program does not specify a version number of the
|
607 |
+
GNU General Public License, you may choose any version ever published
|
608 |
+
by the Free Software Foundation.
|
609 |
+
|
610 |
+
If the Program specifies that a proxy can decide which future
|
611 |
+
versions of the GNU General Public License can be used, that proxy's
|
612 |
+
public statement of acceptance of a version permanently authorizes you
|
613 |
+
to choose that version for the Program.
|
614 |
+
|
615 |
+
Later license versions may give you additional or different
|
616 |
+
permissions. However, no additional obligations are imposed on any
|
617 |
+
author or copyright holder as a result of your choosing to follow a
|
618 |
+
later version.
|
619 |
+
|
620 |
+
15. Disclaimer of Warranty.
|
621 |
+
|
622 |
+
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
623 |
+
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
624 |
+
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
625 |
+
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
626 |
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
627 |
+
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
628 |
+
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
629 |
+
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
630 |
+
|
631 |
+
16. Limitation of Liability.
|
632 |
+
|
633 |
+
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
634 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
635 |
+
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
636 |
+
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
637 |
+
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
638 |
+
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
639 |
+
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
640 |
+
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
641 |
+
SUCH DAMAGES.
|
642 |
+
|
643 |
+
17. Interpretation of Sections 15 and 16.
|
644 |
+
|
645 |
+
If the disclaimer of warranty and limitation of liability provided
|
646 |
+
above cannot be given local legal effect according to their terms,
|
647 |
+
reviewing courts shall apply local law that most closely approximates
|
648 |
+
an absolute waiver of all civil liability in connection with the
|
649 |
+
Program, unless a warranty or assumption of liability accompanies a
|
650 |
+
copy of the Program in return for a fee.
|
651 |
+
|
652 |
+
END OF TERMS AND CONDITIONS
|
653 |
+
|
654 |
+
How to Apply These Terms to Your New Programs
|
655 |
+
|
656 |
+
If you develop a new program, and you want it to be of the greatest
|
657 |
+
possible use to the public, the best way to achieve this is to make it
|
658 |
+
free software which everyone can redistribute and change under these terms.
|
659 |
+
|
660 |
+
To do so, attach the following notices to the program. It is safest
|
661 |
+
to attach them to the start of each source file to most effectively
|
662 |
+
state the exclusion of warranty; and each file should have at least
|
663 |
+
the "copyright" line and a pointer to where the full notice is found.
|
664 |
+
|
665 |
+
<one line to give the program's name and a brief idea of what it does.>
|
666 |
+
Copyright © <year> <name of author>
|
667 |
+
|
668 |
+
This program is free software: you can redistribute it and/or modify
|
669 |
+
it under the terms of the GNU General Public License as published by
|
670 |
+
the Free Software Foundation, either version 3 of the License, or
|
671 |
+
(at your option) any later version.
|
672 |
+
|
673 |
+
This program is distributed in the hope that it will be useful,
|
674 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
675 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
676 |
+
GNU General Public License for more details.
|
677 |
+
|
678 |
+
You should have received a copy of the GNU General Public License
|
679 |
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
680 |
+
|
681 |
+
Also add information on how to contact you by electronic and paper mail.
|
682 |
+
|
683 |
+
If the program does terminal interaction, make it output a short
|
684 |
+
notice like this when it starts in an interactive mode:
|
685 |
+
|
686 |
+
<program> Copyright © <year> <name of author>
|
687 |
+
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
688 |
+
This is free software, and you are welcome to redistribute it
|
689 |
+
under certain conditions; type `show c' for details.
|
690 |
+
|
691 |
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
692 |
+
parts of the General Public License. Of course, your program's commands
|
693 |
+
might be different; for a GUI interface, you would use an "about box".
|
694 |
+
|
695 |
+
You should also get your employer (if you work as a programmer) or school,
|
696 |
+
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
697 |
+
For more information on this, and how to apply and follow the GNU GPL, see
|
698 |
+
<http://www.gnu.org/licenses/>.
|
699 |
+
|
700 |
+
The GNU General Public License does not permit incorporating your program
|
701 |
+
into proprietary programs. If your program is a subroutine library, you
|
702 |
+
may consider it more useful to permit linking proprietary applications with
|
703 |
+
the library. If this is what you want to do, use the GNU Lesser General
|
704 |
+
Public License instead of this License. But first, please read
|
705 |
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
product-csv-import-export.php
CHANGED
@@ -1,417 +1,417 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Plugin Name: Product CSV Import Export (BASIC)
|
4 |
-
Plugin URI: https://
|
5 |
-
Description: Import and Export Products From and To your WooCommerce Store.
|
6 |
-
Author:
|
7 |
-
Author URI: https://www.
|
8 |
-
Version: 1.4.
|
9 |
-
WC tested up to: 3.4.
|
10 |
-
Text Domain: wf_csv_import_export
|
11 |
-
*/
|
12 |
-
|
13 |
-
if (!defined('ABSPATH') || !is_admin()) {
|
14 |
-
return;
|
15 |
-
}
|
16 |
-
|
17 |
-
|
18 |
-
if (!defined('WF_PIPE_CURRENT_VERSION')) {
|
19 |
-
define("WF_PIPE_CURRENT_VERSION", "1.4.
|
20 |
-
}
|
21 |
-
if (!defined('WF_PROD_IMP_EXP_ID')) {
|
22 |
-
define("WF_PROD_IMP_EXP_ID", "wf_prod_imp_exp");
|
23 |
-
}
|
24 |
-
if (!defined('WF_WOOCOMMERCE_CSV_IM_EX')) {
|
25 |
-
define("WF_WOOCOMMERCE_CSV_IM_EX", "wf_woocommerce_csv_im_ex");
|
26 |
-
}
|
27 |
-
/**
|
28 |
-
* Check if WooCommerce is active
|
29 |
-
*/
|
30 |
-
if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
|
31 |
-
|
32 |
-
if (!class_exists('WF_Product_Import_Export_CSV')) :
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Main CSV Import class
|
36 |
-
*/
|
37 |
-
class WF_Product_Import_Export_CSV {
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Constructor
|
41 |
-
*/
|
42 |
-
public function __construct() {
|
43 |
-
if (!defined('WF_ProdImpExpCsv_FILE')) {
|
44 |
-
define('WF_ProdImpExpCsv_FILE', __FILE__);
|
45 |
-
}
|
46 |
-
|
47 |
-
if (!defined('WF_ProdImpExpCsv_BASE')) {
|
48 |
-
define('WF_ProdImpExpCsv_BASE', plugin_dir_path(__FILE__));
|
49 |
-
}
|
50 |
-
|
51 |
-
add_filter('woocommerce_screen_ids', array($this, 'woocommerce_screen_ids'));
|
52 |
-
add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'wf_plugin_action_links'));
|
53 |
-
add_action('init', array($this, 'load_plugin_textdomain'));
|
54 |
-
add_action('init', array($this, 'catch_export_request'), 20);
|
55 |
-
add_action('admin_init', array($this, 'register_importers'));
|
56 |
-
|
57 |
-
add_action('admin_footer', array($this, 'deactivate_scripts'));
|
58 |
-
add_action('wp_ajax_pipe_submit_uninstall_reason', array($this, "send_uninstall_reason"));
|
59 |
-
|
60 |
-
include_once( 'includes/class-wf-prodimpexpcsv-system-status-tools.php' );
|
61 |
-
include_once( 'includes/class-wf-prodimpexpcsv-admin-screen.php' );
|
62 |
-
include_once( 'includes/importer/class-wf-prodimpexpcsv-importer.php' );
|
63 |
-
|
64 |
-
if (defined('DOING_AJAX')) {
|
65 |
-
include_once( 'includes/class-wf-prodimpexpcsv-ajax-handler.php' );
|
66 |
-
}
|
67 |
-
}
|
68 |
-
|
69 |
-
public function wf_plugin_action_links($links) {
|
70 |
-
$plugin_links = array(
|
71 |
-
'<a href="' . admin_url('admin.php?page=wf_woocommerce_csv_im_ex&tab=export') . '">' . __('Import Export', 'wf_csv_import_export') . '</a>',
|
72 |
-
'<a target="_blank" href="https://www.xadapter.com/product/product-import-export-plugin-for-woocommerce/" target="_blank">' . __('Premium Upgrade', 'wf_csv_import_export') . '</a>',
|
73 |
-
'<a target="_blank" href="https://wordpress.org/support/plugin/product-import-export-for-woo/">' . __('Support', 'wf_csv_import_export') . '</a>',
|
74 |
-
'<a target="_blank" href="https://wordpress.org/support/plugin/product-import-export-for-woo/reviews/">' . __('Review', 'wf_csv_import_export') . '</a>',
|
75 |
-
);
|
76 |
-
if (array_key_exists('deactivate', $links)) {
|
77 |
-
$links['deactivate'] = str_replace('<a', '<a class="pipe-deactivate-link"', $links['deactivate']);
|
78 |
-
}
|
79 |
-
return array_merge($plugin_links, $links);
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* Add screen ID
|
84 |
-
*/
|
85 |
-
public function woocommerce_screen_ids($ids) {
|
86 |
-
$ids[] = 'admin'; // For import screen
|
87 |
-
return $ids;
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* Handle localization
|
92 |
-
*/
|
93 |
-
public function load_plugin_textdomain() {
|
94 |
-
load_plugin_textdomain('wf_csv_import_export', false, dirname(plugin_basename(__FILE__)) . '/lang/');
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* Catches an export request and exports the data. This class is only loaded in admin.
|
99 |
-
*/
|
100 |
-
public function catch_export_request() {
|
101 |
-
|
102 |
-
if (!empty($_GET['action']) && !empty($_GET['page']) && $_GET['page'] == 'wf_woocommerce_csv_im_ex') {
|
103 |
-
switch ($_GET['action']) {
|
104 |
-
case "export" :
|
105 |
-
$user_ok = $this->hf_user_permission();
|
106 |
-
if ($user_ok) {
|
107 |
-
include_once( 'includes/exporter/class-wf-prodimpexpcsv-exporter.php' );
|
108 |
-
WF_ProdImpExpCsv_Exporter::do_export('product');
|
109 |
-
} else {
|
110 |
-
wp_redirect(wp_login_url());
|
111 |
-
}
|
112 |
-
break;
|
113 |
-
}
|
114 |
-
}
|
115 |
-
}
|
116 |
-
|
117 |
-
/**
|
118 |
-
* Register importers for use
|
119 |
-
*/
|
120 |
-
public function register_importers() {
|
121 |
-
register_importer('xa_woocommerce_csv', 'XAdapter WooCommerce Product Import (CSV)', __('Import <strong>products</strong> to your store via a csv file.', 'wf_csv_import_export'), 'WF_ProdImpExpCsv_Importer::product_importer');
|
122 |
-
}
|
123 |
-
|
124 |
-
private function hf_user_permission() {
|
125 |
-
// Check if user has rights to export
|
126 |
-
$current_user = wp_get_current_user();
|
127 |
-
$user_ok = false;
|
128 |
-
$wf_roles = apply_filters('hf_user_permission_roles', array('administrator', 'shop_manager'));
|
129 |
-
if ($current_user instanceof WP_User) {
|
130 |
-
$can_users = array_intersect($wf_roles, $current_user->roles);
|
131 |
-
if (!empty($can_users)) {
|
132 |
-
$user_ok = true;
|
133 |
-
}
|
134 |
-
}
|
135 |
-
return $user_ok;
|
136 |
-
}
|
137 |
-
|
138 |
-
private function get_uninstall_reasons() {
|
139 |
-
|
140 |
-
$reasons = array(
|
141 |
-
array(
|
142 |
-
'id' => 'used-it',
|
143 |
-
'text' => __('Used it successfully. Don\'t need anymore.', 'wf_csv_import_export'),
|
144 |
-
'type' => 'reviewhtml',
|
145 |
-
'placeholder' => __('Have used it successfully and aint in need of it anymore', 'wf_csv_import_export')
|
146 |
-
),
|
147 |
-
array(
|
148 |
-
'id' => 'could-not-understand',
|
149 |
-
'text' => __('I couldn\'t understand how to make it work', 'wf_csv_import_export'),
|
150 |
-
'type' => 'textarea',
|
151 |
-
'placeholder' => __('Would you like us to assist you?', 'wf_csv_import_export')
|
152 |
-
),
|
153 |
-
array(
|
154 |
-
'id' => 'found-better-plugin',
|
155 |
-
'text' => __('I found a better plugin', 'wf_csv_import_export'),
|
156 |
-
'type' => 'text',
|
157 |
-
'placeholder' => __('Which plugin?', 'wf_csv_import_export')
|
158 |
-
),
|
159 |
-
array(
|
160 |
-
'id' => 'not-have-that-feature',
|
161 |
-
'text' => __('The plugin is great, but I need specific feature that you don\'t support', 'wf_csv_import_export'),
|
162 |
-
'type' => 'textarea',
|
163 |
-
'placeholder' => __('Could you tell us more about that feature?', 'wf_csv_import_export')
|
164 |
-
),
|
165 |
-
array(
|
166 |
-
'id' => 'is-not-working',
|
167 |
-
'text' => __('The plugin is not working', 'wf_csv_import_export'),
|
168 |
-
'type' => 'textarea',
|
169 |
-
'placeholder' => __('Could you tell us a bit more whats not working?', 'wf_csv_import_export')
|
170 |
-
),
|
171 |
-
array(
|
172 |
-
'id' => 'looking-for-other',
|
173 |
-
'text' => __('It\'s not what I was looking for', 'wf_csv_import_export'),
|
174 |
-
'type' => 'textarea',
|
175 |
-
'placeholder' => __('Could you tell us a bit more?', 'wf_csv_import_export')
|
176 |
-
),
|
177 |
-
array(
|
178 |
-
'id' => 'did-not-work-as-expected',
|
179 |
-
'text' => __('The plugin didn\'t work as expected', 'wf_csv_import_export'),
|
180 |
-
'type' => 'textarea',
|
181 |
-
'placeholder' => __('What did you expect?', 'wf_csv_import_export')
|
182 |
-
),
|
183 |
-
array(
|
184 |
-
'id' => 'other',
|
185 |
-
'text' => __('Other', 'wf_csv_import_export'),
|
186 |
-
'type' => 'textarea',
|
187 |
-
'placeholder' => __('Could you tell us a bit more?', 'wf_csv_import_export')
|
188 |
-
),
|
189 |
-
);
|
190 |
-
|
191 |
-
return $reasons;
|
192 |
-
}
|
193 |
-
|
194 |
-
public function deactivate_scripts() {
|
195 |
-
|
196 |
-
global $pagenow;
|
197 |
-
if ('plugins.php' != $pagenow) {
|
198 |
-
return;
|
199 |
-
}
|
200 |
-
$reasons = $this->get_uninstall_reasons();
|
201 |
-
?>
|
202 |
-
<div class="pipe-modal" id="pipe-pipe-modal">
|
203 |
-
<div class="pipe-modal-wrap">
|
204 |
-
<div class="pipe-modal-header">
|
205 |
-
<h3><?php _e('If you have a moment, please let us know why you are deactivating:', 'wf_csv_import_export'); ?></h3>
|
206 |
-
</div>
|
207 |
-
<div class="pipe-modal-body">
|
208 |
-
<ul class="reasons">
|
209 |
-
<?php foreach ($reasons as $reason) { ?>
|
210 |
-
<li data-type="<?php echo esc_attr($reason['type']); ?>" data-placeholder="<?php echo esc_attr($reason['placeholder']); ?>">
|
211 |
-
<label><input type="radio" name="selected-reason" value="<?php echo $reason['id']; ?>"> <?php echo $reason['text']; ?></label>
|
212 |
-
</li>
|
213 |
-
<?php } ?>
|
214 |
-
</ul>
|
215 |
-
</div>
|
216 |
-
<div class="pipe-modal-footer">
|
217 |
-
<a href="#" class="dont-bother-me"><?php _e('I rather wouldn\'t say', 'wf_csv_import_export'); ?></a>
|
218 |
-
<button class="button-primary pipe-model-submit"><?php _e('Submit & Deactivate', 'wf_csv_import_export'); ?></button>
|
219 |
-
<button class="button-secondary pipe-model-cancel"><?php _e('Cancel', 'wf_csv_import_export'); ?></button>
|
220 |
-
</div>
|
221 |
-
</div>
|
222 |
-
</div>
|
223 |
-
|
224 |
-
<style type="text/css">
|
225 |
-
.pipe-modal {
|
226 |
-
position: fixed;
|
227 |
-
z-index: 99999;
|
228 |
-
top: 0;
|
229 |
-
right: 0;
|
230 |
-
bottom: 0;
|
231 |
-
left: 0;
|
232 |
-
background: rgba(0,0,0,0.5);
|
233 |
-
display: none;
|
234 |
-
}
|
235 |
-
.pipe-modal.modal-active {display: block;}
|
236 |
-
.pipe-modal-wrap {
|
237 |
-
width: 50%;
|
238 |
-
position: relative;
|
239 |
-
margin: 10% auto;
|
240 |
-
background: #fff;
|
241 |
-
}
|
242 |
-
.pipe-modal-header {
|
243 |
-
border-bottom: 1px solid #eee;
|
244 |
-
padding: 8px 20px;
|
245 |
-
}
|
246 |
-
.pipe-modal-header h3 {
|
247 |
-
line-height: 150%;
|
248 |
-
margin: 0;
|
249 |
-
}
|
250 |
-
.pipe-modal-body {padding: 5px 20px 20px 20px;}
|
251 |
-
.pipe-modal-body .input-text,.pipe-modal-body textarea {width:75%;}
|
252 |
-
.pipe-modal-body .reason-input {
|
253 |
-
margin-top: 5px;
|
254 |
-
margin-left: 20px;
|
255 |
-
}
|
256 |
-
.pipe-modal-footer {
|
257 |
-
border-top: 1px solid #eee;
|
258 |
-
padding: 12px 20px;
|
259 |
-
text-align: right;
|
260 |
-
}
|
261 |
-
.reviewlink{
|
262 |
-
padding:10px 0px 0px 35px !important;
|
263 |
-
font-size: 15px;
|
264 |
-
}
|
265 |
-
.review-and-deactivate{
|
266 |
-
padding:5px;
|
267 |
-
}
|
268 |
-
</style>
|
269 |
-
<script type="text/javascript">
|
270 |
-
(function ($) {
|
271 |
-
$(function () {
|
272 |
-
var modal = $('#pipe-pipe-modal');
|
273 |
-
var deactivateLink = '';
|
274 |
-
|
275 |
-
|
276 |
-
$('#the-list').on('click', 'a.pipe-deactivate-link', function (e) {
|
277 |
-
e.preventDefault();
|
278 |
-
modal.addClass('modal-active');
|
279 |
-
deactivateLink = $(this).attr('href');
|
280 |
-
modal.find('a.dont-bother-me').attr('href', deactivateLink).css('float', 'left');
|
281 |
-
});
|
282 |
-
|
283 |
-
$('#pipe-pipe-modal').on('click', 'a.review-and-deactivate', function (e) {
|
284 |
-
e.preventDefault();
|
285 |
-
window.open("https://wordpress.org/support/plugin/product-import-export-for-woo/reviews/#new-post");
|
286 |
-
window.location.href = deactivateLink;
|
287 |
-
});
|
288 |
-
modal.on('click', 'button.pipe-model-cancel', function (e) {
|
289 |
-
e.preventDefault();
|
290 |
-
modal.removeClass('modal-active');
|
291 |
-
});
|
292 |
-
modal.on('click', 'input[type="radio"]', function () {
|
293 |
-
var parent = $(this).parents('li:first');
|
294 |
-
modal.find('.reason-input').remove();
|
295 |
-
var inputType = parent.data('type'),
|
296 |
-
inputPlaceholder = parent.data('placeholder');
|
297 |
-
if('reviewhtml' === inputType) {
|
298 |
-
var reasonInputHtml = '<div class="reviewlink"><a href="#" target="_blank" class="review-and-deactivate"><?php _e('Deactivate and leave a review', 'wf_csv_import_export'); ?> <span class="xa-pipe-rating-link"> ★★★★★ </span></a></div>';
|
299 |
-
}else{
|
300 |
-
var reasonInputHtml = '<div class="reason-input">' + (('text' === inputType) ? '<input type="text" class="input-text" size="40" />' : '<textarea rows="5" cols="45"></textarea>') + '</div>';
|
301 |
-
}
|
302 |
-
if (inputType !== '') {
|
303 |
-
parent.append($(reasonInputHtml));
|
304 |
-
parent.find('input, textarea').attr('placeholder', inputPlaceholder).focus();
|
305 |
-
}
|
306 |
-
});
|
307 |
-
|
308 |
-
modal.on('click', 'button.pipe-model-submit', function (e) {
|
309 |
-
e.preventDefault();
|
310 |
-
var button = $(this);
|
311 |
-
if (button.hasClass('disabled')) {
|
312 |
-
return;
|
313 |
-
}
|
314 |
-
var $radio = $('input[type="radio"]:checked', modal);
|
315 |
-
var $selected_reason = $radio.parents('li:first'),
|
316 |
-
$input = $selected_reason.find('textarea, input[type="text"]');
|
317 |
-
|
318 |
-
$.ajax({
|
319 |
-
url: ajaxurl,
|
320 |
-
type: 'POST',
|
321 |
-
data: {
|
322 |
-
action: 'pipe_submit_uninstall_reason',
|
323 |
-
reason_id: (0 === $radio.length) ? 'none' : $radio.val(),
|
324 |
-
reason_info: (0 !== $input.length) ? $input.val().trim() : ''
|
325 |
-
},
|
326 |
-
beforeSend: function () {
|
327 |
-
button.addClass('disabled');
|
328 |
-
button.text('Processing...');
|
329 |
-
},
|
330 |
-
complete: function () {
|
331 |
-
window.location.href = deactivateLink;
|
332 |
-
}
|
333 |
-
});
|
334 |
-
});
|
335 |
-
});
|
336 |
-
}(jQuery));
|
337 |
-
</script>
|
338 |
-
<?php
|
339 |
-
}
|
340 |
-
|
341 |
-
public function send_uninstall_reason() {
|
342 |
-
|
343 |
-
global $wpdb;
|
344 |
-
|
345 |
-
if (!isset($_POST['reason_id'])) {
|
346 |
-
wp_send_json_error();
|
347 |
-
}
|
348 |
-
|
349 |
-
//$current_user = wp_get_current_user();
|
350 |
-
|
351 |
-
$data = array(
|
352 |
-
'reason_id' => sanitize_text_field($_POST['reason_id']),
|
353 |
-
'plugin' => "productimportexort",
|
354 |
-
'auth' => 'wfpipe_uninstall_1234#',
|
355 |
-
'date' => gmdate("M d, Y h:i:s A"),
|
356 |
-
'url' => home_url(),
|
357 |
-
'user_email' => '',//$current_user->user_email,
|
358 |
-
'reason_info' => isset($_REQUEST['reason_info']) ? trim(stripslashes($_REQUEST['reason_info'])) : '',
|
359 |
-
'software' => $_SERVER['SERVER_SOFTWARE'],
|
360 |
-
'php_version' => phpversion(),
|
361 |
-
'mysql_version' => $wpdb->db_version(),
|
362 |
-
'wp_version' => get_bloginfo('version'),
|
363 |
-
'wc_version' => (!defined('WC_VERSION')) ? '' : WC_VERSION,
|
364 |
-
'locale' => get_locale(),
|
365 |
-
'multisite' => is_multisite() ? 'Yes' : 'No',
|
366 |
-
'wfpipe_version' => WF_PIPE_CURRENT_VERSION
|
367 |
-
);
|
368 |
-
// Write an action/hook here in webtoffe to recieve the data
|
369 |
-
$resp = wp_remote_post('http://feedback.webtoffee.com/wp-json/wfpipe/v1/uninstall', array(
|
370 |
-
'method' => 'POST',
|
371 |
-
'timeout' => 45,
|
372 |
-
'redirection' => 5,
|
373 |
-
'httpversion' => '1.0',
|
374 |
-
'blocking' => false,
|
375 |
-
'headers' => array('user-agent' => 'pipe/' . md5(esc_url(home_url())) . ';'),
|
376 |
-
'body' => $data,
|
377 |
-
'cookies' => array()
|
378 |
-
)
|
379 |
-
);
|
380 |
-
|
381 |
-
wp_send_json_success();
|
382 |
-
}
|
383 |
-
|
384 |
-
}
|
385 |
-
|
386 |
-
endif;
|
387 |
-
|
388 |
-
new WF_Product_Import_Export_CSV();
|
389 |
-
}
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
// Welcome screen tutorial video --> Move this function to inside the class
|
394 |
-
add_action('admin_init', 'impexp_welcome');
|
395 |
-
|
396 |
-
register_activation_hook(__FILE__, 'hf_welcome_screen_activate_basic');
|
397 |
-
|
398 |
-
function hf_welcome_screen_activate_basic() {
|
399 |
-
if (is_plugin_active('product-csv-import-export-for-woocommerce/product-csv-import-export.php')) {
|
400 |
-
deactivate_plugins(basename(__FILE__));
|
401 |
-
wp_die(__("Is everything fine? You already have the Premium version installed in your website. For any issues, kindly raise a ticket via <a target='_blank' href='//support.xadapter.com/'>support.xadapter.com</a>", "wf_csv_import_export"), "", array('back_link' => 1));
|
402 |
-
}
|
403 |
-
update_option('xa_pipe_plugin_installed_date', date('Y-m-d H:i:s'));
|
404 |
-
set_transient('_welcome_screen_activation_redirect', true, 30);
|
405 |
-
}
|
406 |
-
|
407 |
-
if (!function_exists('impexp_welcome')) {
|
408 |
-
|
409 |
-
function impexp_welcome() {
|
410 |
-
if (!get_transient('_welcome_screen_activation_redirect')) {
|
411 |
-
return;
|
412 |
-
}
|
413 |
-
delete_transient('_welcome_screen_activation_redirect');
|
414 |
-
wp_safe_redirect(add_query_arg(array('page' => 'wf_woocommerce_csv_im_ex'), admin_url('admin.php')));
|
415 |
-
}
|
416 |
-
|
417 |
}
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Product CSV Import Export (BASIC)
|
4 |
+
Plugin URI: https://wordpress.org/plugins/product-import-export-for-woo/
|
5 |
+
Description: Import and Export Products From and To your WooCommerce Store.
|
6 |
+
Author: WebToffee
|
7 |
+
Author URI: https://www.webtoffee.com/product/product-import-export-woocommerce/
|
8 |
+
Version: 1.4.5
|
9 |
+
WC tested up to: 3.4.3
|
10 |
+
Text Domain: wf_csv_import_export
|
11 |
+
*/
|
12 |
+
|
13 |
+
if (!defined('ABSPATH') || !is_admin()) {
|
14 |
+
return;
|
15 |
+
}
|
16 |
+
|
17 |
+
|
18 |
+
if (!defined('WF_PIPE_CURRENT_VERSION')) {
|
19 |
+
define("WF_PIPE_CURRENT_VERSION", "1.4.5");
|
20 |
+
}
|
21 |
+
if (!defined('WF_PROD_IMP_EXP_ID')) {
|
22 |
+
define("WF_PROD_IMP_EXP_ID", "wf_prod_imp_exp");
|
23 |
+
}
|
24 |
+
if (!defined('WF_WOOCOMMERCE_CSV_IM_EX')) {
|
25 |
+
define("WF_WOOCOMMERCE_CSV_IM_EX", "wf_woocommerce_csv_im_ex");
|
26 |
+
}
|
27 |
+
/**
|
28 |
+
* Check if WooCommerce is active
|
29 |
+
*/
|
30 |
+
if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
|
31 |
+
|
32 |
+
if (!class_exists('WF_Product_Import_Export_CSV')) :
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Main CSV Import class
|
36 |
+
*/
|
37 |
+
class WF_Product_Import_Export_CSV {
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Constructor
|
41 |
+
*/
|
42 |
+
public function __construct() {
|
43 |
+
if (!defined('WF_ProdImpExpCsv_FILE')) {
|
44 |
+
define('WF_ProdImpExpCsv_FILE', __FILE__);
|
45 |
+
}
|
46 |
+
|
47 |
+
if (!defined('WF_ProdImpExpCsv_BASE')) {
|
48 |
+
define('WF_ProdImpExpCsv_BASE', plugin_dir_path(__FILE__));
|
49 |
+
}
|
50 |
+
|
51 |
+
add_filter('woocommerce_screen_ids', array($this, 'woocommerce_screen_ids'));
|
52 |
+
add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'wf_plugin_action_links'));
|
53 |
+
add_action('init', array($this, 'load_plugin_textdomain'));
|
54 |
+
add_action('init', array($this, 'catch_export_request'), 20);
|
55 |
+
add_action('admin_init', array($this, 'register_importers'));
|
56 |
+
|
57 |
+
add_action('admin_footer', array($this, 'deactivate_scripts'));
|
58 |
+
add_action('wp_ajax_pipe_submit_uninstall_reason', array($this, "send_uninstall_reason"));
|
59 |
+
|
60 |
+
include_once( 'includes/class-wf-prodimpexpcsv-system-status-tools.php' );
|
61 |
+
include_once( 'includes/class-wf-prodimpexpcsv-admin-screen.php' );
|
62 |
+
include_once( 'includes/importer/class-wf-prodimpexpcsv-importer.php' );
|
63 |
+
|
64 |
+
if (defined('DOING_AJAX')) {
|
65 |
+
include_once( 'includes/class-wf-prodimpexpcsv-ajax-handler.php' );
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
public function wf_plugin_action_links($links) {
|
70 |
+
$plugin_links = array(
|
71 |
+
'<a href="' . admin_url('admin.php?page=wf_woocommerce_csv_im_ex&tab=export') . '">' . __('Import Export', 'wf_csv_import_export') . '</a>',
|
72 |
+
'<a target="_blank" href="https://www.xadapter.com/product/product-import-export-plugin-for-woocommerce/" target="_blank">' . __('Premium Upgrade', 'wf_csv_import_export') . '</a>',
|
73 |
+
'<a target="_blank" href="https://wordpress.org/support/plugin/product-import-export-for-woo/">' . __('Support', 'wf_csv_import_export') . '</a>',
|
74 |
+
'<a target="_blank" href="https://wordpress.org/support/plugin/product-import-export-for-woo/reviews/">' . __('Review', 'wf_csv_import_export') . '</a>',
|
75 |
+
);
|
76 |
+
if (array_key_exists('deactivate', $links)) {
|
77 |
+
$links['deactivate'] = str_replace('<a', '<a class="pipe-deactivate-link"', $links['deactivate']);
|
78 |
+
}
|
79 |
+
return array_merge($plugin_links, $links);
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Add screen ID
|
84 |
+
*/
|
85 |
+
public function woocommerce_screen_ids($ids) {
|
86 |
+
$ids[] = 'admin'; // For import screen
|
87 |
+
return $ids;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Handle localization
|
92 |
+
*/
|
93 |
+
public function load_plugin_textdomain() {
|
94 |
+
load_plugin_textdomain('wf_csv_import_export', false, dirname(plugin_basename(__FILE__)) . '/lang/');
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Catches an export request and exports the data. This class is only loaded in admin.
|
99 |
+
*/
|
100 |
+
public function catch_export_request() {
|
101 |
+
|
102 |
+
if (!empty($_GET['action']) && !empty($_GET['page']) && $_GET['page'] == 'wf_woocommerce_csv_im_ex') {
|
103 |
+
switch ($_GET['action']) {
|
104 |
+
case "export" :
|
105 |
+
$user_ok = $this->hf_user_permission();
|
106 |
+
if ($user_ok) {
|
107 |
+
include_once( 'includes/exporter/class-wf-prodimpexpcsv-exporter.php' );
|
108 |
+
WF_ProdImpExpCsv_Exporter::do_export('product');
|
109 |
+
} else {
|
110 |
+
wp_redirect(wp_login_url());
|
111 |
+
}
|
112 |
+
break;
|
113 |
+
}
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Register importers for use
|
119 |
+
*/
|
120 |
+
public function register_importers() {
|
121 |
+
register_importer('xa_woocommerce_csv', 'XAdapter WooCommerce Product Import (CSV)', __('Import <strong>products</strong> to your store via a csv file.', 'wf_csv_import_export'), 'WF_ProdImpExpCsv_Importer::product_importer');
|
122 |
+
}
|
123 |
+
|
124 |
+
private function hf_user_permission() {
|
125 |
+
// Check if user has rights to export
|
126 |
+
$current_user = wp_get_current_user();
|
127 |
+
$user_ok = false;
|
128 |
+
$wf_roles = apply_filters('hf_user_permission_roles', array('administrator', 'shop_manager'));
|
129 |
+
if ($current_user instanceof WP_User) {
|
130 |
+
$can_users = array_intersect($wf_roles, $current_user->roles);
|
131 |
+
if (!empty($can_users)) {
|
132 |
+
$user_ok = true;
|
133 |
+
}
|
134 |
+
}
|
135 |
+
return $user_ok;
|
136 |
+
}
|
137 |
+
|
138 |
+
private function get_uninstall_reasons() {
|
139 |
+
|
140 |
+
$reasons = array(
|
141 |
+
array(
|
142 |
+
'id' => 'used-it',
|
143 |
+
'text' => __('Used it successfully. Don\'t need anymore.', 'wf_csv_import_export'),
|
144 |
+
'type' => 'reviewhtml',
|
145 |
+
'placeholder' => __('Have used it successfully and aint in need of it anymore', 'wf_csv_import_export')
|
146 |
+
),
|
147 |
+
array(
|
148 |
+
'id' => 'could-not-understand',
|
149 |
+
'text' => __('I couldn\'t understand how to make it work', 'wf_csv_import_export'),
|
150 |
+
'type' => 'textarea',
|
151 |
+
'placeholder' => __('Would you like us to assist you?', 'wf_csv_import_export')
|
152 |
+
),
|
153 |
+
array(
|
154 |
+
'id' => 'found-better-plugin',
|
155 |
+
'text' => __('I found a better plugin', 'wf_csv_import_export'),
|
156 |
+
'type' => 'text',
|
157 |
+
'placeholder' => __('Which plugin?', 'wf_csv_import_export')
|
158 |
+
),
|
159 |
+
array(
|
160 |
+
'id' => 'not-have-that-feature',
|
161 |
+
'text' => __('The plugin is great, but I need specific feature that you don\'t support', 'wf_csv_import_export'),
|
162 |
+
'type' => 'textarea',
|
163 |
+
'placeholder' => __('Could you tell us more about that feature?', 'wf_csv_import_export')
|
164 |
+
),
|
165 |
+
array(
|
166 |
+
'id' => 'is-not-working',
|
167 |
+
'text' => __('The plugin is not working', 'wf_csv_import_export'),
|
168 |
+
'type' => 'textarea',
|
169 |
+
'placeholder' => __('Could you tell us a bit more whats not working?', 'wf_csv_import_export')
|
170 |
+
),
|
171 |
+
array(
|
172 |
+
'id' => 'looking-for-other',
|
173 |
+
'text' => __('It\'s not what I was looking for', 'wf_csv_import_export'),
|
174 |
+
'type' => 'textarea',
|
175 |
+
'placeholder' => __('Could you tell us a bit more?', 'wf_csv_import_export')
|
176 |
+
),
|
177 |
+
array(
|
178 |
+
'id' => 'did-not-work-as-expected',
|
179 |
+
'text' => __('The plugin didn\'t work as expected', 'wf_csv_import_export'),
|
180 |
+
'type' => 'textarea',
|
181 |
+
'placeholder' => __('What did you expect?', 'wf_csv_import_export')
|
182 |
+
),
|
183 |
+
array(
|
184 |
+
'id' => 'other',
|
185 |
+
'text' => __('Other', 'wf_csv_import_export'),
|
186 |
+
'type' => 'textarea',
|
187 |
+
'placeholder' => __('Could you tell us a bit more?', 'wf_csv_import_export')
|
188 |
+
),
|
189 |
+
);
|
190 |
+
|
191 |
+
return $reasons;
|
192 |
+
}
|
193 |
+
|
194 |
+
public function deactivate_scripts() {
|
195 |
+
|
196 |
+
global $pagenow;
|
197 |
+
if ('plugins.php' != $pagenow) {
|
198 |
+
return;
|
199 |
+
}
|
200 |
+
$reasons = $this->get_uninstall_reasons();
|
201 |
+
?>
|
202 |
+
<div class="pipe-modal" id="pipe-pipe-modal">
|
203 |
+
<div class="pipe-modal-wrap">
|
204 |
+
<div class="pipe-modal-header">
|
205 |
+
<h3><?php _e('If you have a moment, please let us know why you are deactivating:', 'wf_csv_import_export'); ?></h3>
|
206 |
+
</div>
|
207 |
+
<div class="pipe-modal-body">
|
208 |
+
<ul class="reasons">
|
209 |
+
<?php foreach ($reasons as $reason) { ?>
|
210 |
+
<li data-type="<?php echo esc_attr($reason['type']); ?>" data-placeholder="<?php echo esc_attr($reason['placeholder']); ?>">
|
211 |
+
<label><input type="radio" name="selected-reason" value="<?php echo $reason['id']; ?>"> <?php echo $reason['text']; ?></label>
|
212 |
+
</li>
|
213 |
+
<?php } ?>
|
214 |
+
</ul>
|
215 |
+
</div>
|
216 |
+
<div class="pipe-modal-footer">
|
217 |
+
<a href="#" class="dont-bother-me"><?php _e('I rather wouldn\'t say', 'wf_csv_import_export'); ?></a>
|
218 |
+
<button class="button-primary pipe-model-submit"><?php _e('Submit & Deactivate', 'wf_csv_import_export'); ?></button>
|
219 |
+
<button class="button-secondary pipe-model-cancel"><?php _e('Cancel', 'wf_csv_import_export'); ?></button>
|
220 |
+
</div>
|
221 |
+
</div>
|
222 |
+
</div>
|
223 |
+
|
224 |
+
<style type="text/css">
|
225 |
+
.pipe-modal {
|
226 |
+
position: fixed;
|
227 |
+
z-index: 99999;
|
228 |
+
top: 0;
|
229 |
+
right: 0;
|
230 |
+
bottom: 0;
|
231 |
+
left: 0;
|
232 |
+
background: rgba(0,0,0,0.5);
|
233 |
+
display: none;
|
234 |
+
}
|
235 |
+
.pipe-modal.modal-active {display: block;}
|
236 |
+
.pipe-modal-wrap {
|
237 |
+
width: 50%;
|
238 |
+
position: relative;
|
239 |
+
margin: 10% auto;
|
240 |
+
background: #fff;
|
241 |
+
}
|
242 |
+
.pipe-modal-header {
|
243 |
+
border-bottom: 1px solid #eee;
|
244 |
+
padding: 8px 20px;
|
245 |
+
}
|
246 |
+
.pipe-modal-header h3 {
|
247 |
+
line-height: 150%;
|
248 |
+
margin: 0;
|
249 |
+
}
|
250 |
+
.pipe-modal-body {padding: 5px 20px 20px 20px;}
|
251 |
+
.pipe-modal-body .input-text,.pipe-modal-body textarea {width:75%;}
|
252 |
+
.pipe-modal-body .reason-input {
|
253 |
+
margin-top: 5px;
|
254 |
+
margin-left: 20px;
|
255 |
+
}
|
256 |
+
.pipe-modal-footer {
|
257 |
+
border-top: 1px solid #eee;
|
258 |
+
padding: 12px 20px;
|
259 |
+
text-align: right;
|
260 |
+
}
|
261 |
+
.reviewlink{
|
262 |
+
padding:10px 0px 0px 35px !important;
|
263 |
+
font-size: 15px;
|
264 |
+
}
|
265 |
+
.review-and-deactivate{
|
266 |
+
padding:5px;
|
267 |
+
}
|
268 |
+
</style>
|
269 |
+
<script type="text/javascript">
|
270 |
+
(function ($) {
|
271 |
+
$(function () {
|
272 |
+
var modal = $('#pipe-pipe-modal');
|
273 |
+
var deactivateLink = '';
|
274 |
+
|
275 |
+
|
276 |
+
$('#the-list').on('click', 'a.pipe-deactivate-link', function (e) {
|
277 |
+
e.preventDefault();
|
278 |
+
modal.addClass('modal-active');
|
279 |
+
deactivateLink = $(this).attr('href');
|
280 |
+
modal.find('a.dont-bother-me').attr('href', deactivateLink).css('float', 'left');
|
281 |
+
});
|
282 |
+
|
283 |
+
$('#pipe-pipe-modal').on('click', 'a.review-and-deactivate', function (e) {
|
284 |
+
e.preventDefault();
|
285 |
+
window.open("https://wordpress.org/support/plugin/product-import-export-for-woo/reviews/#new-post");
|
286 |
+
window.location.href = deactivateLink;
|
287 |
+
});
|
288 |
+
modal.on('click', 'button.pipe-model-cancel', function (e) {
|
289 |
+
e.preventDefault();
|
290 |
+
modal.removeClass('modal-active');
|
291 |
+
});
|
292 |
+
modal.on('click', 'input[type="radio"]', function () {
|
293 |
+
var parent = $(this).parents('li:first');
|
294 |
+
modal.find('.reason-input').remove();
|
295 |
+
var inputType = parent.data('type'),
|
296 |
+
inputPlaceholder = parent.data('placeholder');
|
297 |
+
if('reviewhtml' === inputType) {
|
298 |
+
var reasonInputHtml = '<div class="reviewlink"><a href="#" target="_blank" class="review-and-deactivate"><?php _e('Deactivate and leave a review', 'wf_csv_import_export'); ?> <span class="xa-pipe-rating-link"> ★★★★★ </span></a></div>';
|
299 |
+
}else{
|
300 |
+
var reasonInputHtml = '<div class="reason-input">' + (('text' === inputType) ? '<input type="text" class="input-text" size="40" />' : '<textarea rows="5" cols="45"></textarea>') + '</div>';
|
301 |
+
}
|
302 |
+
if (inputType !== '') {
|
303 |
+
parent.append($(reasonInputHtml));
|
304 |
+
parent.find('input, textarea').attr('placeholder', inputPlaceholder).focus();
|
305 |
+
}
|
306 |
+
});
|
307 |
+
|
308 |
+
modal.on('click', 'button.pipe-model-submit', function (e) {
|
309 |
+
e.preventDefault();
|
310 |
+
var button = $(this);
|
311 |
+
if (button.hasClass('disabled')) {
|
312 |
+
return;
|
313 |
+
}
|
314 |
+
var $radio = $('input[type="radio"]:checked', modal);
|
315 |
+
var $selected_reason = $radio.parents('li:first'),
|
316 |
+
$input = $selected_reason.find('textarea, input[type="text"]');
|
317 |
+
|
318 |
+
$.ajax({
|
319 |
+
url: ajaxurl,
|
320 |
+
type: 'POST',
|
321 |
+
data: {
|
322 |
+
action: 'pipe_submit_uninstall_reason',
|
323 |
+
reason_id: (0 === $radio.length) ? 'none' : $radio.val(),
|
324 |
+
reason_info: (0 !== $input.length) ? $input.val().trim() : ''
|
325 |
+
},
|
326 |
+
beforeSend: function () {
|
327 |
+
button.addClass('disabled');
|
328 |
+
button.text('Processing...');
|
329 |
+
},
|
330 |
+
complete: function () {
|
331 |
+
window.location.href = deactivateLink;
|
332 |
+
}
|
333 |
+
});
|
334 |
+
});
|
335 |
+
});
|
336 |
+
}(jQuery));
|
337 |
+
</script>
|
338 |
+
<?php
|
339 |
+
}
|
340 |
+
|
341 |
+
public function send_uninstall_reason() {
|
342 |
+
|
343 |
+
global $wpdb;
|
344 |
+
|
345 |
+
if (!isset($_POST['reason_id'])) {
|
346 |
+
wp_send_json_error();
|
347 |
+
}
|
348 |
+
|
349 |
+
//$current_user = wp_get_current_user();
|
350 |
+
|
351 |
+
$data = array(
|
352 |
+
'reason_id' => sanitize_text_field($_POST['reason_id']),
|
353 |
+
'plugin' => "productimportexort",
|
354 |
+
'auth' => 'wfpipe_uninstall_1234#',
|
355 |
+
'date' => gmdate("M d, Y h:i:s A"),
|
356 |
+
'url' => home_url(),
|
357 |
+
'user_email' => '',//$current_user->user_email,
|
358 |
+
'reason_info' => isset($_REQUEST['reason_info']) ? trim(stripslashes($_REQUEST['reason_info'])) : '',
|
359 |
+
'software' => $_SERVER['SERVER_SOFTWARE'],
|
360 |
+
'php_version' => phpversion(),
|
361 |
+
'mysql_version' => $wpdb->db_version(),
|
362 |
+
'wp_version' => get_bloginfo('version'),
|
363 |
+
'wc_version' => (!defined('WC_VERSION')) ? '' : WC_VERSION,
|
364 |
+
'locale' => get_locale(),
|
365 |
+
'multisite' => is_multisite() ? 'Yes' : 'No',
|
366 |
+
'wfpipe_version' => WF_PIPE_CURRENT_VERSION
|
367 |
+
);
|
368 |
+
// Write an action/hook here in webtoffe to recieve the data
|
369 |
+
$resp = wp_remote_post('http://feedback.webtoffee.com/wp-json/wfpipe/v1/uninstall', array(
|
370 |
+
'method' => 'POST',
|
371 |
+
'timeout' => 45,
|
372 |
+
'redirection' => 5,
|
373 |
+
'httpversion' => '1.0',
|
374 |
+
'blocking' => false,
|
375 |
+
'headers' => array('user-agent' => 'pipe/' . md5(esc_url(home_url())) . ';'),
|
376 |
+
'body' => $data,
|
377 |
+
'cookies' => array()
|
378 |
+
)
|
379 |
+
);
|
380 |
+
|
381 |
+
wp_send_json_success();
|
382 |
+
}
|
383 |
+
|
384 |
+
}
|
385 |
+
|
386 |
+
endif;
|
387 |
+
|
388 |
+
new WF_Product_Import_Export_CSV();
|
389 |
+
}
|
390 |
+
|
391 |
+
|
392 |
+
|
393 |
+
// Welcome screen tutorial video --> Move this function to inside the class
|
394 |
+
add_action('admin_init', 'impexp_welcome');
|
395 |
+
|
396 |
+
register_activation_hook(__FILE__, 'hf_welcome_screen_activate_basic');
|
397 |
+
|
398 |
+
function hf_welcome_screen_activate_basic() {
|
399 |
+
if (is_plugin_active('product-csv-import-export-for-woocommerce/product-csv-import-export.php')) {
|
400 |
+
deactivate_plugins(basename(__FILE__));
|
401 |
+
wp_die(__("Is everything fine? You already have the Premium version installed in your website. For any issues, kindly raise a ticket via <a target='_blank' href='//support.xadapter.com/'>support.xadapter.com</a>", "wf_csv_import_export"), "", array('back_link' => 1));
|
402 |
+
}
|
403 |
+
update_option('xa_pipe_plugin_installed_date', date('Y-m-d H:i:s'));
|
404 |
+
set_transient('_welcome_screen_activation_redirect', true, 30);
|
405 |
+
}
|
406 |
+
|
407 |
+
if (!function_exists('impexp_welcome')) {
|
408 |
+
|
409 |
+
function impexp_welcome() {
|
410 |
+
if (!get_transient('_welcome_screen_activation_redirect')) {
|
411 |
+
return;
|
412 |
+
}
|
413 |
+
delete_transient('_welcome_screen_activation_redirect');
|
414 |
+
wp_safe_redirect(add_query_arg(array('page' => 'wf_woocommerce_csv_im_ex'), admin_url('admin.php')));
|
415 |
+
}
|
416 |
+
|
417 |
}
|
readme.txt
CHANGED
@@ -1,237 +1,240 @@
|
|
1 |
-
|
2 |
-
Contributors:
|
3 |
-
Donate link:
|
4 |
-
Tags: woocommerce product import, woocommerce import products, woocommerce export products, export woocommerce products, import products into woocommerce
|
5 |
-
Requires at least: 3.0.1
|
6 |
-
Tested up to: 4.9.
|
7 |
-
Stable tag: 1.4.
|
8 |
-
License: GPLv3 or later
|
9 |
-
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
-
|
11 |
-
Easily import products into WooCommerce store or export WooCommerce products from the store. Import WooCommerce Products from any CSV to WooCommerce.
|
12 |
-
|
13 |
-
== Description ==
|
14 |
-
|
15 |
-
= Introduction =
|
16 |
-
|
17 |
-
Are you trying to import products into WooCommerce store or export WooCommerce products from the store. This Product import export plugin allows you to import or export WooCommerce simple products ( other pproduct types such as variable products are available only in premium version). It is super simple!
|
18 |
-
|
19 |
-
<ul>
|
20 |
-
<li>Export Simple Products in to a CSV file.</li>
|
21 |
-
<li>Import Simple Products in CSV format in to WooCommerce Store.</li>
|
22 |
-
</ul>
|
23 |
-
|
24 |
-
Highlights: WooCommerce Product Export, WooCommerce Product CSV Import Suite, WooCommerce bulk product upload, WooCommerce import products with images, import amazon products to WooCommerce, Export Products to xls. Pro Version supports both Simple and Variable products.
|
25 |
-
|
26 |
-
= How does it work? =
|
27 |
-
|
28 |
-
The WooCommerce Product Import Export Plugin takes CSV (Comma-Separated Values) file as input. You must create a CSV ( UTF-8 Encoded ) file and enter the product details in a structured format as explained in the tutorial. This is to match each field of CSV file to the field of a particular product that otherwise Admin need to input manually. For example: the post_title field gets mapped to the product name and the regular_price field gets mapped to the regular price of the product. For the plugin to work correctly, you must map headers of all of the column correctly and you must ensure that all of the fields you enter must be in the correct format.
|
29 |
-
|
30 |
-
You can create the CSV from scratch or you can export the product to get the format of CSV. You can use a spreadsheet program, such as LibreOffice , Microsoft Excel, OpenOffice or Google Spreadsheets for creating and modifying the CSV file. Save this file with extension .CSV. After entering all details about products in spreadsheet, you can import product to your online store. With this plugin, you can also export and download product details as a CSV file.
|
31 |
-
|
32 |
-
= Premium version video demo =
|
33 |
-
[youtube http://www.youtube.com/watch?v=fBuf54rUakY&rel=0&showinfo=0]
|
34 |
-
|
35 |
-
<blockquote>
|
36 |
-
|
37 |
-
= Premium version Features =
|
38 |
-
Product Import Export Plugin for WooCommerce is the leading tool for Woocommerce product export and WooCommerce product import. Some of the major features are listed below
|
39 |
-
|
40 |
-
<ul>
|
41 |
-
<li>Export WooCommerce Products (Simple, Group, External and Variations) in to a CSV file.</li>
|
42 |
-
<li>Import Products in to WooCommerce (Simple, Group, External and Variations) in CSV format in to WooComemrce Store.</li>
|
43 |
-
<li>Export WooCommerce Products by Category.</li>
|
44 |
-
<li>Various Filter options for exporting WooCommerce Products. </li>
|
45 |
-
<li>Map and Transform fields while Importing WooCommerce Products.</li>
|
46 |
-
<li>Change values while importing WooCommerce products using Evaluation Fields.</li>
|
47 |
-
<li>Choice to Update or Skip existing imported products. </li>
|
48 |
-
<li>WPML Supported. French and German (Deutschland) language support Out of the Box.</li>
|
49 |
-
<li>Import/Export file from/to a remote server via FTP.</li>
|
50 |
-
<li>Automatic scheduled Import/Export.</li>
|
51 |
-
<li>Supports Product Reviews Export Import.</li>
|
52 |
-
<li>Excellent Support for setting it up!</li>
|
53 |
-
</ul>
|
54 |
-
|
55 |
-
Please visit <a rel="nofollow" href="https://www.xadapter.com/product/product-import-export-plugin-for-woocommerce/">Product Import Export Plugin for WooCommerce</a> for more details
|
56 |
-
|
57 |
-
</blockquote>
|
58 |
-
|
59 |
-
= Product Import Export Plugin for WooCommerce Premium Features =
|
60 |
-
|
61 |
-
WooCommerce import products & WooCommerce export products functionalities made easy.
|
62 |
-
|
63 |
-
[youtube http://www.youtube.com/watch?v=L-01qI1EZWE&rel=0&showinfo=0]
|
64 |
-
|
65 |
-
|
66 |
-
= woocommerce export products =
|
67 |
-
There are multiple cases where one need to export WooCommerce products. It could be either for sending the details to someone else or integrating with a third-party system. For example, you can export woocommerce products as csv file in to an ftp folder on a regular basis using the cron job. This can be read by any third-party application to update its data.
|
68 |
-
|
69 |
-
Export WooCommerce Products: Export and download product data in CSV file format. Plugins supports,
|
70 |
-
|
71 |
-
WooCommerce Simple Products
|
72 |
-
WooCommerce Variable Products.
|
73 |
-
WooCommerce Group Products.
|
74 |
-
WooCommerce External Products.
|
75 |
-
|
76 |
-
In addition, the plugin helps you export Categories, Tags, Products and other Product details into WooCommerce. You can export prices, descriptions, images etc apart from the custom fields (meta), taxonomies and attributes.
|
77 |
-
|
78 |
-
= How to export woocommerce products =
|
79 |
-
|
80 |
-
It is as simple as clicking a button. But if you need to customize your export we have enough advanced customization options built in to the woocommerce product export plugin.
|
81 |
-
|
82 |
-
= WooCommerce Import Products =
|
83 |
-
WooCommerce bulk product upload is one of the main use case where WooCommerce product import functionality is used. 'How to import products into woocommerce' is one of the common question people ask. Our WooCommerce product csv import suite is the perfect answer for this. With is plugin you can import products from any xml or csv to WooCommerce. This saves lot of time and minimises errors.
|
84 |
-
|
85 |
-
Woocommerce product import: You can use the import functionality to:
|
86 |
-
|
87 |
-
Import by selecting file from your computer
|
88 |
-
Import by providing file path on the server
|
89 |
-
Import from file in a remote server via FTP
|
90 |
-
Export Variable Products: Once you export variable product, you will have a simple single CSV which will have both variable and it’s parent details. It will help you to do any changes easily and enables faster import to any WooCommerce site.
|
91 |
-
|
92 |
-
= WooCommerce import variable products =
|
93 |
-
WooCommerce variable product import allows you to import all variations of the products easily. It imports all variable products and it’s properties from a single CSV file. This single CSV file will have both variable and parent data. WooCommerce csv import variable products is key feature of the WooCommerce product import plugin.
|
94 |
-
|
95 |
-
= WooCommerce import products with images =
|
96 |
-
|
97 |
-
A WooCommerce product importer which supports 'woocommerce import products with images' feature is common requirement. The premium plugin has this feature buit into it.
|
98 |
-
|
99 |
-
|
100 |
-
= Other features =
|
101 |
-
|
102 |
-
Export Products by Category: You can even choose desired product categories from the Plugin Settings Page and those Products belongs to selected categories will be exported.
|
103 |
-
|
104 |
-
Export Products by Type: You can selectively export products belonging to specific product types. All you need to do is choose the required product types from the plugin settings page while exporting.
|
105 |
-
Merge Products: This feature is useful for adding more information to existing products, for example when your existing products get modified. To get the modified product details into your online store, you can update the current product by importing modified product CSV file.
|
106 |
-
|
107 |
-
Map and Transform: You can map the fields ( WooCommerce fields ) with column headings ( CSV file header ). To map, select the required field under “Map to Column�? by using drop-down list for a particular column heading. An Evaluation field is used to fix/update the required value for the particular field.
|
108 |
-
|
109 |
-
Cron Job / Scheduled Import Export: WooCommerce Product Import and Export plugin facilitates to schedule the Import and Export of the products. You can auto import the products at regular intervals from CSV which is present on FTP Server by providing starting time and intervals between import. There is an option to skip new products in scheduled import too. You can also auto export the products to FTP in a CSV file at regular intervals. There is also option to use saved mapping files for auto export.
|
110 |
-
|
111 |
-
Supports WooCommerce Product Bundles Plugin.
|
112 |
-
Supports Yoast WooCommerce SEO Plugin.
|
113 |
-
Supports WooCommerce Google Product Feed Plugin.
|
114 |
-
Supports Scheduled Cron Job.
|
115 |
-
|
116 |
-
|
117 |
-
= About XAdapter.com =
|
118 |
-
|
119 |
-
XAdapter creates quality WordPress/WooCommerce plugins that are easy to use and customize. We are proud to have thousands of customers actively using our plugins across the globe.
|
120 |
-
|
121 |
-
|
122 |
-
== Installation ==
|
123 |
-
|
124 |
-
1. Upload the plugin folder to the /wp-content/plugins/ directory.
|
125 |
-
2. Activate the plugin through the Plugins menu in WordPress.
|
126 |
-
3. Thats it! you can now configure the plugin.
|
127 |
-
|
128 |
-
== Frequently Asked Questions ==
|
129 |
-
|
130 |
-
= Does this plugin support of images? =
|
131 |
-
|
132 |
-
Yes. You can import or export product images along with other details
|
133 |
-
|
134 |
-
== Screenshots ==
|
135 |
-
|
136 |
-
1. WooCommerce Product Import Screen
|
137 |
-
|
138 |
-
2. WooCommerce Product Export Screen
|
139 |
-
|
140 |
-
3. Premium Export Settings Screen
|
141 |
-
|
142 |
-
== Changelog ==
|
143 |
-
= 1.4.
|
144 |
-
*
|
145 |
-
*
|
146 |
-
|
147 |
-
|
148 |
-
*
|
149 |
-
* Updates: Tested OK with WC 3.
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
*
|
154 |
-
= 1.4.
|
155 |
-
* Updates: Tested OK with WP 4.9
|
156 |
-
= 1.
|
157 |
-
*
|
158 |
-
= 1.
|
159 |
-
*
|
160 |
-
= 1.3.
|
161 |
-
*
|
162 |
-
= 1.3.
|
163 |
-
*
|
164 |
-
= 1.3.
|
165 |
-
*
|
166 |
-
= 1.3.
|
167 |
-
*
|
168 |
-
= 1.3.
|
169 |
-
*
|
170 |
-
= 1.3.
|
171 |
-
*
|
172 |
-
= 1.3.
|
173 |
-
*
|
174 |
-
= 1.3.
|
175 |
-
*
|
176 |
-
= 1.
|
177 |
-
*
|
178 |
-
= 1.
|
179 |
-
*
|
180 |
-
= 1.2.
|
181 |
-
*
|
182 |
-
= 1.2.
|
183 |
-
*
|
184 |
-
= 1.2.
|
185 |
-
*
|
186 |
-
= 1.1
|
187 |
-
*
|
188 |
-
= 1.
|
189 |
-
* Enhancement:
|
190 |
-
= 1.1.
|
191 |
-
* Enhancement:
|
192 |
-
= 1.1.
|
193 |
-
* Enhancement:
|
194 |
-
= 1.1.
|
195 |
-
*
|
196 |
-
= 1.1.
|
197 |
-
*
|
198 |
-
= 1.1.
|
199 |
-
* Bug fix:
|
200 |
-
= 1.1.
|
201 |
-
*
|
202 |
-
= 1.1.
|
203 |
-
*
|
204 |
-
= 1.1.
|
205 |
-
*
|
206 |
-
= 1.
|
207 |
-
*
|
208 |
-
= 1.0
|
209 |
-
*
|
210 |
-
= 1.0.
|
211 |
-
*
|
212 |
-
= 1.0.
|
213 |
-
*
|
214 |
-
= 1.0.
|
215 |
-
*
|
216 |
-
= 1.0.
|
217 |
-
* Bug Fix:
|
218 |
-
= 1.0.
|
219 |
-
*
|
220 |
-
= 1.0.
|
221 |
-
* Bug Fix: Improved
|
222 |
-
= 1.0.
|
223 |
-
* Bug Fix:
|
224 |
-
|
225 |
-
*
|
226 |
-
|
227 |
-
*
|
228 |
-
|
229 |
-
*
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
|
|
|
|
|
1 |
+
=== Product Import Export for WooCommerce===
|
2 |
+
Contributors: webtoffee
|
3 |
+
Donate link:
|
4 |
+
Tags: woocommerce product import, woocommerce import products, woocommerce export products, export woocommerce products, import products into woocommerce
|
5 |
+
Requires at least: 3.0.1
|
6 |
+
Tested up to: 4.9.7
|
7 |
+
Stable tag: 1.4.5
|
8 |
+
License: GPLv3 or later
|
9 |
+
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
+
|
11 |
+
Easily import products into WooCommerce store or export WooCommerce products from the store. Import WooCommerce Products from any CSV to WooCommerce.
|
12 |
+
|
13 |
+
== Description ==
|
14 |
+
|
15 |
+
= Introduction =
|
16 |
+
|
17 |
+
Are you trying to import products into WooCommerce store or export WooCommerce products from the store. This Product import export plugin allows you to import or export WooCommerce simple products ( other pproduct types such as variable products are available only in premium version). It is super simple!
|
18 |
+
|
19 |
+
<ul>
|
20 |
+
<li>Export Simple Products in to a CSV file.</li>
|
21 |
+
<li>Import Simple Products in CSV format in to WooCommerce Store.</li>
|
22 |
+
</ul>
|
23 |
+
|
24 |
+
Highlights: WooCommerce Product Export, WooCommerce Product CSV Import Suite, WooCommerce bulk product upload, WooCommerce import products with images, import amazon products to WooCommerce, Export Products to xls. Pro Version supports both Simple and Variable products.
|
25 |
+
|
26 |
+
= How does it work? =
|
27 |
+
|
28 |
+
The WooCommerce Product Import Export Plugin takes CSV (Comma-Separated Values) file as input. You must create a CSV ( UTF-8 Encoded ) file and enter the product details in a structured format as explained in the tutorial. This is to match each field of CSV file to the field of a particular product that otherwise Admin need to input manually. For example: the post_title field gets mapped to the product name and the regular_price field gets mapped to the regular price of the product. For the plugin to work correctly, you must map headers of all of the column correctly and you must ensure that all of the fields you enter must be in the correct format.
|
29 |
+
|
30 |
+
You can create the CSV from scratch or you can export the product to get the format of CSV. You can use a spreadsheet program, such as LibreOffice , Microsoft Excel, OpenOffice or Google Spreadsheets for creating and modifying the CSV file. Save this file with extension .CSV. After entering all details about products in spreadsheet, you can import product to your online store. With this plugin, you can also export and download product details as a CSV file.
|
31 |
+
|
32 |
+
= Premium version video demo =
|
33 |
+
[youtube http://www.youtube.com/watch?v=fBuf54rUakY&rel=0&showinfo=0]
|
34 |
+
|
35 |
+
<blockquote>
|
36 |
+
|
37 |
+
= Premium version Features =
|
38 |
+
Product Import Export Plugin for WooCommerce is the leading tool for Woocommerce product export and WooCommerce product import. Some of the major features are listed below
|
39 |
+
|
40 |
+
<ul>
|
41 |
+
<li>Export WooCommerce Products (Simple, Group, External and Variations) in to a CSV file.</li>
|
42 |
+
<li>Import Products in to WooCommerce (Simple, Group, External and Variations) in CSV format in to WooComemrce Store.</li>
|
43 |
+
<li>Export WooCommerce Products by Category.</li>
|
44 |
+
<li>Various Filter options for exporting WooCommerce Products. </li>
|
45 |
+
<li>Map and Transform fields while Importing WooCommerce Products.</li>
|
46 |
+
<li>Change values while importing WooCommerce products using Evaluation Fields.</li>
|
47 |
+
<li>Choice to Update or Skip existing imported products. </li>
|
48 |
+
<li>WPML Supported. French and German (Deutschland) language support Out of the Box.</li>
|
49 |
+
<li>Import/Export file from/to a remote server via FTP.</li>
|
50 |
+
<li>Automatic scheduled Import/Export.</li>
|
51 |
+
<li>Supports Product Reviews Export Import.</li>
|
52 |
+
<li>Excellent Support for setting it up!</li>
|
53 |
+
</ul>
|
54 |
+
|
55 |
+
Please visit <a rel="nofollow" href="https://www.xadapter.com/product/product-import-export-plugin-for-woocommerce/">Product Import Export Plugin for WooCommerce</a> for more details
|
56 |
+
|
57 |
+
</blockquote>
|
58 |
+
|
59 |
+
= Product Import Export Plugin for WooCommerce Premium Features =
|
60 |
+
|
61 |
+
WooCommerce import products & WooCommerce export products functionalities made easy.
|
62 |
+
|
63 |
+
[youtube http://www.youtube.com/watch?v=L-01qI1EZWE&rel=0&showinfo=0]
|
64 |
+
|
65 |
+
|
66 |
+
= woocommerce export products =
|
67 |
+
There are multiple cases where one need to export WooCommerce products. It could be either for sending the details to someone else or integrating with a third-party system. For example, you can export woocommerce products as csv file in to an ftp folder on a regular basis using the cron job. This can be read by any third-party application to update its data.
|
68 |
+
|
69 |
+
Export WooCommerce Products: Export and download product data in CSV file format. Plugins supports,
|
70 |
+
|
71 |
+
WooCommerce Simple Products
|
72 |
+
WooCommerce Variable Products.
|
73 |
+
WooCommerce Group Products.
|
74 |
+
WooCommerce External Products.
|
75 |
+
|
76 |
+
In addition, the plugin helps you export Categories, Tags, Products and other Product details into WooCommerce. You can export prices, descriptions, images etc apart from the custom fields (meta), taxonomies and attributes.
|
77 |
+
|
78 |
+
= How to export woocommerce products =
|
79 |
+
|
80 |
+
It is as simple as clicking a button. But if you need to customize your export we have enough advanced customization options built in to the woocommerce product export plugin.
|
81 |
+
|
82 |
+
= WooCommerce Import Products =
|
83 |
+
WooCommerce bulk product upload is one of the main use case where WooCommerce product import functionality is used. 'How to import products into woocommerce' is one of the common question people ask. Our WooCommerce product csv import suite is the perfect answer for this. With is plugin you can import products from any xml or csv to WooCommerce. This saves lot of time and minimises errors.
|
84 |
+
|
85 |
+
Woocommerce product import: You can use the import functionality to:
|
86 |
+
|
87 |
+
Import by selecting file from your computer
|
88 |
+
Import by providing file path on the server
|
89 |
+
Import from file in a remote server via FTP
|
90 |
+
Export Variable Products: Once you export variable product, you will have a simple single CSV which will have both variable and it’s parent details. It will help you to do any changes easily and enables faster import to any WooCommerce site.
|
91 |
+
|
92 |
+
= WooCommerce import variable products =
|
93 |
+
WooCommerce variable product import allows you to import all variations of the products easily. It imports all variable products and it’s properties from a single CSV file. This single CSV file will have both variable and parent data. WooCommerce csv import variable products is key feature of the WooCommerce product import plugin.
|
94 |
+
|
95 |
+
= WooCommerce import products with images =
|
96 |
+
|
97 |
+
A WooCommerce product importer which supports 'woocommerce import products with images' feature is common requirement. The premium plugin has this feature buit into it.
|
98 |
+
|
99 |
+
|
100 |
+
= Other features =
|
101 |
+
|
102 |
+
Export Products by Category: You can even choose desired product categories from the Plugin Settings Page and those Products belongs to selected categories will be exported.
|
103 |
+
|
104 |
+
Export Products by Type: You can selectively export products belonging to specific product types. All you need to do is choose the required product types from the plugin settings page while exporting.
|
105 |
+
Merge Products: This feature is useful for adding more information to existing products, for example when your existing products get modified. To get the modified product details into your online store, you can update the current product by importing modified product CSV file.
|
106 |
+
|
107 |
+
Map and Transform: You can map the fields ( WooCommerce fields ) with column headings ( CSV file header ). To map, select the required field under “Map to Column�? by using drop-down list for a particular column heading. An Evaluation field is used to fix/update the required value for the particular field.
|
108 |
+
|
109 |
+
Cron Job / Scheduled Import Export: WooCommerce Product Import and Export plugin facilitates to schedule the Import and Export of the products. You can auto import the products at regular intervals from CSV which is present on FTP Server by providing starting time and intervals between import. There is an option to skip new products in scheduled import too. You can also auto export the products to FTP in a CSV file at regular intervals. There is also option to use saved mapping files for auto export.
|
110 |
+
|
111 |
+
Supports WooCommerce Product Bundles Plugin.
|
112 |
+
Supports Yoast WooCommerce SEO Plugin.
|
113 |
+
Supports WooCommerce Google Product Feed Plugin.
|
114 |
+
Supports Scheduled Cron Job.
|
115 |
+
|
116 |
+
|
117 |
+
= About XAdapter.com =
|
118 |
+
|
119 |
+
XAdapter creates quality WordPress/WooCommerce plugins that are easy to use and customize. We are proud to have thousands of customers actively using our plugins across the globe.
|
120 |
+
|
121 |
+
|
122 |
+
== Installation ==
|
123 |
+
|
124 |
+
1. Upload the plugin folder to the /wp-content/plugins/ directory.
|
125 |
+
2. Activate the plugin through the Plugins menu in WordPress.
|
126 |
+
3. Thats it! you can now configure the plugin.
|
127 |
+
|
128 |
+
== Frequently Asked Questions ==
|
129 |
+
|
130 |
+
= Does this plugin support of images? =
|
131 |
+
|
132 |
+
Yes. You can import or export product images along with other details
|
133 |
+
|
134 |
+
== Screenshots ==
|
135 |
+
|
136 |
+
1. WooCommerce Product Import Screen
|
137 |
+
|
138 |
+
2. WooCommerce Product Export Screen
|
139 |
+
|
140 |
+
3. Premium Export Settings Screen
|
141 |
+
|
142 |
+
== Changelog ==
|
143 |
+
= 1.4.5 =
|
144 |
+
* Tested OK with WC 3.4.3
|
145 |
+
* Image import process improved.
|
146 |
+
= 1.4.4 =
|
147 |
+
* Sample CSVs are updated.
|
148 |
+
* Enhancement: Improved parsing.
|
149 |
+
* Updates: Tested OK with WP 4.9.6 and WC 3.4.2
|
150 |
+
* Fixed warnings.
|
151 |
+
= 1.4.3 =
|
152 |
+
* Updates: Interface updated.
|
153 |
+
* Updates: Tested OK with WC 3.3.3
|
154 |
+
= 1.4.2 =
|
155 |
+
* Updates: Tested OK with WP 4.9.4 and WC 3.3.1
|
156 |
+
= 1.4.1 =
|
157 |
+
* Minor content updates
|
158 |
+
= 1.4.0 =
|
159 |
+
* Updates: Tested OK with WP 4.9
|
160 |
+
= 1.3.9 =
|
161 |
+
* BugFix: Invalid argument for foreach loop
|
162 |
+
= 1.3.8 =
|
163 |
+
* BugFix: Product not importing at 100n. n=1,2...
|
164 |
+
= 1.3.7 =
|
165 |
+
* Fixed conflict with Plus version.
|
166 |
+
= 1.3.6 =
|
167 |
+
* Fixed some warnings.
|
168 |
+
= 1.3.5 =
|
169 |
+
* Minor Content Change.
|
170 |
+
= 1.3.4 =
|
171 |
+
* Updates: Added video tutorial.
|
172 |
+
= 1.3.3 =
|
173 |
+
* BugFix: Same title product import message update.
|
174 |
+
= 1.3.2 =
|
175 |
+
* Minor content change.
|
176 |
+
= 1.3.1 =
|
177 |
+
* Function modified for Woocommerce 3.0 Compatibility.
|
178 |
+
= 1.3.0 =
|
179 |
+
* Woocommerce 3.0 Compatibility.
|
180 |
+
= 1.2.4 =
|
181 |
+
* Marketing Content Changed.
|
182 |
+
= 1.2.3 =
|
183 |
+
* New Icon Updated.
|
184 |
+
= 1.2.2 =
|
185 |
+
* Minor content change.
|
186 |
+
= 1.2.1 =
|
187 |
+
* Optimization: Image URL parsing.
|
188 |
+
= 1.2.0 =
|
189 |
+
* Enhancement: German Translation updates.
|
190 |
+
= 1.1.9 =
|
191 |
+
* Enhancement: WPML Support updates.
|
192 |
+
= 1.1.8 =
|
193 |
+
* Enhancement: Security improvements and bug fix.
|
194 |
+
= 1.1.7 =
|
195 |
+
* Enhancement: Security improvements.
|
196 |
+
= 1.1.6 =
|
197 |
+
* Enhancement: Sample CSV updated.
|
198 |
+
= 1.1.5 =
|
199 |
+
* Bug fix: Improved parsing.
|
200 |
+
= 1.1.4 =
|
201 |
+
* Bug fix: Removed deprecated function.
|
202 |
+
= 1.1.3 =
|
203 |
+
* Bug fix: Empty check validation updated.
|
204 |
+
= 1.1.2 =
|
205 |
+
* Minor content change.
|
206 |
+
= 1.1.1 =
|
207 |
+
* Enhancement: Import products that have same title.
|
208 |
+
= 1.1.0 =
|
209 |
+
* Italian Translation added.
|
210 |
+
= 1.0.9 =
|
211 |
+
* Hungarian Translation added.
|
212 |
+
= 1.0.8 =
|
213 |
+
* Minor content change.
|
214 |
+
= 1.0.7 =
|
215 |
+
* Enhancement: Updated support forum links and contact details.
|
216 |
+
= 1.0.6 =
|
217 |
+
* Bug Fix: fixed issue with SKU while exporting.
|
218 |
+
= 1.0.5 =
|
219 |
+
* Feature: Added Multilingual support and French Translation.
|
220 |
+
= 1.0.4 =
|
221 |
+
* Bug Fix: Improved Evaluation field and help message in mapping section.
|
222 |
+
= 1.0.3 =
|
223 |
+
* Bug Fix: Sorting priority Set to ID by default while exporting.
|
224 |
+
= 1.0.2 =
|
225 |
+
* Bug Fix: Improved parsing while importing product price with currency symbol and thousand separator.
|
226 |
+
= 1.0.1 =
|
227 |
+
* Bug Fix: Fixed issue with Evaluation field with single quotes.
|
228 |
+
* Bug Fix: Option to import gallery images.
|
229 |
+
* Enhancement: Improved help text for Post name and Stock quantity.
|
230 |
+
* Enhancement: Improved label text for Product type, category , tags and shipping class.
|
231 |
+
* Enhancement: Included links to Documentation and sample CSV.
|
232 |
+
= 1.0.0 =
|
233 |
+
* Import /Export Woocommerce Products.
|
234 |
+
|
235 |
+
|
236 |
+
== Upgrade Notice ==
|
237 |
+
|
238 |
+
= 1.4.5 =
|
239 |
+
* Tested OK with WC 3.4.3
|
240 |
+
* Image import process improved.
|
styles/wf-style.css
CHANGED
@@ -1,232 +1,232 @@
|
|
1 |
-
#icon-woocommerce-importer {
|
2 |
-
background-image: url(../images/wf-import.png) !important;
|
3 |
-
background-position: -3px -5px;
|
4 |
-
}
|
5 |
-
.widefat_importer td {
|
6 |
-
vertical-align: middle;
|
7 |
-
padding: 5px 9px;
|
8 |
-
}
|
9 |
-
#import-progress {
|
10 |
-
width: 100%;
|
11 |
-
}
|
12 |
-
#import-progress td, #import-progress th {
|
13 |
-
padding: .5em 1em;
|
14 |
-
}
|
15 |
-
#import-progress td.status, #import-progress th.status {
|
16 |
-
width: 32px;
|
17 |
-
}
|
18 |
-
#import-progress td.row, #import-progress th.row {
|
19 |
-
width: 3em;
|
20 |
-
text-align: center;
|
21 |
-
}
|
22 |
-
#import-progress td.reason, #import-progress th.reason {
|
23 |
-
text-align: right;
|
24 |
-
}
|
25 |
-
#import-progress tr.importer-loading td {
|
26 |
-
background: url(../images/wf-ajax-loader.gif) no-repeat center center;
|
27 |
-
height: 32px;
|
28 |
-
}
|
29 |
-
#import-progress .merged td,
|
30 |
-
#import-progress .imported td {
|
31 |
-
}
|
32 |
-
#import-progress .skipped td {
|
33 |
-
border-bottom-color: #dbcb83;
|
34 |
-
background: #f2ecd2;
|
35 |
-
}
|
36 |
-
#import-progress .failed td {
|
37 |
-
border-bottom-color: #e6adaa;
|
38 |
-
background: #f2d3d2;
|
39 |
-
}
|
40 |
-
#import-progress mark.result {
|
41 |
-
height: 0;
|
42 |
-
display: block;
|
43 |
-
line-height: 16px;
|
44 |
-
overflow: hidden;
|
45 |
-
padding: 16px 0 0 0;
|
46 |
-
}
|
47 |
-
#import-progress .skipped mark.result {
|
48 |
-
background: url(../images/wf-notice.png) no-repeat center top;
|
49 |
-
}
|
50 |
-
#import-progress .merged mark.result,
|
51 |
-
#import-progress .imported mark.result {
|
52 |
-
background: url(../images/wf-success.png) no-repeat center top;
|
53 |
-
}
|
54 |
-
#import-progress .failed mark.result {
|
55 |
-
background: url(../images/wf-failed.png) no-repeat center top;
|
56 |
-
}
|
57 |
-
#import-progress .complete td {
|
58 |
-
background: #000;
|
59 |
-
border-color: #000;
|
60 |
-
border-top: 4px solid #000;
|
61 |
-
color: #fff;
|
62 |
-
font-size: 1.5em;
|
63 |
-
padding: .95em 1em 1em;
|
64 |
-
text-align: center;
|
65 |
-
}
|
66 |
-
#import-progress .regenerating td {
|
67 |
-
padding: 0;
|
68 |
-
}
|
69 |
-
#import-progress .regenerating div.progress {
|
70 |
-
background: #464646;
|
71 |
-
padding: .95em 1em 1em;
|
72 |
-
color: #fff;
|
73 |
-
overflow: hidden;
|
74 |
-
width: 0;
|
75 |
-
float: left;
|
76 |
-
text-align: left;
|
77 |
-
white-space: nowrap;
|
78 |
-
}
|
79 |
-
.update{
|
80 |
-
background: #fff;
|
81 |
-
border-left: 4px solid #fff;
|
82 |
-
padding: 1px 12px;
|
83 |
-
border-left-color: #46b450;
|
84 |
-
margin-top: 10px;
|
85 |
-
}
|
86 |
-
#datagrid { border-collapse: collapse; text-align: left; width: 90%; }
|
87 |
-
#datagrid {
|
88 |
-
background: #fff; overflow: hidden;
|
89 |
-
}
|
90 |
-
#datagrid td{ padding: 3px 25px; }
|
91 |
-
#datagrid th { padding: 3px 25px; color: #fff; background-color: #ccc; font-weight: bold;font-size: 15px; }
|
92 |
-
#datagrid td input {
|
93 |
-
margin-top: 4px;
|
94 |
-
}
|
95 |
-
|
96 |
-
.woocommerce-message a.button-primary, .woocommerce-message button.button-primary{
|
97 |
-
background: #0085ba none repeat scroll 0 0 !important;
|
98 |
-
border-color: #0073aa #006799 #006799 !important;}
|
99 |
-
.woocommerce-message{border-left-color:#46b450 !important;}
|
100 |
-
.rate-star{
|
101 |
-
background: rgba(0, 0, 0, 0) url("../images/stars.png") no-repeat scroll 0 0;
|
102 |
-
display: inline-block;
|
103 |
-
height: 24px;
|
104 |
-
position: relative;
|
105 |
-
top: 10px;
|
106 |
-
width: 125px;
|
107 |
-
}
|
108 |
-
.rate-us{
|
109 |
-
background-color: #ffeeff;
|
110 |
-
border-color: #e6db55;
|
111 |
-
border-radius: 3px;
|
112 |
-
border-style: solid;
|
113 |
-
border-width: 1px;
|
114 |
-
margin: 15px 0;
|
115 |
-
padding: 0 0.6em;
|
116 |
-
}
|
117 |
-
.clearfix{
|
118 |
-
clear: both;
|
119 |
-
}
|
120 |
-
.nav-tab-wrapper .nav-tab-premium {
|
121 |
-
background: #5ccc96;
|
122 |
-
color: white;
|
123 |
-
border-color: #5ccc96;
|
124 |
-
}
|
125 |
-
.pipe-main-box{
|
126 |
-
width: 100%;
|
127 |
-
}
|
128 |
-
.pipe-main-box input {
|
129 |
-
box-shadow: none;
|
130 |
-
padding: 7px 10px;
|
131 |
-
}
|
132 |
-
.pipe-view{
|
133 |
-
width:65%;
|
134 |
-
float: left;
|
135 |
-
}
|
136 |
-
.market-box{
|
137 |
-
width:30%;
|
138 |
-
float: right;
|
139 |
-
}
|
140 |
-
.bg-white {
|
141 |
-
background: #fff;
|
142 |
-
}
|
143 |
-
.p-20p {
|
144 |
-
padding: 20px;
|
145 |
-
}
|
146 |
-
.getting-started-video{
|
147 |
-
background: #fff;
|
148 |
-
padding: 5px;
|
149 |
-
margin-bottom: 23px;
|
150 |
-
}
|
151 |
-
.getting-started-video h2{
|
152 |
-
text-align: center;
|
153 |
-
padding: 5px;
|
154 |
-
}
|
155 |
-
|
156 |
-
.getting-started-video iframe{
|
157 |
-
margin:5px auto 25px auto;
|
158 |
-
display: block;
|
159 |
-
}
|
160 |
-
.pipe-premium-features{
|
161 |
-
background: #fff;
|
162 |
-
padding:5px;
|
163 |
-
}
|
164 |
-
.pipe-premium-features ul {
|
165 |
-
padding-left: 20px;
|
166 |
-
padding-right: 20px;
|
167 |
-
}
|
168 |
-
.pipe-premium-features li {
|
169 |
-
margin-bottom: 15px;
|
170 |
-
padding-left: 15px;
|
171 |
-
}
|
172 |
-
.pipe-premium-features li:before
|
173 |
-
{
|
174 |
-
font-family: dashicons;
|
175 |
-
text-decoration: inherit;
|
176 |
-
font-weight: 400;
|
177 |
-
font-style: normal;
|
178 |
-
vertical-align: top;
|
179 |
-
text-align: center;
|
180 |
-
content: "\f147";
|
181 |
-
margin-right: 10px;
|
182 |
-
margin-left: -25px;
|
183 |
-
font-size: 16px;
|
184 |
-
color: #3085bb;
|
185 |
-
}
|
186 |
-
.pipe-premium-features .button {
|
187 |
-
margin-bottom: 20px;
|
188 |
-
}
|
189 |
-
.pipe-premium-features .button-go-pro {
|
190 |
-
box-shadow: none;
|
191 |
-
border: 0;
|
192 |
-
text-shadow: none;
|
193 |
-
padding: 10px 15px;
|
194 |
-
height: auto;
|
195 |
-
font-size: 18px;
|
196 |
-
border-radius: 4px;
|
197 |
-
font-weight: 600;
|
198 |
-
background: #00cb95;
|
199 |
-
margin-top: 20px;
|
200 |
-
}
|
201 |
-
.pipe-premium-features .button-go-pro:hover,
|
202 |
-
.pipe-premium-features .button-go-pro:focus,
|
203 |
-
.pipe-premium-features .button-go-pro:active {
|
204 |
-
background: #00a378;
|
205 |
-
}
|
206 |
-
.pipe-premium-features .button-doc-demo {
|
207 |
-
border: 0;
|
208 |
-
background: #d8d8dc;
|
209 |
-
box-shadow: none;
|
210 |
-
padding: 10px 15px;
|
211 |
-
font-size: 15px;
|
212 |
-
height: auto;
|
213 |
-
margin-left: 10px;
|
214 |
-
margin-right: 10px;
|
215 |
-
margin-top: 10px;
|
216 |
-
}
|
217 |
-
.pipe-premium-features .button-doc-demo:hover,
|
218 |
-
.pipe-premium-features .button-doc-demo:focus,
|
219 |
-
.pipe-premium-features .button-doc-demo:active {
|
220 |
-
background: #dfdfe4;
|
221 |
-
}
|
222 |
-
.xa-pipe-rating-link{color:#ffc600;}
|
223 |
-
|
224 |
-
.pipe-review-widget{
|
225 |
-
background: #fff;
|
226 |
-
padding: 5px;
|
227 |
-
margin-top: 23px;
|
228 |
-
}
|
229 |
-
.pipe-review-widget p{
|
230 |
-
margin-right:5px;
|
231 |
-
margin-left:5px;
|
232 |
}
|
1 |
+
#icon-woocommerce-importer {
|
2 |
+
background-image: url(../images/wf-import.png) !important;
|
3 |
+
background-position: -3px -5px;
|
4 |
+
}
|
5 |
+
.widefat_importer td {
|
6 |
+
vertical-align: middle;
|
7 |
+
padding: 5px 9px;
|
8 |
+
}
|
9 |
+
#import-progress {
|
10 |
+
width: 100%;
|
11 |
+
}
|
12 |
+
#import-progress td, #import-progress th {
|
13 |
+
padding: .5em 1em;
|
14 |
+
}
|
15 |
+
#import-progress td.status, #import-progress th.status {
|
16 |
+
width: 32px;
|
17 |
+
}
|
18 |
+
#import-progress td.row, #import-progress th.row {
|
19 |
+
width: 3em;
|
20 |
+
text-align: center;
|
21 |
+
}
|
22 |
+
#import-progress td.reason, #import-progress th.reason {
|
23 |
+
text-align: right;
|
24 |
+
}
|
25 |
+
#import-progress tr.importer-loading td {
|
26 |
+
background: url(../images/wf-ajax-loader.gif) no-repeat center center;
|
27 |
+
height: 32px;
|
28 |
+
}
|
29 |
+
#import-progress .merged td,
|
30 |
+
#import-progress .imported td {
|
31 |
+
}
|
32 |
+
#import-progress .skipped td {
|
33 |
+
border-bottom-color: #dbcb83;
|
34 |
+
background: #f2ecd2;
|
35 |
+
}
|
36 |
+
#import-progress .failed td {
|
37 |
+
border-bottom-color: #e6adaa;
|
38 |
+
background: #f2d3d2;
|
39 |
+
}
|
40 |
+
#import-progress mark.result {
|
41 |
+
height: 0;
|
42 |
+
display: block;
|
43 |
+
line-height: 16px;
|
44 |
+
overflow: hidden;
|
45 |
+
padding: 16px 0 0 0;
|
46 |
+
}
|
47 |
+
#import-progress .skipped mark.result {
|
48 |
+
background: url(../images/wf-notice.png) no-repeat center top;
|
49 |
+
}
|
50 |
+
#import-progress .merged mark.result,
|
51 |
+
#import-progress .imported mark.result {
|
52 |
+
background: url(../images/wf-success.png) no-repeat center top;
|
53 |
+
}
|
54 |
+
#import-progress .failed mark.result {
|
55 |
+
background: url(../images/wf-failed.png) no-repeat center top;
|
56 |
+
}
|
57 |
+
#import-progress .complete td {
|
58 |
+
background: #000;
|
59 |
+
border-color: #000;
|
60 |
+
border-top: 4px solid #000;
|
61 |
+
color: #fff;
|
62 |
+
font-size: 1.5em;
|
63 |
+
padding: .95em 1em 1em;
|
64 |
+
text-align: center;
|
65 |
+
}
|
66 |
+
#import-progress .regenerating td {
|
67 |
+
padding: 0;
|
68 |
+
}
|
69 |
+
#import-progress .regenerating div.progress {
|
70 |
+
background: #464646;
|
71 |
+
padding: .95em 1em 1em;
|
72 |
+
color: #fff;
|
73 |
+
overflow: hidden;
|
74 |
+
width: 0;
|
75 |
+
float: left;
|
76 |
+
text-align: left;
|
77 |
+
white-space: nowrap;
|
78 |
+
}
|
79 |
+
.update{
|
80 |
+
background: #fff;
|
81 |
+
border-left: 4px solid #fff;
|
82 |
+
padding: 1px 12px;
|
83 |
+
border-left-color: #46b450;
|
84 |
+
margin-top: 10px;
|
85 |
+
}
|
86 |
+
#datagrid { border-collapse: collapse; text-align: left; width: 90%; }
|
87 |
+
#datagrid {
|
88 |
+
background: #fff; overflow: hidden;
|
89 |
+
}
|
90 |
+
#datagrid td{ padding: 3px 25px; }
|
91 |
+
#datagrid th { padding: 3px 25px; color: #fff; background-color: #ccc; font-weight: bold;font-size: 15px; }
|
92 |
+
#datagrid td input {
|
93 |
+
margin-top: 4px;
|
94 |
+
}
|
95 |
+
|
96 |
+
.woocommerce-message a.button-primary, .woocommerce-message button.button-primary{
|
97 |
+
background: #0085ba none repeat scroll 0 0 !important;
|
98 |
+
border-color: #0073aa #006799 #006799 !important;}
|
99 |
+
.woocommerce-message{border-left-color:#46b450 !important;}
|
100 |
+
.rate-star{
|
101 |
+
background: rgba(0, 0, 0, 0) url("../images/stars.png") no-repeat scroll 0 0;
|
102 |
+
display: inline-block;
|
103 |
+
height: 24px;
|
104 |
+
position: relative;
|
105 |
+
top: 10px;
|
106 |
+
width: 125px;
|
107 |
+
}
|
108 |
+
.rate-us{
|
109 |
+
background-color: #ffeeff;
|
110 |
+
border-color: #e6db55;
|
111 |
+
border-radius: 3px;
|
112 |
+
border-style: solid;
|
113 |
+
border-width: 1px;
|
114 |
+
margin: 15px 0;
|
115 |
+
padding: 0 0.6em;
|
116 |
+
}
|
117 |
+
.clearfix{
|
118 |
+
clear: both;
|
119 |
+
}
|
120 |
+
.nav-tab-wrapper .nav-tab-premium {
|
121 |
+
background: #5ccc96;
|
122 |
+
color: white;
|
123 |
+
border-color: #5ccc96;
|
124 |
+
}
|
125 |
+
.pipe-main-box{
|
126 |
+
width: 100%;
|
127 |
+
}
|
128 |
+
.pipe-main-box input {
|
129 |
+
box-shadow: none;
|
130 |
+
padding: 7px 10px;
|
131 |
+
}
|
132 |
+
.pipe-view{
|
133 |
+
width:65%;
|
134 |
+
float: left;
|
135 |
+
}
|
136 |
+
.market-box{
|
137 |
+
width:30%;
|
138 |
+
float: right;
|
139 |
+
}
|
140 |
+
.bg-white {
|
141 |
+
background: #fff;
|
142 |
+
}
|
143 |
+
.p-20p {
|
144 |
+
padding: 20px;
|
145 |
+
}
|
146 |
+
.getting-started-video{
|
147 |
+
background: #fff;
|
148 |
+
padding: 5px;
|
149 |
+
margin-bottom: 23px;
|
150 |
+
}
|
151 |
+
.getting-started-video h2{
|
152 |
+
text-align: center;
|
153 |
+
padding: 5px;
|
154 |
+
}
|
155 |
+
|
156 |
+
.getting-started-video iframe{
|
157 |
+
margin:5px auto 25px auto;
|
158 |
+
display: block;
|
159 |
+
}
|
160 |
+
.pipe-premium-features{
|
161 |
+
background: #fff;
|
162 |
+
padding:5px;
|
163 |
+
}
|
164 |
+
.pipe-premium-features ul {
|
165 |
+
padding-left: 20px;
|
166 |
+
padding-right: 20px;
|
167 |
+
}
|
168 |
+
.pipe-premium-features li {
|
169 |
+
margin-bottom: 15px;
|
170 |
+
padding-left: 15px;
|
171 |
+
}
|
172 |
+
.pipe-premium-features li:before
|
173 |
+
{
|
174 |
+
font-family: dashicons;
|
175 |
+
text-decoration: inherit;
|
176 |
+
font-weight: 400;
|
177 |
+
font-style: normal;
|
178 |
+
vertical-align: top;
|
179 |
+
text-align: center;
|
180 |
+
content: "\f147";
|
181 |
+
margin-right: 10px;
|
182 |
+
margin-left: -25px;
|
183 |
+
font-size: 16px;
|
184 |
+
color: #3085bb;
|
185 |
+
}
|
186 |
+
.pipe-premium-features .button {
|
187 |
+
margin-bottom: 20px;
|
188 |
+
}
|
189 |
+
.pipe-premium-features .button-go-pro {
|
190 |
+
box-shadow: none;
|
191 |
+
border: 0;
|
192 |
+
text-shadow: none;
|
193 |
+
padding: 10px 15px;
|
194 |
+
height: auto;
|
195 |
+
font-size: 18px;
|
196 |
+
border-radius: 4px;
|
197 |
+
font-weight: 600;
|
198 |
+
background: #00cb95;
|
199 |
+
margin-top: 20px;
|
200 |
+
}
|
201 |
+
.pipe-premium-features .button-go-pro:hover,
|
202 |
+
.pipe-premium-features .button-go-pro:focus,
|
203 |
+
.pipe-premium-features .button-go-pro:active {
|
204 |
+
background: #00a378;
|
205 |
+
}
|
206 |
+
.pipe-premium-features .button-doc-demo {
|
207 |
+
border: 0;
|
208 |
+
background: #d8d8dc;
|
209 |
+
box-shadow: none;
|
210 |
+
padding: 10px 15px;
|
211 |
+
font-size: 15px;
|
212 |
+
height: auto;
|
213 |
+
margin-left: 10px;
|
214 |
+
margin-right: 10px;
|
215 |
+
margin-top: 10px;
|
216 |
+
}
|
217 |
+
.pipe-premium-features .button-doc-demo:hover,
|
218 |
+
.pipe-premium-features .button-doc-demo:focus,
|
219 |
+
.pipe-premium-features .button-doc-demo:active {
|
220 |
+
background: #dfdfe4;
|
221 |
+
}
|
222 |
+
.xa-pipe-rating-link{color:#ffc600;}
|
223 |
+
|
224 |
+
.pipe-review-widget{
|
225 |
+
background: #fff;
|
226 |
+
padding: 5px;
|
227 |
+
margin-top: 23px;
|
228 |
+
}
|
229 |
+
.pipe-review-widget p{
|
230 |
+
margin-right:5px;
|
231 |
+
margin-left:5px;
|
232 |
}
|