# Template Overrides

Bizzwishlist allows you to customize the wishlist page design by overriding the plugin's template files from your WordPress theme. This gives you full control over the HTML markup and layout without modifying the plugin files directly.

## How Template Overrides Work

The plugin looks for template files in the following order:

1. **Your theme:** `yourtheme/bizzwishlist/` directory
2. **Plugin default:** `wp-content/plugins/bizzwishlist/templates/` directory

If a matching template file is found in your theme, it takes priority over the plugin's default template.

## Available Templates

| Template File | Description |
|---------------|-------------|
| `wishlist-page.php` | The full wishlist page layout (used by the `[bizzwishlist]` shortcode) |

## Step-by-Step: Overriding the Wishlist Page Template

### Step 1: Create the Override Directory

In your active theme's folder, create a directory called `bizzwishlist`:

```
wp-content/themes/your-theme/bizzwishlist/
```

### Step 2: Copy the Template File

Copy the template file from the plugin to your theme:

**From:**
```
wp-content/plugins/bizzwishlist/templates/wishlist-page.php
```

**To:**
```
wp-content/themes/your-theme/bizzwishlist/wishlist-page.php
```

### Step 3: Customize the Template

Edit the copied file in your theme to customize the HTML, CSS classes, layout, or any other aspect of the wishlist page.

### Step 4: Verify

Visit your wishlist page to confirm that your customized template is being used.

## Template Variables

The following variables are available inside the `wishlist-page.php` template:

| Variable | Type | Description |
|----------|------|-------------|
| `$products` | `array` | Array of product data. Each item contains a `product` (WC_Product object) and `variation_id` (int). |
| `$share_url` | `string` | The unique shareable URL for this wishlist |
| `$is_shared` | `bool` | `true` if viewing someone else's shared wishlist (read-only mode) |

## Example: Accessing Template Variables

```php
<?php
// Loop through wishlist products
foreach ( $products as $item ) :
    $product      = $item['product'];   // WC_Product object
    $variation_id = $item['variation_id']; // int (0 if no variation)
    ?>
    <div class="my-wishlist-item">
        <img src="<?php echo esc_url( wp_get_attachment_url( $product->get_image_id() ) ); ?>" alt="">
        <h3><?php echo esc_html( $product->get_name() ); ?></h3>
        <p><?php echo wp_kses_post( $product->get_price_html() ); ?></p>
    </div>
<?php endforeach; ?>
```

## Important Notes

- **Do not edit the plugin's template files directly.** Plugin updates will overwrite your changes. Always use the theme override method.
- Keep your overridden template in sync with plugin updates. If the plugin adds new template variables or changes the structure in a future version, you may need to update your override.
- The `$is_shared` variable is useful for conditionally hiding edit actions (remove buttons, checkboxes) when displaying a shared wishlist.
