Import Products from any XML or CSV to WooCommerce - Version 1.1.6

Version Description

  • fixed saving shipping class option
  • fixed import product attributes
Download this release

Release Info

Developer soflyy
Plugin Icon 128x128 Import Products from any XML or CSV to WooCommerce
Version 1.1.6
Comparing to
See all releases

Code changes from version 1.1.5 to 1.1.6

actions/admin_notices.php CHANGED
@@ -31,7 +31,7 @@ function pmwi_admin_notices() {
31
 
32
  }
33
 
34
- if ( class_exists( 'PMXI_Plugin' ) and ( version_compare(PMXI_VERSION, '3.3.6') <= 0 and PMXI_EDITION == 'paid' or version_compare(PMXI_VERSION, '3.1.1') <= 0 and PMXI_EDITION == 'free') ) {
35
  ?>
36
  <div class="error"><p>
37
  <?php printf(
@@ -42,7 +42,7 @@ function pmwi_admin_notices() {
42
  <?php
43
 
44
  deactivate_plugins( PMWI_FREE_ROOT_DIR . '/plugin.php');
45
- }
46
 
47
  $input = new PMWI_Input();
48
  $messages = $input->get('PMWI_nt', array());
31
 
32
  }
33
 
34
+ if ( class_exists( 'PMXI_Plugin' ) and ( (version_compare(PMXI_VERSION, '3.3.6') <= 0 or version_compare(PMXI_VERSION, '4.0.0') >= 0 ) and PMXI_EDITION == 'paid' or version_compare(PMXI_VERSION, '3.1.1') <= 0 and PMXI_EDITION == 'free') ) {
35
  ?>
36
  <div class="error"><p>
37
  <?php printf(
42
  <?php
43
 
44
  deactivate_plugins( PMWI_FREE_ROOT_DIR . '/plugin.php');
45
+ }
46
 
47
  $input = new PMWI_Input();
48
  $messages = $input->get('PMWI_nt', array());
classes/helper.php CHANGED
@@ -14,6 +14,11 @@ class PMWI_Helper {
14
  const GLOB_NODOTS = 1024;
15
  const GLOB_RECURSE = 2048;
16
 
 
 
 
 
 
17
  /**
18
  * A safe empowered glob().
19
  *
@@ -86,11 +91,6 @@ class PMWI_Helper {
86
  return $array;
87
 
88
  }
89
-
90
- const FNM_PATHNAME = 1;
91
- const FNM_NOESCAPE = 2;
92
- const FNM_PERIOD = 4;
93
- const FNM_CASEFOLD = 16;
94
 
95
  /**
96
  * non-POSIX complient remplacement for the fnmatch
@@ -110,22 +110,22 @@ class PMWI_Helper {
110
  );
111
 
112
  // Forward slash in string must be in pattern:
113
- if ($flags & FNM_PATHNAME) {
114
  $transforms['\*'] = '[^/]*';
115
  }
116
 
117
  // Back slash should not be escaped:
118
- if ($flags & FNM_NOESCAPE) {
119
  unset($transforms['\\']);
120
  }
121
 
122
  // Perform case insensitive match:
123
- if ($flags & FNM_CASEFOLD) {
124
  $modifiers .= 'i';
125
  }
126
 
127
  // Period at start must be the same as pattern:
128
- if ($flags & FNM_PERIOD) {
129
  if (strpos($string, '.') === 0 && strpos($pattern, '.') !== 0) return false;
130
  }
131
 
14
  const GLOB_NODOTS = 1024;
15
  const GLOB_RECURSE = 2048;
16
 
17
+ const FNM_PATHNAME = 1;
18
+ const FNM_NOESCAPE = 2;
19
+ const FNM_PERIOD = 4;
20
+ const FNM_CASEFOLD = 16;
21
+
22
  /**
23
  * A safe empowered glob().
24
  *
91
  return $array;
92
 
93
  }
 
 
 
 
 
94
 
95
  /**
96
  * non-POSIX complient remplacement for the fnmatch
110
  );
111
 
112
  // Forward slash in string must be in pattern:
113
+ if ($flags & self::FNM_PATHNAME) {
114
  $transforms['\*'] = '[^/]*';
115
  }
116
 
117
  // Back slash should not be escaped:
118
+ if ($flags & self::FNM_NOESCAPE) {
119
  unset($transforms['\\']);
120
  }
121
 
122
  // Perform case insensitive match:
123
+ if ($flags & self::FNM_CASEFOLD) {
124
  $modifiers .= 'i';
125
  }
126
 
127
  // Period at start must be the same as pattern:
128
+ if ($flags & self::FNM_PERIOD) {
129
  if (strpos($string, '.') === 0 && strpos($pattern, '.') !== 0) return false;
130
  }
131
 
controllers/admin/import.php CHANGED
@@ -17,10 +17,8 @@ class PMWI_Admin_Import extends PMWI_Controller_Admin {
17
  $this->data['id'] = $id = $this->input->get('id');
18
 
19
  $this->data['import'] = $import = new PMXI_Import_Record();
20
- if ( ! $id or $import->getById($id)->isEmpty()) { // specified import is not found
21
- $post = $this->input->post(
22
- $default
23
- );
24
  }
25
  else
26
  $post = $this->input->post(
17
  $this->data['id'] = $id = $this->input->get('id');
18
 
19
  $this->data['import'] = $import = new PMXI_Import_Record();
20
+ if ( ! $id or $import->getById($id)->isEmpty()) { // specified import is not found
21
+ $post = $this->input->post( apply_filters( 'pmxi_options_options', $default, true) );
 
 
22
  }
23
  else
24
  $post = $this->input->post(
filters/pmxi_article_data.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+ function pmwi_pmxi_article_data($articleData, $import, $post_to_update){
3
+ if ( $import->options['custom_type'] == 'product' and ! $import->options['is_update_product_type']){
4
+ $articleData['post_type'] = $post_to_update->post_type;
5
+ }
6
+ return $articleData;
7
+ }
filters/pmxi_custom_field_to_update.php CHANGED
@@ -3,10 +3,14 @@ function pmwi_pmxi_custom_field_to_update( $field_to_update, $post_type, $option
3
 
4
  if ($field_to_update === false || $post_type != 'product') return $field_to_update;
5
 
6
- if ($options['update_attributes_logic'] == 'full_update') return true;
 
 
 
7
  if ($options['is_update_attributes'] and $options['update_attributes_logic'] == "only" and ! empty($options['attributes_list']) and is_array($options['attributes_list']) and in_array(str_replace("attribute_", "", $m_key), $options['attributes_list']) ) return true;
8
  if ($options['is_update_attributes'] and $options['update_attributes_logic'] == "all_except" and ( empty($options['attributes_list']) or ! in_array(str_replace("attribute_", "", $m_key), $options['attributes_list']) )) return true;
9
 
10
  return false;
 
11
  }
12
  ?>
3
 
4
  if ($field_to_update === false || $post_type != 'product') return $field_to_update;
5
 
6
+ // Do not update attributes
7
+ if ($options['update_all_data'] == 'no' and ! $options['is_update_attributes'] and ( ! in_array($cur_meta_key, array('_default_attributes', '_product_attributes')) or strpos($cur_meta_key, "attribute_") === false)) return true;
8
+
9
+ if ($options['is_update_attributes'] and $options['update_attributes_logic'] == 'full_update') return true;
10
  if ($options['is_update_attributes'] and $options['update_attributes_logic'] == "only" and ! empty($options['attributes_list']) and is_array($options['attributes_list']) and in_array(str_replace("attribute_", "", $m_key), $options['attributes_list']) ) return true;
11
  if ($options['is_update_attributes'] and $options['update_attributes_logic'] == "all_except" and ( empty($options['attributes_list']) or ! in_array(str_replace("attribute_", "", $m_key), $options['attributes_list']) )) return true;
12
 
13
  return false;
14
+
15
  }
16
  ?>
models/import/record.php CHANGED
@@ -461,8 +461,15 @@ class PMWI_Import_Record extends PMWI_Model_Record {
461
  $product_type = empty( $product_types[$i] ) ? 'simple' : sanitize_title( stripslashes( $product_types[$i] ) );
462
 
463
  if ( ! $import->options['is_update_product_type'] and ! empty($articleData['ID']) ){
 
464
  $product = get_product($pid);
465
  $product_type = $product->product_type;
 
 
 
 
 
 
466
  }
467
 
468
  $is_downloadable = $product_downloadable[$i];
@@ -478,7 +485,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
478
  foreach (get_post_meta($pid, '') as $cur_meta_key => $cur_meta_val) $existing_meta_keys[] = $cur_meta_key;
479
 
480
  // Product type + Downloadable/Virtual
481
- wp_set_object_terms( $pid, $product_type, 'product_type' );
482
  if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_downloadable')) update_post_meta( $pid, '_downloadable', ($is_downloadable == "yes") ? 'yes' : 'no' );
483
  if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_virtual')) update_post_meta( $pid, '_virtual', ($is_virtual == "yes") ? 'yes' : 'no' );
484
 
@@ -511,8 +518,11 @@ class PMWI_Import_Record extends PMWI_Model_Record {
511
 
512
  // Save shipping class
513
  if ( pmwi_is_update_taxonomy($articleData, $import->options, 'product_shipping_class') ){
514
- $product_shipping_class = is_numeric($product_shipping_class[$i]) && $product_shipping_class[$i] > 0 && $product_type != 'external' ? absint( $product_shipping_class[$i] ) : $product_shipping_class[$i];
515
- wp_set_object_terms( $pid, $product_shipping_class, 'product_shipping_class');
 
 
 
516
  }
517
 
518
  // Unique SKU
@@ -580,7 +590,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
580
  // Update only these Attributes, leave the rest alone
581
  if ($import->options['update_all_data'] == "no" and $import->options['update_attributes_logic'] == 'only'){
582
  if ( ! empty($import->options['attributes_list']) and is_array($import->options['attributes_list'])) {
583
- if ( ! in_array( ( ($is_taxonomy) ? "pa_" . $attr_name : $attr_name ) , array_filter($import->options['attributes_list'], 'trim'))){
584
  $attribute_position++;
585
  continue;
586
  }
@@ -594,7 +604,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
594
  // Leave these attributes alone, update all other Attributes
595
  if ($import->options['update_all_data'] == "no" and $import->options['update_attributes_logic'] == 'all_except'){
596
  if ( ! empty($import->options['attributes_list']) and is_array($import->options['attributes_list'])) {
597
- if ( in_array( ( ($is_taxonomy) ? "pa_" . $attr_name : $attr_name ) , array_filter($import->options['attributes_list'], 'trim'))){
598
  $attribute_position++;
599
  continue;
600
  }
@@ -619,30 +629,29 @@ class PMWI_Import_Record extends PMWI_Model_Record {
619
  $terms = get_terms( wc_attribute_taxonomy_name( $attr_name ), array('hide_empty' => false));
620
 
621
  if ( ! is_wp_error($terms) ){
622
-
623
  foreach ($values as $key => $value) {
624
  $term_founded = false;
625
  if ( count($terms) > 0 ){
626
- foreach ( $terms as $term ) {
627
- if ( strtolower($term->name) == trim(strtolower($value)) or $term->slug == sanitize_title(trim(strtolower($value)))) {
628
- $attr_values[] = $term->slug;
629
  $term_founded = true;
630
  break;
631
  }
632
  }
633
- }
634
  if ( ! $term_founded and intval($attr_data['is_create_taxonomy_terms'][$i]) ){
635
  $term = wp_insert_term(
636
  $value, // the term
637
- wc_attribute_taxonomy_name( $attr_name ) // the taxonomy
638
  );
639
- if ( ! is_wp_error($term) ){
640
- $term = get_term_by( 'id', $term['term_id'], wc_attribute_taxonomy_name( $attr_name ));
641
- $attr_values[] = $term->slug;
642
- }
643
 
644
  }
645
- }
 
646
  }
647
  else {
648
  $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: %s.', 'pmxi_plugin'), $terms->get_error_message()));
@@ -650,11 +659,12 @@ class PMWI_Import_Record extends PMWI_Model_Record {
650
  }
651
 
652
  $values = $attr_values;
653
-
 
654
  }
655
  else $values = array();
656
 
657
- }
658
 
659
  // Update post terms
660
  if ( taxonomy_exists( wc_attribute_taxonomy_name( $attr_name ) ))
@@ -662,7 +672,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
662
 
663
  if ( !empty($values) ) {
664
  // Add attribute to array, but don't set values
665
- $attributes[ wc_attribute_taxonomy_name( $attr_name ) ] = array(
666
  'name' => wc_attribute_taxonomy_name( $attr_name ),
667
  'value' => '',
668
  'position' => $attribute_position,
@@ -671,6 +681,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
671
  'is_taxonomy' => 1,
672
  'is_create_taxonomy_terms' => (!empty($attr_data['is_create_taxonomy_terms'][$i])) ? 1 : 0
673
  );
 
674
  }
675
 
676
  } else {
@@ -710,7 +721,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
710
  if ( ! in_array( $product_type, array( 'grouped' ) ) ) {
711
 
712
  $date_from = isset( $product_sale_price_dates_from[$i] ) ? $product_sale_price_dates_from[$i] : '';
713
- $date_to = isset( $product_sale_price_dates_to[$i] ) ? $product_sale_price_dates_to[$i] : '';
714
 
715
  // Dates
716
  if ( $date_from ){
@@ -736,7 +747,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
736
  if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_price')) update_post_meta( $pid, '_price', stripslashes( $product_sale_price[$i] ) );
737
  }
738
  else{
739
- if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_price')) update_post_meta( $pid, '_price', stripslashes( $product_regular_price[$i] ) );
740
  }
741
 
742
  if ( $product_sale_price[$i] != '' && $date_from && strtotime( $date_from ) < strtotime( 'NOW', current_time( 'timestamp' ) ) ){
@@ -748,37 +759,59 @@ class PMWI_Import_Record extends PMWI_Model_Record {
748
  if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_sale_price_dates_from')) update_post_meta( $pid, '_sale_price_dates_from', '');
749
  if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_sale_price_dates_to')) update_post_meta( $pid, '_sale_price_dates_to', '');
750
  }
751
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
752
 
753
- if ($import->options['is_multiple_grouping_product'] != 'yes'){
754
- if ($import->options['grouping_indicator'] == 'xpath' and ! is_numeric($product_grouping_parent[$i])){
755
- $dpost = pmxi_findDuplicates(array(
756
- 'post_type' => 'product',
757
  'ID' => $pid,
758
- 'post_parent' => $articleData['post_parent'],
759
- 'post_title' => $product_grouping_parent[$i]
760
- ));
761
- if (!empty($dpost))
762
- $product_grouping_parent[$i] = $dpost[0];
763
- else
764
- $product_grouping_parent[$i] = 0;
765
- }
766
- elseif ($import->options['grouping_indicator'] != 'xpath'){
767
- $dpost = pmxi_findDuplicates($articleData, $custom_grouping_indicator_name[$i], $custom_grouping_indicator_value[$i], 'custom field');
768
- if (!empty($dpost))
769
- $product_grouping_parent[$i] = array_shift($dpost);
770
- else
771
- $product_grouping_parent[$i] = 0;
772
  }
773
  }
774
 
775
- if ( "" != $product_grouping_parent[$i] and absint($product_grouping_parent[$i]) > 0){
776
- wp_update_post(array(
777
- 'ID' => $pid,
778
- 'post_parent' => absint( $product_grouping_parent[$i] )
779
- ));
780
- }
781
-
782
  // Update parent if grouped so price sorting works and stays in sync with the cheapest child
783
  if ( $product_type == 'grouped' || ( "" != $product_grouping_parent[$i] and absint($product_grouping_parent[$i]) > 0)) {
784
 
@@ -810,7 +843,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
810
  }
811
 
812
  // Clear cache/transients
813
- //$woocommerce->clear_product_transients( $clear_id );
814
  }
815
  }
816
  }
@@ -845,7 +878,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
845
  if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_stock')) update_post_meta( $pid, '_stock', (int) $product_stock_qty[$i] );
846
  if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_stock_status')) update_post_meta( $pid, '_stock_status', stripslashes( $product_stock_status[$i] ) );
847
  if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_backorders')) update_post_meta( $pid, '_backorders', stripslashes( $product_allow_backorders[$i] ) );
848
- if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_manage_stock')) update_post_meta( $pid, '_manage_stock', 'yes' );
849
 
850
  // Check stock level
851
  if ( $product_type !== 'variable' && $product_allow_backorders[$i] == 'no' && (int) $product_stock_qty[$i] < 1 ){
@@ -951,7 +984,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
951
  if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_download_expiry')) update_post_meta( $pid, '_download_expiry', esc_attr( $_download_expiry ) );
952
  if ( isset( $product_download_type[$i] ) )
953
  if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_download_type')) update_post_meta( $pid, '_download_type', esc_attr( $product_download_type[$i] ) );
954
- }
955
 
956
  }
957
 
@@ -962,7 +995,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
962
  if ( ! taxonomy_exists( wc_attribute_taxonomy_name( $attr_name ) ) ) {
963
 
964
  // Grab the submitted data
965
- $attribute_name = ( isset( $attr_name ) ) ? pmwi_sanitize_taxonomy_name( stripslashes( (string) $attr_name ) ) : '';
966
  $attribute_label = ucwords( stripslashes( (string) $attr_name ));
967
  $attribute_type = 'select';
968
  $attribute_orderby = 'menu_order';
@@ -979,37 +1012,45 @@ class PMWI_Import_Record extends PMWI_Model_Record {
979
  );
980
 
981
  if ( in_array( $attribute_name, $reserved_terms ) ) {
982
- $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Slug “%s” is not allowed because it is a reserved term. Change it, please.', 'pmxi_plugin'), sanitize_title( $attribute_name )));
983
  }
984
  else{
985
- $this->wpdb->insert(
986
- $this->wpdb->prefix . 'woocommerce_attribute_taxonomies',
987
- array(
988
- 'attribute_label' => $attribute_label,
989
- 'attribute_name' => $attribute_name,
990
- 'attribute_type' => $attribute_type,
991
- 'attribute_orderby' => $attribute_orderby,
992
- )
993
- );
994
-
995
- $logger and call_user_func($logger, sprintf(__('<b>CREATED</b>: Taxonomy attribute “%s” have been successfully created.', 'pmxi_plugin'), sanitize_title( $attribute_name )));
996
-
997
  // Register the taxonomy now so that the import works!
998
  $domain = wc_attribute_taxonomy_name( $attr_name );
999
- register_taxonomy( $domain,
1000
- apply_filters( 'woocommerce_taxonomy_objects_' . $domain, array('product') ),
1001
- apply_filters( 'woocommerce_taxonomy_args_' . $domain, array(
1002
- 'hierarchical' => true,
1003
- 'show_ui' => false,
1004
- 'query_var' => true,
1005
- 'rewrite' => false,
1006
- ) )
1007
- );
1008
-
1009
- delete_transient( 'wc_attribute_taxonomies' );
1010
- $attribute_taxonomies = $this->wpdb->get_results( "SELECT * FROM " . $this->wpdb->prefix . "woocommerce_attribute_taxonomies" );
1011
- set_transient( 'wc_attribute_taxonomies', $attribute_taxonomies );
1012
- apply_filters( 'woocommerce_attribute_taxonomies', $attribute_taxonomies );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1013
  }
1014
 
1015
  }
@@ -1175,7 +1216,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
1175
  return $caps;
1176
  }
1177
 
1178
- function duplicate_post_copy_post_meta_info($new_id, $post) {
1179
  $post_meta_keys = get_post_custom_keys($post->ID);
1180
  $meta_blacklist = array();
1181
  $meta_keys = array_diff($post_meta_keys, $meta_blacklist);
@@ -1185,7 +1226,7 @@ class PMWI_Import_Record extends PMWI_Model_Record {
1185
 
1186
  foreach ($meta_values as $meta_value) {
1187
  $meta_value = maybe_unserialize($meta_value);
1188
- update_post_meta($new_id, $meta_key, $meta_value);
1189
  }
1190
  }
1191
 
461
  $product_type = empty( $product_types[$i] ) ? 'simple' : sanitize_title( stripslashes( $product_types[$i] ) );
462
 
463
  if ( ! $import->options['is_update_product_type'] and ! empty($articleData['ID']) ){
464
+
465
  $product = get_product($pid);
466
  $product_type = $product->product_type;
467
+
468
+ /*if ( strpos($articleData['post_title'], 'Variation') === 0 ) {
469
+ $this->wpdb->update( $this->wpdb->posts, array('post_type' => 'product_variation', array('ID' => $articleData['ID']) ));
470
+ $product_type = 'variable';
471
+ }*/
472
+
473
  }
474
 
475
  $is_downloadable = $product_downloadable[$i];
485
  foreach (get_post_meta($pid, '') as $cur_meta_key => $cur_meta_val) $existing_meta_keys[] = $cur_meta_key;
486
 
487
  // Product type + Downloadable/Virtual
488
+ if (empty($articleData['ID']) or $import->options['is_update_product_type']) wp_set_object_terms( $pid, $product_type, 'product_type' );
489
  if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_downloadable')) update_post_meta( $pid, '_downloadable', ($is_downloadable == "yes") ? 'yes' : 'no' );
490
  if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_virtual')) update_post_meta( $pid, '_virtual', ($is_virtual == "yes") ? 'yes' : 'no' );
491
 
518
 
519
  // Save shipping class
520
  if ( pmwi_is_update_taxonomy($articleData, $import->options, 'product_shipping_class') ){
521
+ $pshipping_class = is_numeric($product_shipping_class[$i]) && $product_shipping_class[$i] > 0 && $product_type != 'external' ? absint( $product_shipping_class[$i] ) : $product_shipping_class[$i];
522
+ if ($pshipping_class == "-1")
523
+ wp_set_object_terms( $pid, NULL, 'product_shipping_class');
524
+ else
525
+ wp_set_object_terms( $pid, $pshipping_class, 'product_shipping_class');
526
  }
527
 
528
  // Unique SKU
590
  // Update only these Attributes, leave the rest alone
591
  if ($import->options['update_all_data'] == "no" and $import->options['update_attributes_logic'] == 'only'){
592
  if ( ! empty($import->options['attributes_list']) and is_array($import->options['attributes_list'])) {
593
+ if ( ! in_array( ( ($is_taxonomy) ? wc_attribute_taxonomy_name( $attr_name ) : $attr_name ) , array_filter($import->options['attributes_list'], 'trim'))){
594
  $attribute_position++;
595
  continue;
596
  }
604
  // Leave these attributes alone, update all other Attributes
605
  if ($import->options['update_all_data'] == "no" and $import->options['update_attributes_logic'] == 'all_except'){
606
  if ( ! empty($import->options['attributes_list']) and is_array($import->options['attributes_list'])) {
607
+ if ( in_array( ( ($is_taxonomy) ? wc_attribute_taxonomy_name( $attr_name ) : $attr_name ) , array_filter($import->options['attributes_list'], 'trim'))){
608
  $attribute_position++;
609
  continue;
610
  }
629
  $terms = get_terms( wc_attribute_taxonomy_name( $attr_name ), array('hide_empty' => false));
630
 
631
  if ( ! is_wp_error($terms) ){
632
+
633
  foreach ($values as $key => $value) {
634
  $term_founded = false;
635
  if ( count($terms) > 0 ){
636
+ foreach ( $terms as $term ) {
637
+ if ( strtolower($term->name) == trim(strtolower($value)) or $term->slug == sanitize_title(trim(strtolower($value))) or $term->slug == trim($value)) {
638
+ $attr_values[] = (int) $term->term_id;
639
  $term_founded = true;
640
  break;
641
  }
642
  }
643
+ }
644
  if ( ! $term_founded and intval($attr_data['is_create_taxonomy_terms'][$i]) ){
645
  $term = wp_insert_term(
646
  $value, // the term
647
+ wc_attribute_taxonomy_name( $attr_name ) // the taxonomy
648
  );
649
+ if ( ! is_wp_error($term) )
650
+ $attr_values[] = (int) $term['term_id'];
 
 
651
 
652
  }
653
+ }
654
+
655
  }
656
  else {
657
  $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: %s.', 'pmxi_plugin'), $terms->get_error_message()));
659
  }
660
 
661
  $values = $attr_values;
662
+ $values = array_map( 'intval', $values );
663
+ $values = array_unique( $values );
664
  }
665
  else $values = array();
666
 
667
+ }
668
 
669
  // Update post terms
670
  if ( taxonomy_exists( wc_attribute_taxonomy_name( $attr_name ) ))
672
 
673
  if ( !empty($values) ) {
674
  // Add attribute to array, but don't set values
675
+ $attributes[ sanitize_title(wc_attribute_taxonomy_name( $attr_name )) ] = array(
676
  'name' => wc_attribute_taxonomy_name( $attr_name ),
677
  'value' => '',
678
  'position' => $attribute_position,
681
  'is_taxonomy' => 1,
682
  'is_create_taxonomy_terms' => (!empty($attr_data['is_create_taxonomy_terms'][$i])) ? 1 : 0
683
  );
684
+
685
  }
686
 
687
  } else {
721
  if ( ! in_array( $product_type, array( 'grouped' ) ) ) {
722
 
723
  $date_from = isset( $product_sale_price_dates_from[$i] ) ? $product_sale_price_dates_from[$i] : '';
724
+ $date_to = isset( $product_sale_price_dates_to[$i] ) ? $product_sale_price_dates_to[$i] : '';
725
 
726
  // Dates
727
  if ( $date_from ){
747
  if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_price')) update_post_meta( $pid, '_price', stripslashes( $product_sale_price[$i] ) );
748
  }
749
  else{
750
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_price')) update_post_meta( $pid, '_price', stripslashes( $product_regular_price[$i] ) );
751
  }
752
 
753
  if ( $product_sale_price[$i] != '' && $date_from && strtotime( $date_from ) < strtotime( 'NOW', current_time( 'timestamp' ) ) ){
759
  if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_sale_price_dates_from')) update_post_meta( $pid, '_sale_price_dates_from', '');
760
  if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_sale_price_dates_to')) update_post_meta( $pid, '_sale_price_dates_to', '');
761
  }
762
+ }
763
+
764
+ // Variable and grouped products have no prices
765
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_regular_price')){
766
+ update_post_meta( $pid, '_regular_price_tmp', $tmp = get_post_meta( $pid, '_regular_price', true) );
767
+ }
768
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_sale_price')){
769
+ update_post_meta( $pid, '_sale_price_tmp', $tmp = get_post_meta( $pid, '_sale_price', true ) );
770
+ }
771
+ if ( class_exists('woocommerce_wholesale_pricing') and (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, 'wholesale_price'))){
772
+ update_post_meta( $pid, 'pmxi_wholesale_price_tmp', $tmp = get_post_meta( $pid, 'pmxi_wholesale_price', true ) );
773
+ }
774
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_sale_price_dates_from')){
775
+ update_post_meta( $pid, '_sale_price_dates_from_tmp', $tmp = get_post_meta( $pid, '_sale_price_dates_from', true ) );
776
+ }
777
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_sale_price_dates_to')){
778
+ update_post_meta( $pid, '_sale_price_dates_to_tmp', $tmp = get_post_meta( $pid, '_sale_price_dates_to', true ) );
779
+ }
780
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_price')){
781
+ update_post_meta( $pid, '_price_tmp', $tmp = get_post_meta( $pid, '_price', true ) );
782
+ }
783
+
784
+ if (in_array( $product_type, array( 'simple', 'external' ) )) {
785
+ if ($import->options['is_multiple_grouping_product'] != 'yes'){
786
+ if ($import->options['grouping_indicator'] == 'xpath' and ! is_numeric($product_grouping_parent[$i])){
787
+ $dpost = pmxi_findDuplicates(array(
788
+ 'post_type' => 'product',
789
+ 'ID' => $pid,
790
+ 'post_parent' => $articleData['post_parent'],
791
+ 'post_title' => $product_grouping_parent[$i]
792
+ ));
793
+ if (!empty($dpost))
794
+ $product_grouping_parent[$i] = $dpost[0];
795
+ else
796
+ $product_grouping_parent[$i] = 0;
797
+ }
798
+ elseif ($import->options['grouping_indicator'] != 'xpath'){
799
+ $dpost = pmxi_findDuplicates($articleData, $custom_grouping_indicator_name[$i], $custom_grouping_indicator_value[$i], 'custom field');
800
+ if (!empty($dpost))
801
+ $product_grouping_parent[$i] = array_shift($dpost);
802
+ else
803
+ $product_grouping_parent[$i] = 0;
804
+ }
805
+ }
806
 
807
+ if ( "" != $product_grouping_parent[$i] and absint($product_grouping_parent[$i]) > 0){
808
+ wp_update_post(array(
 
 
809
  'ID' => $pid,
810
+ 'post_parent' => absint( $product_grouping_parent[$i] )
811
+ ));
 
 
 
 
 
 
 
 
 
 
 
 
812
  }
813
  }
814
 
 
 
 
 
 
 
 
815
  // Update parent if grouped so price sorting works and stays in sync with the cheapest child
816
  if ( $product_type == 'grouped' || ( "" != $product_grouping_parent[$i] and absint($product_grouping_parent[$i]) > 0)) {
817
 
843
  }
844
 
845
  // Clear cache/transients
846
+ wc_delete_product_transients( $clear_id );
847
  }
848
  }
849
  }
878
  if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_stock')) update_post_meta( $pid, '_stock', (int) $product_stock_qty[$i] );
879
  if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_stock_status')) update_post_meta( $pid, '_stock_status', stripslashes( $product_stock_status[$i] ) );
880
  if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_backorders')) update_post_meta( $pid, '_backorders', stripslashes( $product_allow_backorders[$i] ) );
881
+ if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_manage_stock')) update_post_meta( $pid, '_manage_stock', 'yes' );
882
 
883
  // Check stock level
884
  if ( $product_type !== 'variable' && $product_allow_backorders[$i] == 'no' && (int) $product_stock_qty[$i] < 1 ){
984
  if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_download_expiry')) update_post_meta( $pid, '_download_expiry', esc_attr( $_download_expiry ) );
985
  if ( isset( $product_download_type[$i] ) )
986
  if (empty($articleData['ID']) or $this->is_update_custom_field($existing_meta_keys, $import->options, '_download_type')) update_post_meta( $pid, '_download_type', esc_attr( $product_download_type[$i] ) );
987
+ }
988
 
989
  }
990
 
995
  if ( ! taxonomy_exists( wc_attribute_taxonomy_name( $attr_name ) ) ) {
996
 
997
  // Grab the submitted data
998
+ $attribute_name = ( isset( $attr_name ) ) ? wc_sanitize_taxonomy_name( stripslashes( (string) $attr_name ) ) : '';
999
  $attribute_label = ucwords( stripslashes( (string) $attr_name ));
1000
  $attribute_type = 'select';
1001
  $attribute_orderby = 'menu_order';
1012
  );
1013
 
1014
  if ( in_array( $attribute_name, $reserved_terms ) ) {
1015
+ $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Slug “%s” is not allowed because it is a reserved term. Change it, please.', 'pmxi_plugin'), wc_attribute_taxonomy_name( $attribute_name )));
1016
  }
1017
  else{
 
 
 
 
 
 
 
 
 
 
 
 
1018
  // Register the taxonomy now so that the import works!
1019
  $domain = wc_attribute_taxonomy_name( $attr_name );
1020
+ if (strlen($domain) <= 32){
1021
+
1022
+ $this->wpdb->insert(
1023
+ $this->wpdb->prefix . 'woocommerce_attribute_taxonomies',
1024
+ array(
1025
+ 'attribute_label' => $attribute_label,
1026
+ 'attribute_name' => $attribute_name,
1027
+ 'attribute_type' => $attribute_type,
1028
+ 'attribute_orderby' => $attribute_orderby,
1029
+ )
1030
+ );
1031
+
1032
+ register_taxonomy( $domain,
1033
+ apply_filters( 'woocommerce_taxonomy_objects_' . $domain, array('product') ),
1034
+ apply_filters( 'woocommerce_taxonomy_args_' . $domain, array(
1035
+ 'hierarchical' => true,
1036
+ 'show_ui' => false,
1037
+ 'query_var' => true,
1038
+ 'rewrite' => false,
1039
+ ) )
1040
+ );
1041
+
1042
+ delete_transient( 'wc_attribute_taxonomies' );
1043
+ $attribute_taxonomies = $this->wpdb->get_results( "SELECT * FROM " . $this->wpdb->prefix . "woocommerce_attribute_taxonomies" );
1044
+ set_transient( 'wc_attribute_taxonomies', $attribute_taxonomies );
1045
+ apply_filters( 'woocommerce_attribute_taxonomies', $attribute_taxonomies );
1046
+
1047
+ $logger and call_user_func($logger, sprintf(__('<b>CREATED</b>: Taxonomy attribute “%s” have been successfully created.', 'pmxi_plugin'), wc_attribute_taxonomy_name( $attribute_name )));
1048
+
1049
+ }
1050
+ else{
1051
+ $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Taxonomy “%s” name is more than 32 characters. Change it, please.', 'pmxi_plugin'), $attr_name));
1052
+ }
1053
+
1054
  }
1055
 
1056
  }
1216
  return $caps;
1217
  }
1218
 
1219
+ function duplicate_post_copy_post_meta_info($new_id, $post, $options = array(), $is_duplicate = false) {
1220
  $post_meta_keys = get_post_custom_keys($post->ID);
1221
  $meta_blacklist = array();
1222
  $meta_keys = array_diff($post_meta_keys, $meta_blacklist);
1226
 
1227
  foreach ($meta_values as $meta_value) {
1228
  $meta_value = maybe_unserialize($meta_value);
1229
+ if ( ! $is_duplicate or $this->is_update_custom_field($existing_meta_keys, $options, $meta_key)) update_post_meta($new_id, $meta_key, $meta_value);
1230
  }
1231
  }
1232
 
plugin.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP All Import - WooCommerce Add-On
4
  Plugin URI: http://www.wpallimport.com/
5
  Description: An extremely easy, drag & drop importer to import WooCommerce simple products. A paid upgrade is available for premium support and support for Variable, Grouped, and External/Affiliate products
6
- Version: 1.1.5
7
  Author: Soflyy
8
  */
9
  /**
@@ -24,7 +24,7 @@ define('PMWI_FREE_ROOT_URL', rtrim(plugin_dir_url(__FILE__), '/'));
24
  */
25
  define('PMWI_PREFIX', 'pmwi_');
26
 
27
- define('PMWI_FREE_VERSION', '1.1.5');
28
 
29
  define('PMWI_EDITION', 'free');
30
 
@@ -540,6 +540,8 @@ final class PMWI_Plugin {
540
  'custom_grouping_indicator_name' => '',
541
  'custom_grouping_indicator_value' => '',
542
  'is_update_product_type' => 1,
 
 
543
 
544
  'is_update_attributes' => 1,
545
  'update_attributes_logic' => 'full_update',
@@ -550,5 +552,4 @@ final class PMWI_Plugin {
550
  }
551
  }
552
 
553
- PMWI_Plugin::getInstance();
554
-
3
  Plugin Name: WP All Import - WooCommerce Add-On
4
  Plugin URI: http://www.wpallimport.com/
5
  Description: An extremely easy, drag & drop importer to import WooCommerce simple products. A paid upgrade is available for premium support and support for Variable, Grouped, and External/Affiliate products
6
+ Version: 1.1.6
7
  Author: Soflyy
8
  */
9
  /**
24
  */
25
  define('PMWI_PREFIX', 'pmwi_');
26
 
27
+ define('PMWI_FREE_VERSION', '1.1.6');
28
 
29
  define('PMWI_EDITION', 'free');
30
 
540
  'custom_grouping_indicator_name' => '',
541
  'custom_grouping_indicator_value' => '',
542
  'is_update_product_type' => 1,
543
+ 'make_simple_product' => 0,
544
+ 'variable_sku_add_parent' => 0,
545
 
546
  'is_update_attributes' => 1,
547
  'update_attributes_logic' => 'full_update',
552
  }
553
  }
554
 
555
+ PMWI_Plugin::getInstance();
 
readme.txt CHANGED
@@ -1,8 +1,8 @@
1
  === Import Products from any XML or CSV to WooCommerce ===
2
  Contributors: soflyy
3
  Requires at least: 3.5
4
- Tested up to: 3.9.1
5
- Stable tag: 1.1.5
6
  License: GPLv2 or later
7
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  Tags: woocommerce xml import, woocommerce csv import, woocommerce, import, xml, csv, wp all import
@@ -73,9 +73,13 @@ The WooCommerce add-on will appear in the Step 4 of WP All Import.
73
 
74
  == Changelog ==
75
 
 
 
 
 
76
  = 1.1.5 =
77
  * fixed updating shipping class
78
- = fixed updating tax class
79
 
80
  = 1.1.4 =
81
  * fixed automatic fixing of improperly formatted prices
1
  === Import Products from any XML or CSV to WooCommerce ===
2
  Contributors: soflyy
3
  Requires at least: 3.5
4
+ Tested up to: 4.0
5
+ Stable tag: 1.1.6
6
  License: GPLv2 or later
7
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  Tags: woocommerce xml import, woocommerce csv import, woocommerce, import, xml, csv, wp all import
73
 
74
  == Changelog ==
75
 
76
+ = 1.1.6 =
77
+ * fixed saving shipping class option
78
+ * fixed import product attributes
79
+
80
  = 1.1.5 =
81
  * fixed updating shipping class
82
+ * fixed updating tax class
83
 
84
  = 1.1.4 =
85
  * fixed automatic fixing of improperly formatted prices
static/js/admin.js CHANGED
@@ -78,7 +78,7 @@
78
  if ($('#link_all_variations').is(':checked')) $('.variations_tab').hide(); else if (is_variable) $('.variations_tab').show();
79
 
80
  if ($('#xml_matching_parent').is(':checked') && is_variable) $('#variations_tag').show(); else $('#variations_tag').hide();
81
-
82
  if ( ! is_simple ) {
83
  $('.woocommerce_options_panel').find('input, select').attr('disabled','disabled');
84
  $('.upgrade_template').show();
@@ -213,11 +213,12 @@
213
 
214
  var parent_tagno = parseInt($('.tag').find('input[name="tagno"]').val());
215
 
216
- $('#variations_console').load('admin.php?page=pmxi-admin-import&action=evaluate_variations', {xpath: $input.val(), tagno: $variation_tagno, parent_tagno: parent_tagno}, function (data) {
 
217
  $input.attr('readonly', false);
218
  $xml.xml('dragable');
219
  $('#close_xml_tree').show();
220
- });
221
  };
222
 
223
  $xml.find('.navigation a').live('click', function () {
78
  if ($('#link_all_variations').is(':checked')) $('.variations_tab').hide(); else if (is_variable) $('.variations_tab').show();
79
 
80
  if ($('#xml_matching_parent').is(':checked') && is_variable) $('#variations_tag').show(); else $('#variations_tag').hide();
81
+
82
  if ( ! is_simple ) {
83
  $('.woocommerce_options_panel').find('input, select').attr('disabled','disabled');
84
  $('.upgrade_template').show();
213
 
214
  var parent_tagno = parseInt($('.tag').find('input[name="tagno"]').val());
215
 
216
+ $.post('admin.php?page=pmxi-admin-import&action=evaluate_variations', {xpath: $input.val(), tagno: $variation_tagno, parent_tagno: parent_tagno}, function (data) {
217
+ $('#variations_console').html(data.html);
218
  $input.attr('readonly', false);
219
  $xml.xml('dragable');
220
  $('#close_xml_tree').show();
221
+ }, 'json');
222
  };
223
 
224
  $xml.find('.navigation a').live('click', function () {
views/admin/import/index.php CHANGED
@@ -230,10 +230,18 @@
230
  </div>
231
  <div class="switcher-target-multiple_product_tax_class_yes" style="padding-left:17px;">
232
  <div class="input">
 
 
 
 
 
 
 
 
233
  <select class="select short" name="multiple_product_tax_class">
234
- <option value="" <?php echo '' == $post['multiple_product_tax_class'] ? 'selected="selected"': '' ?>><?php _e('Standard', 'woocommerce');?></option>
235
- <option value="reduced-rate" <?php echo 'reduced-rate' == $post['multiple_product_tax_class'] ? 'selected="selected"': '' ?>><?php _e('Reduced Rate', 'woocommerce');?></option>
236
- <option value="zero-rate" <?php echo 'zero-rate' == $post['multiple_product_tax_class'] ? 'selected="selected"': '' ?>><?php _e('Zero Rate', 'woocommerce');?></option>
237
  </select>
238
  </div>
239
  </div>
@@ -367,16 +375,18 @@
367
  <!-- SHIPPING -->
368
 
369
  <div class="panel woocommerce_options_panel" id="shipping_product_data" style="display:none;">
 
370
  <p class="upgrade_template" style='display:none; font-size: 1.3em; font-weight: bold;'>
371
  <a href="http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=wooco&utm_campaign=free+plugin+wooco" target="_blank" class="upgrade_link">Upgrade to the pro version of the WooCommerce Add-On to import to grouped, affiliate/external, and variable products.</a>
372
  </p>
 
373
  <div class="options_group">
374
  <p class="form-field">
375
- <label><?php _e("Weight (kg)"); ?></label>
376
  <input type="text" class="short" placeholder="0.00" name="single_product_weight" style="" value="<?php echo esc_attr($post['single_product_weight']) ?>"/>
377
  </p>
378
  <p class="form-field">
379
- <label><?php _e("Dimensions (cm)"); ?></label>
380
  <input type="text" class="short" placeholder="Length" name="single_product_length" style="margin-right:5px;" value="<?php echo esc_attr($post['single_product_length']) ?>"/>
381
  <input type="text" class="short" placeholder="Width" name="single_product_width" style="margin-right:5px;" value="<?php echo esc_attr($post['single_product_width']) ?>"/>
382
  <input type="text" class="short" placeholder="Height" name="single_product_height" style="" value="<?php echo esc_attr($post['single_product_height']) ?>"/>
@@ -392,8 +402,7 @@
392
  <div class="switcher-target-multiple_product_shipping_class_yes" style="padding-left:17px;">
393
  <div class="input">
394
  <?php
395
- $classes = get_the_terms( 0, 'product_shipping_class' );
396
- if ( $classes && ! is_wp_error( $classes ) ) $current_shipping_class = current($classes)->term_id; else $current_shipping_class = '';
397
 
398
  $args = array(
399
  'taxonomy' => 'product_shipping_class',
@@ -401,7 +410,7 @@
401
  'show_option_none' => __( 'No shipping class', 'woocommerce' ),
402
  'name' => 'multiple_product_shipping_class',
403
  'id' => 'multiple_product_shipping_class',
404
- 'selected' => $current_shipping_class,
405
  'class' => 'select short'
406
  );
407
 
@@ -428,9 +437,11 @@
428
  <!-- LINKED PRODUCT -->
429
 
430
  <div class="panel woocommerce_options_panel" id="linked_product_data" style="display:none;">
 
431
  <p class="upgrade_template" style='display:none; font-size: 1.3em; font-weight: bold;'>
432
  <a href="http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=wooco&utm_campaign=free+plugin+wooco" target="_blank" class="upgrade_link">Upgrade to the pro version of the WooCommerce Add-On to import to grouped, affiliate/external, and variable products.</a>
433
  </p>
 
434
  <div class="options_group">
435
  <p class="form-field">
436
  <label><?php _e("Up-Sells"); ?></label>
@@ -536,9 +547,11 @@
536
  <!-- ATTRIBUTES -->
537
 
538
  <div class="panel woocommerce_options_panel" id="woocommerce_attributes" style="display:none;">
 
539
  <p class="upgrade_template" style='display:none; font-size: 1.3em; font-weight: bold;'>
540
  <a href="http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=wooco&utm_campaign=free+plugin+wooco" target="_blank" class="upgrade_link">Upgrade to the pro version of the WooCommerce Add-On to import to grouped, affiliate/external, and variable products.</a>
541
  </p>
 
542
  <div class="input">
543
  <table class="form-table custom-params" id="attributes_table" style="max-width:95%;">
544
  <thead>
@@ -841,6 +854,12 @@
841
  <p class="form-field">
842
  <label style="width:150px;"><?php _e('SKU','woocommerce');?></label>
843
  <input type="text" value="<?php echo esc_attr($post['variable_sku']) ?>" style="" name="variable_sku" class="short">
 
 
 
 
 
 
844
  </p>
845
  <p class="form-field">
846
  <label style="width:150px;"><?php _e('Stock Qty', 'woocommerce');?></label>
@@ -1019,12 +1038,20 @@
1019
  </div>
1020
  <div class="switcher-target-multiple_variable_product_tax_class_yes" style="padding-left:17px;">
1021
  <div class="input">
 
 
 
 
 
 
 
 
1022
  <select class="select short" name="multiple_variable_product_tax_class">
1023
  <option value="parent" <?php echo 'parent' == $post['multiple_variable_product_tax_class'] ? 'selected="selected"': '' ?>><?php _e('Same as parent', 'woocommerce');?></option>
1024
- <option value="" <?php echo '' == $post['multiple_variable_product_tax_class'] ? 'selected="selected"': '' ?>><?php _e('Standard', 'woocommerce');?></option>
1025
- <option value="reduced-rate" <?php echo 'reduced-rate' == $post['multiple_variable_product_tax_class'] ? 'selected="selected"': '' ?>><?php _e('Reduced Rate', 'woocommerce');?></option>
1026
- <option value="zero-rate" <?php echo 'zero-rate' == $post['multiple_variable_product_tax_class'] ? 'selected="selected"': '' ?>><?php _e('Zero Rate', 'woocommerce');?></option>
1027
- </select>
1028
  </div>
1029
  </div>
1030
  </div>
@@ -1149,7 +1176,7 @@
1149
  <?php foreach ($post['variable_attribute_name'] as $i => $name): if ("" == $name) continue; ?>
1150
  <tr class="form-field">
1151
  <td><input type="text" name="variable_attribute_name[]" value="<?php echo esc_attr($name) ?>" style="width:95% !important;"/></td>
1152
- <td><textarea name="variable_attribute_value[]" placeholder="Enter some text, or some attributes by pipe (|) separating values."><?php echo str_replace("&amp;","&", htmlentities(htmlentities($post['variable_attribute_value'][$i]))); ?></textarea>
1153
  <br>
1154
  <span class='in_variations' style="margin-left:0px;">
1155
  <input type="checkbox" name="variable_in_variations[]" id="variable_in_variations_<?php echo $i; ?>" <?php echo ($post['variable_in_variations'][$i]) ? 'checked="checked"' : ''; ?> style="width: auto; position: relative; top: 1px; left: 0px;" value="1"/>
@@ -1326,7 +1353,7 @@
1326
  <a href="http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=wooco&utm_campaign=free+plugin+wooco" target="_blank" class="upgrade_link">Upgrade to the pro version of the WooCommerce Add-On to import to grouped, affiliate/external, and variable products.</a>
1327
  </p>
1328
  <div class="options_group">
1329
- <p class="form-field" style="font-size:16px; font-weight:bold;"><?php _e('Re-import options','pmxi_plugin');?></p>
1330
  <div class="input" style="padding-left:20px;">
1331
  <input type="hidden" name="missing_records_stock_status" value="0" />
1332
  <input type="checkbox" id="missing_records_stock_status" name="missing_records_stock_status" value="1" <?php echo $post['missing_records_stock_status'] ? 'checked="checked"' : '' ?> />
@@ -1350,6 +1377,13 @@
1350
  <input type="checkbox" id="disable_prepare_price" name="disable_prepare_price" value="1" <?php echo $post['disable_prepare_price'] ? 'checked="checked"' : '' ?> />
1351
  <label for="disable_prepare_price"><?php _e('Disable automatic fixing of improperly formatted prices.', 'pmxi_plugin') ?></label>
1352
  <a href="#help" class="help" title="<?php _e('Plugin will NOT fix prices that presented with currency symbol.', 'pmxi_plugin') ?>" style="position:relative; top:-2px;">?</a>
 
 
 
 
 
 
 
1353
  </div>
1354
  </div>
1355
  </div>
230
  </div>
231
  <div class="switcher-target-multiple_product_tax_class_yes" style="padding-left:17px;">
232
  <div class="input">
233
+ <?php
234
+ $tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option( 'woocommerce_tax_classes' ) ) ) );
235
+ $classes_options = array();
236
+ $classes_options[''] = __( 'Standard', 'woocommerce' );
237
+ if ( $tax_classes )
238
+ foreach ( $tax_classes as $class )
239
+ $classes_options[ sanitize_title( $class ) ] = esc_html( $class );
240
+ ?>
241
  <select class="select short" name="multiple_product_tax_class">
242
+ <?php foreach ($classes_options as $key => $value):?>
243
+ <option value="<?php echo $key; ?>" <?php echo $key == $post['multiple_product_tax_class'] ? 'selected="selected"': '' ?>><?php echo $value; ?></option>
244
+ <?php endforeach; ?>
245
  </select>
246
  </div>
247
  </div>
375
  <!-- SHIPPING -->
376
 
377
  <div class="panel woocommerce_options_panel" id="shipping_product_data" style="display:none;">
378
+
379
  <p class="upgrade_template" style='display:none; font-size: 1.3em; font-weight: bold;'>
380
  <a href="http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=wooco&utm_campaign=free+plugin+wooco" target="_blank" class="upgrade_link">Upgrade to the pro version of the WooCommerce Add-On to import to grouped, affiliate/external, and variable products.</a>
381
  </p>
382
+
383
  <div class="options_group">
384
  <p class="form-field">
385
+ <label><?php _e("Weight (" . get_option('woocommerce_weight_unit') . ")"); ?></label>
386
  <input type="text" class="short" placeholder="0.00" name="single_product_weight" style="" value="<?php echo esc_attr($post['single_product_weight']) ?>"/>
387
  </p>
388
  <p class="form-field">
389
+ <label><?php _e("Dimensions (" . get_option( 'woocommerce_dimension_unit' ) . ")"); ?></label>
390
  <input type="text" class="short" placeholder="Length" name="single_product_length" style="margin-right:5px;" value="<?php echo esc_attr($post['single_product_length']) ?>"/>
391
  <input type="text" class="short" placeholder="Width" name="single_product_width" style="margin-right:5px;" value="<?php echo esc_attr($post['single_product_width']) ?>"/>
392
  <input type="text" class="short" placeholder="Height" name="single_product_height" style="" value="<?php echo esc_attr($post['single_product_height']) ?>"/>
402
  <div class="switcher-target-multiple_product_shipping_class_yes" style="padding-left:17px;">
403
  <div class="input">
404
  <?php
405
+ $classes = get_the_terms( 0, 'product_shipping_class' );
 
406
 
407
  $args = array(
408
  'taxonomy' => 'product_shipping_class',
410
  'show_option_none' => __( 'No shipping class', 'woocommerce' ),
411
  'name' => 'multiple_product_shipping_class',
412
  'id' => 'multiple_product_shipping_class',
413
+ 'selected' => $post['multiple_product_shipping_class'],
414
  'class' => 'select short'
415
  );
416
 
437
  <!-- LINKED PRODUCT -->
438
 
439
  <div class="panel woocommerce_options_panel" id="linked_product_data" style="display:none;">
440
+
441
  <p class="upgrade_template" style='display:none; font-size: 1.3em; font-weight: bold;'>
442
  <a href="http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=wooco&utm_campaign=free+plugin+wooco" target="_blank" class="upgrade_link">Upgrade to the pro version of the WooCommerce Add-On to import to grouped, affiliate/external, and variable products.</a>
443
  </p>
444
+
445
  <div class="options_group">
446
  <p class="form-field">
447
  <label><?php _e("Up-Sells"); ?></label>
547
  <!-- ATTRIBUTES -->
548
 
549
  <div class="panel woocommerce_options_panel" id="woocommerce_attributes" style="display:none;">
550
+
551
  <p class="upgrade_template" style='display:none; font-size: 1.3em; font-weight: bold;'>
552
  <a href="http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=wooco&utm_campaign=free+plugin+wooco" target="_blank" class="upgrade_link">Upgrade to the pro version of the WooCommerce Add-On to import to grouped, affiliate/external, and variable products.</a>
553
  </p>
554
+
555
  <div class="input">
556
  <table class="form-table custom-params" id="attributes_table" style="max-width:95%;">
557
  <thead>
854
  <p class="form-field">
855
  <label style="width:150px;"><?php _e('SKU','woocommerce');?></label>
856
  <input type="text" value="<?php echo esc_attr($post['variable_sku']) ?>" style="" name="variable_sku" class="short">
857
+ <span class="use_parent">
858
+ <input type="hidden" name="variable_sku_add_parent" value="0"/>
859
+ <input type="checkbox" name="variable_sku_add_parent" id="variable_sku_add_parent" style="position:relative; top:6px; margin-left:5px;" <?php echo ($post['variable_sku_add_parent']) ? 'checked="checked"' : ''; ?>>
860
+ <label for="variable_sku_add_parent" style="top:2px;">Add value to the parent SKU</label>
861
+ <a href="#help" class="help" title="<?php _e('Enable this checkbox to combine SKU from parent and variation products.', 'pmxi_plugin') ?>" style="position:relative; top:2px;">?</a>
862
+ </span>
863
  </p>
864
  <p class="form-field">
865
  <label style="width:150px;"><?php _e('Stock Qty', 'woocommerce');?></label>
1038
  </div>
1039
  <div class="switcher-target-multiple_variable_product_tax_class_yes" style="padding-left:17px;">
1040
  <div class="input">
1041
+ <?php
1042
+ $tax_classes = array_filter( array_map( 'trim', explode( "\n", get_option( 'woocommerce_tax_classes' ) ) ) );
1043
+ $classes_options = array();
1044
+ $classes_options[''] = __( 'Standard', 'woocommerce' );
1045
+ if ( $tax_classes )
1046
+ foreach ( $tax_classes as $class )
1047
+ $classes_options[ sanitize_title( $class ) ] = esc_html( $class );
1048
+ ?>
1049
  <select class="select short" name="multiple_variable_product_tax_class">
1050
  <option value="parent" <?php echo 'parent' == $post['multiple_variable_product_tax_class'] ? 'selected="selected"': '' ?>><?php _e('Same as parent', 'woocommerce');?></option>
1051
+ <?php foreach ($classes_options as $key => $value):?>
1052
+ <option value="<?php echo $key; ?>" <?php echo $key == $post['multiple_variable_product_tax_class'] ? 'selected="selected"': '' ?>><?php echo $value; ?></option>
1053
+ <?php endforeach; ?>
1054
+ </select>
1055
  </div>
1056
  </div>
1057
  </div>
1176
  <?php foreach ($post['variable_attribute_name'] as $i => $name): if ("" == $name) continue; ?>
1177
  <tr class="form-field">
1178
  <td><input type="text" name="variable_attribute_name[]" value="<?php echo esc_attr($name) ?>" style="width:95% !important;"/></td>
1179
+ <td><textarea name="variable_attribute_value[]" placeholder="Enter some text, or some attributes by pipe (|) separating values."><?php echo esc_attr($post['variable_attribute_value'][$i]); ?></textarea>
1180
  <br>
1181
  <span class='in_variations' style="margin-left:0px;">
1182
  <input type="checkbox" name="variable_in_variations[]" id="variable_in_variations_<?php echo $i; ?>" <?php echo ($post['variable_in_variations'][$i]) ? 'checked="checked"' : ''; ?> style="width: auto; position: relative; top: 1px; left: 0px;" value="1"/>
1353
  <a href="http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=wooco&utm_campaign=free+plugin+wooco" target="_blank" class="upgrade_link">Upgrade to the pro version of the WooCommerce Add-On to import to grouped, affiliate/external, and variable products.</a>
1354
  </p>
1355
  <div class="options_group">
1356
+ <p class="form-field" style="font-size:16px; font-weight:bold;"><?php _e('Import options','pmxi_plugin');?></p>
1357
  <div class="input" style="padding-left:20px;">
1358
  <input type="hidden" name="missing_records_stock_status" value="0" />
1359
  <input type="checkbox" id="missing_records_stock_status" name="missing_records_stock_status" value="1" <?php echo $post['missing_records_stock_status'] ? 'checked="checked"' : '' ?> />
1377
  <input type="checkbox" id="disable_prepare_price" name="disable_prepare_price" value="1" <?php echo $post['disable_prepare_price'] ? 'checked="checked"' : '' ?> />
1378
  <label for="disable_prepare_price"><?php _e('Disable automatic fixing of improperly formatted prices.', 'pmxi_plugin') ?></label>
1379
  <a href="#help" class="help" title="<?php _e('Plugin will NOT fix prices that presented with currency symbol.', 'pmxi_plugin') ?>" style="position:relative; top:-2px;">?</a>
1380
+ </div>
1381
+ </div>
1382
+ <div class="options_group show_if_variable">
1383
+ <div class="input" style="padding-left:20px;">
1384
+ <input type="hidden" name="make_simple_product" value="0" />
1385
+ <input type="checkbox" id="make_simple_product" name="make_simple_product" value="1" <?php echo $post['make_simple_product'] ? 'checked="checked"' : '' ?> />
1386
+ <label for="make_simple_product"><?php _e('Create products with no variations as simple products.', 'pmxi_plugin') ?></label>
1387
  </div>
1388
  </div>
1389
  </div>