tab-upvp.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. /**
  3. * Category Manipulations tab partial: Update product variant prices.
  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. <!-- Update Product Variant Prices Operation -->
  16. <div class="studiou-wcpcm-card">
  17. <h2><?php echo esc_html__('Update product variant prices', 'studiou-wc-product-cat-manage'); ?></h2>
  18. <p><?php echo esc_html__('Bulk-update the regular price of product variations matching the selected categories and a chosen variation attribute. Only product records are modified — existing orders and cart contents are not affected.', 'studiou-wc-product-cat-manage'); ?></p>
  19. <form id="studiou-wcpcm-upvp-form" method="post" onsubmit="return false;">
  20. <table class="form-table">
  21. <tr>
  22. <th scope="row">
  23. <label for="upvp_categories_list"><?php echo esc_html__('Select Categories', 'studiou-wc-product-cat-manage'); ?></label>
  24. </th>
  25. <td>
  26. <div class="studiou-wcpcm-categories-list-container">
  27. <div class="studiou-wcpcm-list-actions">
  28. <button type="button" id="studiou-wcpcm-upvp-check-all" class="button">
  29. <?php echo esc_html__('Check All', 'studiou-wc-product-cat-manage'); ?>
  30. </button>
  31. <button type="button" id="studiou-wcpcm-upvp-uncheck-all" class="button">
  32. <?php echo esc_html__('Uncheck All', 'studiou-wc-product-cat-manage'); ?>
  33. </button>
  34. </div>
  35. <div class="studiou-wcpcm-categories-list" id="upvp_categories_list">
  36. <?php foreach ($categories as $category): ?>
  37. <label class="studiou-wcpcm-category-item">
  38. <input type="checkbox" name="upvp_categories[]" value="<?php echo esc_attr($category['id']); ?>">
  39. <span><?php echo esc_html($category['display_name']); ?></span>
  40. </label>
  41. <?php endforeach; ?>
  42. </div>
  43. </div>
  44. </td>
  45. </tr>
  46. <tr>
  47. <th scope="row">
  48. <label for="upvp_attribute"><?php echo esc_html__('Variant attribute', 'studiou-wc-product-cat-manage'); ?></label>
  49. </th>
  50. <td>
  51. <select id="upvp_attribute" name="upvp_attribute" class="regular-text">
  52. <option value=""><?php echo esc_html__('-- Select attribute --', 'studiou-wc-product-cat-manage'); ?></option>
  53. </select>
  54. </td>
  55. </tr>
  56. <tr>
  57. <th scope="row">
  58. <label for="upvp_attribute_value"><?php echo esc_html__('Variant attribute value', 'studiou-wc-product-cat-manage'); ?></label>
  59. </th>
  60. <td>
  61. <select id="upvp_attribute_value" name="upvp_attribute_value" class="regular-text" disabled>
  62. <option value=""><?php echo esc_html__('-- Select value --', 'studiou-wc-product-cat-manage'); ?></option>
  63. </select>
  64. </td>
  65. </tr>
  66. <tr>
  67. <th scope="row">
  68. <label for="upvp_new_price"><?php echo esc_html__('New Price', 'studiou-wc-product-cat-manage'); ?></label>
  69. </th>
  70. <td>
  71. <input type="number" step="0.01" min="0" id="upvp_new_price" name="upvp_new_price" class="regular-text">
  72. </td>
  73. </tr>
  74. <tr>
  75. <th scope="row">
  76. <?php echo esc_html__('Affected variations', 'studiou-wc-product-cat-manage'); ?>
  77. </th>
  78. <td>
  79. <strong id="studiou-wcpcm-upvp-affected-count">0</strong>
  80. </td>
  81. </tr>
  82. </table>
  83. <div class="submit-buttons">
  84. <button type="button" id="studiou-wcpcm-upvp-dry-run-button" class="button">
  85. <?php echo esc_html__('Dry Run', 'studiou-wc-product-cat-manage'); ?>
  86. </button>
  87. <button type="button" id="studiou-wcpcm-upvp-apply-button" class="button button-primary">
  88. <?php echo esc_html__('Apply', 'studiou-wc-product-cat-manage'); ?>
  89. </button>
  90. <span class="spinner"></span>
  91. </div>
  92. </form>
  93. <div class="studiou-wcpcm-upvp-results" style="display: none;">
  94. <h3><?php echo esc_html__('Results', 'studiou-wc-product-cat-manage'); ?></h3>
  95. <div id="studiou-wcpcm-upvp-message"></div>
  96. </div>
  97. </div>