=== Inventory Sync for Leela Cotton ===
Contributors: luumtech
Tags: woocommerce, stock, inventory, ean, barcode
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.2.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Keeps WooCommerce stock in step with the Leela wholesale catalogue, matched on EAN. Published by Luumtech, not by Leela Cotton.

== Description ==

For authorised dealers of Leela Cotton. Connects your WooCommerce shop to the
Leela Partner API so that when an article sells out at Leela, your listing goes
out of stock too, without anyone touching a spreadsheet.

**How it works**

* Matches your products to Leela's catalogue on EAN (barcode).
* Pulls only what changed since the last run, so a sync costs one request when
  nothing has moved.
* Optionally receives push updates over a signed webhook, for changes within
  seconds rather than minutes.
* Writes quantity and stock status; optionally applies a safety buffer so a
  burst of orders on Leela's side cannot make you oversell.

**What is transferred**

Only EAN, SKU, quantity and a timestamp. No prices, no customer data, no orders.

**Requirements**

* An active Leela dealer account and an API key from partners.leela.eco
* WooCommerce 8.0 or newer
* Your products' EANs in the SKU field, or in a GTIN plugin's custom field

== External services ==

This plugin connects to the Leela Partner API, a service operated by Leela
Cotton Naturtextilien Handels GmbH, to read the stock levels it writes into your
shop. It is the only external service the plugin contacts, and the plugin does
nothing without it.

**When it connects**

* When you save your API key, to verify it.
* On each scheduled sync (every 15 minutes by default), and whenever you press
  Sync in the settings screen.
* If you enable the optional webhook, once to register your site's callback URL
  and once to remove it again when you disable it. After that the Leela API
  contacts your site rather than the other way round.

**What is sent**

* Your API key, as an HTTP Authorization header, so the service knows which
  dealer is asking.
* A numeric sync cursor, which is the version number of the last change your
  shop received. It carries no information about your shop beyond how recently
  it synced.
* When registering the webhook only: your site's callback URL, and your site's
  hostname as a label so you can recognise the endpoint in the partner portal.

No product data, customer data, order data or prices are ever sent.

**What is received**

For each changed article: EAN (barcode), SKU, quantity, an in-stock flag, a
timestamp and a version number. Nothing else.

Service: https://partners.leela.eco
Terms: https://partners.leela.eco/imprint
Privacy policy: https://partners.leela.eco/data-policy
Data we share: https://partners.leela.eco/data-policy

== Installation ==

1. Upload the plugin zip under Plugins → Add New → Upload Plugin, then activate.
2. Go to WooCommerce → Inventory Sync for Leela.
3. Paste the API key from partners.leela.eco and save. The connection is tested
   on save.
4. Choose your match field and sync interval.
5. Press "Run full sync" for the first import.

== Screenshots ==

1. The settings screen: connection, EAN matching, stock handling and sync interval.
2. Real-time updates, and the result of the last run: changes received, products updated, barcodes with no match here.
3. Diagnostics and the log: products whose SKU does not look like a barcode, and every run recorded.

== Frequently Asked Questions ==

= Where do I get an API key? =

Sign in at partners.leela.eco with the same account you use to place wholesale
orders, then open API keys.

= Nothing is syncing. =

Almost always an EAN mismatch. The Diagnostics section on the settings screen
lists products whose SKU does not look like a barcode.

= My scheduled syncs are irregular. =

WordPress cron only fires when someone visits your site. On a quiet shop this
drifts. Enable the webhook, or run WP-Cron from a real system cron.

= Does this create products? =

No. It only updates the stock of products that already exist in your shop.

= Does this plugin send anything about my shop to Leela? =

Only your API key and a numeric sync cursor. Not your products, your customers,
your orders or your prices. See the External services section above for the
exact list in both directions.

= Is my API key safe here? =

WordPress stores plugin options in plain text, so anyone with admin access to
your WordPress can read it. Give the key an IP allowlist in the partner portal
so it cannot be used from anywhere but your server, and rotate it when staff
with admin access leave.

== Changelog ==

= 1.2.4 =
* Renamed to "Inventory Sync for Leela Cotton". The installation directory,
  the settings and the registered webhook are unchanged: only the name shown
  in the plugins list and on the settings screen is different.
* The plugin now reports its own version number to the Leela API. It had
  been announcing 1.2.0 since that release, whatever version was actually
  installed. Nothing about syncing changes.

= 1.2.3 =
* Maintenance release.
