diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 37f52d9..103486f 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -19,7 +19,8 @@ "Bash(do msgfmt -o \"$po%.po.mo\" \"$po\")", "Bash(done)", "Bash(git commit -m \"$\\(cat <<''EOF''\nRelease version 1.1.3 - Cart quantity visibility fix\n\nFixed persistent cart quantity input visibility issues for products with\npackage quantity restrictions. Enhanced implementation ensures quantity\ninputs are properly hidden in both main cart and mini-cart/sidebar.\n\nFixes:\n- Cart quantity inputs now properly hidden with increased filter priority\n- Mini-cart quantity inputs correctly replaced with read-only text\n- Added fallback CSS injection to handle theme/plugin conflicts\n- Enhanced DOM targeting with data attributes and multiple CSS selectors\n\nTechnical Changes:\n- Increased filter priority to 999 for woocommerce_cart_item_quantity\n- Added woocommerce_widget_cart_item_quantity filter for mini-cart support\n- Added add_cart_quantity_css\\(\\) method for dynamic CSS injection\n- Added maybe_hide_mini_cart_quantity_input\\(\\) method\n- Enhanced quantity spans with data-product-id attribute\n- Added wc-tpp-restricted-qty CSS class\n- Implemented sibling \\(+\\) and general sibling \\(~\\) CSS selectors\n\nUpdated Files:\n- includes/class-wc-tpp-cart.php \\(enhanced with mini-cart support\\)\n- wc-tier-and-package-prices.php \\(version 1.1.3\\)\n- composer.json \\(version 1.1.3\\)\n- CHANGELOG.md \\(v1.1.3 section\\)\n- All translation files \\(.pot, .po, .mo\\) updated to version 1.1.3\n\nšŸ¤– Generated with [Claude Code]\\(https://claude.com/claude-code\\)\n\nCo-Authored-By: Claude Sonnet 4.5 \nEOF\n\\)\")", - "Bash(git commit:*)" + "Bash(git commit:*)", + "Bash(node -c:*)" ] } } diff --git a/CHANGELOG.md b/CHANGELOG.md index 336444b..9d54627 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,33 @@ All notable changes to WooCommerce Tier and Package Prices will be documented in The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.1.7] - 2025-12-22 + +### Added + +- Optional text labels for tier pricing (similar to package labels) +- Clickable tier pricing rows that auto-populate quantity field +- Add to Cart button auto-disable when quantity is 0 or less + +### Enhanced + +- Tier pricing table rows now clickable with visual hover feedback +- Clicking a tier row sets quantity to that tier's minimum quantity +- Smooth scroll animation to quantity field when tier is clicked +- Add to Cart button disabled state with visual feedback (opacity, cursor) +- Tier labels display below quantity in frontend table (italic, gray text) + +### Technical Details + +- Added optional `label` field to tier pricing meta box (admin/tier-row.twig) +- Updated tier save logic to store label field (class-wc-tpp-product-meta.php) +- Enhanced tier pricing template to display labels (frontend/tier-pricing-table.twig) +- Added click handler for tier rows (assets/js/frontend.js) +- Added `updateAddToCartButton()` function to manage button state +- CSS: `.wc-tpp-tier-label` styling for tier labels +- CSS: Clickable cursor and hover animation for tier rows +- CSS: Disabled button styling (`.single_add_to_cart_button:disabled`) + ## [1.1.6] - 2025-12-21 ### Fixed diff --git a/assets/css/frontend.css b/assets/css/frontend.css index 8587905..8cc319f 100644 --- a/assets/css/frontend.css +++ b/assets/css/frontend.css @@ -50,11 +50,13 @@ .wc-tpp-table tbody tr { border-bottom: 1px solid #e0e0e0; - transition: background-color 0.2s; + transition: all 0.2s; + cursor: pointer; } .wc-tpp-table tbody tr:hover { background: #f5f5f5; + transform: translateX(2px); } .wc-tpp-table tbody tr.wc-tpp-active-tier { @@ -67,6 +69,14 @@ font-size: 0.95em; } +.wc-tpp-tier-label { + display: inline-block; + margin-top: 4px; + color: #666; + font-style: italic; + font-size: 0.9em; +} + /* Package pricing */ .wc-tpp-packages { display: grid; @@ -209,6 +219,14 @@ a.wc-tpp-view-options:hover { font-size: 0.95em; } +/* Disabled add to cart button */ +.single_add_to_cart_button.disabled, +.single_add_to_cart_button:disabled { + opacity: 0.5; + cursor: not-allowed; + pointer-events: none; +} + /* Responsive design */ @media (max-width: 768px) { .wc-tpp-packages { diff --git a/assets/js/frontend.js b/assets/js/frontend.js index 4da8b16..8e36491 100644 --- a/assets/js/frontend.js +++ b/assets/js/frontend.js @@ -8,6 +8,7 @@ $(document).ready(function() { const $quantityInput = $('input.qty'); const $priceDisplay = $('.woocommerce-Price-amount.amount').first(); + const $addToCartButton = $('.single_add_to_cart_button'); const isRestrictedMode = $('.wc-tpp-package-pricing-table').hasClass('wc-tpp-restricted-mode'); if ($quantityInput.length === 0 && !isRestrictedMode) { @@ -154,9 +155,35 @@ $('.wc-tpp-price-message').remove(); } + // Toggle add to cart button state based on quantity + function updateAddToCartButton() { + const quantity = parseInt($quantityInput.val()) || 0; + + if (quantity <= 0) { + $addToCartButton.prop('disabled', true).addClass('disabled'); + } else { + $addToCartButton.prop('disabled', false).removeClass('disabled'); + } + } + // Handle quantity input changes $quantityInput.on('input change', function() { updatePriceDisplay(); + updateAddToCartButton(); + }); + + // Handle tier pricing row clicks + $('.wc-tpp-tier-pricing-table tbody tr').on('click', function() { + const minQty = parseInt($(this).data('min-qty')); + + if ($quantityInput.length > 0 && !isRestrictedMode) { + $quantityInput.val(minQty).trigger('change'); + + // Scroll to quantity input for better UX + $('html, body').animate({ + scrollTop: $quantityInput.offset().top - 100 + }, 300); + } }); // Handle package selection @@ -212,6 +239,11 @@ if (!isRestrictedMode) { updatePriceDisplay(); } + + // Initial button state check + if ($quantityInput.length > 0 && $addToCartButton.length > 0) { + updateAddToCartButton(); + } }); })(jQuery); diff --git a/composer.json b/composer.json index 2161249..2eec1a1 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "magdev/wc-tier-package-prices", "description": "WooCommerce plugin for tier pricing and package prices with Twig templates", - "version": "1.1.6", + "version": "1.1.7", "type": "wordpress-plugin", "license": "GPL-2.0-or-later", "authors": [ diff --git a/includes/class-wc-tpp-product-meta.php b/includes/class-wc-tpp-product-meta.php index 57a86b2..2a6424a 100644 --- a/includes/class-wc-tpp-product-meta.php +++ b/includes/class-wc-tpp-product-meta.php @@ -81,7 +81,7 @@ class WC_TPP_Product_Meta {