1 Commits

Author SHA1 Message Date
dea2c5f0b3 Release version 1.0.2
- Migrate settings to WooCommerce Settings page
- Add WC_TPP_Settings class for proper WooCommerce integration
- Remove standalone settings submenu
- Improve UX with native WooCommerce settings UI
2025-12-21 05:14:19 +01:00
12 changed files with 472 additions and 80 deletions

View File

@@ -5,7 +5,9 @@
"Bash(msgfmt:*)",
"Bash(ls:*)",
"Bash(mkdir:*)",
"Bash(composer init:*)"
"Bash(composer init:*)",
"Bash(composer install:*)",
"Bash(composer update:*)"
]
}
}

View File

@@ -5,6 +5,27 @@ 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.0.2] - 2025-12-21
### Changed
- Migrated settings to WooCommerce Settings page as dedicated tab
- Settings now appear under WooCommerce > Settings > Tier & Package Prices
- Improved integration with WooCommerce native settings API
### Added
- WC_TPP_Settings class extending WC_Settings_Page
- Better integration with WooCommerce settings system
- Consistent UI with other WooCommerce settings tabs
### Removed
- Standalone settings submenu (WooCommerce > Tier & Package Prices)
- Custom settings template (templates/admin/settings-page.twig)
### Technical
- Implemented WooCommerce settings filter hook (woocommerce_get_settings_pages)
- Uses WC_Admin_Settings for rendering and saving
- Automatic settings persistence via WooCommerce API
## [1.0.1] - 2025-12-21
### Added

View File

@@ -1,7 +1,7 @@
{
"name": "magdev/wc-tier-package-prices",
"description": "WooCommerce plugin for tier pricing and package prices with Twig templates",
"version": "1.0.1",
"version": "1.0.2",
"type": "wordpress-plugin",
"license": "GPL-2.0-or-later",
"authors": [

View File

@@ -10,39 +10,24 @@ if (!defined('ABSPATH')) {
class WC_TPP_Admin {
public function __construct() {
add_action('admin_menu', array($this, 'add_admin_menu'));
add_action('admin_init', array($this, 'register_settings'));
add_filter('woocommerce_get_settings_pages', array($this, 'add_settings_page'));
add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
}
public function add_admin_menu() {
add_submenu_page(
'woocommerce',
__('Tier & Package Prices', 'wc-tier-package-prices'),
__('Tier & Package Prices', 'wc-tier-package-prices'),
'manage_woocommerce',
'wc-tier-package-prices',
array($this, 'settings_page')
);
}
public function register_settings() {
register_setting('wc_tpp_settings', 'wc_tpp_enable_tier_pricing');
register_setting('wc_tpp_settings', 'wc_tpp_enable_package_pricing');
register_setting('wc_tpp_settings', 'wc_tpp_display_table');
register_setting('wc_tpp_settings', 'wc_tpp_display_position');
/**
* Add settings page to WooCommerce settings
*/
public function add_settings_page($settings) {
$settings[] = include WC_TPP_PLUGIN_DIR . 'includes/class-wc-tpp-settings.php';
return $settings;
}
public function enqueue_admin_scripts($hook) {
if ('woocommerce_page_wc-tier-package-prices' === $hook || 'post.php' === $hook || 'post-new.php' === $hook) {
if ('woocommerce_page_wc-settings' === $hook || 'post.php' === $hook || 'post-new.php' === $hook) {
wp_enqueue_style('wc-tpp-admin', WC_TPP_PLUGIN_URL . 'assets/css/admin.css', array(), WC_TPP_VERSION);
wp_enqueue_script('wc-tpp-admin', WC_TPP_PLUGIN_URL . 'assets/js/admin.js', array('jquery'), WC_TPP_VERSION, true);
}
}
public function settings_page() {
WC_TPP_Template_Loader::get_instance()->display('admin/settings-page.twig');
}
}
new WC_TPP_Admin();

View File

@@ -0,0 +1,134 @@
<?php
/**
* WooCommerce Settings Integration
*
* Adds Tier & Package Prices settings to WooCommerce Settings > Advanced tab
*
* @package WC_Tier_Package_Prices
*/
if (!defined('ABSPATH')) {
exit;
}
if (!class_exists('WC_Settings_Page')) {
return;
}
/**
* WC_TPP_Settings class
*/
class WC_TPP_Settings extends WC_Settings_Page {
/**
* Constructor
*/
public function __construct() {
$this->id = 'tier_package_prices';
$this->label = __('Tier & Package Prices', 'wc-tier-package-prices');
parent::__construct();
}
/**
* Get sections
*
* @return array
*/
public function get_sections() {
$sections = array(
'' => __('General', 'wc-tier-package-prices'),
);
return apply_filters('woocommerce_get_sections_' . $this->id, $sections);
}
/**
* Get settings array
*
* @param string $current_section Current section name.
* @return array
*/
public function get_settings($current_section = '') {
$settings = array();
if ('' === $current_section) {
$settings = array(
array(
'title' => __('Tier & Package Prices Settings', 'wc-tier-package-prices'),
'type' => 'title',
'desc' => __('Configure tier pricing and package pricing options for your WooCommerce products.', 'wc-tier-package-prices'),
'id' => 'wc_tpp_settings',
),
array(
'title' => __('Enable Tier Pricing', 'wc-tier-package-prices'),
'desc' => __('Enable tier pricing for products', 'wc-tier-package-prices'),
'id' => 'wc_tpp_enable_tier_pricing',
'default' => 'yes',
'type' => 'checkbox',
'desc_tip' => __('Allow quantity-based pricing tiers. Customers get discounted prices when buying in larger quantities.', 'wc-tier-package-prices'),
),
array(
'title' => __('Enable Package Pricing', 'wc-tier-package-prices'),
'desc' => __('Enable fixed-price packages for products', 'wc-tier-package-prices'),
'id' => 'wc_tpp_enable_package_pricing',
'default' => 'yes',
'type' => 'checkbox',
'desc_tip' => __('Allow fixed-price packages with specific quantities. For example: 10 pieces for $50, 25 pieces for $100.', 'wc-tier-package-prices'),
),
array(
'title' => __('Display Pricing Table', 'wc-tier-package-prices'),
'desc' => __('Show tier and package pricing table on product pages', 'wc-tier-package-prices'),
'id' => 'wc_tpp_display_table',
'default' => 'yes',
'type' => 'checkbox',
'desc_tip' => __('Display the pricing table to customers on product pages.', 'wc-tier-package-prices'),
),
array(
'title' => __('Display Position', 'wc-tier-package-prices'),
'desc' => __('Choose where to display the pricing table on product pages.', 'wc-tier-package-prices'),
'id' => 'wc_tpp_display_position',
'default' => 'after_add_to_cart',
'type' => 'select',
'class' => 'wc-enhanced-select',
'css' => 'min-width:300px;',
'desc_tip' => true,
'options' => array(
'before_add_to_cart' => __('Before Add to Cart Button', 'wc-tier-package-prices'),
'after_add_to_cart' => __('After Add to Cart Button', 'wc-tier-package-prices'),
'after_price' => __('After Price', 'wc-tier-package-prices'),
),
),
array(
'type' => 'sectionend',
'id' => 'wc_tpp_settings',
),
);
}
return apply_filters('woocommerce_get_settings_' . $this->id, $settings, $current_section);
}
/**
* Output the settings
*/
public function output() {
$settings = $this->get_settings();
WC_Admin_Settings::output_fields($settings);
}
/**
* Save settings
*/
public function save() {
$settings = $this->get_settings();
WC_Admin_Settings::save_fields($settings);
}
}
return new WC_TPP_Settings();

174
releases/README.md Normal file
View File

@@ -0,0 +1,174 @@
# WooCommerce Tier and Package Prices - Releases
This directory contains production-ready releases of the WooCommerce Tier and Package Prices plugin.
## Latest Release
**Version 1.0.1** - December 21, 2025
### Quick Install
```bash
# Download the package
wget https://your-domain.com/releases/wc-tier-and-package-prices-1.0.1.zip
# Verify checksum (optional but recommended)
sha256sum wc-tier-and-package-prices-1.0.1.zip
# Should match: 92c1385d92527e77646e37f23c1bd1555a4290a5ec9314c0ee6ed896ded55e88
# Install via WordPress admin or WP-CLI
wp plugin install wc-tier-and-package-prices-1.0.1.zip --activate
```
## Files in This Directory
### Release Packages
| File | Description | Size |
|------|-------------|------|
| `wc-tier-and-package-prices-1.0.1.zip` | Production plugin package | 395 KB |
| `wc-tier-and-package-prices-1.0.1.zip.sha256` | SHA-256 checksum | - |
| `wc-tier-and-package-prices-1.0.1.zip.md5` | MD5 checksum | - |
| `RELEASE-INFO-1.0.1.md` | Detailed release information | - |
## Verification
### Verify Package Integrity
**Using SHA-256:**
```bash
sha256sum -c wc-tier-and-package-prices-1.0.1.zip.sha256
```
**Using MD5:**
```bash
md5sum -c wc-tier-and-package-prices-1.0.1.zip.md5
```
### Expected Checksums
**SHA-256:**
```
92c1385d92527e77646e37f23c1bd1555a4290a5ec9314c0ee6ed896ded55e88
```
**MD5:**
```
e6cfc9b88df9e7763be0cd56517ce8ab
```
## Installation Methods
### Method 1: WordPress Admin (Recommended for most users)
1. Download `wc-tier-and-package-prices-1.0.1.zip`
2. Go to **WordPress Admin > Plugins > Add New**
3. Click **Upload Plugin**
4. Choose the downloaded ZIP file
5. Click **Install Now**
6. Click **Activate Plugin**
### Method 2: WP-CLI (For developers)
```bash
wp plugin install /path/to/wc-tier-and-package-prices-1.0.1.zip --activate
```
### Method 3: Manual Installation (Advanced)
```bash
# Extract to wp-content/plugins/
unzip wc-tier-and-package-prices-1.0.1.zip -d /path/to/wordpress/wp-content/plugins/
# Set correct permissions
chmod -R 755 /path/to/wordpress/wp-content/plugins/wc-tier-and-package-prices
# Activate via WordPress admin or WP-CLI
wp plugin activate wc-tier-and-package-prices
```
## What's Included
### Core Features
- ✅ Tier pricing (quantity-based discounts)
- ✅ Package pricing (fixed-price bundles)
- ✅ Twig template engine
- ✅ WooCommerce HPOS compatible
- ✅ Multilingual support
### Translations
- 🇺🇸 English (US)
- 🇩🇪 German (Germany)
- 🇨🇭 German (Switzerland, Informal)
### Production Ready
- ✅ Optimized autoloader
- ✅ No development dependencies
- ✅ Compiled Twig templates support
- ✅ Tested with WooCommerce 8.0 - 10.0
## Package Contents
```
wc-tier-and-package-prices/
├── assets/ # CSS and JavaScript
│ ├── css/
│ └── js/
├── includes/ # PHP classes
│ ├── class-wc-tpp-admin.php
│ ├── class-wc-tpp-cart.php
│ ├── class-wc-tpp-frontend.php
│ ├── class-wc-tpp-product-meta.php
│ └── class-wc-tpp-template-loader.php
├── languages/ # Translation files
│ ├── wc-tier-package-prices-de_CH_informal.*
│ ├── wc-tier-package-prices-de_DE.*
│ ├── wc-tier-package-prices-en_US.*
│ └── wc-tier-package-prices.pot
├── templates/ # Twig templates
│ ├── admin/
│ └── frontend/
├── vendor/ # Composer dependencies
│ └── twig/twig/
├── CHANGELOG.md
├── README.md
├── composer.json
└── wc-tier-and-package-prices.php
```
## System Requirements
| Requirement | Minimum Version |
|-------------|----------------|
| WordPress | 6.0+ |
| PHP | 7.4+ |
| WooCommerce | 8.0+ |
| MySQL | 5.6+ |
## Support
- **Documentation:** See main README.md
- **Issues:** https://src.bundespruefstelle.ch/wc-tier-package-prices/issues
- **Author:** Marco Graetsch
## Version History
### 1.0.1 (2025-12-21)
- Added Twig template engine
- Added Swiss German translation
- Improved template organization
- Enhanced security with auto-escaping
### 1.0.0 (2025-12-21)
- Initial release
- Tier pricing functionality
- Package pricing functionality
- German and English translations
## License
GPL v2 or later - https://www.gnu.org/licenses/gpl-2.0.html
---
**Note:** All packages are production-ready with optimized autoloaders and no development dependencies included.

View File

@@ -0,0 +1,127 @@
# WooCommerce Tier and Package Prices - Release 1.0.1
**Release Date:** December 21, 2025
**Version:** 1.0.1
**Package Size:** 395 KB
**Git Tag:** v1.0.1
## Download
**File:** `wc-tier-and-package-prices-1.0.1.zip`
### Checksums
**SHA256:**
```
92c1385d92527e77646e37f23c1bd1555a4290a5ec9314c0ee6ed896ded55e88
```
**MD5:**
```
e6cfc9b88df9e7763be0cd56517ce8ab
```
## Installation
1. Download the ZIP file: `wc-tier-and-package-prices-1.0.1.zip`
2. Log in to your WordPress admin panel
3. Navigate to **Plugins > Add New > Upload Plugin**
4. Choose the downloaded ZIP file
5. Click **Install Now**
6. After installation, click **Activate Plugin**
### Requirements
- **WordPress:** 6.0 or higher
- **PHP:** 7.4 or higher
- **WooCommerce:** 8.0 or higher
## What's New in 1.0.1
### New Features
-**Twig Template Engine** - Modern template system with automatic escaping
-**Swiss German Translation** - Added de_CH_informal translation
-**Template Caching** - Improved performance with compiled templates
-**Composer Integration** - Professional dependency management
### Improvements
- 🔄 Migrated all templates from PHP to Twig format
- 🔒 Enhanced security with automatic HTML escaping
- 📁 Better template organization (admin/ and frontend/ directories)
- 🎨 Cleaner separation of logic and presentation
### Technical Changes
- Added Twig v3.22.2 dependency
- Created WC_TPP_Template_Loader class for centralized rendering
- Integrated WordPress functions (__(), wc_price(), etc.) into Twig
- Optimized autoloader for production
- Removed legacy PHP templates
## Package Contents
The installation package includes:
### Core Files
- `wc-tier-and-package-prices.php` - Main plugin file
- `composer.json` - Dependency configuration
- `CHANGELOG.md` - Full version history
- `README.md` - Plugin documentation
### Directories
- `includes/` - PHP class files
- `class-wc-tpp-admin.php`
- `class-wc-tpp-cart.php`
- `class-wc-tpp-frontend.php`
- `class-wc-tpp-product-meta.php`
- `class-wc-tpp-template-loader.php`
- `templates/` - Twig template files
- `admin/` - Admin interface templates
- `frontend/` - Customer-facing templates
- `languages/` - Translation files
- de_CH_informal (Swiss German, Informal)
- de_DE (German, Germany)
- en_US (English, US)
- `assets/` - CSS and JavaScript files
- `vendor/` - Composer dependencies (Twig)
## Translations Included
1. **English (US)** - en_US ✅
2. **German (Germany)** - de_DE ✅
3. **German (Switzerland, Informal)** - de_CH_informal ✅ NEW!
## Features
### Tier Pricing
- Quantity-based discount tiers
- Automatic price calculation
- Volume discount display
### Package Pricing
- Fixed-price bundles
- Custom package labels
- Multiple package options per product
### Admin Features
- Easy-to-use product meta boxes
- Configurable display positions
- Settings page for global options
### Frontend Features
- Beautiful pricing tables
- Real-time cart updates
- Responsive design
## Support
- **Documentation:** See README.md and USAGE_EXAMPLES.md
- **Issues:** https://src.bundespruefstelle.ch/wc-tier-package-prices/issues
- **Author:** Marco Graetsch
## License
GPL v2 or later - https://www.gnu.org/licenses/gpl-2.0.html
---
**Note:** This is a production-ready package with optimized autoloader and no development dependencies.

Binary file not shown.

View File

@@ -0,0 +1 @@
e6cfc9b88df9e7763be0cd56517ce8ab wc-tier-and-package-prices-1.0.1.zip

View File

@@ -0,0 +1 @@
92c1385d92527e77646e37f23c1bd1555a4290a5ec9314c0ee6ed896ded55e88 wc-tier-and-package-prices-1.0.1.zip

View File

@@ -1,53 +0,0 @@
{#
# Admin Settings Page Template
#
# @package WC_Tier_Package_Prices
#}
<div class="wrap">
<h1>{{ get_admin_page_title()|esc_html }}</h1>
<form action="options.php" method="post">
{{ settings_fields('wc_tpp_settings') }}
<table class="form-table">
<tr>
<th scope="row">
<label for="wc_tpp_enable_tier_pricing">{{ 'Enable Tier Pricing'|__('wc-tier-package-prices') }}</label>
</th>
<td>
<input type="checkbox" id="wc_tpp_enable_tier_pricing" name="wc_tpp_enable_tier_pricing" value="yes" {{ checked(get_option('wc_tpp_enable_tier_pricing'), 'yes')|raw }}>
<p class="description">{{ 'Enable tier pricing for products'|__('wc-tier-package-prices') }}</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="wc_tpp_enable_package_pricing">{{ 'Enable Package Pricing'|__('wc-tier-package-prices') }}</label>
</th>
<td>
<input type="checkbox" id="wc_tpp_enable_package_pricing" name="wc_tpp_enable_package_pricing" value="yes" {{ checked(get_option('wc_tpp_enable_package_pricing'), 'yes')|raw }}>
<p class="description">{{ 'Enable fixed-price packages for products'|__('wc-tier-package-prices') }}</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="wc_tpp_display_table">{{ 'Display Pricing Table'|__('wc-tier-package-prices') }}</label>
</th>
<td>
<input type="checkbox" id="wc_tpp_display_table" name="wc_tpp_display_table" value="yes" {{ checked(get_option('wc_tpp_display_table'), 'yes')|raw }}>
<p class="description">{{ 'Show tier and package pricing table on product pages'|__('wc-tier-package-prices') }}</p>
</td>
</tr>
<tr>
<th scope="row">
<label for="wc_tpp_display_position">{{ 'Display Position'|__('wc-tier-package-prices') }}</label>
</th>
<td>
<select id="wc_tpp_display_position" name="wc_tpp_display_position">
<option value="before_add_to_cart" {{ selected(get_option('wc_tpp_display_position'), 'before_add_to_cart')|raw }}>{{ 'Before Add to Cart'|__('wc-tier-package-prices') }}</option>
<option value="after_add_to_cart" {{ selected(get_option('wc_tpp_display_position'), 'after_add_to_cart')|raw }}>{{ 'After Add to Cart'|__('wc-tier-package-prices') }}</option>
<option value="after_price" {{ selected(get_option('wc_tpp_display_position'), 'after_price')|raw }}>{{ 'After Price'|__('wc-tier-package-prices') }}</option>
</select>
</td>
</tr>
</table>
{{ submit_button() }}
</form>
</div>

View File

@@ -4,7 +4,7 @@
* Plugin Name: WooCommerce Tier and Package Prices
* Plugin URI: https://src.bundespruefstelle.ch/wc-tier-package-prices
* Description: Add tier pricing and package prices to WooCommerce products with configurable quantities at fixed prices
* Version: 1.0.1
* Version: 1.0.2
* Author: Marco Graetsch
* Author URI: https://src.bundespruefstelle.ch/magdev
* Text Domain: wc-tier-package-prices
@@ -22,7 +22,7 @@ if (!defined('ABSPATH')) {
}
// Define plugin constants
define('WC_TPP_VERSION', '1.0.1');
define('WC_TPP_VERSION', '1.0.2');
define('WC_TPP_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('WC_TPP_PLUGIN_URL', plugin_dir_url(__FILE__));
define('WC_TPP_PLUGIN_BASENAME', plugin_basename(__FILE__));