diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 673c391..d164847 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -5,7 +5,9 @@ "Bash(msgfmt:*)", "Bash(ls:*)", "Bash(mkdir:*)", - "Bash(composer init:*)" + "Bash(composer init:*)", + "Bash(composer install:*)", + "Bash(composer update:*)" ] } } diff --git a/CHANGELOG.md b/CHANGELOG.md index 41b10eb..b9bf41c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/composer.json b/composer.json index 5ec4957..63f3cf7 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.0.1", + "version": "1.0.2", "type": "wordpress-plugin", "license": "GPL-2.0-or-later", "authors": [ diff --git a/includes/class-wc-tpp-admin.php b/includes/class-wc-tpp-admin.php index c65ed58..6c97be7 100644 --- a/includes/class-wc-tpp-admin.php +++ b/includes/class-wc-tpp-admin.php @@ -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(); diff --git a/includes/class-wc-tpp-settings.php b/includes/class-wc-tpp-settings.php new file mode 100644 index 0000000..7aafbcf --- /dev/null +++ b/includes/class-wc-tpp-settings.php @@ -0,0 +1,134 @@ + 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(); diff --git a/releases/README.md b/releases/README.md new file mode 100644 index 0000000..bb9ec6d --- /dev/null +++ b/releases/README.md @@ -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. diff --git a/releases/RELEASE-INFO-1.0.1.md b/releases/RELEASE-INFO-1.0.1.md new file mode 100644 index 0000000..6410280 --- /dev/null +++ b/releases/RELEASE-INFO-1.0.1.md @@ -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. diff --git a/releases/wc-tier-and-package-prices-1.0.1.zip b/releases/wc-tier-and-package-prices-1.0.1.zip new file mode 100644 index 0000000..fbe951f Binary files /dev/null and b/releases/wc-tier-and-package-prices-1.0.1.zip differ diff --git a/releases/wc-tier-and-package-prices-1.0.1.zip.md5 b/releases/wc-tier-and-package-prices-1.0.1.zip.md5 new file mode 100644 index 0000000..de41333 --- /dev/null +++ b/releases/wc-tier-and-package-prices-1.0.1.zip.md5 @@ -0,0 +1 @@ +e6cfc9b88df9e7763be0cd56517ce8ab wc-tier-and-package-prices-1.0.1.zip diff --git a/releases/wc-tier-and-package-prices-1.0.1.zip.sha256 b/releases/wc-tier-and-package-prices-1.0.1.zip.sha256 new file mode 100644 index 0000000..0fe3de6 --- /dev/null +++ b/releases/wc-tier-and-package-prices-1.0.1.zip.sha256 @@ -0,0 +1 @@ +92c1385d92527e77646e37f23c1bd1555a4290a5ec9314c0ee6ed896ded55e88 wc-tier-and-package-prices-1.0.1.zip diff --git a/templates/admin/settings-page.twig b/templates/admin/settings-page.twig deleted file mode 100644 index e2525cf..0000000 --- a/templates/admin/settings-page.twig +++ /dev/null @@ -1,53 +0,0 @@ -{# - # Admin Settings Page Template - # - # @package WC_Tier_Package_Prices - #} -
-

{{ get_admin_page_title()|esc_html }}

-
- {{ settings_fields('wc_tpp_settings') }} - - - - - - - - - - - - - - - - - -
- - - -

{{ 'Enable tier pricing for products'|__('wc-tier-package-prices') }}

-
- - - -

{{ 'Enable fixed-price packages for products'|__('wc-tier-package-prices') }}

-
- - - -

{{ 'Show tier and package pricing table on product pages'|__('wc-tier-package-prices') }}

-
- - - -
- {{ submit_button() }} -
-
diff --git a/wc-tier-and-package-prices.php b/wc-tier-and-package-prices.php index 56732ef..690e537 100644 --- a/wc-tier-and-package-prices.php +++ b/wc-tier-and-package-prices.php @@ -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__));