Add pricing system with tiers, seasons, and calculator (v0.2.0)
All checks were successful
Create Release Package / build-release (push) Successful in 1m19s

- Create PricingTier enum for short/mid/long-term pricing
- Add Season class for seasonal pricing with date ranges
- Implement Calculator for price calculations with breakdown
- Add pricing meta box to Room post type
- Create Seasons admin page for managing seasonal pricing
- Add Pricing settings tab with tier thresholds
- Support weekend surcharges and configurable weekend days
- Add price column to room list admin

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-31 14:10:30 +01:00
parent f24a347bb1
commit dabfe1e826
12 changed files with 1911 additions and 25 deletions

View File

@@ -38,15 +38,6 @@ This project is proudly **"vibe-coded"** using Claude.AI - the entire codebase w
**Note for AI Assistants:** Clean this section after the specific features are done or new releases are made. Effective changes are tracked in `CHANGELOG.md`. Do not add completed versions here - document them in the Session History section at the end of this file.
### Version 0.1.0 - Core Data Structures
- Custom Post Type: Buildings (address, contact, description, images)
- Custom Post Type: Rooms (building reference, capacity, amenities)
- Custom Taxonomy: Room Types (Standard, Suite, Family, etc.)
- Custom Taxonomy: Amenities (WiFi, Parking, Breakfast, etc.)
- Gutenberg blocks for Buildings and Rooms
- See `PLAN.md` for full implementation roadmap
## Technical Stack
- **Language:** PHP 8.3.x
@@ -215,11 +206,17 @@ wp-bnb/
│ └── release.yml # CI/CD release pipeline
├── src/ # PHP source code (PSR-4: Magdev\WpBnb)
│ ├── Plugin.php # Main plugin singleton
│ ├── Admin/ # Admin pages
│ │ └── Seasons.php # Seasons management page
│ ├── License/
│ │ └── Manager.php # License management
│ ├── PostTypes/ # Custom post types
│ │ ├── Building.php # Building post type
│ │ └── Room.php # Room post type
│ ├── Pricing/ # Pricing system
│ │ ├── Calculator.php # Price calculation
│ │ ├── PricingTier.php # Pricing tier enum
│ │ └── Season.php # Seasonal pricing
│ └── Taxonomies/ # Custom taxonomies
│ ├── Amenity.php # Amenity taxonomy (tags)
│ └── RoomType.php # Room type taxonomy (categories)
@@ -350,3 +347,53 @@ Admin features always work; frontend requires valid license.
- Gallery implementation uses `wp.media` frame with multiple selection
- Admin assets need conditional loading based on both hook suffix and post type
- Status badges use inline styles for color coding (avoiding extra CSS complexity)
### 2026-01-31 - Version 0.2.0 (Pricing System)
**Completed:**
- Created `src/Pricing/PricingTier.php` enum class
- SHORT_TERM, MID_TERM, LONG_TERM cases
- Labels, units, default thresholds
- `fromNights()` for automatic tier detection
- Created `src/Pricing/Season.php` class
- Seasonal pricing with date ranges (MM-DD format)
- Year-spanning seasons support (e.g., Dec 20 to Jan 6)
- Price modifier (multiplier) per season
- Priority system for overlapping seasons
- CRUD operations stored in wp_options
- Default seasons: High Season, Winter Holidays, Low Season
- Created `src/Pricing/Calculator.php` class
- Price calculation with tier detection
- Seasonal modifier application
- Weekend surcharge support
- Detailed price breakdown
- Currency formatting with symbol/suffix
- Added pricing meta box to Room post type
- Base prices for each tier
- Weekend surcharge field
- Link to pricing settings
- Price column in admin list
- Added Pricing tab to settings page
- Configurable tier thresholds
- Weekend days selection (checkboxes)
- Quick view of configured seasons
- Created `src/Admin/Seasons.php` admin page
- List view with all seasons
- Add/Edit season forms
- Delete with confirmation
- Create default seasons option
- Date formatting for display
- Updated admin.css with pricing styles
- Updated admin.js with pricing interactions
- Updated Plugin.php to register Seasons admin page
- Updated version to 0.2.0
**Learnings:**
- PHP 8.1+ enums work well for pricing tiers with methods
- Season date ranges use MM-DD format for annual recurrence
- Year-spanning seasons require special comparison logic
- Price modifiers as multipliers are more flexible than percentages
- Calculator class separates concerns from post type class
- Weekend days stored as comma-separated string in options