Release version 1.1.21 - Add multilingual support for Swiss locales

Added translations for Swiss German (formal and informal), Swiss French,
and Swiss Italian locales to support multilingual e-commerce in Switzerland.

New Features:
- Added de_CH (Swiss German - formal "Sie") translation
- Added de_DE_informal (Informal German - "du") translation
- Added fr_CH (Swiss French) translation
- Added it_CH (Swiss Italian) translation

Technical Changes:
- Created 4 new .po translation source files
- Compiled all .po files to .mo format for runtime use
- Updated version to 1.1.21 in plugin header and constant
- Updated composer.json version to 1.1.21
- Swiss locales use CHF currency formatting (e.g., "CHF 50.-")
- German informal translations use "du/dein" instead of "Sie/Ihr"

Documentation:
- Updated CHANGELOG.md with v1.1.21 release notes
- Updated CLAUDE.md with current version and translation status
- Marked roadmap item as completed in CLAUDE.md

Release Package:
- Created wc-tier-and-package-prices-1.1.21.zip (404 KB)
- Generated MD5 checksum: 16813b3ed0d1001d5f60194d61d36fc2
- Generated SHA256 checksum: e0063852a9ac23b1fd994471a2829f9dcbe26316f00ddee2d00f77c7c6a47c8f

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-23 01:44:41 +01:00
parent b1d31f4894
commit f958c7b640
15 changed files with 1089 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
# WooCommerce Tier and Package Prices - AI Context Document
**Last Updated:** 2025-12-23
**Current Version:** 1.1.20
**Current Version:** 1.1.21
**Author:** Marco Graetsch
**Project Status:** Production-ready WordPress plugin
@@ -76,6 +76,7 @@ wc-tier-and-package-prices/
### Class Responsibilities
#### 1. `WC_Tier_Package_Prices` (Main Plugin Class)
- **Location:** `wc-tier-and-package-prices.php`
- **Pattern:** Singleton
- **Responsibilities:**
@@ -86,6 +87,7 @@ wc-tier-and-package-prices/
- Activation/deactivation hooks
#### 2. `WC_TPP_Admin`
- **Location:** `includes/class-wc-tpp-admin.php`
- **Pattern:** Singleton
- **Responsibilities:**
@@ -95,6 +97,7 @@ wc-tier-and-package-prices/
- Product meta box asset loading
#### 3. `WC_TPP_Settings`
- **Location:** `includes/class-wc-tpp-settings.php`
- **Extends:** `WC_Settings_Page` (WooCommerce core)
- **Responsibilities:**
@@ -103,6 +106,7 @@ wc-tier-and-package-prices/
- Setting persistence through WooCommerce options API
**Global Settings:**
- `wc_tpp_enable_tier_pricing` (yes/no)
- `wc_tpp_enable_package_pricing` (yes/no)
- `wc_tpp_display_table` (yes/no) - Show pricing tables on product pages
@@ -110,6 +114,7 @@ wc-tier-and-package-prices/
- `wc_tpp_restrict_package_quantities` (yes/no) - Global quantity restrictions
#### 4. `WC_TPP_Product_Meta`
- **Location:** `includes/class-wc-tpp-product-meta.php`
- **Responsibilities:**
- Adds tier/package pricing fields to product edit page
@@ -119,11 +124,13 @@ wc-tier-and-package-prices/
- Prevents autosave from corrupting data
**Product Meta Keys:**
- `_wc_tpp_tiers` - Array of tier objects `[{min_qty, price, label}]`
- `_wc_tpp_packages` - Array of package objects `[{qty, price, label}]`
- `_wc_tpp_restrict_to_packages` - Per-product quantity restriction (yes/no)
#### 5. `WC_TPP_Frontend`
- **Location:** `includes/class-wc-tpp-frontend.php`
- **Responsibilities:**
- Enqueues frontend CSS/JS on product pages
@@ -134,6 +141,7 @@ wc-tier-and-package-prices/
- Static methods for price lookups (`get_tier_price()`, `get_package_price()`)
#### 6. `WC_TPP_Cart`
- **Location:** `includes/class-wc-tpp-cart.php`
- **Responsibilities:**
- **MOST CRITICAL CLASS** - Handles all cart price calculations
@@ -145,11 +153,13 @@ wc-tier-and-package-prices/
- **WooCommerce Blocks support** via `woocommerce_store_api_product_quantity_editable` filter
**Price Calculation Priority (in `apply_tier_package_pricing()`):**
1. Check for exact package match → Use package price if found
2. Check for tier match → Use tier price if found
3. Fall back to regular product price
#### 7. `WC_TPP_Template_Loader`
- **Location:** `includes/class-wc-tpp-template-loader.php`
- **Pattern:** Singleton
- **Responsibilities:**
@@ -196,6 +206,7 @@ Products can be configured to ONLY allow purchase in package quantities:
### WooCommerce Blocks Compatibility
**CRITICAL BUG FIXED in v1.1.20:**
- Filter `woocommerce_store_api_product_quantity_editable` passes `WC_Product` object, NOT cart item array
- Previous code tried to use product object as array → fatal error
- Fixed by accepting product object and using `$product->get_id()`
@@ -228,6 +239,7 @@ new WC_TPP_Frontend(); // Auto-instantiate
**Exception:** Admin and Settings classes use singleton pattern to prevent duplicates.
### Security Best Practices
- All user inputs are sanitized (integers for quantities/prices)
- Nonce verification on form submissions
- Capability checks (`edit_products`) before saving
@@ -243,16 +255,30 @@ _e('Text to translate', 'wc-tier-package-prices')
Text domain: `wc-tier-package-prices`
**Available Translations (as of v1.1.21):**
- `en_US` - English (United States)
- `de_DE` - German (Germany, formal)
- `de_DE_informal` - German (Germany, informal "du")
- `de_CH` - German (Switzerland, formal "Sie")
- `de_CH_informal` - German (Switzerland, informal "du")
- `fr_CH` - French (Switzerland)
- `it_CH` - Italian (Switzerland)
Note: Swiss locales use CHF currency formatting in examples (e.g., "CHF 50.-")
## Known Issues & Historical Context
### Settings Page Duplication Saga (v1.1.15-1.1.19)
Multiple versions attempted to fix settings page appearing twice:
- **Root cause:** Settings file auto-instantiation + Composer autoloader
- **Solution:** Removed auto-instantiation from settings file, explicit instantiation in admin class
- **Prevention:** Singleton pattern + duplicate detection in array
### Class Redeclaration Issues (v1.1.8-1.1.14)
Plugin was completely non-functional:
- **Cause:** Incorrect initialization pattern without `class_exists()` guards
- **Solution:** Added guards and restored direct instantiation pattern
- **Lesson:** Always wrap class declarations in `class_exists()` checks
@@ -262,6 +288,7 @@ Plugin was completely non-functional:
Fatal error: Cannot use object of type WC_Product_Simple as array
Location: includes/class-wc-tpp-cart.php:233
```
- **Cause:** Filter signature mismatch - expected array, received product object
- **Fix:** Changed method signature to accept `WC_Product $product` instead of `$cart_item` array
- **Status:** FIXED in v1.1.20
@@ -270,6 +297,7 @@ Location: includes/class-wc-tpp-cart.php:233
### Version Bumping
Update version in 3 places:
1. `wc-tier-and-package-prices.php` - Plugin header comment (line 7)
2. `wc-tier-and-package-prices.php` - `WC_TPP_VERSION` constant (line 26)
3. `composer.json` - version field (optional, not critical)
@@ -281,7 +309,7 @@ cd releases
# Create zip excluding dev files
zip -r wc-tier-and-package-prices-X.X.X.zip .. \
-x '*.git*' '*.log' '.claude/*' 'releases/*' 'node_modules/*' \
-x '*.git*' '*.log' '.claude/*' 'CLAUDE.md' 'releases/*' 'node_modules/*' \
'.DS_Store' 'Thumbs.db' '.vscode/*' '.idea/*' '*.sublime-*' \
'notes.*' 'logs/*' 'templates/cache/*' 'composer.lock'
@@ -293,6 +321,7 @@ sha256sum wc-tier-and-package-prices-X.X.X.zip > wc-tier-and-package-prices-X.X.
**IMPORTANT:** The `vendor/` directory MUST be included in releases (Twig dependency required for runtime).
### What Gets Released
- All plugin source files
- Compiled vendor dependencies
- Translation files (.mo compiled from .po)
@@ -300,6 +329,7 @@ sha256sum wc-tier-and-package-prices-X.X.X.zip > wc-tier-and-package-prices-X.X.
- Documentation (README, CHANGELOG, etc.)
### What's Excluded
- Git metadata (`.git/`)
- Development files (`.vscode/`, `.claude/`, `CLAUDE.md`)
- Logs and cache files
@@ -311,6 +341,7 @@ sha256sum wc-tier-and-package-prices-X.X.X.zip > wc-tier-and-package-prices-X.X.
When making changes, test these critical paths:
### Admin
- [ ] Settings page appears once under WooCommerce > Tier & Package Prices
- [ ] Settings save correctly
- [ ] Product edit page shows tier/package meta boxes
@@ -319,6 +350,7 @@ When making changes, test these critical paths:
- [ ] Data saves when clicking "Update" on product
### Frontend (Product Page)
- [ ] Pricing tables display when configured
- [ ] Package buttons update quantity selector
- [ ] Price updates dynamically when quantity changes
@@ -326,6 +358,7 @@ When making changes, test these critical paths:
- [ ] "View Options" appears on catalog for restricted products
### Cart & Checkout
- [ ] Correct prices applied for tier pricing
- [ ] Correct prices applied for package pricing
- [ ] Cart displays pricing type labels
@@ -334,6 +367,7 @@ When making changes, test these critical paths:
- [ ] Checkout totals are correct
### WooCommerce Blocks (Critical!)
- [ ] Mini cart block doesn't throw fatal errors
- [ ] Cart block works correctly
- [ ] Checkout block processes orders
@@ -341,19 +375,35 @@ When making changes, test these critical paths:
## Development Tips for Future AI Assistants
### Future Features and Roadmap
The is a hierarchical list for upcoming features and can be considered as a
Roadmap for the upcoming development.
#### Version 1.1.x
1. ~~Add translations for `de_CH`, `de_DE_informal`, `fr_CH`, `it_CH`~~**COMPLETED in v1.1.21**
#### Version 1.2.x
1. New Feature: 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
1. Check `includes/class-wc-tpp-cart.php` first
2. The `apply_tier_package_pricing()` method runs on `woocommerce_before_calculate_totals`
3. Always validate product objects with `is_a($product, 'WC_Product')`
4. Remember: WooCommerce expects UNIT prices, not total prices (except for internal calculations)
### When Working with WooCommerce Hooks
- WooCommerce has both classic and block-based systems
- Classic cart uses different hooks than Store API (blocks)
- Always check filter/action documentation for parameter types
- Don't assume cart item arrays everywhere - sometimes it's product objects!
### When Adding Features
- Follow the existing pattern: add setting → add UI → add logic → add template
- Use Twig for all new templates (consistency)
- Add translations for all user-facing strings
@@ -361,6 +411,7 @@ When making changes, test these critical paths:
- Consider both classic and block-based cart/checkout
### When Fixing Bugs
1. Check `CHANGELOG.md` for historical context
2. Look for similar issues in past versions
3. Always add detailed changelog entry explaining root cause
@@ -383,22 +434,26 @@ When making changes, test these critical paths:
## Compatibility Notes
### WordPress
- Minimum: 6.0
- Tested up to: 6.9.x
- Uses standard plugin API, no deprecated functions
### WooCommerce
- Minimum: 8.0
- Tested up to: 10.x
- HPOS compatible (declared via `FeaturesUtil::declare_compatibility`)
- Blocks compatible (with proper filter handling)
### PHP
- Minimum: 7.4
- Uses modern PHP features (type hints acceptable in new code)
- Composer autoloader handles namespacing
### Browsers
- Modern browsers (ES6+ JavaScript)
- Responsive CSS (mobile-friendly)
- jQuery dependency (WooCommerce provides)
@@ -413,6 +468,7 @@ When making changes, test these critical paths:
## Final Notes
This is a production-quality plugin with real-world usage. Any changes should:
1. Maintain backward compatibility with existing tier/package configurations
2. Not break WooCommerce core functionality
3. Work with both classic and block-based themes
@@ -421,9 +477,12 @@ This is a production-quality plugin with real-world usage. Any changes should:
6. Update CHANGELOG.md with detailed explanations
The plugin architecture is solid and well-tested. Most bugs arise from:
- WooCommerce API changes (especially blocks)
- Filter/action signature changes
- Edge cases in cart calculations
- Settings persistence issues
---
Always refer to this document when starting work on this project. Good luck!