# Zoho CRM Integration - Staging Mode ## Overview The Zoho CRM integration has a built-in staging mode to prevent accidental data synchronization from development or staging environments to the production Zoho CRM database. ## How It Works ### Domain Detection - **Production Domain**: `upskillhvac.com` - **Staging Domains**: All other domains (e.g., `*.cloudwaysapps.com`) ### Staging Mode Behavior When running on any domain other than `upskillhvac.com`: 1. **Read Operations**: Allowed (GET requests) 2. **Write Operations**: Blocked (POST, PUT, DELETE, PATCH requests) 3. **Visual Indicators**: Admin interface shows "STAGING MODE ACTIVE" banner 4. **Sync Simulation**: Shows what data would be synced without actually sending it ### Production Mode When running on `upskillhvac.com`: - All operations are allowed - Data syncs directly to Zoho CRM - No staging mode indicators ## Admin Interface ### Staging Mode Indicators - Blue info banner at the top of the Zoho CRM Sync page - Shows current site URL - Displays "STAGING MODE - Simulation Results" on sync operations ### Test Data Preview In staging mode, sync operations return: - Total records that would be synced - Detailed preview of first 5 records - Field mappings that would be used ## Implementation Details ### Class: `HVAC_Zoho_Sync` ```php private function is_sync_allowed() { $site_url = get_site_url(); return strpos($site_url, 'upskillhvac.com') !== false; } ``` ### Class: `HVAC_Zoho_CRM_Auth` ```php // Blocks write operations in staging mode if ($is_staging && in_array($method, array('POST', 'PUT', 'DELETE', 'PATCH'))) { return [simulated response]; } ``` ## Testing in Staging 1. Access WordPress Admin → HVAC Community Events → Zoho CRM Sync 2. See "STAGING MODE ACTIVE" banner 3. Click sync buttons to see simulated results 4. Review test data in expandable preview sections 5. No actual data is sent to Zoho CRM ## Deploying to Production 1. Deploy code to `upskillhvac.com` 2. Staging mode automatically deactivates 3. Sync operations will write to Zoho CRM 4. Monitor first sync carefully ## Configuration No configuration needed - staging mode is automatic based on domain detection. ## Security Benefits - Prevents test data from polluting production CRM - Allows safe testing of sync logic - No configuration mistakes possible - Clear visual indicators prevent confusion ## Troubleshooting ### Staging Mode Not Activating - Check site URL with `get_site_url()` - Ensure domain doesn't contain "upskillhvac.com" ### Production Sync Not Working - Verify site URL contains "upskillhvac.com" - Check OAuth credentials are configured - Review error logs for API issues