Changeset 3456301
- Timestamp:
- 02/08/2026 08:23:00 AM (13 days ago)
- Location:
- priceboard-lite
- Files:
-
- 16 added
- 2 edited
-
tags/1.4.1 (added)
-
tags/1.4.1/languages (added)
-
tags/1.4.1/languages/priceboard-lite-cs_CZ.mo (added)
-
tags/1.4.1/languages/priceboard-lite-cs_CZ.po (added)
-
tags/1.4.1/languages/priceboard-lite-de_DE.mo (added)
-
tags/1.4.1/languages/priceboard-lite-de_DE.po (added)
-
tags/1.4.1/languages/priceboard-lite-hr.mo (added)
-
tags/1.4.1/languages/priceboard-lite-hr.po (added)
-
tags/1.4.1/languages/priceboard-lite-hu_HU.mo (added)
-
tags/1.4.1/languages/priceboard-lite-hu_HU.po (added)
-
tags/1.4.1/languages/priceboard-lite-pl_PL.mo (added)
-
tags/1.4.1/languages/priceboard-lite-pl_PL.po (added)
-
tags/1.4.1/languages/priceboard-lite-ro_RO.mo (added)
-
tags/1.4.1/languages/priceboard-lite-ro_RO.po (added)
-
tags/1.4.1/priceboard-lite.php (added)
-
tags/1.4.1/readme.txt (added)
-
trunk/priceboard-lite.php (modified) (4 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
priceboard-lite/trunk/priceboard-lite.php
r3456291 r3456301 4 4 * Plugin URI: https://priceboard.hu/plugin-info/ 5 5 * Description: Fast WooCommerce price editor for Simple products with live search. 6 * Version: 1. 3.56 * Version: 1.4.1 7 7 * Author: PriceBoard 8 8 * Author URI: https://priceboard.hu … … 46 46 // Szabályos script beágyazás 47 47 public function enqueue_admin_scripts($hook) { 48 // Csak a mi oldalunkon töltődjön be 49 if (strpos($hook, self::SLUG) === false) { 50 return; 48 if (strpos($hook, self::SLUG) === false) { 49 return; 50 } 51 52 wp_register_script('priceboard-ajax-search', false); 53 wp_enqueue_script('priceboard-ajax-search'); 54 55 $js_code = " 56 document.addEventListener('DOMContentLoaded', function() { 57 const searchInput = document.getElementById('pb-search'); 58 const tableBody = document.getElementById('pb-table'); 59 const selectAllCb = document.getElementById('pb-select-all'); 60 let typingTimer; 61 62 // 1. ÉLŐ KERESÉS 63 if (searchInput) { 64 searchInput.addEventListener('input', function() { 65 clearTimeout(typingTimer); 66 tableBody.style.opacity = '0.3'; 67 typingTimer = setTimeout(function() { 68 const formData = new URLSearchParams(); 69 formData.append('action', 'priceboard_live_search'); 70 formData.append('q', searchInput.value); 71 fetch(ajaxurl, { method: 'POST', body: formData }) 72 .then(r => r.json()).then(res => { 73 if (res.success) tableBody.innerHTML = res.data; 74 tableBody.style.opacity = '1'; 75 }); 76 }, 300); 77 }); 51 78 } 52 79 53 // Egy üres scriptet regisztrálunk, amihez hozzáfűzzük az inline kódunkat 54 wp_register_script('priceboard-ajax-search', false); 55 wp_enqueue_script('priceboard-ajax-search'); 56 57 // Itt a javítás: egyetlen " jel az elején és egy " jel a végén a pontosvessző előtt! 58 $js_code = " 59 document.addEventListener('DOMContentLoaded', function() { 60 const searchInput = document.getElementById('pb-search'); 61 const tableBody = document.getElementById('pb-table'); 62 const selectAllCb = document.getElementById('pb-select-all'); 63 let typingTimer; 64 65 // 1. ÉLŐ KERESÉS 66 if (searchInput) { 67 searchInput.addEventListener('input', function() { 68 clearTimeout(typingTimer); 69 tableBody.style.opacity = '0.3'; 70 typingTimer = setTimeout(function() { 71 const formData = new URLSearchParams(); 72 formData.append('action', 'priceboard_live_search'); 73 formData.append('q', searchInput.value); 74 fetch(ajaxurl, { method: 'POST', body: formData }) 75 .then(r => r.json()).then(res => { 76 if (res.success) tableBody.innerHTML = res.data; 77 tableBody.style.opacity = '1'; 78 }); 79 }, 300); 80 }); 81 } 82 83 // 2. MINDET KIJELÖL FUNKCIÓ 84 if (selectAllCb) { 85 selectAllCb.addEventListener('change', function() { 86 const checkboxes = document.querySelectorAll('.pb-select-product'); 87 checkboxes.forEach(cb => cb.checked = selectAllCb.checked); 88 }); 89 } 90 91 // 3. TÖMEGES MÓDOSÍTÁS LOGIKÁJA 92 const applyBtn = document.getElementById('apply-bulk'); 93 if (applyBtn) { 94 applyBtn.addEventListener('click', function() { 95 const valInput = document.getElementById('bulk-value').value.replace(',', '.'); 96 const val = parseFloat(valInput); 97 const type = document.getElementById('bulk-type').value; 98 const dateFrom = document.getElementById('bulk-date-from').value; 99 const dateTo = document.getElementById('bulk-date-to').value; 100 const selectedProducts = document.querySelectorAll('.pb-select-product:checked'); 101 102 if (isNaN(val)) { 103 alert('Kérlek, adj meg egy érvényes számot (pl. 5.6 vagy -12)!'); 104 return; 80 // 2. MINDET KIJELÖL FUNKCIÓ 81 if (selectAllCb) { 82 selectAllCb.addEventListener('change', function() { 83 const checkboxes = document.querySelectorAll('.pb-select-product'); 84 checkboxes.forEach(cb => cb.checked = selectAllCb.checked); 85 }); 86 } 87 88 // 3. TÖMEGES MÓDOSÍTÁS LOGIKÁJA (Target választóval) 89 const applyBtn = document.getElementById('apply-bulk'); 90 if (applyBtn) { 91 applyBtn.addEventListener('click', function() { 92 const valInput = document.getElementById('bulk-value').value.replace(',', '.'); 93 const val = parseFloat(valInput); 94 const type = document.getElementById('bulk-type').value; 95 const target = document.getElementById('bulk-target').value; // Célpont: regular, sale, both 96 const dateFrom = document.getElementById('bulk-date-from').value; 97 const dateTo = document.getElementById('bulk-date-to').value; 98 const selectedProducts = document.querySelectorAll('.pb-select-product:checked'); 99 100 if (isNaN(val)) { 101 alert('Kérlek, adj meg egy érvényes számot!'); 102 return; 103 } 104 105 if (selectedProducts.length === 0) { 106 alert('Nincs kijelölve termék!'); 107 return; 108 } 109 110 selectedProducts.forEach(cb => { 111 const row = cb.closest('tr'); 112 const regInput = row.querySelector('.pb-input-regular'); 113 const saleInput = row.querySelector('.pb-input-sale'); 114 115 // Alapár kinyerése 116 let basePrice = parseFloat(regInput.value.replace(',', '.')); 117 if (isNaN(basePrice)) basePrice = 0; 118 119 // Új érték kiszámítása 120 let newValue = (type === 'percent') ? basePrice * (1 + (val / 100)) : basePrice + val; 121 newValue = Math.max(0, newValue).toFixed(2); 122 123 // Alkalmazás a választott mező(k)re 124 if (target === 'regular' || target === 'both') { 125 regInput.value = newValue; 126 regInput.style.backgroundColor = '#e7f7ed'; 127 setTimeout(() => { regInput.style.backgroundColor = ''; }, 1000); 105 128 } 106 107 if (selectedProducts.length === 0) { 108 alert('Nincs kijelölve termék!'); 109 return; 110 } 111 112 selectedProducts.forEach(cb => { 113 const row = cb.closest('tr'); 114 const regInput = row.querySelector('.pb-input-regular'); 115 const saleInput = row.querySelector('.pb-input-sale'); 116 const fromInput = row.querySelector('.pb-input-from'); 117 const toInput = row.querySelector('.pb-input-to'); 118 119 let originalPrice = parseFloat(regInput.value.replace(',', '.')); 120 if (isNaN(originalPrice)) originalPrice = 0; 121 122 let newSalePrice; 123 if (type === 'percent') { 124 newSalePrice = originalPrice * (1 + (val / 100)); 125 } else { 126 newSalePrice = originalPrice + val; 127 } 128 129 saleInput.value = Math.max(0, newSalePrice).toFixed(2); 130 131 if (dateFrom) fromInput.value = dateFrom; 132 if (dateTo) toInput.value = dateTo; 133 129 130 if (target === 'sale' || target === 'both') { 131 saleInput.value = newValue; 134 132 saleInput.style.backgroundColor = '#e7f7ed'; 135 133 setTimeout(() => { saleInput.style.backgroundColor = ''; }, 1000); 136 }); 134 135 // Dátumok frissítése 136 if (dateFrom) row.querySelector('.pb-input-from').value = dateFrom; 137 if (dateTo) row.querySelector('.pb-input-to').value = dateTo; 138 } 137 139 }); 138 } 139 });"; 140 141 wp_add_inline_script('priceboard-ajax-search', $js_code); 142 } 140 }); 141 } 142 });"; 143 144 wp_add_inline_script('priceboard-ajax-search', $js_code); 145 } 143 146 144 147 public function page() { … … 162 165 if (isset($_GET['saved'])) echo '<div class="notice notice-success is-dismissible"><p>' . esc_html__('Prices saved successfully.', 'priceboard-lite') . '</p></div>'; 163 166 164 // 1. Keresőmező165 167 echo '<div style="margin: 20px 0;"><input type="text" id="pb-search" placeholder="' . esc_attr__('Search simple products by name or SKU...', 'priceboard-lite') . '" style="min-width:450px; padding:12px; border:2px solid #2271b1; border-radius:6px;"></div>'; 166 168 167 // 2. Tömeges Módosító Panel (Bulk Panel)168 169 echo '<div id="pb-bulk-panel" style="background:#f0f6fb; padding:15px; border-radius:8px; border:1px solid #2271b1; margin-bottom:20px; display:flex; gap:12px; align-items:center; flex-wrap: wrap;">'; 169 170 echo '<strong style="color:#2271b1;"><span class="dashicons dashicons-admin-generic" style="vertical-align:middle; margin-right:5px;"></span>' . esc_html__('Tömeges művelet:', 'priceboard-lite') . '</strong>'; 170 171 171 // Érték bevitele (tizedes törtet is elfogad: step="0.01")172 172 echo '<input type="number" id="bulk-value" step="0.01" placeholder="pl. -12.5 vagy 5.6" style="width:140px; padding:6px; border-radius:4px; border:1px solid #8c8f94;">'; 173 173 174 // Típus választó175 174 echo '<select id="bulk-type" style="padding:6px; border-radius:4px;"><option value="percent">% (Százalék)</option><option value="fixed">Ft (Fix összeg)</option></select>'; 176 175 177 // Akció időzítés (Opcionális) 176 // CÉLPONT VÁLASZTÓ (ÚJ) 177 echo '<select id="bulk-target" style="padding:6px; border-radius:4px; font-weight:bold; border-color:#2271b1;">'; 178 echo '<option value="sale">' . esc_html__('Akciós árra', 'priceboard-lite') . '</option>'; 179 echo '<option value="regular">' . esc_html__('Normál árra', 'priceboard-lite') . '</option>'; 180 echo '<option value="both">' . esc_html__('Mindkettőre', 'priceboard-lite') . '</option>'; 181 echo '</select>'; 182 178 183 echo '<div style="display:inline-flex; align-items:center; gap:5px; background:#fff; padding:4px 8px; border-radius:4px; border:1px solid #8c8f94;">'; 179 184 echo '<small style="color:#666;">' . esc_html__('Akció:', 'priceboard-lite') . '</small>'; … … 183 188 echo '</div>'; 184 189 185 // Alkalmazás gomb186 190 echo '<button type="button" id="apply-bulk" class="button button-secondary" style="height:36px;">' . esc_html__('Alkalmazás a kijelöltekre', 'priceboard-lite') . '</button>'; 187 191 echo '</div>'; -
priceboard-lite/trunk/readme.txt
r3456291 r3456301 5 5 Tested up to: 6.9 6 6 Requires PHP: 7.4 7 Stable tag: 1.4. 07 Stable tag: 1.4.1 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 66 66 67 67 = 1.4.0 = 68 69 NEW: Bulk Edit Target Selection - Apply changes to Regular Price, Sale Price, or Both. 70 71 NEW: Sale Scheduling - Added support for promotional start and end dates. 72 73 NEW: Precision Math - Decimal percentages and negative values are now supported. 74 75 FIX: Improved AJAX search performance and minor UI tweaks. 76 77 = 1.4.0 = 68 78 * NEW: Bulk Pricing & Sale Management – Update prices and sale amounts for all selected products simultaneously. 69 79 * NEW: Sale Scheduling Support – Set specific start and end dates for promotional prices using the integrated date picker.
Note: See TracChangeset
for help on using the changeset viewer.