Skip to main content

Version Docs Updated

React SPA β€” Admin Page (since v4.40.0)

The Vendor Management admin page was migrated to a React SPA in v4.40.0. VendorManagementRestController registers 7 REST routes under /wp-json/mhm-rentiva/v1/vendor-management/*. Components: VendorManagementPage, ApplicationTable, VendorTable, VendorDetailPanel, ActionBar. Data is fetched client-side β€” no full PHP page render.

Purpose

Rentiva can transform from a centralized vehicle rental system into a Multi-Vendor marketplace. This document explains the vendor lifecycle in technical detail.

🀝 Vendor Management

The stages a user must pass through to become a Vendor in the system, and the technical structures behind that process, are summarized below.


πŸ—οΈ 1. Vendor Role & Authorization​

rentiva_vendor Role​

Every approved vendor is assigned this role, which comes with the following capabilities:

  • edit_posts: Can add their own vehicles.
  • upload_files: Can upload vehicle images.
  • read: Can access the vendor dashboard.

πŸ›‘οΈ Ownership Enforcement (VendorOwnershipEnforcer)​

The user_has_cap filter is used to prevent vendors from accessing each other's vehicles or bookings:

  • A vendor can only edit vehicle records where the post_author value matches their own user_id.
  • The "All Vehicles" list in the admin portal is filtered to show only the vendor's own records.

πŸ“‹ 2. Application Management (mhm_vendor_app)​

Vendor applicant data is stored within the mhm_vendor_app Custom Post Type (CPT):

  • Onboarding Flow: Pending β†’ Approved / Rejected.
  • Data Security: IBAN data collected during application is encrypted using VendorApplicationManager::encrypt_iban() with the AES-256-CBC method.
  • Document Tracking: Identity, driver's license, and proof of address documents are associated with the WordPress Media Library under _vendor_doc_* meta keys.

βš™οΈ 3. Operational Controls​

Approval & Meta Synchronization (VendorOnboardingController)​

When an admin approves an application:

  1. Phone, city, and IBAN data from the mhm_vendor_app record are copied to the user's (WP_User) meta tables.
  2. The user's role is upgraded from customer to rentiva_vendor.
  3. The mhm_rentiva_vendor_approved hook is triggered and a welcome email is sent.

Profile Management (VendorProfileExtension)​

The WordPress profile page (wp-admin/profile.php) is extended with vendor-specific fields:

  • Store Information: Bio, tax number, and service areas.
  • Financial Information: Masked IBAN display (e.g., TR***5678).

Vendor Settings Page (v4.23.1)​

The settings page in the vendor dashboard (vendor-settings.php) was completely redesigned in v4.23.1:

  • CSS Architecture: All inline styles removed and moved to vendor-forms.css using the .mhm-vendor-form__* CSS class structure.
  • New Fields: Account Holder and Tax Office fields added.
  • City Selection: Uses the SelectWoo component (CityHelper::render_select()) instead of a text input.
  • Notification System: Success/error notifications standardized using the mhm-vendor-notice class structure.
Technical Note

All form fields on the vendor settings page are styled using BEM-like classes such as .mhm-vendor-form__group, .mhm-vendor-form__label, .mhm-vendor-form__input. Follow the same class structure when adding new fields.


Lifecycle Summary​


🚐 5. Vendor Transfer Location & Route Management (v4.23.0)​

With v4.23.0, vendors can select locations and routes for transfer services:

City-Based Filtering​

On the vendor vehicle submission form ([rentiva_vehicle_submit]), only locations and routes within the city specified in the vendor's application are listed. This is part of the City β†’ Point hierarchy.

Per-Route Pricing​

  • The vendor selects the routes they want to serve.
  • For each route, they enter their own price within the min_price β€” max_price range set by the admin.
  • Capacity details (passengers, luggage) are defined at the vehicle level.

Meta Structure​

  • _mhm_rentiva_transfer_locations: Locations the vendor serves (array)
  • _mhm_rentiva_transfer_routes: Routes the vendor serves (array)
  • _mhm_rentiva_transfer_route_prices: Per-route vendor prices (JSON)

Admin View​

On the vehicle edit screen (VehicleTransferMetaBox), the vendor's city and their selected locations/routes are displayed.


πŸ”„ Vehicle Lifecycle Management (v4.24.0)​

A comprehensive vehicle lifecycle system was implemented in v4.24.0:

FeatureDetail
StatusesActive / Paused / Withdrawn / Expired / Pending Review
Listing period90 days (admin-configurable), renewable by vendor
Cancellation penalty systemGraduated penalty points (2nd withdrawal 10%, 3rd+ 25%)
Reliability score0–100 performance rating
Cooldown period7-day waiting period after withdrawal
Anti-gamingCancelled booking dates blocked for 30 days

Remaining Time Display on Vendor Vehicle Cards (v4.24.1)​

Each vehicle card in the vendor dashboard shows the remaining listing time:

StatusDisplayColor
> 50% time remaining"Remaining: X days"🟒 Green
20%–50% time remaining"Remaining: X days"🟑 Yellow
< 20% time remaining"Remaining: X days"πŸ”΄ Red
Expired"Expired" badgeβ€”

CSS classes: .mhm-vendor-listing-card__remaining with .is-green, .is-yellow, .is-red variants.


πŸ’° Paid Listing System (v4.24.1)​

Vendors may be required to pay via WooCommerce to publish a vehicle listing. This feature can be toggled by the admin.

Admin Settings (Settings β†’ Vendor Marketplace β†’ Listing Fee)​

SettingTypeDefaultDescription
Enable Listing FeeCheckboxOffEnable/disable the paid listing system
Fee ModelSelectOne-Timeone_time or per_period (every 90-day period)
Listing Fee AmountNumber0Fee amount in store currency

Payment Flow​

Trigger Points​

ActionFree FlowPaid Flow
New VehicleForm β†’ Pending ReviewForm β†’ Draft β†’ WC Payment β†’ Pending Review
Renewal (expired)AJAX β†’ Lifecycle renewalAJAX β†’ WC Payment β†’ Lifecycle renewal
Relist (withdrawn)AJAX β†’ Lifecycle relistAJAX β†’ WC Payment β†’ Lifecycle relist

WooCommerce Product​

  • Type: WC_Product_Simple (virtual, hidden)
  • SKU: mhm-rentiva-listing-fee
  • Visibility: Hidden in the store (not shown in shop/search results)
  • Price: Dynamically read from admin settings
  • Cart meta: _mhm_listing_vehicle_id, _mhm_listing_action (new/renew/relist)
  • Auto-creation: Automatically created when the feature is first enabled

Grandfather Rule​

  • Existing active vehicles are not affected when the feature is enabled
  • Renewal payment is required when the 90-day listing period expires
  • No retroactive fees applied

Commission Relationship​

The listing fee and commission are independent of each other:

  • Vendor pays the listing fee (upfront, per listing)
  • Vendor pays commission (percentage, per booking)
  • There is no discount or offset between the two

Technical Class​

ListingFeeManager (src/Admin/Vehicle/ListingFeeManager.php):

  • is_enabled() β€” Checks whether the feature is active
  • requires_payment(string $action) β€” Determines if payment is required for the given action
  • get_or_create_product() β€” Creates or returns the existing WC product
  • add_to_cart(int $vehicle_id, string $action) β€” Adds to cart and returns the payment URL
  • on_order_completed() β€” Publishes the vehicle when the order is completed

Users with the vendor role see a "Vendor Dashboard" menu link in the sidebar on the WooCommerce My Account page. This link redirects to /panel/.

User RoleMenu ItemURL
rentiva_vendorVendor Dashboard/panel/
Other roles (customer, etc.)Become a Vendor/hesabim/vendor-apply/

Technical Details:

  • WooCommerceIntegration::add_menu_items() β€” Menu item is switched based on vendor role check
  • WooCommerceIntegration::vendor_panel_endpoint_url() β€” Redirects the vendor-panel endpoint to the /panel/ page
  • The vendor application URL slug is translatable via the _x() function (SEO-compatible)

πŸ”“ Unsuspend Action (v4.43.0)​

Admins can now unsuspend a vendor directly from the Vendor Management admin page without navigating to the user profile. The unsuspend action:

  • Restores the vendor's rentiva_vendor role (from suspended state).
  • Re-publishes any vehicles that were unpublished at suspension time.
  • Sends a reactivation email to the vendor.
  • Logs the action in the commission audit log.

REST endpoint: POST /wp-json/mhm-rentiva/v1/vendor-management/unsuspend (requires manage_options).


πŸ“‹ Commission Audit Log (v4.43.0)​

Every commission transaction is now written to a persistent audit log, accessible from the Vendor Management detail panel. Each entry records:

FieldDescription
event_typecommission_applied, commission_reversed, vendor_suspended, vendor_unsuspended, penalty_applied, penalty_deferred
vendor_idVendor user ID
booking_idAssociated booking (where applicable)
amountCommission or penalty amount (signed float)
noteAdmin or system-generated note
created_atTimestamp
admin_user_idAdmin who triggered the event (NULL for system events)

The audit log is append-only β€” entries are never deleted or modified. Use it to trace disputes, verify payouts, and audit automated penalty events.

REST endpoint: GET /wp-json/mhm-rentiva/v1/vendor-management/{vendor_id}/audit-log


React Components (v4.40.0+)​

ComponentPurpose
VendorManagementPageRoot β€” tab navigation (Applications / Vendors / Audit)
ApplicationTablePaginated pending application list with approve/reject actions
VendorTableActive vendor list with search and status filter
VendorDetailPanelSlide-in panel: IBAN (masked), documents, audit log, actions
ActionBarSuspend / Unsuspend / Edit quick-action row

REST Namespace: GET/POST /wp-json/mhm-rentiva/v1/vendor-management/*


Known Issues (Discovered in v4.23.1)​

IssueDetailStatus
Vehicle status filter_mhm_vehicle_status is not checked in search queries β€” vehicles in maintenance are visible.Discovered
Vendor suspensionVendorOnboardingController::suspend() does not unpublish vendor vehicles.Discovered

Section Summary​

  • Data isolation is guaranteed by VendorOwnershipEnforcer.
  • All critical application data is stored encrypted.
  • rentiva_vendor capabilities apply only to posts owned by the vendor.
  • Vendors can only access locations and routes in their own city. (v4.23.0)
  • The vendor settings page was redesigned with a BEM-like CSS class structure. (v4.23.1)
  • City selection uses the SelectWoo component across all forms. (v4.23.1)
  • Vehicle lifecycle system (90-day listing, pausing, renewal, withdrawal) implemented. (v4.24.0)
  • Paid listing system: WooCommerce checkout-based payment gate, admin-configurable. (v4.24.1)
  • Remaining time display on vendor vehicle cards (color-coded). (v4.24.1)
  • "Vendor Dashboard" link added for vendors in the WC My Account menu. (v4.24.1)

Changelog​

DateVersionNote
07.05.20264.43.0Unsuspend action (role restore + vehicle re-publish + email). Commission audit log (append-only, 6 event types).
06.05.20264.40.0Full React SPA migration. VendorManagementRestController (7 REST routes). VendorManagementPage, ApplicationTable, VendorTable, VendorDetailPanel, ActionBar components.
23.04.20264.27.2English translation added.
01.04.20264.24.1Paid listing system (ListingFeeManager), remaining time display, WC My Account "Vendor Dashboard" menu link, 18 new tests.
29.03.20264.24.0Vehicle lifecycle system implemented (Phases 0-4, 6-7). Pause, renewal, withdrawal, reliability score.
28.03.20264.23.1Vendor settings page redesign, Account Holder and Tax Office fields, city SelectWoo migration.
26.03.20264.23.0Vendor Transfer Location/Route management, City→Point hierarchy, and per-route pricing added.
19.03.20264.21.2CPT, Enforcer, and Onboarding details added.