1. Context
A short-term apartment rental marketplace operating in a mountain ski resort required an automated last-minute discount system integrated into its WordPress (Listeo + WooCommerce) platform to support dynamic pricing during seasonal demand fluctuations.
The solution needed to affect:
- Booking widget totals
- Confirmation page
- Pay-for-order endpoint
- Owner dashboard
- Multiple payment gateways
The objective was to implement a backend-driven pricing mechanism that maintained consistency across all booking stages.
2. Operational Constraints
The system presented several architectural constraints:
- Listeo uses a non-cart booking flow with AJAX-based price injection
- WooCommerce totals are calculated separately
- Card payments include a dynamic 3.6% processing fee
- Bank transfer includes 0% fee
- The pay-for-order endpoint re-renders DOM content
- AJAX refreshes override custom modifications
- The owner dashboard displayed only original price
- Confirmation page markup required careful handling
Full synchronization between backend calculations and frontend presentation was required across multiple endpoints.
3. System Requirements
The solution needed to:
- Detect eligible bookings within defined time windows
- Apply discounts at backend level
- Store pricing metadata reliably
- Integrate with WooCommerce fee logic
- Remain compatible with multiple payment gateways
- Preserve accuracy during asynchronous DOM updates
- Avoid cart-based dependency
This section shows thinking before coding.
4. Architecture & Implementation
4.1 Custom Plugin Development
A production-ready plugin was developed:
listeo-last-minute-offer
Core responsibilities:
- Booking eligibility detection
- Discount calculation
- Order meta storage
- WooCommerce fee integration
- Payment gateway compatibility
4.2 Listing Page Synchronization
- Injected “Last Minute 30% OFF” indicator
- Implemented live recalculation inside booking widget
- Prevented duplication on AJAX reload
- Maintained clean summary structure
4.3 Confirmation Page Stabilization
Rather than rewriting full list elements:
- Targeted price span updates only
- Updated data attributes safely
- Inserted discount row above total
- Preserved markup integrity
4.4 Pay-for-Order Recalculation Engine
WooCommerce and gateway scripts asynchronously re-rendered pricing elements.
To ensure stable behavior:
- Payment method change detection
- Radio state stabilization
- Manual summary refresh trigger
- MutationObserver-based fallback
- Defensive recalculation layer
Resulting behavior:
- Correct totals on first selection
- Immediate gateway fee update
- No visual flicker
- Stable recalculation

4.5 Owner Dashboard Enhancement
- Displayed original and discounted price
- Injected additional row safely
- Protected against AJAX redraw overwrites
5. Implementation Notes
Implementation Notes
- Custom WooCommerce fee manipulation
- Booking meta persistence
- AJAX interception
- MutationObserver-based DOM stabilization
- Multi-endpoint synchronization
- Defensive markup parsing
- Backwards compatibility with Listeo core
6. Outcome
- Fully automated last-minute discount system
- Accurate totals across all booking stages
- Stable recalculation behavior
- Compatible with multiple payment methods
- Production-ready implementation
- No cart dependency
7. Business Impact
- Improved pricing transparency
- Reduced payment confusion
- Clear discount visibility
- Improved booking confidence
- Consistent user experience
The system remains stable in production and continues to operate without cart-based dependencies.