=== WEARFITS Shoes Tryon ===
Contributors: wearfits
Tags: woocommerce, ar, virtual try-on, shoes, 3d
Requires at least: 6.2
Tested up to: 6.9.4
Requires PHP: 8.0
Stable tag: 0.2.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Virtual Try-On button for WooCommerce shoe products, powered by WEARFITS AR.

== Description ==

WEARFITS Shoe Try-On is a free plugin that lets your WooCommerce/WordPress shop offer augmented-reality try-on for shoes, straight from the single product page.

* Adds a **Virtual Try-On** button to each eligible shoe product.
* On desktop, clicking the button opens a modal with a QR code — customers scan it with their phone to enter AR.
* On mobile, the button opens the WEARFITS AR viewer directly.
* In **Product Data → WEARFITS Try-On**, set a try-on URL manually or click **Digitize with WEARFITS** to generate one automatically from the product's gallery images.
* Automatic digitization uses the WEARFITS API (api.wearfits.com). Jobs run asynchronously; the viewer URL lands on the product when processing finishes.

WEARFITS is a virtual try-on platform for clothing and footwear. For shoes, it can automatically turn your product photos into 3D models and AR try-on links — no manual modeling required. Learn more at [wearfits.com](https://wearfits.com), or sign up for an API key at [dash.wearfits.com](https://dash.wearfits.com).

**About licensing:** Only this WordPress plugin is open source under GPLv2-or-later — you may redistribute and modify the plugin code freely, subject to GPL terms (including attribution). The WEARFITS service (api.wearfits.com, dash.wearfits.com, the AR viewer, and the underlying 3D pipeline) is a separate commercial product of Wearfits sp. z o.o.; "WEARFITS" is a trademark of Wearfits sp. z o.o. and is not licensed under GPL.

== Installation ==

1. Upload the plugin zip via **Plugins → Add New → Upload Plugin**, then **Install Now** and **Activate**.
2. Open **WooCommerce → WEARFITS Try-On** and paste your API key (available at [dash.wearfits.com](https://dash.wearfits.com)). If you prefer, define `WEARFITS_SHOES_TRYON_API_KEY` in `wp-config.php` instead.
3. Edit a product in the *Shoes* (or similar footwear) category, open the **Product Data → WEARFITS Try-On** tab, and either paste a try-on URL manually or click **Digitize with WEARFITS** to generate one from the product's images.
4. The button appears on the product page as soon as a valid try-on URL is stored.

== Frequently Asked Questions ==

= Does the plugin send my product images anywhere? =

Only when you click **Digitize with WEARFITS**. In that case, the plugin submits the product's gallery image URLs to `api.wearfits.com/api/v1/shoe-3d`, which generates a 3D model and returns a try-on viewer URL. No data is sent during normal browsing or product editing.

= Which products are eligible for automatic digitization? =

By default, any product in a category whose slug or name contains *shoe*, *footwear*, *buty*, or *obuwie*. Override the rule via the `wearfits_shoes_tryon_is_eligible_product` filter if your shop uses different taxonomy.

= Can I use the plugin without the WEARFITS API? =

Yes. Leave the API key empty and paste a try-on URL manually per product (Stage 1 flow). The storefront button behaves the same either way.

= What happens if a digitization job fails? =

The plugin shows the failure reason reported by WEARFITS directly on the product edit screen and leaves any existing manual try-on URL untouched. You can click **Retry digitization** to submit another job.

== Requirements ==

* WooCommerce 8.0 or later.
* WordPress 6.2 or later.
* PHP 8.0 or later.

== External services ==

This plugin connects to the WEARFITS API to turn your product photos into 3D models and AR try-on links. WEARFITS is a third-party service operated by Wearfits sp. z o.o. — you need a WEARFITS account (free at [dash.wearfits.com](https://dash.wearfits.com)) to obtain the API key used by this plugin.

**When the plugin sends data, what it sends, and why**

* On every click of the **Digitize with WEARFITS** button in the product editor, the plugin sends a POST request to `https://api.wearfits.com/api/v1/shoe-3d`. The request body contains the public URLs of that product's gallery images so that WEARFITS can generate a 3D model and return a try-on viewer URL.
* The plugin then periodically polls `https://api.wearfits.com/api/v1/jobs/{jobId}` (GET) to check the job's progress until it completes.
* No customer data (no names, emails, orders, IP addresses) is ever sent.
* The plugin does **not** make any outbound request without the merchant explicitly clicking Digitize.

**Terms and privacy**

* WEARFITS Terms of Service: [https://wearfits.com/terms](https://wearfits.com/terms)
* WEARFITS Privacy Policy: [https://wearfits.com/privacy](https://wearfits.com/privacy)

By using the automatic digitization feature you agree to let WEARFITS process your product images for the purpose of generating 3D models and viewer URLs. You can stop using the feature at any time by not clicking Digitize — the plugin will not contact WEARFITS.

== Privacy ==

The plugin stores the following in your WordPress database:

* `wearfits_shoes_tryon_api_key` option — your WEARFITS API key (required for the Digitize feature; can be provided via the `WEARFITS_SHOES_TRYON_API_KEY` PHP constant instead to keep it out of the database).
* Per-product meta `_wearfits_tryon_url`, `_wearfits_tryon_enabled`, `_wearfits_job_*` — the viewer URL and digitization job state for each product.

The plugin does not set cookies and does not collect analytics.

== Developer hooks ==

* `wearfits_shoes_tryon_is_eligible_product` (filter, bool) — override the default category-based eligibility check.
* `wearfits_shoes_tryon_image_urls` (filter, string[]) — override the image URL list sent to the WEARFITS API (e.g. for shops on a non-public media CDN).
* `wearfits_shoes_tryon_should_render` (filter, bool) — control whether the Virtual Try-On button renders on a given product.
* `wearfits_shoes_tryon_button_html` (filter, string) — replace the button markup. Output is sanitized with `wp_kses`.

== Source code ==

The plugin ships with its full source, not just compiled assets. Inside the plugin folder:

* `src/tryon-modal/` — JavaScript + SCSS source for the storefront QR modal.
* `build/` — compiled output generated by `npm run build` (Webpack via @wordpress/scripts).
* `package.json` + `webpack.config.js` — build tools.
* `bin/build-release-zip.sh` — produces a shippable zip.

To rebuild the assets from source:

```
cd wp-content/plugins/wearfits-shoes-tryon
npm install
npm run build
```

Node 18+ is recommended.

== Support ==

Need help? Contact the WEARFITS team at [wearfits.com/contact](https://wearfits.com/contact).

== Changelog ==

= 0.2.4 =
* Bumped `Tested up to: 6.9` to `Tested up to: 6.9.4` and `WC tested up to: 9.4` to `10.7` so the Woo Marketplace Validation Test accepts the headers. No functional changes.

= 0.2.3 =
* Plugin Name header changed to "WEARFITS Shoes Tryon" so the WordPress.org-derived slug matches the plugin folder, text domain, and meta-key prefix (`wearfits-shoes-tryon`). Visible admin menu, button labels, and frontend UI copy still read "WEARFITS Try-On"; this change affects only the plugins-list title and the WP.org permalink.
* Release zip now includes the full source tree (`src/`, `package.json`, `webpack.config.js`, `bin/`) alongside compiled assets, satisfying the WP.org "human-readable code" guideline without requiring a public development repository.
* Added a "Source code" section to the readme listing where source lives and how to rebuild.

= 0.2.2 =
* Plugin directory readme: tag list trimmed to five (WordPress.org cap), added an External services section documenting every outbound request to api.wearfits.com with links to the WEARFITS Terms of Service and Privacy Policy, and an expanded Privacy section listing the exact option and post-meta keys the plugin stores.

= 0.2.1 =
* Admin product tab now updates job status live (Queued → Processing → Completed) without a page reload; polls an internal AJAX endpoint every 3 s.
* Removed the post-completion page reload that could race with classic/TinyMCE editor init and trigger "Can't create duplicate variable: 'LocaleTimestampParser'" errors.
* First Action Scheduler poll after a digitize submission is scheduled 5 s out (was 30 s) so the admin UI reflects progress within one poll cycle.

= 0.2.0 =
* Added settings page for the WEARFITS API key (WooCommerce → WEARFITS Try-On).
* Added **Digitize with WEARFITS** button in the product editor; Action Scheduler polls job status with exponential backoff and writes the returned viewer URL into product meta.
* Failure reasons reported by WEARFITS (e.g. upload errors) now surface directly on the product edit screen.
* Server-side guards: atomic per-product submission lock, shoe/footwear category eligibility check, strict public-URL validation for both submitted images and returned viewer URLs.
* Desktop QR modal: focus trap, Esc to close, improved mobile detection (iPadOS correctly treated as mobile).
* Admin styling moved to versioned CSS/JS assets.

= 0.1.0 =
* Initial MVP release. Manual per-product try-on URL + Virtual Try-On button with desktop QR modal and mobile deep link.
