Skip to main content

Rentiva v4.36.0 — Transfer Booking Add-ons

· 4 min read
MaxHandMade
Maintainer

Transfer customers can finally pick add-ons. v4.36.0 extends the existing vehicle_addon post type with a context taxonomy (rental / transfer / both) and three pricing types (per booking / per day / per passenger). When a customer clicks "Add to cart" on a transfer search result, a modal slides up showing the relevant add-ons with a live multiplier-aware total.

Why

Up to v4.35.0, the add-on system was rental-only. The transfer add-to-cart handler had a hard-coded 'selected_addons' => array() placeholder where the rental flow would have carried the customer's selections. That meant zero ancillary revenue on transfers — no child seats, no extra waiting time, no welcome banners, no VIP assistant. Vendors who already had a perfectly good catalogue of add-ons couldn't surface any of it on the transfer side.

v4.36.0 closes that gap without forking the data model. One CPT, one catalogue, one place for the vendor to manage add-ons. The same record can target a rental booking, a transfer, or both.

The data model in one paragraph

vehicle_addon gains an addon_context taxonomy with three default terms — rental, transfer, both — and a _mhm_addon_pricing_type post meta with three enum values — per_booking (flat), per_day (rental days × price), per_passenger (passenger count × price). The pricing types form an (allowed × context) matrix: per_day only makes sense for rental, per_passenger only for transfer, per_booking works in both. A radio metabox on the admin edit screen, a JS-driven dynamic select, and a server-side validator all enforce the same rule.

The transfer modal

When a search result's "Add to cart" button is clicked, a vanilla-JS modal opens with the available transfer add-ons. Required add-ons are pre-checked and locked. Optional ones come with a live total that respects the pricing type:

  • per_booking shows + 50 ₺ (flat).
  • per_passenger shows + 15 ₺ × 3 yolcu = 45 ₺ (live multiplied by the trip's passenger count).

The footer line keeps a running grand total: Vehicle 280 ₺ + add-ons 95 ₺ = 375 ₺. "Cancel" backs out without dispatching anything; "Add to cart" submits the selected IDs alongside the existing vehicle/origin/destination/datetime payload.

If a vendor configured zero transfer-context add-ons, the modal is suppressed entirely — the existing direct-add behaviour kicks in untouched.

Migration that never overwrites

Existing add-on records are auto-assigned to rental context with per_booking pricing on the first init after upgrade. The data lane is gated by an option flag and never overwrites a value the operator has already set. If the flag is manually reset, the migration re-runs idempotently — operator overrides survive.

This is the same schema/data lane separation the codebase has used since v4.27.4: the schema lane (taxonomy register + default term seed) runs every request as a normal WP API call; the data lane (legacy backfill) runs once and stops.

One pricing calculator, both flows

AddonPricingCalculator::calculate( $addon_id, $context ) is the single source of truth. The rental booking total filter, the transfer cart AJAX handler, the admin booking detail page, the WC order item meta — all of them go through this one helper. The context array is shaped {rental_days?, adults?, children?}; rental fills rental_days, transfer fills adults and children, and the calculator picks whichever it needs based on the addon's pricing type.

This is the cheapest insurance against the rental and transfer math drifting apart over time.

Lite limit unchanged

Lite still caps at 4 published add-ons total — combined rental and transfer. The vendor decides how to split the slots. The admin notice copy was updated to make this explicit ("Lite sürümünde en fazla 4 ek hizmet ekleyebilirsiniz (kiralama + transfer ortak)…").

Stats

  • PHPUnit: 864 → 904 (+40 across 7 new test classes)
  • PHPCS: 0 errors
  • Files: 7 new PHP classes, 3 new CSS/JS files, ~10 modified PHP files
  • i18n: all sources English; Turkish translations in mhm-rentiva-tr_TR.po; JS strings localised via wp_localize_script
  • Schema: CURRENT_VERSION 3.6.0 → 3.7.0

What ships next

  • v4.37.0 — Transfer Locations Map View. The deferred per_km pricing type ships here, where its UX value (visualising distance against a haritada) finally has the supporting context.
  • v4.38.0 — Vendor Directory Page (Dokan-style standalone catalogue).
  • v4.39.0 — Vendor Profile Page (unblocks Vehicle Lifecycle Phase 5).