=== TryonX - AI Virtual Try-On for WooCommerce ===
Contributors: wpxero
Donate link: https://wpxero.com
Tags: woocommerce, virtual try-on, ai fashion, clothing store, try before you buy
Requires at least: 5.6
Tested up to: 6.8
Requires PHP: 7.2
Stable tag: 1.2.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

AI virtual try-on for WooCommerce — shoppers see outfits on themselves before checkout. Boost sales, reduce returns, powered by Gemini.

== Description ==

**Turn your WooCommerce store into an AI fitting room.**

TryonX adds a **“Try On”** button to product pages so customers upload a photo and instantly see how your apparel looks on them — powered by **Google Gemini 2.5 Flash Image AI**. No app. No custom theme rebuild. Install, connect your API key, and start offering **virtual try-on for WooCommerce** in minutes.

Shoppers buy with confidence. You sell more. Returns drop. That is the promise of **AI try-on for online fashion** — and TryonX brings it to WordPress stores of every size.

= Why WooCommerce stores install TryonX =

* **Higher conversion** — Customers who visualize a fit are more likely to add to cart.
* **Fewer “will it fit?” doubts** — Answer the #1 question in fashion e-commerce before checkout.
* **Lower return rates** — Better expectations mean fewer size and style surprises.
* **Shareable moments** — Results can be shared on social media; your products get organic reach.
* **Works on mobile** — Most fashion traffic is mobile; TryonX is built mobile-first.
* **Analytics built in** — See which products get the most try-ons and measure engagement.

= Who is this plugin for? =

* **Fashion & apparel** WooCommerce stores (tees, hoodies, dresses, jackets, activewear)
* **Boutiques & DTC brands** that want a premium, interactive product experience
* **Agencies** building modern WooCommerce sites with Elementor, Divi, or block themes
* **Merchants** ready to differentiate with **AI-powered virtual fitting** without enterprise pricing

= Key features =

* **AI virtual try-on** — Photorealistic garment visualization with Google Gemini 2.5 Flash Image
* **One photo, many products** — Session memory: upload once, try your whole catalog category
* **Bulk try-on** — “Try more products” grid suggests similar items customers can test instantly
* **Before / after compare** — Slider and side-by-side views to wow shoppers
* **Add to cart from results** — Close the loop from try-on to purchase in one click
* **Variable products** — Supports variations (size, color) with the correct garment image
* **Per-product controls** — Enable/disable try-on per product + custom flat-lay garment image
* **Shortcode** — `[tryonx]` or `[tryonx product_id="123"]` for landing pages and builders
* **Privacy-ready** — Consent checkbox, rate limits, optional login-only, IP anonymization
* **Analytics dashboard** — Try-on counts, success rate, top products, daily chart, WP dashboard widget
* **Theme-friendly** — Compatible with Hello Elementor, Divi, and stores where `global $product` varies
* **Developer hooks** — Filters and actions for custom integrations

= How virtual try-on works (3 steps) =

1. **Shopper uploads a photo** on your WooCommerce product page (JPEG, PNG, or WebP).
2. **TryonX sends the photo + product image to Gemini AI** and generates a realistic try-on result.
3. **Customer compares, downloads, shares, or adds to cart** — then tries more products without re-uploading.

= Setup in under 5 minutes =

1. Install TryonX and activate WooCommerce.
2. Go to **WooCommerce → Virtual Try-On**.
3. Paste your [Google AI Studio](https://aistudio.google.com/app/api-keys) API key.
4. Select clothing categories (or enable per product).
5. Publish — the **Try On** button appears on eligible products.

= Requirements =

* WordPress 5.6+ and **WooCommerce** (required)
* PHP 7.2+
* Google Gemini API key with access to **gemini-2.5-flash-image** (paid plan required for image generation — see [Google AI Pricing](https://ai.google.dev/pricing))
* Outbound HTTPS from your server to Google’s API
* Product featured image (or custom garment image per product)

**Best for:** Clothing and apparel. Other product types may be supported in future updates.

= Use TryonX anywhere =

* Single product pages (automatic button)
* Custom pages via shortcode: `[tryonx product_id="42"]`
* Category-driven enablement for entire collections
* Optional custom garment photo per SKU for flat-lay or model shots

**Note:** Image generation uses Google’s Gemini API. You control your API key and usage costs. Photos are processed only when a customer clicks Generate.

== External services ==

This plugin connects to **Google’s Gemini AI API** to generate virtual try-on images when a shopper uses the feature.

**What data is sent:**

* The customer’s uploaded photo and the WooCommerce product (garment) image
* Data is sent only when the customer clicks **Generate**
* Images are transmitted over HTTPS (Base64 in the API request)

**API endpoint:** `https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image:generateContent`

**Data handling:**

* Temporary processing files are deleted after use
* Generated try-on images are saved in your WordPress `uploads` folder
* Session photos expire after 24 hours
* Google’s retention policies apply to API requests — see their terms below

**Service provider:** Google LLC

* [Google AI Terms of Service](https://ai.google.dev/terms)
* [Google Privacy Policy](https://policies.google.com/privacy)

== Installation ==

1. Upload the plugin or install from **Plugins → Add New**.
2. Activate **TryonX** and ensure **WooCommerce** is active.
3. Open **WooCommerce → Virtual Try-On**.
4. Enter your Gemini API key from [Google AI Studio](https://aistudio.google.com/app/api-keys).
5. Check the product categories that should show **Try On** (e.g. Clothing, T-Shirts).
6. Visit a product page, upload a test photo, and click **Generate**.

**Pro tip:** Edit any product → **Product data → Virtual Try-On** to force-enable try-on or upload a dedicated garment image for better AI results.

== Frequently Asked Questions ==

= What is the best virtual try-on plugin for WooCommerce? =

TryonX is built specifically for WooCommerce fashion stores. It combines Gemini AI image generation, session-based multi-product try-on, comparison tools, analytics, add-to-cart on results, and per-product controls — without requiring a separate SaaS subscription beyond your Google API usage.

= How do I add virtual try-on to my WooCommerce store? =

Install TryonX, add your Gemini API key under **WooCommerce → Virtual Try-On**, enable your apparel categories, and the **Try On** button appears on product pages. Use `[tryonx]` on any page for custom placement.

= Does TryonX work with Elementor, Divi, and block themes? =

Yes. TryonX hooks into standard WooCommerce product templates and includes theme compatibility helpers for stores where the global product object may be a slug or ID (Hello Elementor, Divi, etc.).

= Is TryonX free? =

The plugin is free to install. Virtual try-on image generation requires a **paid Google Gemini API plan** for the `gemini-2.5-flash-image` model. Review [Google AI Pricing](https://ai.google.dev/pricing) for current rates.

= What products work with AI try-on? =

Clothing and apparel work best: t-shirts, hoodies, dresses, jackets, and similar items with a clear garment image. Enable by category or per product. Upload a custom **garment image** in the product editor for flat-lay or model photos.

= Will this help reduce WooCommerce returns? =

Virtual try-on helps customers set realistic expectations before purchase, which can reduce fit-related returns. Results vary by store, catalog, and customer base — use built-in analytics to track try-on volume and top products.

= Does it work on mobile phones? =

Yes. The try-on modal is fully responsive for mobile, tablet, and desktop — where most fashion shoppers browse.

= Can customers try multiple products with one photo? =

Yes. After the first successful try-on, their photo is saved for 24 hours so they can try other products in the same session or from the **Try More Products** grid without uploading again.

= Is TryonX GDPR-friendly? =

TryonX includes optional photo consent text, session expiry (24 hours), automatic cleanup of old session files, rate limiting, and optional IP anonymization in analytics. You remain responsible for your store’s privacy policy and lawful basis for processing customer photos.

= The Try On button does not show on my product page =

Check that: (1) WooCommerce is active, (2) the product’s category is enabled in plugin settings or the product is set to **Enabled** under Virtual Try-On, (3) the product has a featured or garment image, and (4) you are viewing a single product page.

= Try-on generation failed or timed out =

Confirm your Gemini API key is valid, your plan includes image generation, images are under 5MB (JPEG/PNG/WebP), and your host allows outbound HTTPS. Large images or slow servers may need a longer timeout — contact your host if timeouts persist.

= Can I embed try-on on a landing page? =

Yes. Use the shortcode `[tryonx product_id="123"]` replacing `123` with your product ID, or `[tryonx]` on a product page to use the current product.

== Screenshots ==

1. Try On button on WooCommerce single product page — ready for shoppers
2. AI virtual try-on modal — upload photo and generate with Gemini
3. Photorealistic try-on result with download, share, and add to cart
4. Before and after comparison slider — interactive fit preview
5. Try more products grid — bulk virtual try-on in one session
6. Try-on analytics dashboard — track engagement and top products
7. Admin settings — API key, categories, privacy, and display options

== Changelog ==

#### 1.2.0 [May 15, 2026]
- Added: Per-product try-on settings and custom garment image (WooCommerce product tab)
- Added: `[tryonx]` shortcode for landing pages and custom layouts
- Added: Privacy controls — consent checkbox, rate limiting, login-only mode, IP anonymization
- Added: Add to cart button on try-on results
- Added: Variable product variation selector in the modal
- Added: `TRYONX_Helpers::resolve_product()` and `get_single_product()` for reliable product detection across themes
- Added: `TRYONX_Helpers::upload_file_url()` for correct public file URLs
- Fixed: Fatal error on product pages when themes set `global $product` to a slug string (Elementor, Hello Elementor, Divi, and similar)
- Fixed: Generated try-on result images showing as broken — upload URLs were missing a slash between folder and filename
- Fixed: Session photo thumbnails not loading in the try-on modal
- Fixed: Session-only try-on no longer requires re-uploading user image
- Fixed: Upload directory paths unified (`tryonx-results`, `tryonx-temp`, `tryonx-sessions`)
- Fixed: `$_FILES` sanitization bug that broke image uploads
- Improved: Assets load only on eligible product pages (better performance)
- Improved: Compare view uses customer photo instead of product image
- Improved: Upload path helpers always use trailing slashes; `.htaccess` rules refresh on existing installs
- Improved: WooCommerce missing admin notice

#### 1.1.1 [April 15, 2026]
- Improved: Compatibility with latest WordPress and WooCommerce versions

#### 1.1.0 [March 10, 2025]
- Added: Session management — upload once, try multiple products
- Added: Before/after comparison (slider and side-by-side)
- Added: Analytics dashboard and WooCommerce widget
- Added: Bulk try-on for same-category products
- Added: Social sharing and image download
- Updated: Gemini 2.5 Flash Image model
- Improved: Security, validation, and error handling
- Improved: Mobile-first responsive design
- Note: gemini-2.5-flash-image now requires a paid Google API plan

#### 1.0.1 [December 15, 2024]
- Fixed: Bug fixes and stability improvements

#### 1.0.0 [November 20, 2024]
- Initial release

== Upgrade Notice ==

= 1.2.0 =
Major release: per-product settings, shortcode, privacy controls, variable products, add to cart, and critical fixes for theme compatibility and result image URLs. Generate a new try-on after updating.

= 1.1.1 =
Compatibility with latest WordPress and WooCommerce versions.
