You've already forked wc-tier-and-package-prices
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3e06137559 |
@@ -8,7 +8,12 @@
|
||||
"Bash(composer init:*)",
|
||||
"Bash(composer install:*)",
|
||||
"Bash(composer update:*)",
|
||||
"Bash(git add:*)"
|
||||
"Bash(git add:*)",
|
||||
"Bash(git commit -m \"$\\(cat <<''EOF''\nRelease version 1.1.0 - Package quantity restriction feature\n\nAdded comprehensive package quantity restriction functionality that allows\nlimiting product purchases to predefined package sizes only.\n\nFeatures:\n- Global setting to enable package quantity restrictions\n- Per-product override for quantity restrictions\n- Automatic hiding of quantity input field when restricted\n- Frontend validation with package selection UI\n- Server-side cart validation\n- User-friendly error messages\n- Complete translations for all supported languages\n\n🤖 Generated with [Claude Code]\\(https://claude.com/claude-code\\)\n\nCo-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>\nEOF\n\\)\")",
|
||||
"Bash(git tag:*)",
|
||||
"Bash(rsync:*)",
|
||||
"Bash(zip -r:*)",
|
||||
"Bash(cat:*)"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
18
CHANGELOG.md
18
CHANGELOG.md
@@ -5,6 +5,24 @@ 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.1.1] - 2025-12-21
|
||||
|
||||
### Added
|
||||
- Cart quantity field hiding when package restriction is enabled
|
||||
- Automatic read-only quantity display in cart for restricted products
|
||||
|
||||
### Changed
|
||||
- Cart quantity input replaced with plain text when restrictions apply
|
||||
- Enhanced cart display to prevent quantity modification for restricted products
|
||||
|
||||
### Fixed
|
||||
- Cart quantity bypass vulnerability for package-restricted products
|
||||
|
||||
### Technical
|
||||
- Added `maybe_hide_cart_quantity_input()` method in WC_TPP_Cart class
|
||||
- Extended `woocommerce_cart_item_quantity` filter hook
|
||||
- CSS class `wc-tpp-cart-quantity` for styled quantity display
|
||||
|
||||
## [1.1.0] - 2025-12-21
|
||||
|
||||
### Added
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "magdev/wc-tier-package-prices",
|
||||
"description": "WooCommerce plugin for tier pricing and package prices with Twig templates",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.1",
|
||||
"type": "wordpress-plugin",
|
||||
"license": "GPL-2.0-or-later",
|
||||
"authors": [
|
||||
|
||||
@@ -14,6 +14,7 @@ class WC_TPP_Cart {
|
||||
add_filter('woocommerce_cart_item_price', array($this, 'display_cart_item_price'), 10, 3);
|
||||
add_filter('woocommerce_cart_item_subtotal', array($this, 'display_cart_item_subtotal'), 10, 3);
|
||||
add_filter('woocommerce_add_to_cart_validation', array($this, 'validate_package_quantity'), 10, 3);
|
||||
add_filter('woocommerce_cart_item_quantity', array($this, 'maybe_hide_cart_quantity_input'), 10, 3);
|
||||
}
|
||||
|
||||
public function apply_tier_package_pricing($cart) {
|
||||
@@ -137,6 +138,24 @@ class WC_TPP_Cart {
|
||||
|
||||
return $passed;
|
||||
}
|
||||
|
||||
public function maybe_hide_cart_quantity_input($product_quantity, $cart_item_key, $cart_item) {
|
||||
$product_id = $cart_item['product_id'];
|
||||
|
||||
// Check if restriction is enabled globally or for this product
|
||||
$global_restrict = get_option('wc_tpp_restrict_package_quantities', 'no') === 'yes';
|
||||
$product_restrict = get_post_meta($product_id, '_wc_tpp_restrict_to_packages', true) === 'yes';
|
||||
|
||||
// Get packages for this product
|
||||
$packages = get_post_meta($product_id, '_wc_tpp_packages', true);
|
||||
|
||||
// If restriction is enabled and packages exist, show quantity as text only
|
||||
if (($global_restrict || $product_restrict) && !empty($packages)) {
|
||||
return sprintf('<span class="wc-tpp-cart-quantity">%s</span>', $cart_item['quantity']);
|
||||
}
|
||||
|
||||
return $product_quantity;
|
||||
}
|
||||
}
|
||||
|
||||
new WC_TPP_Cart();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# This file is distributed under the GPL v2 or later.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WooCommerce Tier and Package Prices 1.1.0\n"
|
||||
"Project-Id-Version: WooCommerce Tier and Package Prices 1.1.1\n"
|
||||
"Report-Msgid-Bugs-To: https://src.bundespruefstelle.ch/wc-tier-package-prices\n"
|
||||
"POT-Creation-Date: 2025-12-21 00:00+0000\n"
|
||||
"PO-Revision-Date: 2025-12-21 00:00+0000\n"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# This file is distributed under the GPL v2 or later.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WooCommerce Tier and Package Prices 1.1.0\n"
|
||||
"Project-Id-Version: WooCommerce Tier and Package Prices 1.1.1\n"
|
||||
"Report-Msgid-Bugs-To: https://src.bundespruefstelle.ch/wc-tier-package-prices\n"
|
||||
"POT-Creation-Date: 2025-12-21 00:00+0000\n"
|
||||
"PO-Revision-Date: 2025-12-21 00:00+0000\n"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# This file is distributed under the GPL v2 or later.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WooCommerce Tier and Package Prices 1.1.0\n"
|
||||
"Project-Id-Version: WooCommerce Tier and Package Prices 1.1.1\n"
|
||||
"Report-Msgid-Bugs-To: https://src.bundespruefstelle.ch/wc-tier-package-prices\n"
|
||||
"POT-Creation-Date: 2025-12-21 00:00+0000\n"
|
||||
"PO-Revision-Date: 2025-12-21 00:00+0000\n"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# This file is distributed under the GPL v2 or later.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: WooCommerce Tier and Package Prices 1.1.0\n"
|
||||
"Project-Id-Version: WooCommerce Tier and Package Prices 1.1.1\n"
|
||||
"Report-Msgid-Bugs-To: https://src.bundespruefstelle.ch/wc-tier-package-prices\n"
|
||||
"POT-Creation-Date: 2025-12-21 00:00+0000\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
|
||||
345
releases/RELEASE-INFO-1.1.0.md
Normal file
345
releases/RELEASE-INFO-1.1.0.md
Normal file
@@ -0,0 +1,345 @@
|
||||
# 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_validation` filter integration
|
||||
- Added `wc-tpp-restricted-mode` CSS class
|
||||
- Added `wc-tpp-package-selectable` CSS 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
|
||||
|
||||
1. Download the ZIP file: `wc-tier-and-package-prices-1.1.0.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**
|
||||
7. 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:**
|
||||
1. Deactivate the current version
|
||||
2. Upload and activate version 1.1.0
|
||||
3. All existing settings and data will be automatically preserved
|
||||
4. 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
|
||||
1. "Restrict to Package Quantities" - Checkbox label
|
||||
2. "Limit quantities to defined package sizes only" - Checkbox description
|
||||
3. "When enabled, customers can only purchase..." - Tooltip text
|
||||
|
||||
### Product Meta Box
|
||||
4. "Restrict to Package Quantities" - Checkbox label (same as above)
|
||||
5. "Only allow quantities defined in packages above" - Tooltip text
|
||||
|
||||
### Frontend Display
|
||||
6. "Choose a package size below" - User notice in restricted mode
|
||||
|
||||
### Cart Validation
|
||||
7. "this product" - Fallback product name
|
||||
8. "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:**
|
||||
1. Go to WooCommerce > Settings > Tier & Package Prices
|
||||
2. Check "Restrict to Package Quantities"
|
||||
3. Save changes
|
||||
4. 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:**
|
||||
1. Leave global setting unchecked
|
||||
2. Edit the specific product
|
||||
3. Scroll to Package Pricing section
|
||||
4. Check "Restrict to Package Quantities"
|
||||
5. Update product
|
||||
|
||||
**Result:** Only that product enforces restrictions
|
||||
|
||||
### Example 3: Mixed Approach
|
||||
|
||||
**Scenario:** Most products are restricted, but some allow custom quantities
|
||||
|
||||
**Configuration:**
|
||||
1. Enable global restriction
|
||||
2. For products that should allow custom quantities, simply don't define any packages
|
||||
3. 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.0
|
||||
- `composer.json` - Version updated to 1.1.0
|
||||
- `CHANGELOG.md` - Added v1.1.0 section
|
||||
- `includes/class-wc-tpp-settings.php` - Added restriction setting
|
||||
- `includes/class-wc-tpp-product-meta.php` - Added per-product checkbox
|
||||
- `includes/class-wc-tpp-frontend.php` - Added quantity hiding logic
|
||||
- `includes/class-wc-tpp-cart.php` - Added validation method
|
||||
- `assets/js/frontend.js` - Added restricted mode handling
|
||||
- `templates/frontend/package-pricing-display.twig` - Added restriction notice
|
||||
- `templates/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
|
||||
1. Restriction only works when packages are defined
|
||||
2. Cannot restrict to tier quantities (only packages)
|
||||
3. 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.
|
||||
BIN
releases/wc-tier-and-package-prices-1.1.0.zip
Normal file
BIN
releases/wc-tier-and-package-prices-1.1.0.zip
Normal file
Binary file not shown.
1
releases/wc-tier-and-package-prices-1.1.0.zip.md5
Normal file
1
releases/wc-tier-and-package-prices-1.1.0.zip.md5
Normal file
@@ -0,0 +1 @@
|
||||
ef68125c54b0c10f04ba82d48a98b4aa wc-tier-and-package-prices-1.1.0.zip
|
||||
1
releases/wc-tier-and-package-prices-1.1.0.zip.sha256
Normal file
1
releases/wc-tier-and-package-prices-1.1.0.zip.sha256
Normal file
@@ -0,0 +1 @@
|
||||
da6b462f3dc297b282ed0da258b78fd9f2f82f3e76289c4c8fadd1ac9e02c55b wc-tier-and-package-prices-1.1.0.zip
|
||||
@@ -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.1.0
|
||||
* Version: 1.1.1
|
||||
* 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.1.0');
|
||||
define('WC_TPP_VERSION', '1.1.1');
|
||||
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__));
|
||||
|
||||
Reference in New Issue
Block a user