diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d68463..5e30011 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,39 @@ 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.2.6] - 2025-12-30 + +### Fixed + +- **Parent Product Pricing Forms Not Visible (Critical)**: Variable products were missing the pricing configuration forms on the parent product edit page. The v1.2.5 feature for parent product default pricing was implemented in the backend logic (cart calculations and frontend display) but the admin UI to configure these defaults was not added. Now variable product parents have a dedicated "Default Tier & Package Pricing for All Variations" section in the product edit page where administrators can configure default pricing that applies to all variations unless a specific variation overrides it. + +- **Table Headers Not Hiding When Empty**: The CSS selector for hiding table headers when no pricing rules exist was using an incorrect approach. The sibling selector `~` doesn't work when `` comes before `
` in the HTML structure. Removed the sibling selector and kept only the `:has()` pseudo-class approach with `!important` flag for proper specificity. + +### Technical Details + +**Parent Product Forms Fix**: +- Added new method `add_variable_parent_pricing_fields()` in `WC_TPP_Product_Meta` class +- Hooked to `woocommerce_product_options_pricing` action but only displays for variable products +- Modified existing `add_tier_pricing_fields()` and `add_package_pricing_fields()` to skip variable products (they now only show for simple products) +- Parent product forms use same field names as simple products (`_wc_tpp_tiers`, `_wc_tpp_packages`, `_wc_tpp_restrict_to_packages`) +- Data is saved to parent product post meta using existing `save_tier_package_fields()` method +- Backend fallback logic from v1.2.5 now has matching admin UI for configuration + +**CSS Selector Fix**: +- Removed incorrect `.wc-tpp-tiers-container:empty ~ thead` selector (sibling selector can't target previous elements) +- Kept only `.wc-tpp-tiers-table:has(tbody.wc-tpp-tiers-container:empty) thead` with `!important` flag +- `:has()` pseudo-class is supported in modern browsers (Chrome 105+, Firefox 121+, Safari 15.4+) + +**User Impact**: +- Administrators can now configure default tier/package pricing on variable product parents (feature was non-functional in v1.2.5) +- Table headers properly hide when no pricing rules exist, creating cleaner admin interface +- No data migration needed - existing configurations remain intact + +### Changed Files + +- `includes/class-wc-tpp-product-meta.php` - Added `add_variable_parent_pricing_fields()` method; modified `add_tier_pricing_fields()` and `add_package_pricing_fields()` to skip variable products +- `assets/css/admin.css` - Fixed table header hiding CSS selector; removed incorrect sibling selector; added `!important` flag + ## [1.2.5] - 2025-12-30 ### Added diff --git a/CLAUDE.md b/CLAUDE.md index ed2a6e9..eb15211 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -759,11 +759,21 @@ Roadmap for the upcoming development. 2. ~~Bug 2 in v1.2.3: Increase the margin between checkbox and label and put the help icon right next to the label, not at the right border~~ ✅ **FIXED in v1.2.4** - Increased checkbox right margin from 8px to 12px. Repositioned help tip icon to display inline right next to the label text using flexbox layout with `display: inline-flex`, removing float positioning that caused it to appear at the right edge. -##### Planned Enhancements for v1.2.5+ +##### Enhancements (Completed in v1.2.5) -1. Hide the table-headers in admin area until a tier or respectivly a package price is defined. +1. ~~Hide the table-headers in admin area until a tier or respectivly a package price is defined.~~ ✅ **COMPLETED in v1.2.5** - Added CSS `:has()` pseudo-class selectors to automatically hide table headers when tbody is empty. Creates a cleaner interface showing only the helpful empty state message and "Add" button when no pricing rules are configured. -2. Make it possible to define tier or package prices on variable products in the parent product as a default for that product and all variants of it unless a variant has its own tier or package prices. +2. ~~Make it possible to define tier or package prices on variable products in the parent product as a default for that product and all variants of it unless a variant has its own tier or package prices.~~ ✅ **COMPLETED in v1.2.5** - Implemented parent product default pricing with automatic fallback. Variable products can define tier/package pricing once at parent level; variations inherit these defaults unless they have their own specific pricing. Added helper methods in cart class and updated all pricing/restriction checks to support parent fallback. + +##### Fixes for v1.2.5 + +1. The table headers in admin are still visible. + +2. The parent product fallback on variable product is also not visible. + +##### Planned Enhancements for v1.2.6+ + +1. Create different, selectable templates for tierprices and packages to use in the frontend. Make the new templates selectable globally on the settings-page, not per product. ### When Debugging Cart Issues diff --git a/assets/css/admin.css b/assets/css/admin.css index 60b4dd0..346c6f5 100644 --- a/assets/css/admin.css +++ b/assets/css/admin.css @@ -112,15 +112,10 @@ } /* Hide table headers when there are no pricing rules */ -.wc-tpp-tiers-container:empty ~ thead, -.wc-tpp-packages-container:empty ~ thead { - display: none; -} - -/* Alternative approach: hide thead when tbody is empty (more reliable) */ +/* Use :has() pseudo-class to check if tbody is empty */ .wc-tpp-tiers-table:has(tbody.wc-tpp-tiers-container:empty) thead, .wc-tpp-packages-table:has(tbody.wc-tpp-packages-container:empty) thead { - display: none; + display: none !important; } /* Checkbox styling improvements */ diff --git a/composer.json b/composer.json index 56a2dea..3b9711a 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.2.5", + "version": "1.2.6", "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 4cfd7b7..23b72ca 100644 --- a/includes/class-wc-tpp-product-meta.php +++ b/includes/class-wc-tpp-product-meta.php @@ -16,13 +16,127 @@ if (!class_exists('WC_TPP_Product_Meta')) { add_action('woocommerce_product_options_pricing', array($this, 'add_package_pricing_fields')); add_action('woocommerce_process_product_meta', array($this, 'save_tier_package_fields')); + // Variable product parent hooks (for default pricing) + add_action('woocommerce_product_options_pricing', array($this, 'add_variable_parent_pricing_fields')); + // Variable product variation hooks add_action('woocommerce_variation_options_pricing', array($this, 'add_variation_pricing_fields'), 10, 3); add_action('woocommerce_save_product_variation', array($this, 'save_variation_pricing_fields'), 10, 2); } + /** + * Add tier and package pricing fields for variable product parents + * These serve as defaults for all variations unless overridden + */ + public function add_variable_parent_pricing_fields() { + global $post; + + // Only show for variable products, not simple products + $product = wc_get_product($post->ID); + if (!$product || !$product->is_type('variable')) { + return; + } + + ?> + + ID); + if ($product && $product->is_type('variable')) { + return; + } + ?>