=== Express AI - Sipariş Entegrasyonu ===
Contributors: expressai
Tags: woocommerce, expressai, shipping, orders, integration
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.1.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Feeds your WooCommerce orders to Express AI using the Express AI Custom Integration (CUSTOM_API) schema.

== Description ==

This plugin exposes two REST endpoints that Express AI can consume through its "Custom Integration" (CUSTOM_API) integration type:

* `GET /wp-json/express-ai-siparis-entegrasyonu/v1/orders` — the endpoint Express AI uses to fetch orders page by page (supports `page`, `pageSize` and `status` parameters; the response format is `{ page, pageSize, totalCount, hasMore, orders[] }`).
* `POST /wp-json/express-ai-siparis-entegrasyonu/v1/status` — the endpoint Express AI uses to feed back order status, reference code and shipment tracking information. The reference code is stored in order meta (`_expressai_reference_code`).

= Features =

* Three authentication methods: API Key + Secret (X-API-Key / X-API-Secret), Basic Auth, Bearer Token.
* Flexible field mapping: barcode, color (productColor) and size (productSize) values can be read from any product attribute or custom field (meta key) you choose. Unmapped fields are sent as empty strings ("").
* WooCommerce to Express AI status mapping table. Statuses awaiting payment/approval (pending, on-hold, failed) are never sent, as required by the Express AI "Awaiting rule".
* Automatic E.164 phone number normalization (+905XXXXXXXXX) — required by Express AI for non-marketplace orders.
* Optional WooCommerce order status updates and order notes driven by the Express AI status feed.
* Shipment tracking view: the tracking number and tracking link received through the status feed are shown in an "Express AI Shipment Tracking" box on the order edit screen and in an "Express AI Tracking" column on the orders list.
* Compatible with WooCommerce HPOS (High-Performance Order Storage).

= Setup in the Express AI panel =

1. Sign in to your account at https://expressai.com.tr.
2. Go to Integrations, create a New Integration and choose the "Custom Integration" (CUSTOM_API) type.
3. Enter `https://yoursite.com/wp-json/express-ai-siparis-entegrasyonu/v1/orders` as the Order API URL and `https://yoursite.com/wp-json/express-ai-siparis-entegrasyonu/v1/status` as the Status Feed API URL.
4. Enter the same authentication method and credentials configured on the plugin settings page (WooCommerce → Express AI Entegrasyon) into the Express AI panel.
5. Use "Verify" to test the connection; your orders will start flowing automatically.

== Installation ==

1. Upload the plugin folder to the `/wp-content/plugins/` directory.
2. Activate the plugin through the WordPress admin panel (WooCommerce must be installed).
3. Configure the settings under WooCommerce → Express AI Entegrasyon.

== Frequently Asked Questions ==

= Basic Auth / Bearer Token does not work =

Some Apache/CGI servers do not pass the `Authorization` header to PHP. Add `SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1` to your `.htaccess` file, or use the API Key + Secret method instead.

= Which orders are sent? =

Only orders whose WooCommerce status is mapped to an Express AI status in the settings mapping table. Orders awaiting payment or approval are never sent under any circumstances.

== External services ==

This plugin does not send any outgoing requests and does not transmit data to any third-party service. It only exposes two REST endpoints on your site (`/wp-json/express-ai-siparis-entegrasyonu/v1/orders` and `/wp-json/express-ai-siparis-entegrasyonu/v1/status`); the Express AI system connects to these endpoints using the credentials you define in the plugin settings. The data flow is entirely controlled by the Express AI integration configuration that you set up yourself.

About the Express AI service: [Privacy Policy](https://expressai.com.tr/gizlilik-politikasi)

== Changelog ==

= 1.1.2 =
* Order status badge CSS is now enqueued via wp_enqueue_style instead of an inline style tag.
* REST requests are rejected when Basic Auth credentials are not configured (security hardening).
* REST namespace renamed to express-ai-siparis-entegrasyonu/v1 (update your Express AI panel URLs).

= 1.1.1 =
* Text domain aligned with the plugin slug (express-ai-siparis-entegrasyonu) — WordPress.org directory requirement.
* readme rewritten in English; added "External services" statement.
* Tested with WordPress 7.0.

= 1.1.0 =
* Added Express AI specific WooCommerce order statuses: Picking, Invoiced, At Delivery Point, Package Damaged, Could Not Be Supplied (Express AI).
* The status feed map now covers all 11 Express AI statuses; UnDelivered is mapped to "Failed" by default.
* "Automatically update WooCommerce order status" is now enabled by default on new installations.
* Missing/empty status mappings are filled automatically on upgrade (existing non-empty mappings are not touched).

= 1.0.0 =
* Initial release.
