=== Contrado Integration for WooCommerce ===
Contributors: contrado
Tags: woocommerce, print-on-demand, contrado, product sync, order sync
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
Requires Plugins: woocommerce
Stable tag: 1.0.4
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Sync Contrado print-on-demand products, collections, and orders with your WooCommerce store.

== Description ==

Contrado Integration for WooCommerce connects your store to the [Contrado](https://www.contrado.com) print-on-demand platform via the Helix API. It keeps your products, stock levels, and order statuses in sync automatically.

* Product range: 470+ print-on-demand products including clothing, homeware, wall art, game mats, and more.
* Worldwide fulfilment: products are made on demand and shipped internationally.
* Automatic shipping profile sync, including quantity-based delivery pricing per destination country.

**Features**

* **Full product sync** — Import your entire Contrado catalogue as WooCommerce variable products, complete with attributes, variations, images, and pricing.
* **Collection sync** — Import products from a single Contrado collection.
* **Order sync** — Import Contrado order live fulfilment status updates.
* **Out-of-stock variation hiding** — OOS variations are removed from the product-page dropdowns in real time so customers can never add unavailable options to their cart.
* **Discontinued product cleanup** — Products no longer in your Contrado catalogue are permanently removed from WooCommerce on a full sync.
* **Webhook support** — Receive real-time push updates from Contrado for stock changes, design modifications, and order status changes.
* **HPOS compatible** — Fully compatible with WooCommerce High-Performance Order Storage.
* **Tabbed admin UI** — A dedicated top-level admin page with Sync and Support tabs, live progress bar, and post-sync statistics (synced / failed / total).

**External Services**

This plugin connects to the **Contrado Helix API** to retrieve product and order data and to submit orders for fulfilment. The API endpoint is configured by the store owner under *WooCommerce → Settings → Integrations → Contrado Integration for WooCommerce*. No data is sent to Contrado without the store owner explicitly configuring their API credentials and triggering a sync.

Please review the Contrado [Privacy Policy](https://www.contrado.com/privacy-cookies) and [Terms of Service](https://www.contrado.com/terms-conditions) before use.

== Installation ==

1. Upload the `contrado-integration-for-woocommerce` folder to your `/wp-content/plugins/` directory, OR install it directly through the WordPress admin by going to *Plugins → Add New → Upload Plugin* (and uploading the `.zip` file).
2. Activate **Contrado Integration for WooCommerce** through *Plugins → Installed Plugins*.
3. Go to **WooCommerce → Settings → Integrations → Contrado Integration for WooCommerce** and enter:
   * **API Base URL** — your Contrado Helix API endpoint (e.g. `https://api.contrado.app/helix/v1`).
   * **API Key** — your Contrado API key (stored encrypted in the database).
4. Click **Test Connection** to verify your credentials.
5. Copy the generated **Webhook URL** and register it in your Contrado account under *API Integration → Webhook*.
6. Navigate to **Contrado** in the WordPress admin sidebar and run your first sync.

== Frequently Asked Questions ==

= Does this plugin work without WooCommerce? =

No. WooCommerce 8.0 or later must be installed and active.

= Which Contrado currencies are supported? =

GBP, USD, EUR, AUD, CAD, NZD, AED, JPY, and SEK. For EUR stores, the site locale determines the exact culture code (de-DE, fr-FR, es-ES, etc.).

= What happens to products removed from Contrado? =

On a full catalogue sync, any WooCommerce product not returned by the Contrado API is permanently deleted. A webhook event (`ProductDiscontinue`) will also remove a product immediately when received.

= Are my API credentials stored securely? =

Yes. The API key is encrypted before being stored in the WordPress database using AES-256 encryption derived from the WordPress security keys.

= Can I sync only some products? =

Yes. Use the **Sync by Collection** card on the admin page to import products from a single Contrado collection.

= Does large catalogues cause timeouts? =

No. Product sync uses WooCommerce's Action Scheduler to process products in background batches, so timeouts are not an issue regardless of catalogue size.

== Screenshots ==

1. The Contrado admin page — Sync tab showing all three sync cards with last-sync statistics.
2. The API settings page — API credentials and webhook URL configuration.

== Changelog ==

= 1.0.4 =
* Fix: updated "Tested up to" to WordPress 7.1.

= 1.0.3 =
* Fix: Plugin URI and Author URI are now distinct as required by WordPress.org guidelines.

= 1.0.2 =
* Fix: removed a duplicate Action Scheduler hook registration that could run order retry submissions twice.
* Fix: removed a dead Action Scheduler hook referencing a non-existent method.
* Fix: all inline `<script>`/`<style>` output replaced with properly enqueued assets (`wp_enqueue_script`/`wp_enqueue_style`).
* Fix: admin notices are now capability- and screen-scoped instead of showing on every wp-admin page.
* Fix: corrected outdated Privacy Policy, Terms of Service, and other contrado.com links.

= 1.0.1 =
* New: expanded shipping profile coverage — every destination country now receives accurate, automatically calculated delivery pricing at checkout.
* New: quantity-based shipping pricing (base cost + per-item increment, capped at a maximum) now applies consistently across every shipping profile/region worldwide.

= 1.0.0 =
* Initial release.
* Full product and variation sync with out-of-stock hiding.
* Order submission and status sync.
* Webhook receiver for real-time stock, design, and order status updates.
* Tabbed admin UI with live progress bar and sync statistics.
* Top-level admin menu with branded icon.
* Discontinued product auto-deletion on full sync.
* HPOS (High-Performance Order Storage) compatibility.

== Upgrade Notice ==

= 1.0.2 =
Bug fixes and WordPress.org compliance fixes (asset enqueuing, admin notice scope, duplicate/dead hooks). Recommended for all users.

= 1.0.1 =
Adds worldwide shipping profile coverage with accurate quantity-based delivery pricing for every country. Recommended for all users.

= 1.0.0 =
Initial release — no upgrade required.
