Enhanced package quantity restriction enforcement by hiding the cart quantity input field when restrictions are enabled. This prevents customers from modifying quantities in the cart to bypass package restrictions. Changes: - Added cart quantity input hiding for restricted products - Implemented woocommerce_cart_item_quantity filter hook - Created maybe_hide_cart_quantity_input() method in WC_TPP_Cart - Fixed cart quantity bypass vulnerability - Cart displays quantity as read-only text for restricted products 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
11 KiB
WooCommerce Tier and Package Prices - Release 1.1.0
Release Date: December 21, 2025 Version: 1.1.0 Package Size: 387 KB Git Tag: v1.1.0
Download
File: wc-tier-and-package-prices-1.1.0.zip
Checksums
SHA256:
da6b462f3dc297b282ed0da258b78fd9f2f82f3e76289c4c8fadd1ac9e02c55b
MD5:
ef68125c54b0c10f04ba82d48a98b4aa
What's New in 1.1.0
Major Features
- ✨ Package Quantity Restriction - NEW
- Limit product purchases to predefined package sizes only
- Perfect for bulk-only sales, sample packs, or fixed bundle quantities
- Global and per-product configuration options
New Settings
-
🌍 Global Restriction Setting
- Enable quantity restrictions site-wide
- Located in: WooCommerce > Settings > Tier & Package Prices
- Description: "Limit quantities to defined package sizes only"
-
📦 Per-Product Restriction Setting
- Override global setting on individual products
- Located in: Product Edit > Package Pricing section
- Checkbox: "Restrict to Package Quantities"
Frontend Enhancements
-
🎨 Enhanced Package Selection UI
- Automatic quantity field hiding when restriction is enabled
- Clear notice: "Choose a package size below"
- Visual package selection with highlighted states
- Responsive package selection buttons
-
✅ Client-Side Validation
- JavaScript prevents form submission without package selection
- Alert message guides users to select a package
- Real-time visual feedback on selection
Backend Validation
- 🛡️ Server-Side Cart Validation
- Validates quantity matches defined packages
- Prevents manual quantity manipulation
- User-friendly error messages
- Example: "The quantity 15 is not available for Product Name. Please choose from the available package sizes: 10, 20, 50"
Technical Improvements
- New method:
WC_TPP_Cart::validate_package_quantity() - New method:
WC_TPP_Frontend::maybe_hide_quantity_input() - Enhanced
woocommerce_add_to_cart_validationfilter integration - Added
wc-tpp-restricted-modeCSS class - Added
wc-tpp-package-selectableCSS class for styling - New product meta key:
_wc_tpp_restrict_to_packages - New global option:
wc_tpp_restrict_package_quantities
Translations
- Added 7 new translatable strings
- Updated all language files (en_US, de_DE, de_CH_informal)
- All .mo files recompiled with new strings
Installation
- Download the ZIP file:
wc-tier-and-package-prices-1.1.0.zip - Log in to your WordPress admin panel
- Navigate to Plugins > Add New > Upload Plugin
- Choose the downloaded ZIP file
- Click Install Now
- After installation, click Activate Plugin
- Go to WooCommerce > Settings > Tier & Package Prices to configure
Upgrade from 1.0.x
This is a minor version update with new features. No data migration needed.
Steps:
- Deactivate the current version
- Upload and activate version 1.1.0
- All existing settings and data will be automatically preserved
- Review new restriction settings if desired
Upgrade from 1.0.2
No breaking changes. Safe to upgrade directly. New restriction feature is disabled by default.
Requirements
- WordPress: 6.0 or higher
- PHP: 7.4 or higher
- WooCommerce: 8.0 or higher
New Strings Translation Reference
All new strings in this release:
Settings Page
- "Restrict to Package Quantities" - Checkbox label
- "Limit quantities to defined package sizes only" - Checkbox description
- "When enabled, customers can only purchase..." - Tooltip text
Product Meta Box
- "Restrict to Package Quantities" - Checkbox label (same as above)
- "Only allow quantities defined in packages above" - Tooltip text
Frontend Display
- "Choose a package size below" - User notice in restricted mode
Cart Validation
- "this product" - Fallback product name
- "The quantity %1$d is not available for %2$s..." - Error message template
Use Cases
Bulk-Only Sales
Enable restriction globally to sell products only in bulk quantities.
Example:
- Package 1: 100 units at $500
- Package 2: 250 units at $1,100
- Package 3: 500 units at $2,000
Customers can only purchase these exact quantities.
Sample Packs
Create fixed sample packs with no custom quantities.
Example:
- Starter Pack: 10 items
- Trial Pack: 25 items
- Full Pack: 50 items
Promotional Bundles
Offer promotional pricing only for specific bundle sizes.
Example:
- Holiday Bundle: 12 units (seasonal pricing)
- Party Pack: 24 units (bulk discount)
- Wholesale Bundle: 100 units (wholesale pricing)
Configuration Examples
Example 1: Site-Wide Restriction
Scenario: All products should only be sold in packages
Configuration:
- Go to WooCommerce > Settings > Tier & Package Prices
- Check "Restrict to Package Quantities"
- Save changes
- Configure package sizes for each product
Result: All products with packages defined will enforce quantity restrictions
Example 2: Per-Product Restriction
Scenario: Only specific products need quantity restrictions
Configuration:
- Leave global setting unchecked
- Edit the specific product
- Scroll to Package Pricing section
- Check "Restrict to Package Quantities"
- Update product
Result: Only that product enforces restrictions
Example 3: Mixed Approach
Scenario: Most products are restricted, but some allow custom quantities
Configuration:
- Enable global restriction
- For products that should allow custom quantities, simply don't define any packages
- Products without packages defined won't show restrictions
Feature Compatibility
Works With
- ✅ WooCommerce 8.0 - 10.0
- ✅ WordPress 6.0+
- ✅ HPOS (High-Performance Order Storage)
- ✅ All WooCommerce themes
- ✅ Tier pricing (can use both features together)
- ✅ Package pricing (required for restriction)
- ✅ All pricing table display positions
Requirements for Restriction Feature
- Product must have at least one package defined
- Either global or per-product restriction must be enabled
- Package pricing must be enabled in settings
Package Contents
The installation package includes all files from version 1.0.2 plus:
Modified Files
wc-tier-and-package-prices.php- Version updated to 1.1.0composer.json- Version updated to 1.1.0CHANGELOG.md- Added v1.1.0 sectionincludes/class-wc-tpp-settings.php- Added restriction settingincludes/class-wc-tpp-product-meta.php- Added per-product checkboxincludes/class-wc-tpp-frontend.php- Added quantity hiding logicincludes/class-wc-tpp-cart.php- Added validation methodassets/js/frontend.js- Added restricted mode handlingtemplates/frontend/package-pricing-display.twig- Added restriction noticetemplates/frontend/pricing-table.twig- Pass restriction flag- All translation files (.po/.mo) - Updated with new strings
Complete Directory Structure
wc-tier-and-package-prices/
├── assets/
│ ├── css/
│ │ ├── admin.css
│ │ └── frontend.css
│ └── js/
│ ├── admin.js
│ └── frontend.js (UPDATED)
├── includes/
│ ├── class-wc-tpp-admin.php
│ ├── class-wc-tpp-cart.php (UPDATED)
│ ├── class-wc-tpp-frontend.php (UPDATED)
│ ├── class-wc-tpp-product-meta.php (UPDATED)
│ ├── class-wc-tpp-settings.php (UPDATED)
│ └── class-wc-tpp-template-loader.php
├── languages/ (ALL UPDATED)
│ ├── wc-tier-package-prices-de_CH_informal.po/mo
│ ├── wc-tier-package-prices-de_DE.po/mo
│ ├── wc-tier-package-prices-en_US.po/mo
│ └── wc-tier-package-prices.pot
├── templates/
│ ├── admin/
│ │ ├── package-row.twig
│ │ └── tier-row.twig
│ └── frontend/
│ ├── package-pricing-display.twig (UPDATED)
│ ├── pricing-table.twig (UPDATED)
│ └── tier-pricing-table.twig
├── vendor/ (Twig v3.22.2)
├── CHANGELOG.md (UPDATED)
├── composer.json (UPDATED)
└── wc-tier-and-package-prices.php (UPDATED)
Features (Complete List)
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
- ✅ NEW: Quantity restriction to packages only
Admin Features
- ✅ WooCommerce Settings integration
- ✅ Easy-to-use product meta boxes
- ✅ Configurable display positions
- ✅ Native WooCommerce UI
- ✅ NEW: Global restriction setting
- ✅ NEW: Per-product restriction override
Frontend Features
- ✅ Beautiful pricing tables (Twig templates)
- ✅ Real-time cart updates
- ✅ Responsive design
- ✅ 3 languages supported
- ✅ NEW: Package-only selection mode
- ✅ NEW: Automatic quantity field hiding
- ✅ NEW: Visual package selection
Validation & Security
- ✅ NEW: Client-side JavaScript validation
- ✅ NEW: Server-side cart validation
- ✅ NEW: User-friendly error messages
- ✅ WooCommerce HPOS compatible
Breaking Changes
None. This release is fully backward compatible.
The new restriction feature is disabled by default and must be explicitly enabled.
Migration Notes
From 1.0.2
- No migration needed
- New settings appear automatically in admin
- Feature is disabled by default
Settings Location
All settings remain in: WooCommerce > Settings > Tier & Package Prices
Data Preservation
- All existing tier pricing data preserved
- All existing package pricing data preserved
- All product meta data preserved
- No database changes required
Known Limitations
Current Version
- Restriction only works when packages are defined
- Cannot restrict to tier quantities (only packages)
- Restriction applies to entire product (no variation-level control)
Future Enhancements
These features may be added in future versions:
- Variation-level restriction control
- Restrict to tier quantities option
- Minimum/maximum package selection limits
Support
- Documentation: See README.md and CHANGELOG.md
- Previous Release: See RELEASE-INFO-1.0.2.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
Production Ready: This package includes optimized autoloader and no development dependencies.
What's Next: Version 1.1.0 completes the package restriction feature set. Future versions may add variation-level controls and tier quantity restrictions.