# Factorize Watch — 5-Minute Quickstart

Get a daily, read-only snapshot of the eBay market for your most popular products (plus your own Facebook Page posts) without giving anything write access to your accounts.

## Prerequisites

- WordPress 6.2+ with PHP 7.4+
- WooCommerce active (the sweep targets your products and the table shows your prices)
- An eBay developer account for a Browse API OAuth token (free at developer.ebay.com)
- Optional: a Facebook Page access token with `pages_read_engagement` for the Page posts reader

## Install

1. Copy the `factorize-watch` folder into `wp-content/plugins/` (or install the ZIP via Plugins → Add New).
2. Activate **Factorize Watch**. A **Factorize** menu appears in the admin sidebar — any Factorize plugin alone creates the shared hub.

## First value in 4 steps

1. Open **Factorize → Marketplace**. You'll see the read-only notice and a Credentials form (this is the keys-later empty state — nothing runs until you add keys).
2. Paste your **eBay OAuth token** (developer.ebay.com → your app → OAuth). Optionally add your **Facebook Page ID or name** and **Page access token**. Either platform works alone.
3. Click **Save & sync now**. The plugin runs a GET-only eBay Browse search for your top products and reads your Page's latest posts.
4. Read the results on the same screen: your price vs. active eBay listings, eBay median, and the low–high spread per product, plus your latest Facebook posts. From here it refreshes automatically once a day.

Bonus: with eBay data present, each swept product's `et_popularity` score is refined (75% industry heuristic + up to 25 points of live market activity), which sibling Factorize plugins use for popularity sorting.

## Configuration

Defaults live in `config.php` and are read through `empire_market_config( $key )`. Override any subset by saving an array to the `factorize-watch_options` option, or filter the merged config at runtime with the `factorize-watch_config` filter.

| Key | Default | Effect |
| --- | --- | --- |
| `top_products` | `15` | How many of your most popular products (ordered by the `et_popularity` post meta, descending) are swept against eBay on each sync. |
| `sync_recurrence` | `daily` | WP-Cron recurrence name for the `et_marketplace_sync` event. Must be a registered cron schedule. |

Credentials are **not** in this config — the eBay token, Facebook Page, and Facebook token are managed on the Marketplace admin page and stored in the `et_marketplace_settings` option. The latest snapshot lives in `et_marketplace_data`.

Example override:

```php
update_option( 'factorize-watch_options', array( 'top_products' => 25 ) );
```

## Troubleshooting

- **"No keys yet" and no data on the page.** That's the designed empty state, not an error — the plugin does nothing until credentials are saved. Note the first *scheduled* run is about an hour after activation and WP-Cron only fires on site traffic, so use **Save & sync now** for an instant first snapshot.
- **Changed `sync_recurrence` but the schedule didn't change.** The cron event is scheduled once (on `init`, only when no event exists). Delete the existing event so it re-schedules with the new recurrence: `wp cron event delete et_marketplace_sync`.
- **An `ebay_error` notice (e.g. `HTTP 401`) and a partial table.** eBay OAuth tokens expire; the sweep stops at the first failed request, so one expired token halts the rest of that sync. Paste a fresh token and hit **Save & sync now**. Also note the eBay query uses the first 8 words of each product title — very generic titles can match unrelated listings, so specific titles give better market numbers.
