=== Vtryon ===
Contributors: Vtryon
Tags: woocommerce, virtual try-on, fashion, ai, e-commerce
Requires at least: 5.8
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 1.0.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

AI try-on for WooCommerce: sync products with Vtryon, validate photos, show results—all handled server-side.

== Description ==

Vtryon connects your store to the Vtryon service so customers can upload a portrait photo and preview how a product looks on them.

**Key features**

* Dynamic authentication: login and token caching using store credentials (server-side only).
* Automated garment syncing: one-click sync uploads the WooCommerce featured image (JPG/PNG) and stores the Garment ID. **Sync All** on the Products list or on a category edit screen syncs only products still missing a Garment ID, with progress (hover the button for details).
* Download control: optionally hide the **Download result** button on the storefront while keeping the result image and “Try another photo” (WooCommerce → Vtryon → Settings).
* Image validation: multi-step flow checks customer photos against AI quality rules before try-on runs.
* Granular control: storewide on/off for the whole site; optional logged-in-only mode; enable or disable try-on per product category and per product.
* Product page placement: choose where the try-on block appears on single product pages (WooCommerce hooks/priorities), with shortcode support for custom layouts.
* Polished admin and storefront UI with accessible notices (bundled SweetAlert2 on relevant screens).
* Efficient polling for validation and task status to limit unnecessary requests.
* Developer hooks and filters to adjust payloads, limits, and behavior.

**Coming soon**

Planned for future releases:

* Ready-to-use catalog SKU image generation
* Pose generation for the same SKU
* Expanded AI fashion workflows inside WooCommerce

For catalog-ready SKU images or extra poses today, use the Vtryon website or app: https://vtryon.legresca.ai/app

**Frontend flow**

When a product has a Garment ID and try-on is allowed (storewide setting, product/category toggles, and any logged-in-only rule), the try-on block appears on the product page at the placement chosen under WooCommerce → Vtryon → Settings, unless you output it only via the shortcode. The customer uploads a portrait (JPG/PNG), the image is validated, a try-on task runs, and the result is shown; downloading the file is available when **Download result button** is enabled in settings.

**Developer hooks**

*Filters*

* `vtryon_upload_person_payload` — person image upload payload.
* `vtryon_create_task_payload` — task creation JSON.
* `vtryon_max_upload_size` — max upload size (default 5 MB).
* `vtryon_default_garment_type` — garment type (default `stitched`).
* `vtryon_api_base_url` — override API base URL (advanced).
* `vtryon_display_preset_definitions` — register or change product page placement presets (`hook`, `priority`, `label` per preset).
* `vtryon_display_position` — override the resolved hook, priority, and preset slug for the single-product try-on block.
* `vtryon_bulk_sync_max_products` — max products per **Sync All** run (default 2000).

*Actions*

* `vtryon_before_upload_person` — before sending a person image.
* `vtryon_after_create_task` — after a task is created.
* `vtryon_before_download` / `vtryon_after_download` — around result download tracking.

**Requirements**

* WooCommerce (active)
* PHP 7.4+
* A valid Vtryon account (sign up at https://vtryon.legresca.ai/app )

== Installation ==

1. Install from the Plugins screen.
2. Activate the plugin.
3. Install and activate **WooCommerce**.
4. Go to **WooCommerce → Vtryon**. If you do not have an account, sign up at https://vtryon.legresca.ai/app (Create Account), then sign in to Vtryon.
5. Enter the same **Email / Phone** and **Password** you use for Vtryon and save. The plugin tests the connection and shows a status notice.
6. Under **Storewide try-on**, keep **Enable virtual try-on for the entire site** checked unless you want try-on hidden everywhere (category/product settings apply only when this is on).
7. Under **Product page placement**, choose where the try-on block appears on single product pages (default: after add to cart).
8. (Optional) Enable **Visibility** to show the try-on button only to logged-in users.
9. Under **Download result button**, choose whether to show the download control after a try-on completes.
10. For each product: set a JPG or PNG featured image, enable Vtryon on the product, and use **Sync with Vtryon** (product edit screen or **Garment ID** column on the Products list). Use **Sync All** on the Products list (or **Garment sync** on a category) to batch-sync only products missing a Garment ID.

== Frequently Asked Questions ==

= Does this require WooCommerce? =

Yes. The plugin checks for WooCommerce and shows an admin notice if it is missing.

= Are API credentials exposed to visitors? =

No. Only the WordPress REST URL and a REST nonce are passed to the browser; login and garment APIs run on the server.

= What image formats are supported? =

Featured images and customer uploads use **JPG** and **PNG** (validated with WordPress file checks).

= Does the plugin load third-party scripts on my store? =

The plugin bundles SweetAlert2 for admin sync feedback and storefront messages. No remote script loads are required for core operation.

= Can I turn off try-on for the whole store or move the try-on block? =

Yes. Use **WooCommerce → Vtryon → Settings**: uncheck **Enable virtual try-on for the entire site** to disable try-on site-wide, and use **Product page placement** to change where the block appears. For a custom position you can also use the `[vtryon]` shortcode (and remove the automatic hook in code if you need only the shortcode).

= Where is the full Markdown documentation? =

The same documentation ships as `README.md` in the plugin folder. It is also shown under **WooCommerce → Vtryon → Help guide** below the quick start section.

== External services ==

This plugin connects to the **Vtryon** service (operated by Legresca) to provide AI virtual try-on functionality.

**What the service is used for**

* Merchant authentication — the store owner's Vtryon credentials are used to obtain a short-lived access token.
* Garment sync — product featured images are uploaded to Vtryon so the AI can dress customers in them.
* Person image upload — when a customer initiates a try-on, their uploaded portrait is sent to Vtryon for processing.
* Person image validation — Vtryon checks the uploaded photo against quality rules (lighting, face detection, pose) before running the try-on.
* Try-on task creation — Vtryon combines the person image and the garment to generate the try-on result.
* Status polling — the plugin queries Vtryon to check when the result is ready.
* Result retrieval — the generated try-on image URL is retrieved from Vtryon and stored privately on the WordPress side; the image is then served to the customer through a WordPress-side proxy, so the raw Vtryon URL is never exposed to the browser.

**What data is sent and when**

* **Merchant credentials** (email / phone and password) are sent to the Vtryon authentication endpoint when the plugin connects or refreshes its access token. Credentials are stored only in the WordPress database and are never sent to the browser.
* **Product images** are sent when the merchant manually syncs a product with Vtryon or uses the Sync All feature. Only the WooCommerce featured image is uploaded.
* **Customer portrait photos** are sent to Vtryon only when a site visitor explicitly initiates a virtual try-on and agrees to the consent notice on the product page. Photos are not stored locally by the plugin.
* **Session / task identifiers** are exchanged between WordPress and the Vtryon API during status polling and result retrieval. These identifiers are kept server-side only and are never passed to the visitor's browser.

**Service provider**

Vtryon

**Privacy Policy:** https://vtryon.legresca.ai/privacy-policy

**Terms of Service:** https://vtryon.legresca.ai/terms

== Changelog ==

= 1.0.0 =

* Initial release on WordPress.org guidelines baseline.

== Upgrade Notice ==

= 1.0.0 =

Initial release.
