You've already forked wc-tier-and-package-prices
Merge branch 'dev'
This commit is contained in:
33
CHANGELOG.md
33
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/),
|
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).
|
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 `<thead>` comes before `<tbody>` 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
|
## [1.2.5] - 2025-12-30
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
16
CLAUDE.md
16
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.
|
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
|
### When Debugging Cart Issues
|
||||||
|
|
||||||
|
|||||||
@@ -112,15 +112,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Hide table headers when there are no pricing rules */
|
/* Hide table headers when there are no pricing rules */
|
||||||
.wc-tpp-tiers-container:empty ~ thead,
|
/* Use :has() pseudo-class to check if tbody is empty */
|
||||||
.wc-tpp-packages-container:empty ~ thead {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Alternative approach: hide thead when tbody is empty (more reliable) */
|
|
||||||
.wc-tpp-tiers-table:has(tbody.wc-tpp-tiers-container:empty) thead,
|
.wc-tpp-tiers-table:has(tbody.wc-tpp-tiers-container:empty) thead,
|
||||||
.wc-tpp-packages-table:has(tbody.wc-tpp-packages-container:empty) thead {
|
.wc-tpp-packages-table:has(tbody.wc-tpp-packages-container:empty) thead {
|
||||||
display: none;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Checkbox styling improvements */
|
/* Checkbox styling improvements */
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "magdev/wc-tier-package-prices",
|
"name": "magdev/wc-tier-package-prices",
|
||||||
"description": "WooCommerce plugin for tier pricing and package prices with Twig templates",
|
"description": "WooCommerce plugin for tier pricing and package prices with Twig templates",
|
||||||
"version": "1.2.5",
|
"version": "1.2.6",
|
||||||
"type": "wordpress-plugin",
|
"type": "wordpress-plugin",
|
||||||
"license": "GPL-2.0-or-later",
|
"license": "GPL-2.0-or-later",
|
||||||
"authors": [
|
"authors": [
|
||||||
|
|||||||
@@ -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_product_options_pricing', array($this, 'add_package_pricing_fields'));
|
||||||
add_action('woocommerce_process_product_meta', array($this, 'save_tier_package_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
|
// Variable product variation hooks
|
||||||
add_action('woocommerce_variation_options_pricing', array($this, 'add_variation_pricing_fields'), 10, 3);
|
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_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;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<div class="options_group wc-tpp-variable-parent-pricing">
|
||||||
|
<p class="form-field">
|
||||||
|
<strong><?php _e('Default Tier & Package Pricing for All Variations', 'wc-tier-package-prices'); ?></strong>
|
||||||
|
<span class="woocommerce-help-tip" data-tip="<?php esc_attr_e('Set default pricing for all variations. Individual variations can override these defaults with their own specific pricing.', 'wc-tier-package-prices'); ?>"></span>
|
||||||
|
</p>
|
||||||
|
<p class="description" style="margin-left: 12px; margin-bottom: 15px;">
|
||||||
|
<?php _e('Configure default tier and package pricing here. All variations will inherit these settings unless they define their own specific pricing.', 'wc-tier-package-prices'); ?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<!-- Tier Pricing Section -->
|
||||||
|
<div class="wc-tpp-parent-tier-pricing" style="margin-left: 12px;">
|
||||||
|
<p><strong><?php _e('Tier Pricing', 'wc-tier-package-prices'); ?></strong></p>
|
||||||
|
<table class="widefat wc-tpp-tiers-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><?php _e('Min Quantity', 'wc-tier-package-prices'); ?></th>
|
||||||
|
<th><?php _e('Price', 'wc-tier-package-prices'); ?></th>
|
||||||
|
<th><?php _e('Label (optional)', 'wc-tier-package-prices'); ?></th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="wc-tpp-tiers-container">
|
||||||
|
<?php
|
||||||
|
$tiers = get_post_meta($post->ID, '_wc_tpp_tiers', true);
|
||||||
|
if (!is_array($tiers)) {
|
||||||
|
$tiers = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($tiers as $index => $tier) {
|
||||||
|
$this->render_tier_row($index, $tier);
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<p class="form-field">
|
||||||
|
<button type="button" class="button wc-tpp-add-tier"><?php _e('Add Tier', 'wc-tier-package-prices'); ?></button>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Package Pricing Section -->
|
||||||
|
<div class="wc-tpp-parent-package-pricing" style="margin-left: 12px; margin-top: 20px;">
|
||||||
|
<p><strong><?php _e('Package Pricing', 'wc-tier-package-prices'); ?></strong></p>
|
||||||
|
<table class="widefat wc-tpp-packages-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><?php _e('Quantity', 'wc-tier-package-prices'); ?></th>
|
||||||
|
<th><?php _e('Price', 'wc-tier-package-prices'); ?></th>
|
||||||
|
<th><?php _e('Label (optional)', 'wc-tier-package-prices'); ?></th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="wc-tpp-packages-container">
|
||||||
|
<?php
|
||||||
|
$packages = get_post_meta($post->ID, '_wc_tpp_packages', true);
|
||||||
|
if (!is_array($packages)) {
|
||||||
|
$packages = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($packages as $index => $package) {
|
||||||
|
$this->render_package_row($index, $package);
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<p class="form-field">
|
||||||
|
<button type="button" class="button wc-tpp-add-package"><?php _e('Add Package', 'wc-tier-package-prices'); ?></button>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
woocommerce_wp_checkbox(array(
|
||||||
|
'id' => '_wc_tpp_restrict_to_packages',
|
||||||
|
'label' => __('Restrict to Package Quantities (Default)', 'wc-tier-package-prices'),
|
||||||
|
'description' => __('Default restriction setting for all variations. Only allow quantities defined in packages above.', 'wc-tier-package-prices'),
|
||||||
|
'desc_tip' => true,
|
||||||
|
));
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Templates for JavaScript (shared between simple and variable parent) -->
|
||||||
|
<script type="text/html" id="wc-tpp-tier-row-template">
|
||||||
|
<?php $this->render_tier_row('{{INDEX}}', array('min_qty' => '', 'price' => '', 'label' => '')); ?>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/html" id="wc-tpp-package-row-template">
|
||||||
|
<?php $this->render_package_row('{{INDEX}}', array('qty' => '', 'price' => '', 'label' => '')); ?>
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
public function add_tier_pricing_fields() {
|
public function add_tier_pricing_fields() {
|
||||||
global $post;
|
global $post;
|
||||||
|
|
||||||
|
// Only show for simple products (variable products use add_variable_parent_pricing_fields)
|
||||||
|
$product = wc_get_product($post->ID);
|
||||||
|
if ($product && $product->is_type('variable')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="options_group wc-tpp-tier-pricing">
|
<div class="options_group wc-tpp-tier-pricing">
|
||||||
<p class="form-field">
|
<p class="form-field">
|
||||||
@@ -62,6 +176,13 @@ if (!class_exists('WC_TPP_Product_Meta')) {
|
|||||||
|
|
||||||
public function add_package_pricing_fields() {
|
public function add_package_pricing_fields() {
|
||||||
global $post;
|
global $post;
|
||||||
|
|
||||||
|
// Only show for simple products (variable products use add_variable_parent_pricing_fields)
|
||||||
|
$product = wc_get_product($post->ID);
|
||||||
|
if ($product && $product->is_type('variable')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="options_group wc-tpp-package-pricing">
|
<div class="options_group wc-tpp-package-pricing">
|
||||||
<p class="form-field">
|
<p class="form-field">
|
||||||
|
|||||||
BIN
releases/wc-tier-and-package-prices-1.2.6.zip
Normal file
BIN
releases/wc-tier-and-package-prices-1.2.6.zip
Normal file
Binary file not shown.
1
releases/wc-tier-and-package-prices-1.2.6.zip.md5
Normal file
1
releases/wc-tier-and-package-prices-1.2.6.zip.md5
Normal file
@@ -0,0 +1 @@
|
|||||||
|
b2c862fbad94f42f0756fb496a1dd920 wc-tier-and-package-prices-1.2.6.zip
|
||||||
1
releases/wc-tier-and-package-prices-1.2.6.zip.sha256
Normal file
1
releases/wc-tier-and-package-prices-1.2.6.zip.sha256
Normal file
@@ -0,0 +1 @@
|
|||||||
|
19a00c7fc2f42326f52d2da063766abd1c0b47d1701b9050c018bfb2bafae6f6 wc-tier-and-package-prices-1.2.6.zip
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
* Plugin Name: WooCommerce Tier and Package Prices
|
* Plugin Name: WooCommerce Tier and Package Prices
|
||||||
* Plugin URI: https://src.bundespruefstelle.ch/magdev/wc-tier-package-prices
|
* Plugin URI: https://src.bundespruefstelle.ch/magdev/wc-tier-package-prices
|
||||||
* Description: Add tier pricing and package prices to WooCommerce products with configurable quantities at fixed prices
|
* Description: Add tier pricing and package prices to WooCommerce products with configurable quantities at fixed prices
|
||||||
* Version: 1.2.5
|
* Version: 1.2.6
|
||||||
* Author: Marco Graetsch
|
* Author: Marco Graetsch
|
||||||
* Author URI: https://src.bundespruefstelle.ch/magdev
|
* Author URI: https://src.bundespruefstelle.ch/magdev
|
||||||
* Text Domain: wc-tier-package-prices
|
* Text Domain: wc-tier-package-prices
|
||||||
@@ -23,7 +23,7 @@ if (!defined('ABSPATH')) {
|
|||||||
|
|
||||||
// Define plugin constants
|
// Define plugin constants
|
||||||
if (!defined('WC_TPP_VERSION')) {
|
if (!defined('WC_TPP_VERSION')) {
|
||||||
define('WC_TPP_VERSION', '1.2.5');
|
define('WC_TPP_VERSION', '1.2.6');
|
||||||
}
|
}
|
||||||
if (!defined('WC_TPP_PLUGIN_DIR')) {
|
if (!defined('WC_TPP_PLUGIN_DIR')) {
|
||||||
define('WC_TPP_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
define('WC_TPP_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
||||||
|
|||||||
Reference in New Issue
Block a user