Эх сурвалжийг харах

studiou-wc-product-cat-manage: add support batch description update, update translations

Dalibor Votruba 1 жил өмнө
parent
commit
99e1d64623

+ 56 - 4
studiou-wc-product-cat-manage/assets/css/admin.css

@@ -66,7 +66,8 @@
 
 .studiou-wcpcm-import-results,
 .studiou-wcpcm-export-results,
-.studiou-wcpcm-move-results {
+.studiou-wcpcm-move-results,
+.studiou-wcpcm-batch-description-results {
     margin-top: 30px;
     padding-top: 20px;
     border-top: 1px solid #eee;
@@ -99,23 +100,74 @@
     width: 300px;
 }
 
-.studiou-wcpcm-move-results {
+.studiou-wcpcm-move-results,
+.studiou-wcpcm-batch-description-results {
     background: #f9f9f9;
     padding: 15px;
     border: 1px solid #ddd;
     border-radius: 4px;
 }
 
-.studiou-wcpcm-move-results h3 {
+.studiou-wcpcm-move-results h3,
+.studiou-wcpcm-batch-description-results h3 {
     margin-top: 0;
     margin-bottom: 10px;
 }
 
-.studiou-wcpcm-move-results #studiou-wcpcm-move-message {
+.studiou-wcpcm-move-results #studiou-wcpcm-move-message,
+.studiou-wcpcm-batch-description-results #studiou-wcpcm-batch-description-message {
     font-weight: 500;
     color: #333;
 }
 
+/* Categories list styles */
+.studiou-wcpcm-categories-list-container {
+    border: 1px solid #ddd;
+    border-radius: 4px;
+    background: #fff;
+}
+
+.studiou-wcpcm-list-actions {
+    padding: 10px;
+    border-bottom: 1px solid #ddd;
+    background: #f9f9f9;
+}
+
+.studiou-wcpcm-list-actions .button {
+    margin-right: 10px;
+}
+
+.studiou-wcpcm-categories-list {
+    max-height: 200px;
+    overflow-y: auto;
+    padding: 10px;
+}
+
+.studiou-wcpcm-category-item {
+    display: block;
+    padding: 8px 0;
+    border-bottom: 1px solid #f0f0f0;
+    cursor: pointer;
+    user-select: none;
+}
+
+.studiou-wcpcm-category-item:last-child {
+    border-bottom: none;
+}
+
+.studiou-wcpcm-category-item:hover {
+    background-color: #f8f9fa;
+}
+
+.studiou-wcpcm-category-item input[type="checkbox"] {
+    margin-right: 8px;
+    margin-top: 0;
+}
+
+.studiou-wcpcm-category-item span {
+    vertical-align: top;
+}
+
 /* Info notes styling */
 .studiou-wcpcm-card ul {
     margin-left: 20px;

+ 103 - 0
studiou-wc-product-cat-manage/assets/js/admin.js

@@ -30,6 +30,12 @@
             console.log('STUDIOU WC: Move form NOT found');
         }
         
+        // Batch description form handling
+        if ($('#studiou-wcpcm-batch-description-form').length) {
+            console.log('STUDIOU WC: Batch description form found');
+            initBatchDescriptionForm();
+        }
+        
         // Sample CSV download handler
         if ($('#studiou-wcpcm-download-sample').length) {
             initSampleDownload();
@@ -228,6 +234,101 @@
         });
     }
     
+    /**
+     * Initialize batch description form
+     */
+    function initBatchDescriptionForm() {
+        console.log('STUDIOU WC: Initializing batch description form handlers');
+        
+        // Check all button handler
+        $('#studiou-wcpcm-check-all').on('click', function(e) {
+            e.preventDefault();
+            console.log('STUDIOU WC: Check all button clicked');
+            $('#categories_list input[type="checkbox"]').prop('checked', true);
+        });
+        
+        // Uncheck all button handler
+        $('#studiou-wcpcm-uncheck-all').on('click', function(e) {
+            e.preventDefault();
+            console.log('STUDIOU WC: Uncheck all button clicked');
+            $('#categories_list input[type="checkbox"]').prop('checked', false);
+        });
+        
+        // Form submit handler
+        $('#studiou-wcpcm-batch-description-form').on('submit', function(e) {
+            e.preventDefault();
+            
+            console.log('STUDIOU WC: Batch description form submitted');
+            
+            // Get selected categories
+            var selectedCategories = [];
+            $('#categories_list input[type="checkbox"]:checked').each(function() {
+                selectedCategories.push($(this).val());
+            });
+            
+            var description = $('#category_description').val();
+            
+            console.log('STUDIOU WC: Selected categories:', selectedCategories);
+            console.log('STUDIOU WC: Description:', description);
+            
+            // Validate input
+            if (selectedCategories.length === 0) {
+                console.log('STUDIOU WC: No categories selected');
+                showNotice('error', 'Please select at least one category');
+                return;
+            }
+            
+            // Show spinner
+            var $submitBtn = $(this).find('#studiou-wcpcm-batch-description-button');
+            var $spinner = $(this).find('.spinner');
+            
+            $submitBtn.prop('disabled', true);
+            $spinner.css('visibility', 'visible');
+            
+            // Clear previous notices
+            $('.studiou-wcpcm-notice-area').empty();
+            
+            // Debug: Log AJAX request details
+            console.log('STUDIOU WC: Sending batch description AJAX request to:', studiouWcpcm.ajaxUrl);
+            console.log('STUDIOU WC: Nonce:', studiouWcpcm.nonce);
+            
+            // Send AJAX request
+            $.ajax({
+                url: studiouWcpcm.ajaxUrl,
+                type: 'POST',
+                data: {
+                    action: 'studiou_wcpcm_batch_description',
+                    selected_categories: selectedCategories,
+                    description: description,
+                    nonce: studiouWcpcm.nonce
+                },
+                success: function(response) {
+                    console.log('STUDIOU WC: Batch description AJAX response:', response);
+                    
+                    if (response.success) {
+                        showNotice('success', studiouWcpcm.i18n.batchDescriptionSuccess || 'Batch description operation successful');
+                        
+                        // Show results
+                        $('#studiou-wcpcm-batch-description-message').html('<p>' + response.data.message + '</p>');
+                        $('.studiou-wcpcm-batch-description-results').show();
+                    } else {
+                        showNotice('error', response.data.message);
+                    }
+                },
+                error: function(xhr, status, error) {
+                    console.error('STUDIOU WC: Batch description AJAX error:', status, error);
+                    console.error('STUDIOU WC: Response text:', xhr.responseText);
+                    showNotice('error', (studiouWcpcm.i18n.batchDescriptionError || 'Batch description operation error') + ': ' + error);
+                },
+                complete: function() {
+                    // Hide spinner
+                    $submitBtn.prop('disabled', false);
+                    $spinner.css('visibility', 'hidden');
+                }
+            });
+        });
+    }
+    
     /**
      * Initialize sample CSV download
      */
@@ -281,6 +382,8 @@
         console.log('STUDIOU WC: Move button exists:', $('#studiou-wcpcm-move-button').length > 0);
         console.log('STUDIOU WC: Source select exists:', $('#source_category').length > 0);
         console.log('STUDIOU WC: Target select exists:', $('#target_category').length > 0);
+        console.log('STUDIOU WC: Batch description form exists:', $('#studiou-wcpcm-batch-description-form').length > 0);
+        console.log('STUDIOU WC: Batch description button exists:', $('#studiou-wcpcm-batch-description-button').length > 0);
     });
     
 })(jQuery);

+ 102 - 5
studiou-wc-product-cat-manage/includes/class-studiou-wc-product-cat-manage-manipulator.php

@@ -33,22 +33,119 @@ class Studiou_WC_Product_Cat_Manage_Manipulator {
         
         // Register AJAX handlers
         add_action('wp_ajax_studiou_wcpcm_move_products', array($this, 'handle_move_products_ajax'));
+        add_action('wp_ajax_studiou_wcpcm_batch_description', array($this, 'handle_batch_description_ajax'));
         
         // Add a test AJAX handler to verify AJAX is working
         add_action('wp_ajax_studiou_wcpcm_test', array($this, 'handle_test_ajax'));
         
         // Debug: Log that the handler is being registered
         if (defined('WP_DEBUG') && WP_DEBUG) {
-            error_log('STUDIOU WC: AJAX handler wp_ajax_studiou_wcpcm_move_products registered');
+            error_log('STUDIOU WC: AJAX handlers registered - move_products and batch_description');
         }
     }
     
     /**
-     * Test AJAX handler to verify AJAX is working
+     * Handle AJAX batch description request
      */
-    public function handle_test_ajax() {
-        error_log('STUDIOU WC: Test AJAX handler called');
-        wp_send_json_success(array('message' => 'AJAX is working'));
+    public function handle_batch_description_ajax() {
+        // Clean all output buffers and prevent any output
+        while (ob_get_level()) {
+            ob_end_clean();
+        }
+        
+        // Start a new output buffer to catch any unwanted output
+        ob_start();
+        
+        // Suppress PHP errors/notices during AJAX to prevent JSON corruption
+        $original_error_reporting = error_reporting();
+        error_reporting(0);
+        
+        // Enable error logging only
+        if (defined('WP_DEBUG') && WP_DEBUG) {
+            error_log('STUDIOU WC: Batch description AJAX handler called');
+            error_log('STUDIOU WC: POST data: ' . print_r($_POST, true));
+        }
+        
+        try {
+            // Check nonce
+            if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'studiou-wcpcm-nonce')) {
+                wp_send_json_error(array(
+                    'message' => __('Security check failed', 'studiou-wc-product-cat-manage')
+                ));
+            }
+            
+            // Check permissions
+            if (!current_user_can('manage_woocommerce')) {
+                wp_send_json_error(array(
+                    'message' => __('You do not have sufficient permissions', 'studiou-wc-product-cat-manage')
+                ));
+            }
+            
+            // Validate input
+            if (!isset($_POST['selected_categories']) || !isset($_POST['description'])) {
+                wp_send_json_error(array(
+                    'message' => __('Missing required parameters', 'studiou-wc-product-cat-manage')
+                ));
+            }
+            
+            $selected_categories = array_map('intval', $_POST['selected_categories']);
+            $description = sanitize_textarea_field($_POST['description']);
+            
+            // Debug logging
+            if (defined('WP_DEBUG') && WP_DEBUG) {
+                error_log('STUDIOU WC: Batch description operation started - Categories: ' . implode(', ', $selected_categories));
+                error_log('STUDIOU WC: Description: ' . $description);
+            }
+            
+            // Validate categories
+            if (empty($selected_categories)) {
+                wp_send_json_error(array(
+                    'message' => __('Please select at least one category', 'studiou-wc-product-cat-manage')
+                ));
+            }
+            
+            // Execute batch description operation
+            $result = $this->update_categories_description($selected_categories, $description);
+            
+            // Debug logging
+            if (defined('WP_DEBUG') && WP_DEBUG) {
+                error_log('STUDIOU WC: Batch description operation completed - Updated: ' . $result['updated_count'] . ' categories');
+                error_log('STUDIOU WC: Sending success response: ' . print_r($result, true));
+            }
+            
+            // Clean any output that might have been generated
+            ob_clean();
+            
+            // Return success response
+            wp_send_json_success(array(
+                'message' => $result['message'],
+                'updated_count' => $result['updated_count'],
+                'failed_count' => isset($result['failed_count']) ? $result['failed_count'] : 0
+            ));
+            
+        } catch (Exception $e) {
+            // Debug logging
+            if (defined('WP_DEBUG') && WP_DEBUG) {
+                error_log('STUDIOU WC: Batch description operation failed - ' . $e->getMessage());
+                error_log('STUDIOU WC: Exception trace: ' . $e->getTraceAsString());
+            }
+            
+            // Clean any output that might have been generated
+            ob_clean();
+            
+            wp_send_json_error(array(
+                'message' => sprintf(
+                    __('Error during batch description operation: %s', 'studiou-wc-product-cat-manage'),
+                    $e->getMessage()
+                )
+            ));
+        } finally {
+            // Restore original error reporting
+            error_reporting($original_error_reporting);
+            
+            // End the output buffer
+            ob_end_clean();
+        }
     }
     
     /**

+ 7 - 0
studiou-wc-product-cat-manage/instructions.txt

@@ -67,4 +67,11 @@ Plugin will have following features:
 				- iterate products from source category
 				- product in iteration will me reassigned to target category (and remove from source category)
 				- at the end of operation print out output information how many products was moved and new count of products in source category and new count of products in target ctegory.
+		- In screen Category manipulations implements operation called "Batch description between categories" in header to set description to selected product category.
+			- There will be listbox with checkboxes with Category list. Listbox will have client operations "check all", "uncheck all".
+			- There will be multiline textbox called "Product categories description".
+ 			- The will be button "Do" that start operation:
+				- iterate selected product categories.
+				- category in iteration will be set category field "Description"
+				- at the end of operation print out output information how many categories was set.
 	- all text will be translatable 

BIN
studiou-wc-product-cat-manage/languages/studiou-wc-product-cat-manage-cs_CZ.mo


+ 104 - 14
studiou-wc-product-cat-manage/languages/studiou-wc-product-cat-manage-cs_CZ.po

@@ -3,7 +3,7 @@
 # This file is distributed under the same license as the QDR - Studiou WC Export/Import Product Categories package.
 msgid ""
 msgstr ""
-"Project-Id-Version: QDR - Studiou WC Export/Import Product Categories 1.2.0\n"
+"Project-Id-Version: QDR - Studiou WC Export/Import Product Categories 1.2.1\n"
 "Report-Msgid-Bugs-To: https://www.quadarax.com/plugins/studiou-wc-product-"
 "cat-manage\n"
 "POT-Creation-Date: 2025-05-15 12:00+0000\n"
@@ -46,12 +46,10 @@ msgstr ""
 "9.8 nebo vyšší. Prosím %snainstalujte nebo aktualizujte WooCommerce%s."
 
 #: studiou-wc-product-cat-manage.php:102 views/import.php:14
-#: views/import.php:41
 msgid "Import Product Categories"
 msgstr "Import kategorií produktů"
 
 #: studiou-wc-product-cat-manage.php:109 views/export.php:14
-#: views/export.php:37
 msgid "Export Product Categories"
 msgstr "Export kategorií produktů"
 
@@ -87,6 +85,14 @@ msgstr "Chyba operace přesunu"
 msgid "Please select different source and target categories"
 msgstr "Prosím vyberte rozdílné zdrojové a cílové kategorie"
 
+#: studiou-wc-product-cat-manage.php:149
+msgid "Batch description operation successful"
+msgstr "Hromadná operace popisu úspěšná"
+
+#: studiou-wc-product-cat-manage.php:150
+msgid "Batch description operation error"
+msgstr "Chyba hromadné operace popisu"
+
 #: includes/class-studiou-wc-product-cat-manage-db.php:128
 msgid "Product category '%s' already exists. Skipped."
 msgstr "Kategorie produktu '%s' již existuje. Přeskočeno."
@@ -117,12 +123,14 @@ msgstr "Kategorie produktu '%s' smazána."
 #: includes/class-studiou-wc-product-cat-manage-export.php:43
 #: includes/class-studiou-wc-product-cat-manage-import.php:60
 #: includes/class-studiou-wc-product-cat-manage-manipulator.php:39
+#: includes/class-studiou-wc-product-cat-manage-manipulator.php:90
 msgid "Security check failed"
 msgstr "Bezpečnostní kontrola selhala"
 
 #: includes/class-studiou-wc-product-cat-manage-export.php:49
 #: includes/class-studiou-wc-product-cat-manage-import.php:66
 #: includes/class-studiou-wc-product-cat-manage-manipulator.php:45
+#: includes/class-studiou-wc-product-cat-manage-manipulator.php:96
 #: includes/class-studiou-wc-product-cat-manage-export.php:78
 #: includes/class-studiou-wc-product-cat-manage-export.php:86
 msgid "You do not have sufficient permissions"
@@ -206,6 +214,7 @@ msgid "Imported %d items:"
 msgstr "Importováno %d položek:"
 
 #: includes/class-studiou-wc-product-cat-manage-manipulator.php:51
+#: includes/class-studiou-wc-product-cat-manage-manipulator.php:102
 msgid "Missing required parameters"
 msgstr "Chybí požadované parametry"
 
@@ -225,7 +234,27 @@ msgstr "Chyba během operace přesunu: %s"
 msgid "Invalid category specified"
 msgstr "Zadána neplatná kategorie"
 
+#: includes/class-studiou-wc-product-cat-manage-manipulator.php:108
+msgid "Please select at least one category"
+msgstr "Prosím vyberte alespoň jednu kategorii"
+
+#: includes/class-studiou-wc-product-cat-manage-manipulator.php:132
+msgid "Error during batch description operation: %s"
+msgstr "Chyba během hromadné operace popisu: %s"
+
 #: includes/class-studiou-wc-product-cat-manage-manipulator.php:144
+msgid "No products found in source category \"%s\". Nothing to move."
+msgstr "V zdrojové kategorii \"%s\" nebyly nalezeny žádné produkty. Není co přesunout."
+
+#: includes/class-studiou-wc-product-cat-manage-manipulator.php:210
+msgid ""
+"Failed to move any products from \"%s\" to \"%s\". All %d products "
+"encountered errors during the move operation."
+msgstr ""
+"Nepodařilo se přesunout žádné produkty z \"%s\" do \"%s\". Všech %d produktů "
+"narazilo na chyby během operace přesunu."
+
+#: includes/class-studiou-wc-product-cat-manage-manipulator.php:220
 msgid ""
 "Moved %d products from \"%s\" to \"%s\". Source category now has %d "
 "products, target category now has %d products."
@@ -233,6 +262,26 @@ msgstr ""
 "Přesunuto %d produktů z \"%s\" do \"%s\". Zdrojová kategorie nyní má %d "
 "produktů, cílová kategorie nyní má %d produktů."
 
+#: includes/class-studiou-wc-product-cat-manage-manipulator.php:229
+msgid "Note: %d products failed to move due to errors."
+msgstr "Poznámka: %d produktů se nepodařilo přesunout kvůli chybám."
+
+#: includes/class-studiou-wc-product-cat-manage-manipulator.php:285
+msgid "Failed to update any category descriptions. %d categories encountered errors."
+msgstr "Nepodařilo se aktualizovat popisy žádných kategorií. %d kategorií narazilo na chyby."
+
+#: includes/class-studiou-wc-product-cat-manage-manipulator.php:291
+msgid "Successfully updated descriptions for %d categories: %s"
+msgstr "Úspěšně aktualizovány popisy pro %d kategorií: %s"
+
+#: includes/class-studiou-wc-product-cat-manage-manipulator.php:293
+msgid ", and %d more"
+msgstr ", a %d dalších"
+
+#: includes/class-studiou-wc-product-cat-manage-manipulator.php:297
+msgid "Note: %d categories failed to update due to errors."
+msgstr "Poznámka: %d kategorií se nepodařilo aktualizovat kvůli chybám."
+
 #: views/export.php:17
 msgid "Export to CSV"
 msgstr "Export do CSV"
@@ -373,35 +422,72 @@ msgstr "Zdrojová kategorie"
 msgid "-- Select Source Category --"
 msgstr "-- Vyberte zdrojovou kategorii --"
 
-#: views/manipulations.php:40
+#: views/manipulations.php:44
 msgid "Select the category from which products will be moved."
 msgstr "Vyberte kategorii, ze které budou produkty přesunuty."
 
-#: views/manipulations.php:46
+#: views/manipulations.php:54
 msgid "Target Category"
 msgstr "Cílová kategorie"
 
-#: views/manipulations.php:50
+#: views/manipulations.php:58
 msgid "-- Select Target Category --"
 msgstr "-- Vyberte cílovou kategorii --"
 
-#: views/manipulations.php:56
+#: views/manipulations.php:68
 msgid "Select the category to which products will be moved."
 msgstr "Vyberte kategorii, do které budou produkty přesunuty."
 
-#: views/manipulations.php:63
+#: views/manipulations.php:75
+#: views/manipulations.php:117
 msgid "Do"
 msgstr "Provést"
 
-#: views/manipulations.php:70
+#: views/manipulations.php:82
 msgid "Move Results"
 msgstr "Výsledky přesunu"
 
-#: views/manipulations.php:77
+#: views/manipulations.php:88
+msgid "Batch description between categories"
+msgstr "Hromadný popis mezi kategoriemi"
+
+#: views/manipulations.php:90
+msgid "This operation allows you to set the same description for multiple categories at once."
+msgstr "Tato operace umožňuje nastavit stejný popis pro více kategorií najednou."
+
+#: views/manipulations.php:96
+msgid "Select Categories"
+msgstr "Vyberte kategorie"
+
+#: views/manipulations.php:100
+msgid "Check All"
+msgstr "Vybrat vše"
+
+#: views/manipulations.php:103
+msgid "Uncheck All"
+msgstr "Zrušit výběr všech"
+
+#: views/manipulations.php:113
+msgid "Select the categories for which you want to set the description."
+msgstr "Vyberte kategorie, pro které chcete nastavit popis."
+
+#: views/manipulations.php:119
+msgid "Product categories description"
+msgstr "Popis kategorií produktů"
+
+#: views/manipulations.php:121
+msgid "Enter the description that will be applied to all selected categories."
+msgstr "Zadejte popis, který bude aplikován na všechny vybrané kategorie."
+
+#: views/manipulations.php:129
+msgid "Batch Description Results"
+msgstr "Výsledky hromadného popisu"
+
+#: views/manipulations.php:136
 msgid "Important Notes"
 msgstr "Důležité poznámky"
 
-#: views/manipulations.php:79
+#: views/manipulations.php:138
 msgid ""
 "Products can be assigned to multiple categories. This operation will remove "
 "the product from the source category and add it to the target category."
@@ -409,7 +495,7 @@ msgstr ""
 "Produkty mohou být přiřazeny k více kategoriím. Tato operace odstraní "
 "produkt ze zdrojové kategorie a přidá jej do cílové kategorie."
 
-#: views/manipulations.php:80
+#: views/manipulations.php:139
 msgid ""
 "If a product is only assigned to the source category, it will be moved "
 "entirely to the target category."
@@ -417,7 +503,7 @@ msgstr ""
 "Pokud je produkt přiřazen pouze ke zdrojové kategorii, bude zcela přesunut "
 "do cílové kategorie."
 
-#: views/manipulations.php:81
+#: views/manipulations.php:140
 msgid ""
 "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 "
@@ -426,10 +512,14 @@ msgstr ""
 "Pokud je produkt přiřazen k více kategoriím včetně zdrojové kategorie, "
 "zůstane v ostatních kategoriích a bude přesunut do cílové kategorie."
 
-#: views/manipulations.php:82
+#: views/manipulations.php:141
 msgid ""
 "The operation processes all products regardless of their status (published, "
 "draft, private)."
 msgstr ""
 "Operace zpracovává všechny produkty bez ohledu na jejich stav (publikované, "
 "koncepty, soukromé)."
+
+#: views/manipulations.php:142
+msgid "The batch description operation will overwrite the existing descriptions for all selected categories."
+msgstr "Hromadná operace popisu přepíše stávající popisy všech vybraných kategorií."

+ 100 - 20
studiou-wc-product-cat-manage/languages/studiou-wc-product-cat-manage.po

@@ -2,7 +2,7 @@
 # This file is distributed under the same license as the QDR - Studiou WC Export/Import Product Categories package.
 msgid ""
 msgstr ""
-"Project-Id-Version: QDR - Studiou WC Export/Import Product Categories 1.2.0\n"
+"Project-Id-Version: QDR - Studiou WC Export/Import Product Categories 1.2.1\n"
 "Report-Msgid-Bugs-To: https://www.quadarax.com/plugins/studiou-wc-product-cat-manage\n"
 "POT-Creation-Date: 2025-05-15 12:00+0000\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
@@ -81,6 +81,14 @@ msgstr ""
 msgid "Please select different source and target categories"
 msgstr ""
 
+#: studiou-wc-product-cat-manage.php:149
+msgid "Batch description operation successful"
+msgstr ""
+
+#: studiou-wc-product-cat-manage.php:150
+msgid "Batch description operation error"
+msgstr ""
+
 #: includes/class-studiou-wc-product-cat-manage-db.php:128
 msgid "Product category '%s' already exists. Skipped."
 msgstr ""
@@ -117,12 +125,14 @@ msgstr ""
 #: includes/class-studiou-wc-product-cat-manage-export.php:43
 #: includes/class-studiou-wc-product-cat-manage-import.php:60
 #: includes/class-studiou-wc-product-cat-manage-manipulator.php:39
+#: includes/class-studiou-wc-product-cat-manage-manipulator.php:90
 msgid "Security check failed"
 msgstr ""
 
 #: includes/class-studiou-wc-product-cat-manage-export.php:49
 #: includes/class-studiou-wc-product-cat-manage-import.php:66
 #: includes/class-studiou-wc-product-cat-manage-manipulator.php:45
+#: includes/class-studiou-wc-product-cat-manage-manipulator.php:96
 msgid "You do not have sufficient permissions"
 msgstr ""
 
@@ -204,6 +214,7 @@ msgid "Imported %d items:"
 msgstr ""
 
 #: includes/class-studiou-wc-product-cat-manage-manipulator.php:51
+#: includes/class-studiou-wc-product-cat-manage-manipulator.php:102
 msgid "Missing required parameters"
 msgstr ""
 
@@ -223,10 +234,46 @@ msgstr ""
 msgid "Invalid category specified"
 msgstr ""
 
+#: includes/class-studiou-wc-product-cat-manage-manipulator.php:108
+msgid "Please select at least one category"
+msgstr ""
+
+#: includes/class-studiou-wc-product-cat-manage-manipulator.php:132
+msgid "Error during batch description operation: %s"
+msgstr ""
+
 #: includes/class-studiou-wc-product-cat-manage-manipulator.php:144
+msgid "No products found in source category \"%s\". Nothing to move."
+msgstr ""
+
+#: includes/class-studiou-wc-product-cat-manage-manipulator.php:210
+msgid "Failed to move any products from \"%s\" to \"%s\". All %d products encountered errors during the move operation."
+msgstr ""
+
+#: includes/class-studiou-wc-product-cat-manage-manipulator.php:220
 msgid "Moved %d products from \"%s\" to \"%s\". Source category now has %d products, target category now has %d products."
 msgstr ""
 
+#: includes/class-studiou-wc-product-cat-manage-manipulator.php:229
+msgid "Note: %d products failed to move due to errors."
+msgstr ""
+
+#: includes/class-studiou-wc-product-cat-manage-manipulator.php:285
+msgid "Failed to update any category descriptions. %d categories encountered errors."
+msgstr ""
+
+#: includes/class-studiou-wc-product-cat-manage-manipulator.php:291
+msgid "Successfully updated descriptions for %d categories: %s"
+msgstr ""
+
+#: includes/class-studiou-wc-product-cat-manage-manipulator.php:293
+msgid ", and %d more"
+msgstr ""
+
+#: includes/class-studiou-wc-product-cat-manage-manipulator.php:297
+msgid "Note: %d categories failed to update due to errors."
+msgstr ""
+
 #: views/export.php:17
 msgid "Export to CSV"
 msgstr ""
@@ -271,10 +318,6 @@ msgstr ""
 msgid "Default is \"U\" (update) for all exported categories"
 msgstr ""
 
-#: views/export.php:37
-msgid "Export Product Categories"
-msgstr ""
-
 #: views/export.php:43
 msgid "Export Complete"
 msgstr ""
@@ -331,10 +374,6 @@ msgstr ""
 msgid "Choose CSV file"
 msgstr ""
 
-#: views/import.php:41
-msgid "Import Product Categories"
-msgstr ""
-
 #: views/import.php:48
 msgid "Import Results"
 msgstr ""
@@ -363,46 +402,87 @@ msgstr ""
 msgid "-- Select Source Category --"
 msgstr ""
 
-#: views/manipulations.php:40
+#: views/manipulations.php:44
 msgid "Select the category from which products will be moved."
 msgstr ""
 
-#: views/manipulations.php:46
+#: views/manipulations.php:54
 msgid "Target Category"
 msgstr ""
 
-#: views/manipulations.php:50
+#: views/manipulations.php:58
 msgid "-- Select Target Category --"
 msgstr ""
 
-#: views/manipulations.php:56
+#: views/manipulations.php:68
 msgid "Select the category to which products will be moved."
 msgstr ""
 
-#: views/manipulations.php:63
+#: views/manipulations.php:75
+#: views/manipulations.php:117
 msgid "Do"
 msgstr ""
 
-#: views/manipulations.php:70
+#: views/manipulations.php:82
 msgid "Move Results"
 msgstr ""
 
-#: views/manipulations.php:77
+#: views/manipulations.php:88
+msgid "Batch description between categories"
+msgstr ""
+
+#: views/manipulations.php:90
+msgid "This operation allows you to set the same description for multiple categories at once."
+msgstr ""
+
+#: views/manipulations.php:96
+msgid "Select Categories"
+msgstr ""
+
+#: views/manipulations.php:100
+msgid "Check All"
+msgstr ""
+
+#: views/manipulations.php:103
+msgid "Uncheck All"
+msgstr ""
+
+#: views/manipulations.php:113
+msgid "Select the categories for which you want to set the description."
+msgstr ""
+
+#: views/manipulations.php:119
+msgid "Product categories description"
+msgstr ""
+
+#: views/manipulations.php:121
+msgid "Enter the description that will be applied to all selected categories."
+msgstr ""
+
+#: views/manipulations.php:129
+msgid "Batch Description Results"
+msgstr ""
+
+#: views/manipulations.php:136
 msgid "Important Notes"
 msgstr ""
 
-#: views/manipulations.php:79
+#: views/manipulations.php:138
 msgid "Products can be assigned to multiple categories. This operation will remove the product from the source category and add it to the target category."
 msgstr ""
 
-#: views/manipulations.php:80
+#: views/manipulations.php:139
 msgid "If a product is only assigned to the source category, it will be moved entirely to the target category."
 msgstr ""
 
-#: views/manipulations.php:81
+#: views/manipulations.php:140
 msgid "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."
 msgstr ""
 
-#: views/manipulations.php:82
+#: views/manipulations.php:141
 msgid "The operation processes all products regardless of their status (published, draft, private)."
+msgstr ""
+
+#: views/manipulations.php:142
+msgid "The batch description operation will overwrite the existing descriptions for all selected categories."
 msgstr ""

+ 25 - 3
studiou-wc-product-cat-manage/readme.md

@@ -6,7 +6,7 @@ A WordPress plugin that extends WooCommerce to provide batch export and import f
 
 ## Description
 
-QDR - Studiou WC Export/Import Product Categories is a powerful WordPress plugin for WooCommerce store administrators who need to manage product categories in bulk. This plugin allows you to export your existing product categories to a CSV file, make modifications, and import them back into your store. Additionally, it provides tools for manipulating categories and moving products between categories.
+QDR - Studiou WC Export/Import Product Categories is a powerful WordPress plugin for WooCommerce store administrators who need to manage product categories in bulk. This plugin allows you to export your existing product categories to a CSV file, make modifications, and import them back into your store. Additionally, it provides tools for manipulating categories, moving products between categories, and batch updating category descriptions.
 
 The plugin also supports the WooCommerce Protected Categories extension, allowing you to manage visibility settings and passwords for your product categories.
 
@@ -16,7 +16,8 @@ The plugin also supports the WooCommerce Protected Categories extension, allowin
 - Import product categories from a CSV file
 - Add, update, or delete product categories in batch
 - Support for WooCommerce Protected Categories visibility settings
-- **NEW**: Move products between categories in bulk
+- **Move products between categories** in bulk
+- **Batch description update** for multiple categories
 - User-friendly interface integrated with WooCommerce admin
 - Comprehensive validation and error reporting
 
@@ -81,6 +82,23 @@ The plugin uses CSV files with the following columns:
 - 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.
 - The operation processes all products regardless of their status (published, draft, private).
 
+#### Batch Description Between Categories
+
+1. Go to Products > Category Manipulations
+2. Scroll to the "Batch description between categories" section
+3. Select one or more categories using the checkboxes
+   - Use "Check All" to select all categories
+   - Use "Uncheck All" to deselect all categories
+4. Enter the description text in the textarea
+5. Click "Do" to apply the description to all selected categories
+6. Review the results showing how many categories were updated
+
+**Important Notes about Batch Description:**
+- The operation will overwrite the existing descriptions for all selected categories
+- Categories can be selected individually or in bulk using the check/uncheck all buttons
+- The description field supports multi-line text
+- All selected categories will receive exactly the same description
+
 ## Sample CSV
 
 ```
@@ -104,7 +122,9 @@ After activation, the plugin adds the following menu items under **Products** in
 
 - Import Product Categories
 - Export Product Categories
-- **Category Manipulations** (NEW)
+- **Category Manipulations**
+  - Move products between categories
+  - **Batch description between categories**
 
 ## License
 
@@ -124,9 +144,11 @@ For support, please visit [https://www.quadarax.com/plugins/studiou-wc-product-c
 ### Version 1.2.0
 - Added Category Manipulations functionality
 - New feature: Move products between categories
+- **New feature: Batch description between categories**
 - Enhanced admin interface with better user feedback
 - Improved security with proper nonce validation
 - Added comprehensive documentation
+- Direct database queries for reliable product detection
 
 ### Version 1.1.0
 - Initial release with import/export functionality

+ 4 - 2
studiou-wc-product-cat-manage/studiou-wc-product-cat-manage.php

@@ -3,7 +3,7 @@
  * Plugin Name: QDR - Studiou WC Export/Import Product Categories
  * Plugin URI: https://www.quadarax.com/plugins/studiou-wc-product-cat-manage
  * Description: Allows batch import and export WooCommerce product categories
- * Version: 1.2.0
+ * Version: 1.2.1
  * Requires at least: 6.8.1
  * Requires PHP: 8.2
  * Author: Dalibor Votruba
@@ -23,7 +23,7 @@ if (!defined('WPINC')) {
 }
 
 // Define plugin constants
-if (!defined('STUDIOU_WCPCM_VERSION')) define('STUDIOU_WCPCM_VERSION', '1.2.0');
+if (!defined('STUDIOU_WCPCM_VERSION')) define('STUDIOU_WCPCM_VERSION', '1.2.1');
 if (!defined('STUDIOU_WCPCM_PLUGIN_DIR')) define('STUDIOU_WCPCM_PLUGIN_DIR', plugin_dir_path(__FILE__));
 if (!defined('STUDIOU_WCPCM_PLUGIN_URL')) define('STUDIOU_WCPCM_PLUGIN_URL', plugin_dir_url(__FILE__));
 if (!defined('STUDIOU_WCPCM_PLUGIN_BASENAME')) define('STUDIOU_WCPCM_PLUGIN_BASENAME', plugin_basename(__FILE__));
@@ -220,6 +220,8 @@ class Studiou_WC_Product_Cat_Manage {
                     'moveSuccess' => __('Move operation successful', 'studiou-wc-product-cat-manage'),
                     'moveError' => __('Move operation error', 'studiou-wc-product-cat-manage'),
                     'selectDifferentCategories' => __('Please select different source and target categories', 'studiou-wc-product-cat-manage'),
+                    'batchDescriptionSuccess' => __('Batch description operation successful', 'studiou-wc-product-cat-manage'),
+                    'batchDescriptionError' => __('Batch description operation error', 'studiou-wc-product-cat-manage'),
                 )
             ));
             

+ 61 - 1
studiou-wc-product-cat-manage/views/manipulations.php

@@ -23,6 +23,7 @@ $categories = $manipulator->get_categories_with_counts();
         <!-- 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>
         
@@ -78,8 +79,66 @@ $categories = $manipulator->get_categories_with_counts();
         </div>
     </div>
     
-    <!-- Add more manipulation operations here in the future -->
+    <!-- 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>
@@ -87,6 +146,7 @@ $categories = $manipulator->get_categories_with_counts();
             <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>