# ⭐ Factorize Perks

> A reason to join: member pricing, shipping credit, and the pitch that sells the upgrade.
>
> **Suite identity:** icon ⭐ · accent `#b48ce0` · part of the [Factorize Suite](../README-FACTORIZE.md)

## What it does

Adds a paid-membership flag to user accounts (`et_member_paid` user meta) with a checkbox on the WordPress user-profile screen for shop managers to toggle it manually. While the flag is set, the member gets a percentage discount on the cart subtotal (applied as a negative fee) and a credit against flat-rate shipping. Non-members browsing auction product pages see a short pitch linking to the My Account page.

## Configuration

| key | default | effect |
| --- | --- | --- |
| `discount_pct` | `5` | Percent off the cart subtotal for paid members. Drives both the fee amount (`subtotal * pct/100`) and the number shown in the "Member discount (5%)" fee label. |
| `shipping_credit` | `10` | Dollars knocked off each flat-rate shipping cost for paid members (floored at $0). Drives the cap in the rate math and the number in both shipping labels. |

Values are read through `empire_perks_config( $key )`. Defaults are merged with the `factorize-perks_options` option (an array stored via `update_option`; the legacy `empire-membership-perks_options` option is still read as a fallback), and the merged result passes through the `factorize-perks_config` filter, so either mechanism can override a key site-wide.

## Works with

- **WooCommerce** (required for the perks): the discount, shipping credit, and product-page pitch all ride WooCommerce hooks; without WooCommerce active those hooks never fire and the plugin does nothing beyond defining the flag helpers. The admin profile checkbox is gated on the `manage_woocommerce` capability.
- **Sibling Factorize plugins/theme**: this plugin defines `EMPIRE_TOOLS_PAID_META` and `empire_tools_is_paid_member()`, which other Factorize components may call to check paid status. It calls no functions from other Factorize plugins itself, so it degrades gracefully when installed alone. Note: activating this plugin alongside the original theme code that still contains these definitions will fatal on redeclaration — remove the theme copy when switching.
- The registration phone field and the one-portal sign-in flow that lived in the same theme file are owned by another plugin and are NOT included here.

## Hooks it registers

- `show_user_profile` / `edit_user_profile` — render the "Paid member" checkbox (`empire_tools_paid_member_field`).
- `personal_options_update` / `edit_user_profile_update` — save the checkbox (`empire_tools_paid_member_save`).
- `woocommerce_cart_calculate_fees` — add the member discount as a negative fee.
- `woocommerce_package_rates` (priority 20) — apply the shipping credit to `flat_rate` methods and relabel them.
- `woocommerce_single_product_summary` (priority 32) — print the member-perks pitch on auction product pages for non-members.
- `admin_init` — register the plugin's card (Customers tab, live discount/credit status) with the shared Factorize hub.

## Publishing

`readme.txt` (the WordPress.org listing) and `QUICKSTART.md` (the 5-minute setup guide) live alongside this file for the WordPress.org release.
