| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- <?php
- /**
- * Category Manipulations page view
- *
- * @since 1.0.0
- * @package Studiou_WC_Product_Cat_Manage
- */
- // If this file is called directly, abort.
- if (!defined('WPINC')) {
- die;
- }
- // Get categories with counts for select boxes
- $manipulator = new Studiou_WC_Product_Cat_Manage_Manipulator(new Studiou_WC_Product_Cat_Manage_DB());
- $categories = $manipulator->get_categories_with_counts();
- ?>
- <div class="wrap studiou-wcpcm-wrap">
- <h1><?php echo esc_html__('Category Manipulations', 'studiou-wc-product-cat-manage'); ?></h1>
-
- <div class="studiou-wcpcm-notice-area">
- <!-- Area for displaying notices -->
- </div>
-
- <!-- Move Products Between Categories Operation -->
- <div class="studiou-wcpcm-card">
- <h2><?php echo esc_html__('Move products between categories', 'studiou-wc-product-cat-manage'); ?></h2>
-
- <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>
-
- <form id="studiou-wcpcm-move-form" method="post">
- <table class="form-table">
- <tr>
- <th scope="row">
- <label for="source_category"><?php echo esc_html__('Source Category', 'studiou-wc-product-cat-manage'); ?></label>
- </th>
- <td>
- <select name="source_category" id="source_category" class="regular-text" required>
- <option value=""><?php echo esc_html__('-- Select Source Category --', 'studiou-wc-product-cat-manage'); ?></option>
- <?php foreach ($categories as $category): ?>
- <option value="<?php echo esc_attr($category['id']); ?>">
- <?php echo esc_html($category['display_name']); ?>
- </option>
- <?php endforeach; ?>
- </select>
- <p class="description"><?php echo esc_html__('Select the category from which products will be moved.', 'studiou-wc-product-cat-manage'); ?></p>
- </td>
- </tr>
- <tr>
- <th scope="row">
- <label for="target_category"><?php echo esc_html__('Target Category', 'studiou-wc-product-cat-manage'); ?></label>
- </th>
- <td>
- <select name="target_category" id="target_category" class="regular-text" required>
- <option value=""><?php echo esc_html__('-- Select Target Category --', 'studiou-wc-product-cat-manage'); ?></option>
- <?php foreach ($categories as $category): ?>
- <option value="<?php echo esc_attr($category['id']); ?>">
- <?php echo esc_html($category['display_name']); ?>
- </option>
- <?php endforeach; ?>
- </select>
- <p class="description"><?php echo esc_html__('Select the category to which products will be moved.', 'studiou-wc-product-cat-manage'); ?></p>
- </td>
- </tr>
- </table>
-
- <div class="submit-buttons">
- <button type="submit" class="button button-primary" id="studiou-wcpcm-move-button">
- <?php echo esc_html__('Do', 'studiou-wc-product-cat-manage'); ?>
- </button>
- <span class="spinner"></span>
- </div>
- </form>
-
- <div class="studiou-wcpcm-move-results" style="display: none;">
- <h3><?php echo esc_html__('Move Results', 'studiou-wc-product-cat-manage'); ?></h3>
- <div id="studiou-wcpcm-move-message"></div>
- </div>
- </div>
-
- <!-- Batch Description Between Categories Operation -->
- <div class="studiou-wcpcm-card">
- <h2><?php echo esc_html__('Batch description between categories', 'studiou-wc-product-cat-manage'); ?></h2>
-
- <p><?php echo esc_html__('This operation allows you to set the same description for multiple categories at once.', 'studiou-wc-product-cat-manage'); ?></p>
-
- <form id="studiou-wcpcm-batch-description-form" method="post">
- <table class="form-table">
- <tr>
- <th scope="row">
- <label for="categories_list"><?php echo esc_html__('Select Categories', 'studiou-wc-product-cat-manage'); ?></label>
- </th>
- <td>
- <div class="studiou-wcpcm-categories-list-container">
- <div class="studiou-wcpcm-list-actions">
- <button type="button" id="studiou-wcpcm-check-all" class="button">
- <?php echo esc_html__('Check All', 'studiou-wc-product-cat-manage'); ?>
- </button>
- <button type="button" id="studiou-wcpcm-uncheck-all" class="button">
- <?php echo esc_html__('Uncheck All', 'studiou-wc-product-cat-manage'); ?>
- </button>
- </div>
- <div class="studiou-wcpcm-categories-list" id="categories_list">
- <?php foreach ($categories as $category): ?>
- <label class="studiou-wcpcm-category-item">
- <input type="checkbox" name="selected_categories[]" value="<?php echo esc_attr($category['id']); ?>">
- <span><?php echo esc_html($category['display_name']); ?></span>
- </label>
- <?php endforeach; ?>
- </div>
- </div>
- <p class="description"><?php echo esc_html__('Select the categories for which you want to set the description.', 'studiou-wc-product-cat-manage'); ?></p>
- </td>
- </tr>
- <tr>
- <th scope="row">
- <label for="category_description"><?php echo esc_html__('Product categories description', 'studiou-wc-product-cat-manage'); ?></label>
- </th>
- <td>
- <textarea name="category_description" id="category_description" rows="5" cols="50" class="large-text"></textarea>
- <p class="description"><?php echo esc_html__('Enter the description that will be applied to all selected categories.', 'studiou-wc-product-cat-manage'); ?></p>
- </td>
- </tr>
- </table>
-
- <div class="submit-buttons">
- <button type="submit" class="button button-primary" id="studiou-wcpcm-batch-description-button">
- <?php echo esc_html__('Do', 'studiou-wc-product-cat-manage'); ?>
- </button>
- <span class="spinner"></span>
- </div>
- </form>
-
- <div class="studiou-wcpcm-batch-description-results" style="display: none;">
- <h3><?php echo esc_html__('Batch Description Results', 'studiou-wc-product-cat-manage'); ?></h3>
- <div id="studiou-wcpcm-batch-description-message"></div>
- </div>
- </div>
-
- <!-- Important Notes -->
- <div class="studiou-wcpcm-card">
- <h2><?php echo esc_html__('Important Notes', 'studiou-wc-product-cat-manage'); ?></h2>
- <ul>
- <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>
- <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>
- <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>
- <li><?php echo esc_html__('The operation processes all products regardless of their status (published, draft, private).', 'studiou-wc-product-cat-manage'); ?></li>
- <li><?php echo esc_html__('The batch description operation will overwrite the existing descriptions for all selected categories.', 'studiou-wc-product-cat-manage'); ?></li>
- </ul>
- </div>
- </div>
|