tab-move.php 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * Category Manipulations tab partial: Move products between categories.
  4. *
  5. * @package Studiou_WC_Product_Cat_Manage
  6. *
  7. * @var Studiou_WC_Product_Cat_Manage_Manipulator $manipulator
  8. */
  9. // If this file is called directly, abort.
  10. if (!defined('WPINC')) {
  11. die;
  12. }
  13. $categories = $manipulator->get_categories_with_counts();
  14. ?>
  15. <!-- Move Products Between Categories Operation -->
  16. <div class="studiou-wcpcm-card">
  17. <h2><?php echo esc_html__('Move products between categories', 'studiou-wc-product-cat-manage'); ?></h2>
  18. <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>
  19. <form id="studiou-wcpcm-move-form" method="post">
  20. <table class="form-table">
  21. <tr>
  22. <th scope="row">
  23. <label for="source_category"><?php echo esc_html__('Source Category', 'studiou-wc-product-cat-manage'); ?></label>
  24. </th>
  25. <td>
  26. <select name="source_category" id="source_category" class="regular-text" required>
  27. <option value=""><?php echo esc_html__('-- Select Source Category --', 'studiou-wc-product-cat-manage'); ?></option>
  28. <?php foreach ($categories as $category): ?>
  29. <option value="<?php echo esc_attr($category['id']); ?>">
  30. <?php echo esc_html($category['display_name']); ?>
  31. </option>
  32. <?php endforeach; ?>
  33. </select>
  34. <p class="description"><?php echo esc_html__('Select the category from which products will be moved.', 'studiou-wc-product-cat-manage'); ?></p>
  35. </td>
  36. </tr>
  37. <tr>
  38. <th scope="row">
  39. <label for="target_category"><?php echo esc_html__('Target Category', 'studiou-wc-product-cat-manage'); ?></label>
  40. </th>
  41. <td>
  42. <select name="target_category" id="target_category" class="regular-text" required>
  43. <option value=""><?php echo esc_html__('-- Select Target Category --', 'studiou-wc-product-cat-manage'); ?></option>
  44. <?php foreach ($categories as $category): ?>
  45. <option value="<?php echo esc_attr($category['id']); ?>">
  46. <?php echo esc_html($category['display_name']); ?>
  47. </option>
  48. <?php endforeach; ?>
  49. </select>
  50. <p class="description"><?php echo esc_html__('Select the category to which products will be moved.', 'studiou-wc-product-cat-manage'); ?></p>
  51. </td>
  52. </tr>
  53. </table>
  54. <div class="submit-buttons">
  55. <button type="submit" class="button button-primary" id="studiou-wcpcm-move-button">
  56. <?php echo esc_html__('Do', 'studiou-wc-product-cat-manage'); ?>
  57. </button>
  58. <span class="spinner"></span>
  59. </div>
  60. </form>
  61. <div class="studiou-wcpcm-move-results" style="display: none;">
  62. <h3><?php echo esc_html__('Move Results', 'studiou-wc-product-cat-manage'); ?></h3>
  63. <div id="studiou-wcpcm-move-message"></div>
  64. </div>
  65. </div>