=== Dark Obsidian Connector ===
Contributors: darkobsidian
Tags: woocommerce, sync, inventory, orders, business management
Requires at least: 6.0
Tested up to: 6.8
Requires PHP: 8.1
Stable tag: 1.0.7
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Connect your WooCommerce store to Dark Obsidian Business OS and sync products, orders, and customers automatically.

== Description ==

Dark Obsidian Connector links your WooCommerce store to [Dark Obsidian Business OS](https://darkobsedian.sameergul.com), a complete business management platform for retail, wholesale, and service businesses.

**What syncs:**

* **Products** — catalog, prices, stock levels, and images
* **Orders** — imported as sales records with full line-item detail
* **Customers** — synced to the Dark Obsidian CRM module
* **Inventory** — real-time stock updates via WooCommerce webhooks
* **Analytics** — revenue trends and business intelligence

**One-click connection. No API keys to copy.**

Click "Connect to Dark Obsidian" in your WordPress admin, sign in to your Dark Obsidian account, choose which business to link, and the connection is established automatically. Credentials are provisioned server-to-server and never stored in WordPress.

**Real-time webhook updates:**

New orders, product changes, and customer registrations in WooCommerce are pushed to Dark Obsidian instantly via WooCommerce's native webhook system.

**Requirements:**

* WordPress 6.0 or higher
* WooCommerce 7.0 or higher
* PHP 8.1 or higher
* HTTPS on your WordPress site
* A Dark Obsidian Business OS account (free trial available at darkobsedian.sameergul.com)

== Installation ==

1. Go to **WordPress Admin → Plugins → Add New → Upload Plugin**
2. Upload the `dark-obsidian-connector.zip` file and click **Install Now**
3. Click **Activate Plugin**
4. Ensure WooCommerce is installed and active
5. Go to **WordPress Admin → Dark Obsidian** (appears in the left menu)
6. Click **Connect to Dark Obsidian →**
7. A secure popup opens — sign in to your Dark Obsidian account and follow the prompts

No API keys or technical configuration are required. The entire setup takes under two minutes.

== Frequently Asked Questions ==

= Do I need a Dark Obsidian account? =

Yes. This plugin is the bridge between your WooCommerce store and Dark Obsidian Business OS. You will need an active account at [darkobsedian.sameergul.com](https://darkobsedian.sameergul.com) to connect.

= Is the connection secure? =

Yes. The initial handshake uses a one-time HMAC-signed nonce with a 15-minute TTL. All subsequent server-to-server calls (from Dark Obsidian to your WordPress site) are verified with HMAC-SHA256 signatures. Credentials are delivered over TLS and never stored in your WordPress database.

= What data is synced? =

Products (name, SKU, price, stock quantity, images), orders (status, totals, line items, customer), and customers (name, email, phone). Only published products are synced. Orders are synced regardless of status.

= Will this slow down my website? =

No. The plugin has zero front-end footprint — it only loads in the WordPress admin and responds to webhook calls. There are no queries on public page loads.

= Can I disconnect at any time? =

Yes. Click **Disconnect** on the Dark Obsidian admin page. This immediately removes the WooCommerce API key and all registered webhooks from your site. Your existing data in Dark Obsidian is not deleted — only the live sync stops.

= What WooCommerce version is required? =

WooCommerce 7.0 or higher. The plugin declares High-Performance Order Storage (HPOS) compatibility and has been tested through WooCommerce 9.x.

= Can I reconnect after disconnecting? =

Yes. Click "Connect to Dark Obsidian →" again. A new API key and webhook set will be provisioned automatically, and your previous sync history in Dark Obsidian will be preserved.

= Is the plugin compatible with multisite? =

The plugin is designed for single-site installs. Multisite compatibility has not been tested.

== Screenshots ==

1. Disconnected state — pre-flight checklist, feature overview, and one-click connect button.
2. Connected state — linked business name, WordPress and WooCommerce version badges, live sync statistics, and management controls.

== Changelog ==

= 1.0.7 =
* Fixed: webhooks were delivered to a URL that was never served, so every product/order/customer change WooCommerce reported was discarded. They now reach Dark Obsidian, and changes appear in the app within seconds instead of on the next polling round.

= 1.0.6 =
* Fixed: the WooCommerce API key was never actually saved. The insert named an `ip` column that does not exist and `nonce` instead of `nonces`, so MySQL rejected it — silently, because the result was never checked. The connection looked successful but every request was rejected as anonymous ("Sorry, you are not allowed to..."). Key creation now fails loudly instead of handing out credentials that were never stored.

= 1.0.5 =
* Added: connection diagnostics to the status endpoint (whether the Authorization header survives to PHP, and whether the API key's user can edit products) so REST auth failures name their cause.

= 1.0.4 =
* Fixed: HTTPS detection behind a proxy now keys off the site's own configured scheme instead of a forwarded header, since hosts disagree on which header they send (or send none).

= 1.0.3 =
* Fixed: WooCommerce REST calls were rejected with "Sorry, you are not allowed to..." on hosts that terminate TLS at a proxy/CDN (Cloudflare, LiteSpeed, most managed hosting). PHP never saw HTTPS, so WooCommerce ignored the API key and demanded OAuth 1.0a instead. Now normalised for REST requests only.
* Fixed: the generated API key could be attached to user ID 1 even when that user is not an administrator, leaving the key without permission to read or write.

= 1.0.2 =
* Fixed: "Plugin URI" (the clickable plugin name in your Plugins list) pointed at a dead link — now points to the plugin's info page.
* Fixed: activation redirect now lands on the plugin's own getting-started page instead of trying to redirect straight to an external domain, which some hosts' security plugins/WAF can silently block.

= 1.0.1 =
* Fixed: connect flow now goes through a proper static consent page instead of a dead link.
* Fixed: activation now redirects straight into the Dark Obsidian sign-in flow (previously a JS popup, silently blocked by most browsers).
* Fixed: admin dashboard text/data was invisible against WordPress's light admin background.
* Fixed: "Last sync" now reflects a real sync time; removed a stat that could never show real data.

= 1.0.0 =
* Initial release.
* One-click connection via Dark Obsidian secure connect portal.
* Automatic WooCommerce REST API key provisioning (read/write, generated server-side).
* Webhook registration for seven event topics: product.created, product.updated, product.deleted, order.created, order.updated, customer.created, customer.updated.
* Admin dashboard with sync statistics (products, orders, customers, last sync time).
* Clean disconnect flow: removes API key and all webhooks, clears plugin options.
* WooCommerce High-Performance Order Storage (HPOS) compatibility declared.

== Upgrade Notice ==

= 1.0.0 =
Initial release — no upgrade steps required.
