Changeset 3452209
- Timestamp:
- 02/02/2026 03:11:01 PM (3 weeks ago)
- Location:
- sidebar-category-tabs/trunk
- Files:
-
- 5 edited
-
README.md (modified) (3 diffs)
-
assets/css/style.css (modified) (1 diff)
-
assets/js/script.js (modified) (4 diffs)
-
sidebar-category-tabs.php (modified) (2 diffs)
-
templates/product-template.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
sidebar-category-tabs/trunk/README.md
r3334873 r3452209 6 6 Requires at least: 5.0 7 7 Tested up to: 6.8.2 8 Stable tag: 1. 1.08 Stable tag: 1.2.0 9 9 Requires PHP: 7.4 10 10 License: GPLv2 or later … … 20 20 21 21 * **Sidebar Navigation:** Displays WooCommerce product categories as tabs in a sidebar. 22 * **Quantity Controls:** Easily adjust product quantities with + and - buttons before adding to cart. 22 23 * **Customizable Design:** Add custom CSS for styling to match your theme. 23 24 * **AJAX Loading:** Dynamically load products without refreshing the page for a smooth user experience. … … 82 83 * Button style CSS fixes 83 84 85 = 1.2.0 = 86 * 1.2.0 release with features: 87 * Added product quantity controls with + and - buttons 88 * Quantity selector allows customers to set custom quantity before adding to cart 89 * Minimum quantity validation (default: 1) 90 * Improved user experience for bulk purchasing 91 84 92 == Upgrade Notice == 85 93 -
sidebar-category-tabs/trunk/assets/css/style.css
r3334867 r3452209 173 173 } 174 174 175 /* 3.5. Quantity Controls */ 176 .sidebar-category-tabs .quantity-wrapper { 177 color: #000; 178 background: #fff; 179 justify-content: center; 180 display: flex; 181 gap: 0; 182 align-items: center; 183 overflow: hidden; 184 width: fit-content; 185 margin: 10px auto; 186 border-radius: 5px; 187 } 188 189 .sidebar-category-tabs .quantity-btn, 190 .sidebar-category-tabs .product-quantity { 191 background-color: transparent; 192 color: inherit; 193 font-weight: bold; 194 font-size: inherit; 195 border: none; 196 display: inline-block; 197 min-width: 0; 198 height: 2.5rem; 199 line-height: 1; 200 transition: background-color 0.3s ease; 201 } 202 203 .sidebar-category-tabs .quantity-wrapper .quantity-btn { 204 background-color: transparent; 205 } 206 207 .sidebar-category-tabs .quantity-btn:focus, 208 .sidebar-category-tabs .product-quantity:focus { 209 outline: none; 210 } 211 212 .sidebar-category-tabs .quantity-btn { 213 padding: 0; 214 cursor: pointer; 215 width: 2.5rem; 216 font-size: 1.25em; 217 text-indent: -100px; 218 overflow: hidden; 219 position: relative; 220 } 221 222 .sidebar-category-tabs .quantity-btn::after, 223 .sidebar-category-tabs .quantity-btn::before { 224 content: ""; 225 height: 2px; 226 width: 10px; 227 position: absolute; 228 display: block; 229 background: #000; 230 top: 0; 231 bottom: 0; 232 left: 0; 233 right: 0; 234 margin: auto; 235 } 236 237 .sidebar-category-tabs .quantity-btn:disabled { 238 color: #ccc; 239 background: #f0f0f0; 240 cursor: not-allowed; 241 border-color: transparent; 242 } 243 .sidebar-category-tabs .quantity-btn:disabled::after, 244 .sidebar-category-tabs .quantity-btn:disabled::before { 245 background: #ccc; 246 } 247 248 .sidebar-category-tabs .quantity-btn:hover { 249 background-color: #e76f51; 250 } 251 252 .sidebar-category-tabs .quantity-btn.qty-minus { 253 border-right: 1px solid #e2e2e2; 254 } 255 256 .sidebar-category-tabs .quantity-btn.qty-plus { 257 border-left: 1px solid #e2e2e2; 258 } 259 .sidebar-category-tabs .quantity-btn.qty-plus::after { 260 transform: rotate(90deg); 261 } 262 263 .sidebar-category-tabs .product-quantity { 264 width: 50px; 265 min-width: 0; 266 display: inline-block; 267 text-align: center; 268 appearance: textfield; 269 } 270 271 .sidebar-category-tabs .product-quantity::-webkit-outer-spin-button, 272 .sidebar-category-tabs .product-quantity::-webkit-inner-spin-button { 273 -webkit-appearance: none; 274 margin: 0; 275 } 276 277 .sidebar-category-tabs .product-quantity[type=number] { 278 -moz-appearance: textfield; 279 } 280 175 281 /* ======================================== 176 282 * 4. Pagination -
sidebar-category-tabs/trunk/assets/js/script.js
r3287244 r3452209 158 158 159 159 /** 160 * Handles quantity controls (+ and - buttons) 161 */ 162 function wsctHandleQuantityControls() { 163 $(document).off('click', '.quantity-btn').on('click', '.quantity-btn', function(e) { 164 e.preventDefault(); 165 166 const button = $(this); 167 const productId = button.data('product-id'); 168 const quantityInput = $('[data-product-id="' + productId + '"].product-quantity'); 169 let currentQty = parseInt(quantityInput.val()); 170 171 if (button.hasClass('qty-plus')) { 172 quantityInput.val(currentQty + 1); 173 } else if (button.hasClass('qty-minus') && currentQty > 1) { 174 quantityInput.val(currentQty - 1); 175 } 176 }); 177 } 178 179 /** 160 180 * Handles adding products to cart 161 181 */ … … 166 186 const button = $(this); 167 187 const productId = button.data('product-id'); 188 const quantityInput = button.closest('.product-content').find('[data-product-id="' + productId + '"].product-quantity'); 189 const quantity = quantityInput.length ? parseInt(quantityInput.val()) : 1; 168 190 169 191 // Disable the button while processing … … 177 199 action: 'woocommerce_add_to_cart', 178 200 product_id: productId, 201 quantity: quantity, 179 202 security: wsct_data.nonce, 180 203 }, … … 217 240 }); 218 241 242 wsctHandleQuantityControls(); 219 243 wsctHandleAddToCart(); 220 244 }); -
sidebar-category-tabs/trunk/sidebar-category-tabs.php
r3334867 r3452209 3 3 * Plugin Name: Sidebar Category Tabs for WooCommerce 4 4 * Description: A WooCommerce plugin that displays category tabs in a sidebar for easy navigation. 5 * Version: 1. 1.05 * Version: 1.2.0 6 6 * Author: WPaladin 7 7 * License: GPL-2.0+ … … 18 18 19 19 // Define plugin constants 20 define( 'WSCT_VERSION', '1. 0.0' );20 define( 'WSCT_VERSION', '1.2.0' ); 21 21 define( 'WSCT_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); 22 22 define( 'WSCT_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); -
sidebar-category-tabs/trunk/templates/product-template.php
r3287244 r3452209 44 44 ?> 45 45 </p> 46 <div class="quantity-wrapper"> 47 <button class="quantity-btn qty-minus" data-product-id="<?php echo esc_attr( $product->get_id() ); ?>">−</button> 48 <input type="number" class="product-quantity" value="1" min="1" data-product-id="<?php echo esc_attr( $product->get_id() ); ?>" readonly /> 49 <button class="quantity-btn qty-plus" data-product-id="<?php echo esc_attr( $product->get_id() ); ?>">+</button> 50 </div> 46 51 <button class="add-to-cart" data-product-id="<?php echo esc_attr( $product->get_id() ); ?>"><?php echo esc_html__( 'Add to Cart', 'sidebar-category-tabs' ); ?></button> 47 52 </div>
Note: See TracChangeset
for help on using the changeset viewer.