html-csv-import-done.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /**
  3. * Admin View: Importer - Done!
  4. *
  5. * @package WooCommerce\Admin\Importers
  6. */
  7. if ( ! defined( 'ABSPATH' ) ) {
  8. exit;
  9. }
  10. ?>
  11. <div class="wc-progress-form-content woocommerce-importer">
  12. <section class="woocommerce-importer-done">
  13. <?php
  14. $results = array();
  15. if ( 0 < $imported ) {
  16. $results[] = sprintf(
  17. /* translators: %d: products count */
  18. _n( '%s product imported', '%s products imported', $imported, 'woocommerce' ),
  19. '<strong>' . number_format_i18n( $imported ) . '</strong>'
  20. );
  21. }
  22. if ( 0 < $updated ) {
  23. $results[] = sprintf(
  24. /* translators: %d: products count */
  25. _n( '%s product updated', '%s products updated', $updated, 'woocommerce' ),
  26. '<strong>' . number_format_i18n( $updated ) . '</strong>'
  27. );
  28. }
  29. if ( 0 < $skipped ) {
  30. $results[] = sprintf(
  31. /* translators: %d: products count */
  32. _n( '%s product was skipped', '%s products were skipped', $skipped, 'woocommerce' ),
  33. '<strong>' . number_format_i18n( $skipped ) . '</strong>'
  34. );
  35. }
  36. if ( 0 < $failed ) {
  37. $results [] = sprintf(
  38. /* translators: %d: products count */
  39. _n( 'Failed to import %s product', 'Failed to import %s products', $failed, 'woocommerce' ),
  40. '<strong>' . number_format_i18n( $failed ) . '</strong>'
  41. );
  42. }
  43. if ( 0 < $failed || 0 < $skipped ) {
  44. $results[] = '<a href="#" class="woocommerce-importer-done-view-errors">' . __( 'View import log', 'woocommerce' ) . '</a>';
  45. }
  46. /* translators: %d: import results */
  47. echo wp_kses_post( __( 'Import complete!', 'woocommerce' ) . ' ' . implode( '. ', $results ) );
  48. ?>
  49. </section>
  50. <section class="wc-importer-error-log" style="display:none">
  51. <table class="widefat wc-importer-error-log-table">
  52. <thead>
  53. <tr>
  54. <th><?php esc_html_e( 'Product', 'woocommerce' ); ?></th>
  55. <th><?php esc_html_e( 'Reason for failure', 'woocommerce' ); ?></th>
  56. </tr>
  57. </thead>
  58. <tbody>
  59. <?php
  60. if ( count( $errors ) ) {
  61. foreach ( $errors as $error ) {
  62. if ( ! is_wp_error( $error ) ) {
  63. continue;
  64. }
  65. $error_data = $error->get_error_data();
  66. ?>
  67. <tr>
  68. <th><code><?php echo esc_html( $error_data['row'] ); ?></code></th>
  69. <td><?php echo esc_html( $error->get_error_message() ); ?></td>
  70. </tr>
  71. <?php
  72. }
  73. }
  74. ?>
  75. </tbody>
  76. </table>
  77. </section>
  78. <script type="text/javascript">
  79. jQuery(function() {
  80. jQuery( '.woocommerce-importer-done-view-errors' ).on( 'click', function() {
  81. jQuery( '.wc-importer-error-log' ).slideToggle();
  82. return false;
  83. } );
  84. } );
  85. </script>
  86. <div class="wc-actions">
  87. <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>
  88. </div>
  89. </div>