initial commit
This commit is contained in:
104
includes/admin/importers/views/html-csv-import-done.php
Normal file
104
includes/admin/importers/views/html-csv-import-done.php
Normal file
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
/**
|
||||
* Admin View: Importer - Done!
|
||||
*
|
||||
* @package WooCommerce\Admin\Importers
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<div class="wc-progress-form-content woocommerce-importer">
|
||||
<section class="woocommerce-importer-done">
|
||||
<?php
|
||||
$results = array();
|
||||
|
||||
if ( 0 < $imported ) {
|
||||
$results[] = sprintf(
|
||||
/* translators: %d: products count */
|
||||
_n( '%s product imported', '%s products imported', $imported, 'woocommerce' ),
|
||||
'<strong>' . number_format_i18n( $imported ) . '</strong>'
|
||||
);
|
||||
}
|
||||
|
||||
if ( 0 < $updated ) {
|
||||
$results[] = sprintf(
|
||||
/* translators: %d: products count */
|
||||
_n( '%s product updated', '%s products updated', $updated, 'woocommerce' ),
|
||||
'<strong>' . number_format_i18n( $updated ) . '</strong>'
|
||||
);
|
||||
}
|
||||
|
||||
if ( 0 < $skipped ) {
|
||||
$results[] = sprintf(
|
||||
/* translators: %d: products count */
|
||||
_n( '%s product was skipped', '%s products were skipped', $skipped, 'woocommerce' ),
|
||||
'<strong>' . number_format_i18n( $skipped ) . '</strong>'
|
||||
);
|
||||
}
|
||||
|
||||
if ( 0 < $failed ) {
|
||||
$results [] = sprintf(
|
||||
/* translators: %d: products count */
|
||||
_n( 'Failed to import %s product', 'Failed to import %s products', $failed, 'woocommerce' ),
|
||||
'<strong>' . number_format_i18n( $failed ) . '</strong>'
|
||||
);
|
||||
}
|
||||
|
||||
if ( 0 < $failed || 0 < $skipped ) {
|
||||
$results[] = '<a href="#" class="woocommerce-importer-done-view-errors">' . __( 'View import log', 'woocommerce' ) . '</a>';
|
||||
}
|
||||
|
||||
if ( ! empty( $file_name ) ) {
|
||||
$results[] = sprintf(
|
||||
/* translators: %s: File name */
|
||||
__( 'File uploaded: %s', 'woocommerce' ),
|
||||
'<strong>' . $file_name . '</strong>'
|
||||
);
|
||||
}
|
||||
|
||||
/* translators: %d: import results */
|
||||
echo wp_kses_post( __( 'Import complete!', 'woocommerce' ) . ' ' . implode( '. ', $results ) );
|
||||
?>
|
||||
</section>
|
||||
<section class="wc-importer-error-log" style="display:none">
|
||||
<table class="widefat wc-importer-error-log-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php esc_html_e( 'Product', 'woocommerce' ); ?></th>
|
||||
<th><?php esc_html_e( 'Reason for failure', 'woocommerce' ); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
if ( count( $errors ) ) {
|
||||
foreach ( $errors as $error ) {
|
||||
if ( ! is_wp_error( $error ) ) {
|
||||
continue;
|
||||
}
|
||||
$error_data = $error->get_error_data();
|
||||
?>
|
||||
<tr>
|
||||
<th><code><?php echo esc_html( $error_data['row'] ); ?></code></th>
|
||||
<td><?php echo esc_html( $error->get_error_message() ); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<script type="text/javascript">
|
||||
jQuery(function() {
|
||||
jQuery( '.woocommerce-importer-done-view-errors' ).on( 'click', function() {
|
||||
jQuery( '.wc-importer-error-log' ).slideToggle();
|
||||
return false;
|
||||
} );
|
||||
} );
|
||||
</script>
|
||||
<div class="wc-actions">
|
||||
<a class="button button-primary" href="<?php echo esc_url( admin_url( 'edit.php?post_type=product' ) ); ?>"><?php esc_html_e( 'View products', 'woocommerce' ); ?></a>
|
||||
</div>
|
||||
</div>
|
13
includes/admin/importers/views/html-csv-import-footer.php
Normal file
13
includes/admin/importers/views/html-csv-import-footer.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* Admin View: Header
|
||||
*
|
||||
* @package WooCommerce\Admin\Importers
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
15
includes/admin/importers/views/html-csv-import-header.php
Normal file
15
includes/admin/importers/views/html-csv-import-header.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* Admin View: Header
|
||||
*
|
||||
* @package WooCommerce\Admin\Importers
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<div class="wrap woocommerce">
|
||||
<h1><?php esc_html_e( 'Import Products', 'woocommerce' ); ?></h1>
|
||||
|
||||
<div class="woocommerce-progress-form-wrapper">
|
65
includes/admin/importers/views/html-csv-import-mapping.php
Normal file
65
includes/admin/importers/views/html-csv-import-mapping.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* Admin View: Importer - CSV mapping
|
||||
*
|
||||
* @package WooCommerce\Admin\Importers
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<form class="wc-progress-form-content woocommerce-importer" method="post" action="<?php echo esc_url( $this->get_next_step_link() ); ?>">
|
||||
<header>
|
||||
<h2><?php esc_html_e( 'Map CSV fields to products', 'woocommerce' ); ?></h2>
|
||||
<p><?php esc_html_e( 'Select fields from your CSV file to map against products fields, or to ignore during import.', 'woocommerce' ); ?></p>
|
||||
</header>
|
||||
<section class="wc-importer-mapping-table-wrapper">
|
||||
<table class="widefat wc-importer-mapping-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php esc_html_e( 'Column name', 'woocommerce' ); ?></th>
|
||||
<th><?php esc_html_e( 'Map to field', 'woocommerce' ); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ( $headers as $index => $name ) : ?>
|
||||
<?php $mapped_value = $mapped_items[ $index ]; ?>
|
||||
<tr>
|
||||
<td class="wc-importer-mapping-table-name">
|
||||
<?php echo esc_html( $name ); ?>
|
||||
<?php if ( ! empty( $sample[ $index ] ) ) : ?>
|
||||
<span class="description"><?php esc_html_e( 'Sample:', 'woocommerce' ); ?> <code><?php echo esc_html( $sample[ $index ] ); ?></code></span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="wc-importer-mapping-table-field">
|
||||
<input type="hidden" name="map_from[<?php echo esc_attr( $index ); ?>]" value="<?php echo esc_attr( $name ); ?>" />
|
||||
<select name="map_to[<?php echo esc_attr( $index ); ?>]">
|
||||
<option value=""><?php esc_html_e( 'Do not import', 'woocommerce' ); ?></option>
|
||||
<option value="">--------------</option>
|
||||
<?php foreach ( $this->get_mapping_options( $mapped_value ) as $key => $value ) : ?>
|
||||
<?php if ( is_array( $value ) ) : ?>
|
||||
<optgroup label="<?php echo esc_attr( $value['name'] ); ?>">
|
||||
<?php foreach ( $value['options'] as $sub_key => $sub_value ) : ?>
|
||||
<option value="<?php echo esc_attr( $sub_key ); ?>" <?php selected( $mapped_value, $sub_key ); ?>><?php echo esc_html( $sub_value ); ?></option>
|
||||
<?php endforeach ?>
|
||||
</optgroup>
|
||||
<?php else : ?>
|
||||
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $mapped_value, $key ); ?>><?php echo esc_html( $value ); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php endforeach ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<div class="wc-actions">
|
||||
<button type="submit" class="button button-primary button-next" value="<?php esc_attr_e( 'Run the importer', 'woocommerce' ); ?>" name="save_step"><?php esc_html_e( 'Run the importer', 'woocommerce' ); ?></button>
|
||||
<input type="hidden" name="file" value="<?php echo esc_attr( $this->file ); ?>" />
|
||||
<input type="hidden" name="delimiter" value="<?php echo esc_attr( $this->delimiter ); ?>" />
|
||||
<input type="hidden" name="update_existing" value="<?php echo (int) $this->update_existing; ?>" />
|
||||
<?php wp_nonce_field( 'woocommerce-csv-importer' ); ?>
|
||||
</div>
|
||||
</form>
|
21
includes/admin/importers/views/html-csv-import-progress.php
Normal file
21
includes/admin/importers/views/html-csv-import-progress.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* Admin View: Importer - CSV import progress
|
||||
*
|
||||
* @package WooCommerce\Admin\Importers
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<div class="wc-progress-form-content woocommerce-importer woocommerce-importer__importing">
|
||||
<header>
|
||||
<span class="spinner is-active"></span>
|
||||
<h2><?php esc_html_e( 'Importing', 'woocommerce' ); ?></h2>
|
||||
<p><?php esc_html_e( 'Your products are now being imported...', 'woocommerce' ); ?></p>
|
||||
</header>
|
||||
<section>
|
||||
<progress class="woocommerce-importer-progress" max="100" value="0"></progress>
|
||||
</section>
|
||||
</div>
|
26
includes/admin/importers/views/html-csv-import-steps.php
Normal file
26
includes/admin/importers/views/html-csv-import-steps.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Admin View: Steps
|
||||
*
|
||||
* @package WooCommerce\Admin\Importers
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<ol class="wc-progress-steps">
|
||||
<?php foreach ( $this->steps as $step_key => $step ) : ?>
|
||||
<?php
|
||||
$step_class = '';
|
||||
if ( $step_key === $this->step ) {
|
||||
$step_class = 'active';
|
||||
} elseif ( array_search( $this->step, array_keys( $this->steps ), true ) > array_search( $step_key, array_keys( $this->steps ), true ) ) {
|
||||
$step_class = 'done';
|
||||
}
|
||||
?>
|
||||
<li class="<?php echo esc_attr( $step_class ); ?>">
|
||||
<?php echo esc_html( $step['name'] ); ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
104
includes/admin/importers/views/html-product-csv-import-form.php
Normal file
104
includes/admin/importers/views/html-product-csv-import-form.php
Normal file
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
/**
|
||||
* Admin View: Product import form
|
||||
*
|
||||
* @package WooCommerce\Admin
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<form class="wc-progress-form-content woocommerce-importer" enctype="multipart/form-data" method="post">
|
||||
<header>
|
||||
<h2><?php esc_html_e( 'Import products from a CSV file', 'woocommerce' ); ?></h2>
|
||||
<p><?php esc_html_e( 'This tool allows you to import (or merge) product data to your store from a CSV or TXT file.', 'woocommerce' ); ?></p>
|
||||
</header>
|
||||
<section>
|
||||
<table class="form-table woocommerce-importer-options">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="upload">
|
||||
<?php esc_html_e( 'Choose a CSV file from your computer:', 'woocommerce' ); ?>
|
||||
</label>
|
||||
</th>
|
||||
<td>
|
||||
<?php
|
||||
if ( ! empty( $upload_dir['error'] ) ) {
|
||||
?>
|
||||
<div class="inline error">
|
||||
<p><?php esc_html_e( 'Before you can upload your import file, you will need to fix the following error:', 'woocommerce' ); ?></p>
|
||||
<p><strong><?php echo esc_html( $upload_dir['error'] ); ?></strong></p>
|
||||
</div>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<input type="file" id="upload" name="import" size="25" />
|
||||
<input type="hidden" name="action" value="save" />
|
||||
<input type="hidden" name="max_file_size" value="<?php echo esc_attr( $bytes ); ?>" />
|
||||
<br>
|
||||
<small>
|
||||
<?php
|
||||
printf(
|
||||
/* translators: %s: maximum upload size */
|
||||
esc_html__( 'Maximum size: %s', 'woocommerce' ),
|
||||
esc_html( $size )
|
||||
);
|
||||
?>
|
||||
</small>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><label for="woocommerce-importer-update-existing"><?php esc_html_e( 'Update existing products', 'woocommerce' ); ?></label><br/></th>
|
||||
<td>
|
||||
<input type="hidden" name="update_existing" value="0" />
|
||||
<input type="checkbox" id="woocommerce-importer-update-existing" name="update_existing" value="1" />
|
||||
<label for="woocommerce-importer-update-existing"><?php esc_html_e( 'Existing products that match by ID or SKU will be updated. Products that do not exist will be skipped.', 'woocommerce' ); ?></label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="woocommerce-importer-advanced hidden">
|
||||
<th>
|
||||
<label for="woocommerce-importer-file-url"><?php esc_html_e( 'Alternatively, enter the path to a CSV file on your server:', 'woocommerce' ); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<label for="woocommerce-importer-file-url" class="woocommerce-importer-file-url-field-wrapper">
|
||||
<code><?php echo esc_html( ABSPATH ) . ' '; ?></code><input type="text" id="woocommerce-importer-file-url" name="file_url" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="woocommerce-importer-advanced hidden">
|
||||
<th><label><?php esc_html_e( 'CSV Delimiter', 'woocommerce' ); ?></label><br/></th>
|
||||
<td><input type="text" name="delimiter" placeholder="," size="2" /></td>
|
||||
</tr>
|
||||
<tr class="woocommerce-importer-advanced hidden">
|
||||
<th><label><?php esc_html_e( 'Use previous column mapping preferences?', 'woocommerce' ); ?></label><br/></th>
|
||||
<td><input type="checkbox" id="woocommerce-importer-map-preferences" name="map_preferences" value="1" /></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<script type="text/javascript">
|
||||
jQuery(function() {
|
||||
jQuery( '.woocommerce-importer-toggle-advanced-options' ).on( 'click', function() {
|
||||
var elements = jQuery( '.woocommerce-importer-advanced' );
|
||||
if ( elements.is( '.hidden' ) ) {
|
||||
elements.removeClass( 'hidden' );
|
||||
jQuery( this ).text( jQuery( this ).data( 'hidetext' ) );
|
||||
} else {
|
||||
elements.addClass( 'hidden' );
|
||||
jQuery( this ).text( jQuery( this ).data( 'showtext' ) );
|
||||
}
|
||||
return false;
|
||||
} );
|
||||
});
|
||||
</script>
|
||||
<div class="wc-actions">
|
||||
<a href="#" class="woocommerce-importer-toggle-advanced-options" data-hidetext="<?php esc_attr_e( 'Hide advanced options', 'woocommerce' ); ?>" data-showtext="<?php esc_attr_e( 'Show advanced options', 'woocommerce' ); ?>"><?php esc_html_e( 'Show advanced options', 'woocommerce' ); ?></a>
|
||||
<button type="submit" class="button button-primary button-next" value="<?php esc_attr_e( 'Continue', 'woocommerce' ); ?>" name="save_step"><?php esc_html_e( 'Continue', 'woocommerce' ); ?></button>
|
||||
<?php wp_nonce_field( 'woocommerce-csv-importer' ); ?>
|
||||
</div>
|
||||
</form>
|
Reference in New Issue
Block a user