We built DEV3 AI Vendor Assistant for Dokan & WCFM as a WordPress plugin in PHP with React screens for the vendor dashboard and the wp-admin app. The assistant appears as an "AI Assistant" page inside the marketplace's own vendor dashboard, in that marketplace's colours.
Key design decisions
- One adapter layer over two marketplaces. An abstract
Adapter answers every marketplace question: who is a vendor, which vendor a staff member works for, who owns a product, which orders contain a vendor's items, where the store bio and SEO fields live and what status a new product gets. Dokan and WCFM each implement it, and the dev3va_marketplace_adapters filter accepts more.
- Ownership checks in one place.
Vendor\Access resolves the acting vendor (staff map to their vendor) and returns a product, photo, order or draft only when it belongs to that vendor. Anything else is a 404, so the IDs of other stores are never confirmed.
- Five gates on every vendor route. Logged in, valid REST nonce, a vendor or staff member, the owner has not switched the assistant off for this store, and the feature is enabled globally or by a per-vendor override. POST requests are also rate limited per user.
- Public data only across stores. Price suggestions compare a product with similar published listings using title, price, rating, review count and store name. Sales and costs are never read. The server keeps the AI's price between 0.5× the lowest and 1.5× the highest comparable.
- Credits and a ledger. Each vendor has monthly credits (listing writer 2, other features 1, adjustable by filter). Every AI call writes a ledger row with tokens and estimated cost, cached answers cost nothing, and a vendor who runs out gets a clear 429 while the basic helpers keep working.
- Drafts and moderation. Every result is a draft the vendor accepts, edits or rejects. AI-written listings can be held as pending for review or flagged, blocked words can warn or block, and the admin can run an AI policy check before approving.
Architecture
The vendor page is registered through Dokan's dashboard nav, query-var and template hooks, or WCFM's menu, endpoint and view hooks, with a shortcode for any other page. The React app calls a dev3va/v1 REST namespace. Listing drafts, price suggestions, buyer replies, store profile and performance tips are separate services, and each one takes the vendor ID from Access instead of the request. The buyer inbox reads product reviews, customer order notes, WCFM inquiries and Dokan Pro support topics, each scoped to the vendor, and writes replies back to the same source. Buyer names are cut to a first name before they reach the screen or the AI. Two custom tables hold drafts and the credit ledger. The API client, settings, usage log and budget cap come from a shared core used across DEV3's plugins.