=== blloyddev Customer Sync for Salesforce ===
Contributors: blloyddev
Tags: salesforce, sync, crm, orders, contacts
Requires at least: 6.0
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Automatically syncs the billing customer from each completed order to a Salesforce Contact via OAuth2 — no Zapier or WP Fusion required.

== Description ==

**blloyddev Customer Sync for Salesforce** connects your store directly to Salesforce using the OAuth2 client-credentials flow (Connected App). Every time an order is marked complete, the customer's name, email, and phone are sent to a Salesforce Apex REST endpoint you control.

= What's included (free) =

* Syncs billing customer to Salesforce on order completion
* Sends first name, last name, email address, and phone number
* OAuth2 client-credentials authentication with token caching
* Test-connection button to verify your Salesforce credentials
* Clean uninstall — removes all plugin data on deletion

= Pro version =

The Pro version adds:

* Full order sync — order number, date, total, and line items
* The Events Calendar support — per-ticket attendee names, emails, and linked event data
* Retry queue — failed syncs are automatically retried hourly
* Manual sync by order ID
* Admin notice when orders fail to sync

= Requirements =

* WordPress 6.0+
* WooCommerce 7.0+
* A Salesforce Connected App with OAuth2 client-credentials flow enabled
* An Apex REST endpoint in your org to receive the payload

== Installation ==

1. Upload the `blloyddev-customer-sync-for-salesforce` folder to `/wp-content/plugins/`, or install via **Plugins > Add New**.
2. Activate the plugin.
3. Go to **Settings > Salesforce Sync** and enter your Salesforce Instance URL, Client ID, and Client Secret.
4. Click **Test Salesforce Connection** to verify.

== Frequently Asked Questions ==

= What data is sent to Salesforce? =

The customer's billing first name, last name, email address, and phone number. No order totals, payment details, or line items are sent in the free version.

= What does the payload look like? =

```json
{
  "firstName": "Jane",
  "lastName":  "Smith",
  "email":     "jane@example.com",
  "phone":     "07700900000"
}
```

= How do I set up the Salesforce Connected App? =

1. In Salesforce Setup, go to **App Manager > New Connected App**.
2. Enable **OAuth Settings** and add the `Full access (full)` scope (or more restrictive as needed).
3. Under **OAuth Policies**, enable **Client Credentials Flow** and assign a Run-As user.
4. Copy the Consumer Key (Client ID) and Consumer Secret into the plugin settings.

= What happens if a sync fails? =

The error is written to your server error log when `WP_DEBUG_LOG` is enabled. For automatic retry and an admin UI for failed syncs, upgrade to Pro.

= Does this store sensitive data? =

The Client ID and Client Secret are stored in the WordPress options table. The access token is cached as a transient and expires automatically. All plugin data is removed when the plugin is deleted.

== Changelog ==

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.0.0 =
Initial release.
