=== WatShop Reseller ===
Contributors: watshop
Tags: woocommerce, reseller, digital products, api, dropshipping
Requires at least: 5.8
Tested up to: 6.6
Requires PHP: 7.4
Stable tag: 1.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Resell the WatShop digital catalog on your own WooCommerce store with automatic import, ordering and credential delivery.

== Description ==

WatShop Reseller connects your WooCommerce store to the WatShop reseller API (https://keys24x7.com):

* **Catalog import** — one click imports the whole WatShop catalog as virtual WooCommerce products (name, description, category, image, stock status). Products are matched by SKU, so re-importing is always safe.
* **Your margin** — set a price margin percentage; shop prices are calculated as WatShop price (INR) × (1 + margin / 100).
* **Auto-sync** — an hourly background task keeps prices and stock status in sync with WatShop (can be turned off).
* **Automatic fulfilment** — when a customer pays, the plugin places the matching order with WatShop using the customer's billing email. If credentials are delivered instantly they are saved to the order and included in the completion email; otherwise a 5-minute background task polls WatShop and emails the customer as soon as the order completes.
* **Failure safety** — if an order cannot be placed (for example insufficient wallet balance), the order gets a note, the site admin gets an email, and a Retry button appears in the WatShop box on the order screen.

Requires an active WatShop reseller account and API key. All prices from the API are in INR (₹).

== Installation ==

1. Make sure WooCommerce is installed and active.
2. Upload the `watshop-reseller` folder to `/wp-content/plugins/`, or upload the zip via Plugins → Add New → Upload Plugin.
3. Activate **WatShop Reseller** through the Plugins screen.
4. Go to **Settings → WatShop Reseller**:
   * enter your API key (from your WatShop reseller dashboard),
   * set your price margin,
   * click **Test Connection** to verify your account name and wallet balance.
5. Click **Import catalog now** to pull the catalog into WooCommerce.
6. Keep your WatShop wallet topped up — orders are debited from it automatically.

== Frequently Asked Questions ==

= What happens when my wallet balance is too low? =

The WooCommerce order stays in place, an order note is added, a warning appears in wp-admin, and the site admin receives an email. After topping up, use the **Retry order** button in the WatShop box on the order edit screen.

= Can an order be charged twice? =

No. The plugin records the placement attempt on the order before the request is sent. If the connection drops and the outcome is unknown, it looks the order up on WatShop first and adopts the existing one instead of ordering again. If it cannot prove what happened, it stops and asks you to check — it never re-sends blindly.

= Where is my API key stored? =

In the plugin's settings option. It is never written into the settings page HTML; the field shows only a masked hint, and leaving it blank keeps the saved key.

= Does uninstalling delete my products? =

No. Uninstalling removes the plugin settings and scheduled tasks but leaves all imported WooCommerce products untouched.

= What currency are prices in? =

The WatShop API returns prices in INR (₹). Your shop price is the INR price plus your configured margin.

== Changelog ==

= 1.1.0 =
* Store moved to https://keys24x7.com — new default API URL, and existing sites still pointing at the old host are migrated automatically on upgrade.
* Double-charge protection: placement attempts are recorded before the request is sent, and an unknown outcome (timeout, dropped connection, PHP fatal) is reconciled against your WatShop order history instead of being re-sent.
* The 5-minute background task now also resolves unknown outcomes, so dropped connections heal without manual work.
* Credentials are delivered to the buyer exactly once — no more duplicate copies from both an order note and the order email.
* The API key is no longer rendered into the settings page HTML; the field shows a masked hint and blank means "keep the saved key".
* Price sync now updates the active price, not just the regular price, so catalogue and cart prices actually change.
* Failures are surfaced as a dismissible wp-admin warning in addition to the order note and admin email; a missing API key is no longer a silent no-op.
* HPOS compatibility is declared early enough to register, plus Cart/Checkout blocks compatibility.
* Re-import no longer overwrites product categories you organised yourself, and products are matched by SKU or remote id so a hand-edited SKU cannot create duplicates.
* Uninstall now also clears the alerts option, and cleans every site on a multisite network.

= 1.0.0 =
* Initial release: catalog import, hourly sync, automatic order placement, credential delivery, retry handling.
