Plugin Directory

Changeset 3452209


Ignore:
Timestamp:
02/02/2026 03:11:01 PM (3 weeks ago)
Author:
wpaladin
Message:

Update: version 1.2.0 – added qty input

Location:
sidebar-category-tabs/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • sidebar-category-tabs/trunk/README.md

    r3334873 r3452209  
    66Requires at least: 5.0
    77Tested up to: 6.8.2
    8 Stable tag: 1.1.0
     8Stable tag: 1.2.0
    99Requires PHP: 7.4
    1010License: GPLv2 or later
     
    2020
    2121* **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.
    2223* **Customizable Design:** Add custom CSS for styling to match your theme.
    2324* **AJAX Loading:** Dynamically load products without refreshing the page for a smooth user experience.
     
    8283  * Button style CSS fixes
    8384
     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
    8492== Upgrade Notice ==
    8593
  • sidebar-category-tabs/trunk/assets/css/style.css

    r3334867 r3452209  
    173173}
    174174
     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
    175281/* ========================================
    176282 * 4. Pagination
  • sidebar-category-tabs/trunk/assets/js/script.js

    r3287244 r3452209  
    158158 
    159159  /**
     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  /**
    160180   * Handles adding products to cart
    161181   */
     
    166186          const button = $(this);
    167187          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;
    168190         
    169191          // Disable the button while processing
     
    177199                  action: 'woocommerce_add_to_cart',
    178200                  product_id: productId,
     201                  quantity: quantity,
    179202                  security: wsct_data.nonce,
    180203              },
     
    217240      });
    218241     
     242      wsctHandleQuantityControls();
    219243      wsctHandleAddToCart();
    220244  });
  • sidebar-category-tabs/trunk/sidebar-category-tabs.php

    r3334867 r3452209  
    33     * Plugin Name: Sidebar Category Tabs for WooCommerce
    44     * Description: A WooCommerce plugin that displays category tabs in a sidebar for easy navigation.
    5      * Version: 1.1.0
     5     * Version: 1.2.0
    66     * Author: WPaladin
    77     * License: GPL-2.0+
     
    1818
    1919    // Define plugin constants
    20     define( 'WSCT_VERSION', '1.0.0' );
     20    define( 'WSCT_VERSION', '1.2.0' );
    2121    define( 'WSCT_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
    2222    define( 'WSCT_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
  • sidebar-category-tabs/trunk/templates/product-template.php

    r3287244 r3452209  
    4444            ?>
    4545        </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>
    4651        <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>
    4752    </div>
Note: See TracChangeset for help on using the changeset viewer.