=== ecomdir Connect ===
Contributors: dukman
Tags: woocommerce, orders, packing, fulfillment, saas
Requires at least: 5.6
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.4.6
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Connect your WooCommerce store to ecomdir for order management, automatic packer assignment, and packer lock.

== Description ==

**ecomdir** is a SaaS order management platform for online stores.

This plugin connects your WooCommerce store to ecomdir so you can manage orders, packers, automatic distribution, AWB generation, and reports from a single dashboard.

= Features =

* One-click connection to ecomdir (auto-creates an Application Password for the WP REST API)
* Custom REST API endpoint `/wp-json/ecomdir/v1/` exposing your orders in a unified format
* Receives packer assignments from ecomdir and stores them on each order
* Prevents changing the packer after the order is confirmed in ecomdir (configurable owner override)
* Displays packer status (name + confirmation time) on the order edit page

All order management (packer list, distribution algorithm, reports, penalties, AWB generation) is done from the ecomdir platform.

== External services ==

This plugin connects to **ecomdir.com**, a third-party SaaS service, in two ways:

1. **One-time connection**: When you click "Save" on the settings page, the plugin sends your ecomdir email and password (plus the generated WordPress Application Password and your store URL) to `https://ecomdir.com/api/connect.php`. This is required to register your store with ecomdir.
   * Data sent: ecomdir email, ecomdir password (used once, not stored), WP Application Password (generated for the API user named "ecomdir"), store URL, platform identifier ("woocommerce").
   * The ecomdir password is **never stored** in the WordPress database — it is cleared from `wp_options` after a successful connection.

2. **Ongoing order sync**: After the connection is established, the ecomdir platform calls your WordPress REST API (`/wp-json/ecomdir/v1/orders`) using Basic Auth with the Application Password. This is a standard WordPress authentication mechanism.

* ecomdir privacy policy: https://ecomdir.com/legal.php?doc=privacy
* ecomdir terms of service: https://ecomdir.com/legal.php?doc=terms
* ecomdir service URL: https://ecomdir.com

By installing this plugin, you agree to send the data listed above to ecomdir.com.

== Installation ==

1. Upload the `ecomdir-connect` folder to `/wp-content/plugins/` or install via Plugins → Add New → Upload Plugin.
2. Activate the plugin from the Plugins menu.
3. Go to **Settings → ecomdir**.
4. Enter your ecomdir email and password.
5. Click Save — done!

After saving, the plugin will:

* Create a WordPress Application Password named "ecomdir" for the current admin user.
* Send the connection payload to `https://ecomdir.com/api/connect.php`.
* Display the connection status on the settings page.

== Frequently Asked Questions ==

= Do I need an ecomdir account? =

Yes. Register for free at https://ecomdir.com — 30 days trial included.

= Is my ecomdir password stored in the database? =

No. The password is used only for the initial connection handshake and immediately cleared from `wp_options` after a successful response from ecomdir.

= What data does ecomdir read from my store? =

After the connection is established, ecomdir reads orders (ID, status, total, customer email, phone, shipping address, line items) through the standard WordPress REST API. It only writes back two pieces of information: the packer assignment (`issuer_id`) and the confirmation timestamp (`packer_viewed_at`), stored as order meta.

= What happens if I uninstall the plugin? =

The Application Password is deleted, the local options are removed, and the WordPress REST endpoints become unavailable. Order history in ecomdir is preserved.

= Does the plugin work with HPOS (High-Performance Order Storage)? =

Yes. The meta box and order updates use the modern `WC_Order` API and are compatible with HPOS.

== Translations ==

* English (default)
* Romanian (included in `/languages/`)

Help translate at https://translate.wordpress.org/projects/wp-plugins/ecomdir-connect/

== Screenshots ==

1. Settings page — connect to ecomdir.
2. Order edit page — packer status meta box.

== Changelog ==

= 1.4.6 =
* Password sanitize callback no longer trims the value (preserves the raw scalar to keep valid passwords intact).

= 1.4.5 =
* Updated privacy/terms URLs in the readme and admin UI to point to the live pages.
* Updated contributors list.

= 1.4.4 =
* Added translators comments to all `sprintf()` strings with placeholders.
* Replaced `date()` with `gmdate()` in REST API filters (avoids timezone issues).
* Prefixed all global variables in `uninstall.php` with `ecomdir_`.
* Added nonce verification before reading `$_POST` data in the packer-lock hook.
* Removed manual `load_plugin_textdomain()` call (WordPress.org loads it automatically).

= 1.4.3 =
* Updated "Tested up to" header to WordPress 7.0.

= 1.4.2 =
* Added sanitization callbacks on all `register_setting()` calls (`ecomdir_password`, `ecomdir_lock_enabled`).
* Renamed plugin to "ecomdir Connect" so the header name, readme title, slug (`ecomdir-connect`), and text domain all match.
* Updated "Tested up to" header to WordPress 6.8.

= 1.4.1 =
* Removed Plugin URI (WordPress.org review compliance: Plugin URI and Author URI must differ).

= 1.4 =
* Required consent checkbox before sending data to ecomdir.com (WordPress.org compliance).
* Connection only happens after the user explicitly opts in.

= 1.3 =
* Show packer name (instead of just ID) in the order meta box.
* Plugin saves `_ecomdir_packer_name` meta when ecomdir sends the assignment.

= 1.2 =
* New REST endpoints: `/products/{id}` and `/products` for product details and search.
* Product image, SKU, price, and stock returned in a unified format.

= 1.1 =
* New custom REST namespace `/wp-json/ecomdir/v1/` exposing orders in a unified format.
* GET/PUT endpoints for orders.
* `/test` endpoint for connection verification.

= 1.0 =
* Initial release.

== Upgrade Notice ==

= 1.3 =
Packer name is now visible in the order meta box. After upgrade, new assignments will include the name; existing orders keep showing the ID until the next assignment.
