=== Luumtech Inventory Sync for Leela ===
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.2
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.

**Please note:** this plugin is published and maintained by Luumtech. It is not
an official Leela Cotton product and it is not endorsed by Leela Cotton
Naturtextilien Handels GmbH. "Leela" appears in the name only to identify the
wholesale service the plugin connects to. See Trademarks below.

**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

== Trademarks ==

Leela and Leela Cotton are trademarks of Leela Cotton Naturtextilien Handels
GmbH, Georg-Wulf-Str. 15, 28199 Bremen, Germany.

This plugin is published and maintained by Luumtech (https://luumtech.com). It
is an independent integration, not an official Leela Cotton product, and Leela
Cotton Naturtextilien Handels GmbH is not responsible for it. The trademark is
used descriptively, to say which wholesale service the plugin talks to, and no
affiliation or endorsement is implied.

WooCommerce and WordPress are trademarks of Automattic Inc. and the WordPress
Foundation respectively, and are likewise used here only to say which platform
this plugin runs on.

Support for this plugin goes to Luumtech, not to Leela Cotton. Questions about a
dealer account or an API key go to the partner portal at partners.leela.eco.

== 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.2 =
* 1.2.1 shipped with a source image that had been left in the project folder and
  should never have been committed. Removed, and the project now ignores that
  file type so it cannot happen again. No code changed.

= 1.2.1 =
* The 1.2.0 package carried the banner, icon and screenshots inside it. The
  directory serves those from its own location, so they were 1 MB of dead weight
  on a 67 KB plugin, downloaded again on every update. They are no longer
  shipped. No code changed.

= 1.2.0 =
* Renamed to "Luumtech Inventory Sync for Leela". The previous name led with a
  trademark Luumtech does not own, which made an independent integration look
  like an official Leela Cotton product. The plugin, its author and its
  behaviour are unchanged.
* Added an explicit trademark and non-affiliation statement to the readme, the
  plugin header and the settings screen.
* Your API key, match settings and sync cursor carry over untouched: they are
  stored under keys this rename did not alter.
* The rename changes the plugin folder, so this version installs beside the old
  copy rather than over it. If both end up active, this one now stands down with
  a notice instead of fataling on duplicate class names. Deactivate and delete
  the old "Leela Partner" copy.

= 1.1.1 =
* Admin notices after saving now travel in a per-user transient instead of the
  URL. Anyone could previously hand an administrator a link that displayed an
  arbitrary notice in their own admin, worded as though this plugin had said it.
* Removed the manual translation loading and the Domain Path header, which
  WordPress has handled by itself since 4.6 for plugins hosted on WordPress.org.
* Sanitised the safety buffer field explicitly rather than relying on the cast,
  and documented every direct database call against the plugin's own log table.

= 1.1.0 =
* Renamed from Leela Stock Sync to Leela Partner. Your settings, API key and
  sync cursor are carried over untouched.
* Documented every request the plugin makes to the Leela Partner API, and the
  data it carries in each direction.
* Tested against WordPress 7.0 and WooCommerce 11.0.

= 1.0.1 =
* A rejected key now names the server that rejected it. "Invalid API key" is
  true of the server being asked and misleading about the key, which is usually
  correct and simply being offered to a staging or local endpoint.
* The settings screen shows the API endpoint whenever it is not the live portal,
  so a site pointed elsewhere says so instead of failing silently.

= 1.0.0 =
* Initial release.
