WP Residence Help WP Residence Help

  • WpEstate
  • WPRESIDENCE
  • Video Tutorials
  • Client Support
  • API
Home / 13. WPResidence / WPEstate CRM / WPResidence CRM Deals — Developer Reference

WPResidence CRM Deals — Developer Reference

9 views 0

Developer documentation for the Deals module in the WPResidence real estate CRM – how the pipeline board is built, the drag-and-drop wire-up, the dual-column schema, and the HubSpot sync.

Storage – wp_wpresidence_crm_deals

Deals live in a 33-column custom table. The schema intentionally mirrors legacy column names alongside new planned names to support the in-progress rename without breaking existing queries.

Dual Column Names

Legacy New
deal_title title
deal_stage stage
deal_status status
deal_probability probability
deal_value amount (for HubSpot)
handler_agent_id assigned_agent_id

Both column sets are populated on write; read code may use either.

Additional Columns

description, private_note, next_action, action_due_date, expected_close_date, stage_changed_at, contact_id, listing_id, hubspot_deal_id, created_at, updated_at.

CRUD API – libs/deal-crud.php

Function Purpose
wpestate_crm_insert_deal($data) Insert; fires wpestate_crm_after_insert_deal
wpestate_crm_get_deal($id) Fetch one
wpestate_crm_get_deals($args) Filters: user_id, status, deal_stage, deal_group, contact_id, lead_id, handler_agent_id, date range, search
wpestate_crm_update_deal($id, $data) Update; fires wpestate_crm_after_update_deal with stage-change detection
wpestate_crm_update_deal_stage($id, $stage) Single-field stage update used by drag-drop
wpestate_crm_delete_deal($id) Delete
wpestate_crm_bulk_delete_deals($ids) Bulk delete
wpestate_crm_get_pipeline_summary() Returns per-stage count and total_value aggregates

Auto-Status Logic

When deal_stage changes, status is recalculated:

closed_won → status = 'won' closed_lost → status = 'lost' anything else → status = 'open'

Pipeline Board UI

Template: page-templates/wpestate-crm-dashboard_deals.php. The board renders one column per stage, read from setting crm_deal_stages. Stage colors come from setting crm_deal_stage_colors (index-matched).

Drag-and-Drop (SortableJS)

SortableJS 1.15.6 is conditionally enqueued on the deals page (see wpestate-crm.php line 59 condition). On drop, JS calls the AJAX action wpestate_crm_update_deal_field:

Property Value
Action wpestate_crm_update_deal_field
Nonce wpestate_crm_update_deal_field
Allowed fields deal_stage, stage, deal_status, next_action, action_due_date, last_contact_date

Other AJAX Endpoints

Action Nonce
wpestate_crm_save_deal wpestate_crm_save_deal
wpestate_crm_delete_deal wpestate_crm_delete_deal
wpestate_crm_get_pipeline wpestate_crm_get_pipeline

Templates

  • page-templates/wpestate-crm-dashboard_deals.php – pipeline board / list toggle.
  • templates/crm_add_deal.php – add/edit form.
  • templates/crm_deal_detail.php – detail page.
  • templates/dashboard_deal_unit.php – single-deal card.

Default Picklists

  • crm_deal_stages – New, Viewing Scheduled, Offer Made, Negotiation, Closed Won, Closed Lost
  • crm_deal_stage_colors – #3498db, #f39c12, #9b59b6, #e67e22, #27ae60, #e74c3c
  • crm_deal_statuses – Open, Won, Lost
  • crm_deal_next_actions – 8 defaults including Call, Email, Meeting, Send Offer
  • crm_deal_probabilities – 10, 25, 50, 75, 90, 100

Hooks

  • wpestate_crm_after_insert_deal – triggers automations (deal_created), webhooks (deal.created), HubSpot sync.
  • wpestate_crm_after_update_deal – detects stage change and fires deal_stage_changed, deal_won, or deal_lost events.

HubSpot Mapping

CRM HubSpot
deal_title / title dealname
deal_value amount
deal_stage Resolved via hubspot_stage_map setting

The HubSpot deal ID is stored on the CRM row as hubspot_deal_id. Contact association uses the HubSpot associations PUT endpoint /crm/v3/objects/deals/{deal_id}/associations/contacts/{contact_id}/deal_to_contact. Full architecture in the HubSpot CRM integration guide.

Pipeline Summary

wpestate_crm_get_pipeline_summary() performs a GROUP BY deal_stage query returning count and SUM(deal_value) per stage. The Stats page consumes this via the stats AJAX endpoint to render the Deals by Pipeline Stage chart.

13. WPResidence / WPEstate CRM

Related Articles

  • WPResidence CRM Security Model — Developer Reference
  • CRM Security and Data Privacy
  • WPResidence CRM Installation and Updates — Developer Reference
  • Installing and Updating the WPResidence CRM

WP Residence Documentation

  • 01. Getting Started
    • How to Get Support
    • Get your buyer license code.
    • Use SSL / https
    • Server / Theme Requirements
  • 02. Installation & Setup
  • 03. Installation FAQ
  • 06. Search & Filtering
    • Advanced Search Display Settings
    • Advanced Search Form
    • Geolocation Search for Half Map
    • Save Search Theme Options
    • Advanced Search Colors
  • 09. Agent, Agency & Developers
  • 08. Property Pages & Layouts
  • 07. Property Lists, Categories & Archive
  • 14. WPResidence Elementor Studio
  • 10. Blog Posts & Blog List
  • 11. Shortcodes
    • Contact Form
    • Featured Agency/Developer
    • Membership Packages
    • Testimonials
    • Google Map with Property Marker
    • Listings per Agent, Agency or Developer
    • Display Categories
    • Agent List
    • Recent Items Slider
    • Recent items
    • List Properties or Articles by ID
    • Featured Agent
    • Featured Article
    • Featured Property
    • Login & Register Form
    • Icon Content Box Shortcode
  • 12. Widgets
  • 04. Theme Options & Global Settings
    • General Settings
    • User Types Settings
    • Appearance
    • Logos & Favicon
    • Header
    • Footer Style and Colors
    • Price & Currency
    • Property Custom Fields
    • Features & Amenities
    • Listing Labels
    • Theme Slider
    • Permalinks
    • Splash Page
    • Social & Contact
    • Map Settings
    • Pin Management
    • How read from file works
    • General Design Settings
    • Custom Colors Settings
    • Header Design & Colors
    • Mobile Menu Colors
    • User Dashboard Colors
    • Print PDF Design
    • Property, Agent, Blog Lists Design Settings
    • Sidebar Widget Design
    • Font management
    • How to add custom CSS
    • Custom Property Card Unit – Beta version
    • Email Management
    • Import & Export theme options
    • reCaptcha settings
    • YELP API Integration
    • iHomefinder Optima Express IDX
    • MEMBERSHIP & PAYMENT Settings
    • Property Submission Page
    • PayPal Setup
    • Stripe Setup
    • Wire Transfer Payment Method
  • 20. Translations & Languages
  • 26. FAQ
  • 10. Pages
  • 11. Header
  • 12. Footer
  • 05. Maps & Location Settings
  • 18. Payments & Monetization
  • Plugins
    • 19. Included Plugins
    • 22. Third Party Plugins – IDX Compatibility
    • 21. Third-Party Plugins – Multi-Language
    • 23. Third party Plugins – Other
  • Technical
    • 24. Technical how to | Custom Code Required
    • 25. Technical: Child Theme

Join Us On

Powered by WP Estate - All Rights Reserved
  • WpEstate
  • WPRESIDENCE
  • Video Tutorials
  • Client Support
  • API