=== ElenaTec Bridge ===
Contributors: elenatec
Requires at least: 6.6
Tested up to: 7.1
Requires PHP: 8.1
Requires Plugins: woocommerce
Stable tag: 0.1.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Tags: woocommerce, inventory, integration

An opt-in connection between a WooCommerce store and an ElenaTec account.

== Description ==

Connect a WooCommerce store to a separate ElenaTec account for opt-in catalog
reconciliation and native draft-order workflows. An ElenaTec account and an
applicable service plan are required. Review service availability and pricing
on the service website before enabling a connection.

Service: https://elenatec.com/
Terms: https://elenatec.com/terminos
Privacy: https://elenatec.com/privacidad
Support and privacy requests: https://elenatec.com/soporte-legal

Configure the existing connector in ElenaTec, choose independent catalog,
price, stock and order policies, and review the initial preview. This plugin
uses WooCommerce Action Scheduler to deliver order identifiers and reconcile
catalog pages. New WooCommerce products are created as drafts.

Supported scope: simple products and WooCommerce variations with distinct SKUs,
persistent store-scoped identities, optional product creation/content updates,
exclusive prices in a matching base currency and tax policy, branch-level
available stock, and native wholesale or commercial draft orders.

Each variation maps to an independent sellable ElenaTec Product SKU with its
WooCommerce parent and variation IDs persisted separately. Existing WooCommerce
variation attributes are preserved. Existing grouped ElenaTec ProductVariant
records require explicit migration/review because the native order and stock
ledger cannot currently fulfill those records independently. New WooCommerce
products are simple drafts; variable parent/attribute creation is not automated.

Cancellation and full refunds cancel eligible unpaid, unfulfilled native drafts
idempotently. Partial refunds, physical returns, approved/dispatched orders and
later content changes require the native review/credit-note workflow. No
automatic payment, invoice, refund payment or shipment is performed.

Catalog reconciliation processes 50 items per page, schedules subsequent pages
five seconds apart, and waits 60 seconds after the last page before restarting.
Large catalogs therefore take longer than one minute. Order reconciliation
restarts five minutes after each pass over the previous 24 hours, up to 10,000
orders per pass, with five seconds between pages.
Timing depends on Action Scheduler/WP-Cron and ElenaTec workers. Stock updates
pause while an order delivery remains unacknowledged or ElenaTec reports pending
or conflicting import work. Each successful delivery acknowledges only its own
generation/UUID, including deduplicated retries. Other notifications stay pending.
Reconciliation retries up to 50 identified pending UUIDs per order before queuing
a fresh notification for the current state. Historical failed actions
are retained unchanged and do not by themselves block a recovered order. Old
unattributed draft-version pending markers require manual review and remain
conservatively blocking. Monitor ElenaTec Health; no hard real-time guarantee.
Delivery bookkeeping marks only _elenatec_pending as ephemeral through a private
native HPOS metadata store. It preserves metadata hooks, cache refresh and native
backfill without installing a global save filter. Nested commercial changes on
the same or another order retain their date and normal notifications. Adding or
acknowledging debt alone does not move the business modified timestamp. The
added_order_meta and deleted_order_meta hooks are native WooCommerce metadata
hooks, not plugin-defined hooks; their names and four-argument contracts are
preserved for compatibility.
Saving settings or deactivating invalidates in-flight work. A snapshot from an
older connection cannot be applied under a new connection, and stale workers
cannot release a catalog lock owned by a newer worker. Existing queued actions
without a revision argument remain compatible; new actions carry a settings
revision. An already transmitted request cannot be recalled by disconnecting.
Operator capability metadata and role definitions are refreshed before writes,
and a scoped final guard checks the connection inside WooCommerce's product-save
hook. This does not turn WooCommerce's multiple native database writes into one
cross-request transaction; unrelated plugins remain responsible for their own
hooks and effects.
Catalog conflicts retain up to 100 identifiers per pass in WooCommerce > ElenaTec.
Other products/pages continue; correct identity or tax policy before retrying.
Inactive mapped ElenaTec products are suspended as Woo drafts with zero stock and
backorders disabled, even when ordinary stock writes are paused. Their mappings
and history remain. Reactivation requires an administrator to publish in Woo;
the bridge does not automatically republish them. Unlinked inactive SKUs cannot
deactivate an unrelated Woo product by SKU alone.
An explicit remote ID owned by another local product is rejected before any
content, stock or suspension-marker write, for simple products and variations.

== Installation scope and translations ==

This candidate is qualified on single-site installations only. Multisite,
network activation and network-wide uninstall have not been qualified. The
uninstall routine processes the current site's options and action groups; do
not rely on it to erase connection secrets across every site in a network.

The interface currently ships in English with translatable strings. Spanish
translations and language-pack behavior have not been verified. Some technical
health and conflict codes remain visible as diagnostic codes.

== External service and privacy ==

The plugin contacts ONLY the public HTTPS ElenaTec bridge endpoint entered by
the administrator after explicit enablement. It sends order IDs, event IDs and
catalog pagination offsets. It receives product identifiers, names, SKUs,
barcodes, configured prices and available quantities.

Separately, ElenaTec retrieves WooCommerce order responses with the read-only
WooCommerce REST credentials configured in ElenaTec. Current order requests do
not select a reduced set of response fields. Depending on the WooCommerce REST
response, ElenaTec can receive order identifiers and status, customer identifiers,
line items, quantities, prices, totals, taxes, billing and shipping contact
details, payment-related order fields and order metadata. A read-only key limits
writes; it does not mean that only a small subset of order data is returned.

The current import uses customer first/last name and email, order and customer
identifiers, status, currency, line items, shipping amounts, tax and total data
for native customer/draft-order records, identity matching, validation and
reconciliation. The plugin does not add analytics, tracking or AI transmission.
This connector does not initiate payment or fiscal-document creation.

ElenaTec's public privacy policy describes service processing, retention, rights
requests and exceptions. Local disconnect or uninstall does not delete customer
or draft-order records already imported into ElenaTec. The plugin imposes no
automatic deletion schedule on those native records. Consult the current policy
and contact the service operator for retention or deletion requests. WordPress
backups and Action Scheduler history follow the site's own retention policy.

Review the linked service terms and privacy policy and obtain merchant
permission before connecting a store. The PHP plugin is GPL-2.0-or-later; use of
the separate ElenaTec service is governed by its service terms. Installation and
activation alone do not enable a remote connection or provision credentials.

Secrets are encrypted using AES-256-GCM and WordPress auth salts. Changing salts
requires re-pairing. ELENATEC_BRIDGE_SECRET in wp-config.php can supply the secret
instead. Neither secret is displayed again. Disconnect erases the local secret
and cancels pending plugin actions; disconnect in ElenaTec and revoke the REST
key separately. Product identities and native orders are retained on uninstall.
Backups and Action Scheduler history follow the site's retention policy.

== Installation ==

1. Use a staging site with PHP OpenSSL, WordPress 6.6+ and WooCommerce 9.0+.
2. Install the ZIP using Plugins > Add New > Upload Plugin, then activate.
3. In ElenaTec > Integrations > WooCommerce, configure a public HTTPS shop URL,
   an existing read-only WooCommerce key, branch and policies. Enter a strong
   shared signing secret of at least 32 characters. Save and test.
4. Under WooCommerce > ElenaTec, copy the bridge endpoint, enter the same secret,
   review the external-service disclosure and explicitly enable the connection.
5. Review every initial preview page and run a bounded reconciliation in ElenaTec.
6. Check WooCommerce > Status > Scheduled Actions (group elenatec-bridge) and
   ElenaTec Health. Action groups have an elenatec-bridge- prefix and a connection
   suffix. Use a real cron runner on staging to measure actual latency.

No credentials or webhooks are provisioned automatically by installing the ZIP.

== Frequently Asked Questions ==

= Are ElenaTec and WooCommerce numeric IDs interchangeable? =
No. Products are paired by persisted store identity or an unambiguous exact SKU
or barcode. Conflicting candidates require review.

= Can I choose another currency or tax policy? =
No conversion is performed. Currency, exclusive-price basis and effective tax
rates must match. Differences fail closed for review; tax settings are preserved.

= What about long outages? =
The automatic recovery window is 24 hours. ElenaTec's manual order sync queues
at most the newest 1,000 orders; it is not an arbitrary historical backfill.
Inspect source counts and obtain a reviewed recovery plan for changes beyond
those bounds before resuming. Never treat a bounded pass as a complete history.

== Changelog ==

= 0.1.2 =
Preserve and document native WooCommerce metadata hooks. Fence in-flight work
when settings, consent or credentials change, refresh operator permissions, and
release catalog locks only when still owned. Reject non-text settings input
and bound remote response size. No payment or fiscal-document behavior added.

= 0.1.1 =
Publication review candidate: align name and version metadata, add verified
public service links and clarify the order-response disclosure and retention.
No synchronization or payment behavior is changed.

= 0.1.0 =
Initial draft: signed identifier transport, durable retries, bounded catalog
reconciliation and persistent identities.
