The challenge
A short-term rental marketplace needed a reliable way to offer last-minute discounts during quieter booking windows. The site was built on WordPress using Listeo and WooCommerce, but the booking flow did not behave like a standard cart checkout. Pricing was injected dynamically, parts of the interface were refreshed with AJAX, and totals changed again depending on the selected payment method.
That meant the discount could not be treated as a simple front-end label or a one-off price adjustment. It had to work consistently across the full booking process, including the booking widget, confirmation page, pay-for-order step, and owner dashboard.
What needed to work
The system had to detect when a booking qualified for a last-minute offer, apply the discount at the correct stage, store the relevant pricing data, and keep everything in sync as the user moved through the booking flow. It also needed to stay compatible with different payment methods, including card payments with a 3.6% processing fee and bank transfer with no added fee.
Because the platform relied heavily on asynchronous updates, the solution also had to survive DOM redraws, AJAX refreshes, and repeated price recalculations without creating duplicates, broken totals, or confusing visual jumps.
My approach
I developed a custom production-ready plugin to handle the logic behind the discount system. Its job was to detect eligible bookings, calculate the discount, store pricing metadata, integrate with WooCommerce fee handling, and keep the final totals accurate across the whole process.
On the listing page, I added live discount visibility inside the booking widget and made sure recalculation remained stable even when AJAX refreshed parts of the interface. On the confirmation page, instead of trying to rebuild entire blocks of markup, I updated only the pieces that needed to change. That kept the output cleaner and reduced the chance of conflicts.
The most delicate part was the pay-for-order stage, where WooCommerce and payment gateway scripts could re-render pricing elements after the page had already loaded. To make that reliable, I added a defensive recalculation layer that responded to payment method changes, refreshed the summary when needed, and used MutationObserver-based fallback logic to keep totals correct without visible flicker.
I also extended the owner dashboard so it could show both the original and discounted price clearly, rather than leaving owners with incomplete information.
Technical notes
This project involved more than adding discount logic. It required careful coordination between backend pricing rules, WooCommerce fee manipulation, metadata storage, AJAX-driven updates, and front-end presentation across multiple endpoints. It also had to remain compatible with Listeo’s booking flow rather than forcing everything into a cart-based structure.
In practice, the work included custom plugin development, booking metadata persistence, price synchronization, gateway-aware recalculation, DOM stabilization, and backwards-compatible handling of Listeo’s existing behavior.
Outcome
The final result was a fully automated last-minute discount system that stayed accurate throughout the full booking journey. Discounts were reflected correctly at each step, payment method fees were recalculated properly, and the experience remained stable even inside a complex AJAX-driven environment.
From a business point of view, the system made pricing clearer, reduced confusion around totals, and improved confidence during checkout. Most importantly, it solved the problem in a way that was dependable in production rather than fragile in demos.