Changeset 3447551
- Timestamp:
- 01/27/2026 07:06:26 AM (2 months ago)
- Location:
- eventano
- Files:
-
- 9 added
- 3 edited
-
tags/1.0.1 (added)
-
tags/1.0.1/assets (added)
-
tags/1.0.1/assets/css (added)
-
tags/1.0.1/assets/css/style.css (added)
-
tags/1.0.1/assets/js (added)
-
tags/1.0.1/assets/js/script.js (added)
-
tags/1.0.1/eventano.php (added)
-
tags/1.0.1/languages (added)
-
tags/1.0.1/readme.txt (added)
-
trunk/assets/js/script.js (modified) (7 diffs)
-
trunk/eventano.php (modified) (5 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
eventano/trunk/assets/js/script.js
r3444696 r3447551 12 12 if (typeof pagenow !== "undefined" && pagenow === "product") { 13 13 let eventano_seatIndex; 14 const MAX_CATEGORIES = 2; // Maximum allowed categories 14 15 15 16 $(document).ready(function () { … … 30 31 .change(); 31 32 32 // Add Seat Category Function 33 // Add Seat Category Function - MODIFIED WITH 2-CATEGORY LIMIT 33 34 window.eventano_addSeatCategory = function () { 34 35 const container = document.getElementById("seat_categories"); 36 const currentCount = container.querySelectorAll(".eventano-seat-category-row").length; 37 38 // Check if maximum categories reached 39 if (currentCount >= MAX_CATEGORIES) { 40 alert("Maximum of 2 categories allowed. Please remove an existing category to add a new one."); 41 return; 42 } 43 35 44 const div = document.createElement("div"); 36 45 div.className = "eventano-seat-category-row"; … … 38 47 <div class="category-grid"> 39 48 <input type="text" name="seat_category[${eventano_seatIndex}][name]" placeholder="Category Name" style="width:100%;" required> 40 <input type="number" class="eventano- eventano-category-seats" name="seat_category[${eventano_seatIndex}][seats]" placeholder="Total Seats" min="1" style="width:100%;" required>49 <input type="number" class="eventano-category-seats" name="seat_category[${eventano_seatIndex}][seats]" placeholder="Total Seats" min="1" style="width:100%;" required> 41 50 <input type="number" name="seat_category[${eventano_seatIndex}][price]" placeholder="Price" min="0" step="0.01" style="width:100%;" required> 42 51 <button type="button" class="button" onclick="eventano_removeSeatCategory(this)">Remove</button> … … 48 57 eventano_seatIndex++; 49 58 eventano_updateCategoryTotal(); 59 eventano_updateCategoryButton(); // Update button state 50 60 }; 51 61 52 // Remove Seat Category Function 62 // Remove Seat Category Function - MODIFIED TO UPDATE BUTTON 53 63 window.eventano_removeSeatCategory = function (btn) { 54 64 const row = btn.closest(".eventano-seat-category-row"); … … 71 81 row.remove(); 72 82 eventano_updateCategoryTotal(); 83 eventano_updateCategoryButton(); // Update button state 73 84 }; 74 85 86 // NEW: Update the "Add Category" button state 87 window.eventano_updateCategoryButton = function () { 88 const container = document.getElementById("seat_categories"); 89 const addButton = document.getElementById("add-category-btn"); 90 91 if (!container || !addButton) return; 92 93 const currentCount = container.querySelectorAll(".eventano-seat-category-row").length; 94 95 // Update button text and state 96 if (currentCount >= MAX_CATEGORIES) { 97 addButton.disabled = true; 98 addButton.textContent = "Add Category (Maximum Reached)"; 99 } else { 100 addButton.disabled = false; 101 addButton.textContent = `Add Category (${currentCount}/${MAX_CATEGORIES})`; 102 } 103 }; 104 75 105 // Update Category Total Function 76 function eventano_updateCategoryTotal() {106 window.eventano_updateCategoryTotal = function () { 77 107 const totalSeats = 78 parseInt(document.getElementById("total_seats") .value) || 0;108 parseInt(document.getElementById("total_seats")?.value) || 0; 79 109 const categoryInputs = document.querySelectorAll( 80 ".eventano- eventano-category-seats"110 ".eventano-category-seats" 81 111 ); 82 112 let categoryTotal = 0; … … 86 116 }); 87 117 88 document.getElementById("category_total").textContent = categoryTotal; 89 document.getElementById("total_display").textContent = totalSeats; 118 const categoryTotalSpan = document.getElementById("category_total"); 119 const totalDisplaySpan = document.getElementById("total_display"); 120 121 if (categoryTotalSpan) categoryTotalSpan.textContent = categoryTotal; 122 if (totalDisplaySpan) totalDisplaySpan.textContent = totalSeats; 90 123 91 124 const warning = document.getElementById("seats_warning"); 92 if (categoryTotal > totalSeats) { 93 warning.style.display = "block"; 94 } else { 95 warning.style.display = "none"; 96 } 97 } 125 if (warning) { 126 if (categoryTotal > totalSeats) { 127 warning.style.display = "block"; 128 } else { 129 warning.style.display = "none"; 130 } 131 } 132 }; 98 133 99 134 // Event Listeners for Category Total Update … … 101 136 $(document).on( 102 137 "input", 103 ".eventano- eventano-category-seats",138 ".eventano-category-seats", 104 139 eventano_updateCategoryTotal 105 140 ); 106 141 107 // Initial update 142 // Initial updates 108 143 eventano_updateCategoryTotal(); 144 eventano_updateCategoryButton(); 109 145 }); 110 146 } -
eventano/trunk/eventano.php
r3444706 r3447551 2 2 3 3 /** 4 * Plugin Name: Eventano - WooCommerce Event Management & Ticketing Plugin4 * Plugin Name: Eventano 5 5 * Description: Custom WooCommerce plugin with Event product type for managing events with categories, seats, and prices. 6 * Version: 1.0. 06 * Version: 1.0.1 7 7 * Author: Vivid 8 8 * Text Domain: eventano … … 199 199 $total_category_seats += intval($cat['seats']); 200 200 } 201 202 // Count existing categories 203 $category_count = count($categories); 201 204 ?> 202 205 <div id="event_product_data" class="panel woocommerce_options_panel"> … … 218 221 <div class="eventano-options_group"> 219 222 <h4 class="eventano-section-title"><?php echo esc_html_e('Seat Categories', 'eventano'); ?></h4> 220 <p class="eventano-section-desc">Example: Adults, Child, Couple, VIP etc. </p>223 <p class="eventano-section-desc">Example: Adults, Child, Couple, VIP etc. <strong>(Maximum 2 categories allowed)</strong></p> 221 224 <p id="seats_warning" class="eventano-seats-warning"> 222 225 Warning: Total category seats exceed available seats! … … 226 229 </p> 227 230 228 <div id="seat_categories" class="eventano-seat-categories" >231 <div id="seat_categories" class="eventano-seat-categories" data-max-categories="2"> 229 232 <?php foreach ($categories as $index => $cat) : 230 233 $cat_booked = isset($cat['used']) ? intval($cat['used']) : 0; … … 276 279 277 280 <p style="padding: 0 12px;"> 278 <button type="button" class="button" onclick="eventano_addSeatCategory()">Add Category</button> 281 <button 282 type="button" 283 class="button" 284 id="add-category-btn" 285 onclick="eventano_addSeatCategory()" 286 <?php echo ($category_count >= 2) ? 'disabled="disabled"' : ''; ?>> 287 <?php 288 if ($category_count >= 2) { 289 echo esc_html__('Add Category (Maximum Reached)', 'eventano'); 290 } else { 291 /* translators: %d is the current number of seat categories added */ 292 printf( 293 esc_html__('Add Category (%d/2)', 'eventano'), 294 esc_html($category_count) 295 ); 296 } 297 298 ?> 299 </button> 279 300 </p> 301 302 303 <?php if ($category_count >= 2): ?> 304 <p style="padding: 0 12px; color: #d63638; font-weight: bold;"> 305 ⚠️ Maximum of 2 categories reached. Remove a category to add a new one. 306 </p> 307 <?php endif; ?> 280 308 </div> 281 309 </div> 282 310 <?php 283 311 } 284 285 312 /** 286 313 * Save Event product data -
eventano/trunk/readme.txt
r3444829 r3447551 5 5 Tested up to: 6.9 6 6 Requires PHP: 7.4 7 Stable tag: 1.0. 07 Stable tag: 1.0.1 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 111 111 == Changelog == 112 112 113 = 1.0.1 - 2026-01-27 = 114 * Security Enhancement 115 113 116 = 1.0.0 - 2026-01-22 = 114 117 * Initial release … … 119 122 120 123 == Upgrade Notice == 124 125 = 1.0.1 = 126 Security Enhancement 121 127 122 128 = 1.0.0 =
Note: See TracChangeset
for help on using the changeset viewer.