# WooCommerce template sync — multi-agent work plan

**Repo:** `divi-bodycommerce`  
**Plugin templates:** `includes/templates/woocommerce/`  
**Reference (local):** `woocommerce/templates/` in your WooCommerce plugin copy (match the WC version you ship against)

---

## Main plan (read this first)

**Goal:** Bring every remaining BodyCommerce WooCommerce override in line with current WooCommerce templates, preserve Divi/BodyCommerce behaviour, and prefer **delegation to core** (via `woocommerce_locate_template` or removing duplicate files) where we do not need a custom file.

**Already completed (baseline — do not redo - just check and if not right fix):**

- `includes/core/template-overrides.php` — early handling for `cart/cart.php`, `cart/cart-empty.php`, `checkout/review-order.php` (core when no custom / minimal files when custom).
- `cart/cart-custom-layout.php`, `cart/cart-empty-custom.php`, `checkout/review-order-shopify.php`.
- Removed pure duplicates: `loop/add-to-cart.php`, `single-product/add-to-cart/simple.php`, `single-product/meta.php`, `single-product/product-thumbnails.php` (core loads).
- `notices/*.php` — docblocks / markup alignment.
- `changelog.txt` — user-facing entries for the above.

**Remaining work:** everything under `myaccount/`, `emails/`, `global/`, `loop/`, `single-product/sale-flash.php`, and the large `checkout/form-checkout.php`.

**How to use this plan:**

1. Point each sub-agent at **one workstream** below (or one file group in a wave).
2. Each agent: diff BodyCommerce file vs `woocommerce/templates/<same path>`, merge upstream changes, keep `get_bodycommerce_option` / Divi output, run `php -l`, update `changelog.txt` under the current unreleased `VERSION`.
3. **Merge / PR order:** land independent workstreams in parallel branches, then merge; resolve conflicts in `changelog.txt` by combining bullet lines.
4. **Shared rules:**  
   - Do not strip BodyCommerce-specific options without an explicit replacement (hooks or settings).  
   - If a file is identical to core + no BC logic, prefer **deleting** the copy and using template delegation (same pattern as cart) — document in the workstream deliverable.  
   - `template-overrides.php`: only touch if adding new locate-template routing; coordinate so two agents do not edit the same hunk in one PR.

---

## What can run in parallel

These streams touch **disjoint files** and can run **at the same time** (separate agents or branches):

| Wave | Workstream | Files (approx.) | Notes |
|------|------------|-----------------|--------|
| **A** | My Account — **shell & navigation** | `my-account.php`, `navigation.php` | Foundation for layout; no dependency on forms batch |
| **B** | My Account — **endpoints & lists** | `dashboard.php`, `orders.php`, `view-order.php`, `downloads.php`, `payment-methods.php`, `my-address.php`, `lost-password-confirmation.php` | Parallel with A |
| **C** | My Account — **auth & account forms** | `form-login.php`, `form-lost-password.php`, `form-reset-password.php`, `form-edit-account.php`, `form-edit-address.php`, `form-add-payment-method.php` | Parallel with A + B |
| **D** | My Account — **BC-only** | `compare.php`, `wishlist.php` | No WC upstream; still review for security/i18n — parallel with A–C |
| **E** | **Global + loop + product flash** | `global/breadcrumb.php`, `loop/sale-flash.php`, `single-product/sale-flash.php` | Parallel with myaccount waves |
| **F** | **Email wrapper templates** | `emails/email-header.php`, `emails/email-footer.php`, `emails/email-styles.php`, `emails/email-order-details.php` | Respect existing `email_improvements` + `enable_email_template` logic in `template-overrides.php` — read before editing |
| **G** | **Checkout (heavy)** | `checkout/form-checkout.php` only | **Run alone** or with streams that do not touch checkout (all others are safe). Prefer one dedicated agent. |

**Sequential / caution:**

- **G (form-checkout)** after or isolated from F if email-related checkout hooks are in doubt — usually still parallel, but the file is **~1700 lines**; assign a **single** agent and split **internally** by section (e.g. step 1 diff WC opening, step 2 merge antispam, step 3 merge Divi) if needed.
- **Changelog:** one final pass or merge to dedupe `changelog.txt` bullets if many PRs land together.

**Parallel diagram (safe default):**

```text
           ┌─ A (shell/nav)     ─┐
           ┌─ B (endpoints)     ─┤
  START ───┼─ C (forms)         ├──► QA / merge
           ┌─ D (compare/wl)   ─┤
           ┌─ E (global/loop)   ─┤
           ┌─ F (emails)        ─┤
           └─ G (form-checkout) ─┘   ← can overlap with A–F in separate branches; avoid editing same files
```

---

## Per-workstream checklists

### A — `myaccount/my-account.php`, `navigation.php`

- Diff vs WC `myaccount/*.php`.
- Preserve BodyCommerce nav layout options and any `[showmodule]` / layout wiring.
- Confirm `wc_print_notices()` / hook order still matches WC expectations.
- **Deliverable:** updated PHP + changelog line + short note if any hook could replace a copy later.

### B — Endpoint templates

- Files: `dashboard.php`, `orders.php`, `view-order.php`, `downloads.php`, `payment-methods.php`, `my-address.php`, `lost-password-confirmation.php`.
- For each: merge WC version bumps (accessibility, escaping, new hooks), keep BC strings/options.
- **Deliverable:** same as A.

### C — Form templates

- Files: all `form-*.php` under `myaccount/`.
- Watch for WC changes to nonces, field classes, and `wc_wp_theme_get_element_class_name( 'button' )` patterns.
- **Deliverable:** same as A.

### D — `compare.php`, `wishlist.php`

- No WC source file; document purpose and add PHPCS/escaping if missing.
- **Deliverable:** code cleanup note + changelog if user-visible.

### E — `global/breadcrumb.php`, `loop/sale-flash.php`, `single-product/sale-flash.php`

- Diff vs WC; preserve option-driven sale flash and breadcrumb behaviour.
- **Deliverable:** merged templates + consider splitting sale-flash into “core + BC partial” in a follow-up (optional note only).

### F — Emails

- Files: `email-header.php`, `email-footer.php`, `email-styles.php`, `email-order-details.php`.
- **Before editing:** re-read `bodycommerce_woo_templates` email gating (modern “email improvements” + `enable_email_template`).
- Merge WC block/classic email markup updates carefully; do not break preview or footer text filters.
- **Deliverable:** merged files + changelog; if BC copy can be dropped when `enable_email_template` is off, note for a future task.

### G — `checkout/form-checkout.php`

- One agent; internal phases: (1) identify BC-only blocks (antispam, multistep, Divi, WPML strings), (2) diff WC `form-checkout.php` (current WC version) for structural/security updates, (3) merge without removing BC features.
- **Deliverable:** same; expect **largest** time box.

---

## Verification (every workstream)

- [ ] `php -l` on every touched file.
- [ ] Smoke: cart, checkout, my account, single product, shop loop (as relevant to files changed).
- [ ] `changelog.txt` under first unreleased `VERSION` (user-facing; no file names in customer-facing bullets per org style when possible).
- [ ] Optional: `diff` or meld against `woocommerce/templates/...` saved in ticket/PR description for reviewers.

---

## Suggested agent prompts (copy/paste)

**Agent — My Account B (endpoints):**  
“Sync `divi-bodycommerce/includes/templates/woocommerce/myaccount/` files: dashboard, orders, view-order, downloads, payment-methods, my-address, lost-password-confirmation. Compare each to the same path under the installed `woocommerce/templates/` directory. Merge upstream WooCommerce changes; preserve all `get_bodycommerce_option` and Divi-related output. Update `changelog.txt`. Do not change `template-overrides.php` unless required for a new override path.”

**Agent — Checkout G:**  
“Sync `divi-bodycommerce/.../checkout/form-checkout.php` with WooCommerce `checkout/form-checkout.php` while preserving the full BodyCommerce custom checkout (multistep, antispam, options). Work in sections; do not remove BC-specific code. Update changelog.”

(Adapt paths to the reviewer’s machine.)

---

## File inventory (remaining overrides)

| Path | Workstream |
|------|------------|
| `checkout/form-checkout.php` | G |
| `checkout/review-order-shopify.php` | *Done / maintain on WC changes only* |
| `cart/cart-*.php` | *Done* |
| `emails/*` (4 files) | F |
| `global/breadcrumb.php` | E |
| `loop/sale-flash.php` | E |
| `single-product/sale-flash.php` | E |
| `myaccount/*` (17 files) | A, B, C, D |
| `notices/*` | *Done* |

---

## Revision

| Date | Author | Change |
|------|--------|--------|
| 2026-04-23 | — | Initial plan after partial template sync |
