=== Prom Model Guard for WooCommerce ===
Contributors: catcodestudio
Tags: woocommerce, prom, marketplace, monitoring, ukraine
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Watches which Prom.ua model card your products are attached to and warns you the moment the binding changes or a product lands on somebody else's model.

== Description ==

Prom.ua merges offers from different sellers onto one shared model card. When the matching goes wrong, your product ends up on the card of a different item: the buyer reads the wrong specification, the wrong reviews and the wrong photos, orders — and blames your shop.

The seller is never told. The binding is not in the Prom API at all, it changes silently, and a shop with a few thousand SKUs has no way of noticing until the complaints arrive.

This plugin notices it for you. It reads your catalogue through the Prom API, then visits the public page of each product and records which model card it currently points at. Next time round it compares — and writes to you as soon as anything moved.

= Free features =

* Catalogue sync with your Prom cabinet through the official API (token from Налаштування → Авторизація та API).
* Model binding of every watched product, read from the public product page — the same page your buyers see.
* Scheduled sweep, in batches and with a configurable pause between requests, so a big catalogue is walked over several passes.
* Journal of every change: attached to a model, moved to another model, detached, Prom category changed, page gone (404).
* E-mail alert with both links side by side — your product and the model it hangs on.
* A ready-to-send complaint text for Prom support, with the product id, article, and both URLs.
* Products matched to your WooCommerce catalogue by external_id or SKU, so alerts carry the name you use in the shop.
* Manual "check now" for a single product and "this binding is correct" to silence a known-good one.
* The free tier watches the first 50 products of the cabinet and checks once a day.

= Pro features =

* The whole catalogue, with no cap on the number of watched products.
* Hourly checks instead of once a day.
* Detection of a wrong model by title mismatch: the product name is compared with the model card title, and the digit tokens (128GB, A54, XL) are weighed separately.
* Alerts mirrored to Telegram.
* Automatic hiding of a product on Prom (status "not on display") while a suspicious binding is unresolved — off by default.
* CSV export of the product list.
* Full journal history instead of the last 30 days.

== External services ==

This plugin talks to two external services.

1. **Prom.ua Public API** — `https://my.prom.ua/api/v1/`. Used to read the shop's own catalogue (GET /products/list) and, if the owner switches the option on, to hide a product (POST /products/edit). Sent: the API token the owner entered, and the product ids being changed. Terms: https://prom.ua/ua/terms-of-use, privacy policy: https://prom.ua/ua/privacy-policy

2. **prom.ua public pages** — `https://prom.ua/ua/p<id>-*.html` and `https://prom.ua/ua/m<id>-*.html`. Fetched to read the model card the product is currently bound to, because that binding is not exposed by the API. Sent: nothing but the request itself.

Telegram notifications (optional, Pro) are delivered through `https://api.telegram.org/` using the bot token the owner enters. Licence keys are verified against `https://catcode.com.ua/wp-json/catcode/v1/license`, which receives the key and the site URL.

== Installation ==

1. Upload the plugin and activate it.
2. Open «Моделі Prom» → «Налаштування», paste the Prom API token and press «Перевірити токен Prom».
3. Press «Синхронізувати й перевірити зараз» — the first pass fills the list.
4. Set the alert e-mail. After that the plugin works on its own schedule.

== Frequently Asked Questions ==

= Does the Prom API return the model binding? =

No. Public API 1.0 returns the seller's own group and the Prom category, and nothing about the model card. The binding is read from the public product page, where it appears as the page's canonical URL.

= How often does it hit prom.ua? =

One request per product, plus one per model card it has not seen before, with a pause between them (1.5 s by default) and a per-pass cap (40 products by default). Both are configurable.

= Will it fix the wrong binding by itself? =

It cannot — only Prom's support can detach a product from a model. The plugin gives you the evidence and the ready text; optionally it can hide the product until the case is resolved.

== Changelog ==

= 1.0.1 =
* A robot check or a technical page from Prom no longer reads as "the product left its model": the saved binding stays, no false alert.
* While the model card page cannot be opened, the product is not marked as suspicious and is not hidden on Prom.
* "This model is correct" applies to that model only and no longer returns after Prom moves the product again.
* The sweep stops as soon as Prom limits requests.
* The catalogue sync walks the whole cabinet before removing positions from the list.
* "Check" in the product list reports the result; problems are shown in words, not as codes.
* An invalid alert address is refused with a message.
* Pro fields no longer look switched on without a licence. Updates of the Pro build arrive through the Updates screen.

= 1.0.0 =
* First release.
