manipulations.php 4.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /**
  3. * Category Manipulations page view
  4. *
  5. * @since 1.0.0
  6. * @package Studiou_WC_Product_Cat_Manage
  7. */
  8. // If this file is called directly, abort.
  9. if (!defined('WPINC')) {
  10. die;
  11. }
  12. // Get categories with counts for select boxes
  13. $manipulator = new Studiou_WC_Product_Cat_Manage_Manipulator(new Studiou_WC_Product_Cat_Manage_DB());
  14. $categories = $manipulator->get_categories_with_counts();
  15. ?>
  16. <div class="wrap studiou-wcpcm-wrap">
  17. <h1><?php echo esc_html__('Category Manipulations', 'studiou-wc-product-cat-manage'); ?></h1>
  18. <div class="studiou-wcpcm-notice-area">
  19. <!-- Area for displaying notices -->
  20. </div>
  21. <div class="studiou-wcpcm-card">
  22. <h2><?php echo esc_html__('Move products between categories', 'studiou-wc-product-cat-manage'); ?></h2>
  23. <p><?php echo esc_html__('This operation allows you to move all products from one category to another. Products will be removed from the source category and added to the target category.', 'studiou-wc-product-cat-manage'); ?></p>
  24. <form id="studiou-wcpcm-move-form" method="post">
  25. <table class="form-table">
  26. <tr>
  27. <th scope="row">
  28. <label for="source_category"><?php echo esc_html__('Source Category', 'studiou-wc-product-cat-manage'); ?></label>
  29. </th>
  30. <td>
  31. <select name="source_category" id="source_category" class="regular-text" required>
  32. <option value=""><?php echo esc_html__('-- Select Source Category --', 'studiou-wc-product-cat-manage'); ?></option>
  33. <?php foreach ($categories as $category): ?>
  34. <option value="<?php echo esc_attr($category['id']); ?>">
  35. <?php echo esc_html($category['display_name']); ?>
  36. </option>
  37. <?php endforeach; ?>
  38. </select>
  39. <p class="description"><?php echo esc_html__('Select the category from which products will be moved.', 'studiou-wc-product-cat-manage'); ?></p>
  40. </td>
  41. </tr>
  42. <tr>
  43. <th scope="row">
  44. <label for="target_category"><?php echo esc_html__('Target Category', 'studiou-wc-product-cat-manage'); ?></label>
  45. </th>
  46. <td>
  47. <select name="target_category" id="target_category" class="regular-text" required>
  48. <option value=""><?php echo esc_html__('-- Select Target Category --', 'studiou-wc-product-cat-manage'); ?></option>
  49. <?php foreach ($categories as $category): ?>
  50. <option value="<?php echo esc_attr($category['id']); ?>">
  51. <?php echo esc_html($category['display_name']); ?>
  52. </option>
  53. <?php endforeach; ?>
  54. </select>
  55. <p class="description"><?php echo esc_html__('Select the category to which products will be moved.', 'studiou-wc-product-cat-manage'); ?></p>
  56. </td>
  57. </tr>
  58. </table>
  59. <div class="submit-buttons">
  60. <button type="submit" class="button button-primary" id="studiou-wcpcm-move-button">
  61. <?php echo esc_html__('Do', 'studiou-wc-product-cat-manage'); ?>
  62. </button>
  63. <span class="spinner"></span>
  64. </div>
  65. </form>
  66. <div class="studiou-wcpcm-move-results" style="display: none;">
  67. <h3><?php echo esc_html__('Move Results', 'studiou-wc-product-cat-manage'); ?></h3>
  68. <div id="studiou-wcpcm-move-message"></div>
  69. </div>
  70. </div>
  71. <!-- Add more manipulation operations here in the future -->
  72. <div class="studiou-wcpcm-card">
  73. <h2><?php echo esc_html__('Important Notes', 'studiou-wc-product-cat-manage'); ?></h2>
  74. <ul>
  75. <li><?php echo esc_html__('Products can be assigned to multiple categories. This operation will remove the product from the source category and add it to the target category.', 'studiou-wc-product-cat-manage'); ?></li>
  76. <li><?php echo esc_html__('If a product is only assigned to the source category, it will be moved entirely to the target category.', 'studiou-wc-product-cat-manage'); ?></li>
  77. <li><?php echo esc_html__('If a product is assigned to multiple categories including the source category, it will remain in the other categories and be moved to the target category.', 'studiou-wc-product-cat-manage'); ?></li>
  78. <li><?php echo esc_html__('The operation processes all products regardless of their status (published, draft, private).', 'studiou-wc-product-cat-manage'); ?></li>
  79. </ul>
  80. </div>
  81. </div>