# ⚙️ Factorize Setup

> Build the store you are logged into, in one screen.

> **Suite identity:** icon ⚙️ · accent `#2f6f9f` · category **Setup** · part of the [Factorize suite](../README-FACTORIZE.md)

## What it does

The Site Builder (`factorize-site-builder/new-site.sh`) assembles a *new*
Docker stack from a zip. Factorize Setup does the same job **inside
wp-admin, to the WordPress it is installed on**: Factorize → Setup asks the
same questions — store name, tagline, address/phone, what you sell (tools /
clothing / general), a dark or light palette, which Factorize features, how
many demo products, auction length — and then, step by step with progress:

1. installs and activates **WooCommerce** from wordpress.org (skipping its
   setup wizard and the "coming soon" curtain);
2. installs **Ultimate WooCommerce Auction** if Auctions is ticked;
3. installs the ticked **Factorize plugins** from `bundle/<slug>.zip`
   (folders already present — e.g. a bind-mounted dev copy — are used as is)
   and activates them;
4. installs and activates the **Empire Tools theme** from
   `bundle/empire-tools.zip`;
5. applies the palette (all 35 theme tokens), generates a two-tone logo +
   favicon, configures WooCommerce (USD, guest checkout, pickup + flat
   rate, pay-at-pickup);
6. seeds demo products in chunks of 12 (placeholder tiles, retail prices,
   stock/sold variety, SKUs `DEMO-0001…`), category thumbnails, deal
   ranks, popularity scores;
7. converts ~60% of in-stock products to live auctions (if bundled);
8. creates the paid demo member (`member@example.com` / `DemoMember1!`);
9. builds the storefront band, home page, and menu;
10. flushes caches and links you to the store, the hub, and the Customizer.

Re-running is safe: settings refresh, products with existing SKUs are
skipped, the logo/band/menu are kept.

## The bundle

`bundle/` holds one zip per sibling plugin and the theme. Rebuild it after
any change to a plugin or the theme:

```
bash wp-content/plugins/factorize-setup/build-bundle.sh
```

Features whose zip is missing show as "not bundled" on the form and cannot
be ticked.

## Configuration

| key | default | effect |
|---|---|---|
| `features` | all nine slugs | which Factorize plugins the wizard offers |
| `default_on` | essentials catalog analytics storefront auctions perks portal | ticked by default |
| `product_chunk` | `12` | demo products created per AJAX step |
| `bundle_dir` | `bundle/` | where the zips live |
| `theme` | `empire-tools` | theme slug to install and activate |

Override via the `factorize-setup_options` option or the
`factorize-setup_config` filter. The last plan is stored in
`factorize-setup_plan`, the last completed build in `factorize-setup_last`.

## Requirements

- WordPress 6.2+, PHP 7.4+, an administrator account (`manage_options`).
- The web server must be able to write `wp-content/plugins` and
  `wp-content/themes` (`FS_METHOD direct` — true in the official Docker
  image; on shared hosting WordPress may ask for FTP credentials instead).
- Internet on the server for the two wordpress.org downloads.

## Works with

Standalone by definition — it is what brings the others in. It ships the
guarded hub copy, so on a blank site it alone stands up the Factorize menu
(the hub accepts plain administrators until WooCommerce exists) with the
Setup tab.

## Testing

`empire-tools-light/run.sh` (a site folder at the repo root) brings up a
**blank** WordPress on port 8630 with only this plugin bind-mounted, installs
core, and activates the plugin; `run.sh wipe` deletes it. See
`tests/VERIFICATION.md` for the recorded end-to-end run.
