# Factorize Portal — 5-Minute Quickstart

One box, one button: the logged-out My Account page asks for an email first, then either logs the customer in or creates their account on the spot. This guide gets you from zip file to working portal in about five minutes.

## Prerequisites

- WordPress 6.2 or newer, PHP 7.4 or newer
- WooCommerce active (the portal enhances WooCommerce's My Account page — without WooCommerce the plugin loads but does nothing visible)
- Customer registration enabled: **WooCommerce → Settings → Accounts & Privacy → "Allow customers to create an account on the 'My account' page"**. The portal submits WooCommerce's real registration form, so that form has to exist on the page.

## Install

1. Upload the `factorize-portal` folder to `/wp-content/plugins/` (or install the zip via **Plugins → Add New → Upload**).
2. Activate **Factorize Portal**. No API keys, no credentials, no setup wizard.

## First value in 4 steps

1. **See the portal.** Log out (or open a private window) and visit your My Account page. The stacked Login + Register forms are now one panel: an email box and a Continue button.
2. **Try an existing account.** Enter an email that has an account — the password field, "Remember me", and "Lost your password?" appear and the button becomes **Log in**. This submits WooCommerce's real login form.
3. **Try a new email.** Enter an address with no account — the panel flips to create-account mode ("No account found for ..."), asks for a password and an optional phone number, and the button becomes **Create account**. Submitting fills and posts WooCommerce's real registration form, so every hook and server-side check still runs.
4. **Find the hub.** In the admin sidebar there is now a **Factorize** menu (shop managers and admins). Under the **Customers** tab you'll see the Portal card with a status line showing whether the phone field is on.

## Configuration

There is no settings screen — one option array and one filter control everything.

| Key | Default | Effect |
| --- | --- | --- |
| `phone_field_enabled` | `true` | Renders the optional phone field on WooCommerce registration, validates its format whenever a number is provided, and saves it to `billing_phone` user meta on account creation. Set `false` to switch all three off. |

Values come from the `factorize-portal_options` option (an array merged over the defaults — a legacy `empire-account-portal_options` row is still honored), and the merged result passes through the `factorize-portal_config` filter. Two ways to override:

```bash
# via WP-CLI
wp option update factorize-portal_options '{"phone_field_enabled":false}' --format=json
```

```php
// via a small plugin or your child theme
add_filter( 'factorize-portal_config', function ( $config ) {
    $config['phone_field_enabled'] = false;
    return $config;
} );
```

## Troubleshooting

- **The page still shows two forms.** The portal script only rewrites the page when both of WooCommerce's real forms are present. The usual cause is registration being disabled in **WooCommerce → Settings → Accounts & Privacy** — with no register form on the page, the script quietly leaves everything alone. Also note the script only loads on the *logged-out* account page, so you will never see the portal while logged in.
- **Continue flashes "Checking…" and then the classic forms appear.** The AJAX account lookup failed, and the portal fell back to the standard login form (on purpose — a failed lookup must never lock anyone out). Common causes: a full-page cache serving a stale copy of the page whose embedded security nonce has expired, or a firewall/security plugin blocking `admin-ajax.php` for logged-out visitors. Exclude the My Account page from page caching and allow the `et_check_user` AJAX action.
- **It works but looks plain.** The plugin ships zero CSS by design — the `et-portal`, `et-portal__stage2`, and `et-portal__offer` classes are hooks for your theme to style (the suite's companion theme carries the reference styles). Everything functions unstyled; add a few rules in your theme to dress it up.
