# Theme Integration

### Override YayMail Templates with Theme

YayMail allows developers to override email templates directly from their theme. This enables advanced customization of email structure without modifying plugin files or adding code snippets.

This approach works similarly to how WooCommerce templates can be overridden from a theme.

Editing plugin files directly is not recommended because any changes will be lost when the plugin updates. Instead, overriding templates from a theme provides an upgrade-safe way to customize templates.

To customize a template, copy the desired file from the plugin into your theme using the following structure:

```
your-theme/
└── yaymail/
    └── emails/
        template-file.php
```

<figure><img src="/files/PNszLD59KRdANomgm06U" alt=""><figcaption></figcaption></figure>

Once the file exists in your theme, YayMail will load this template instead of the default plugin template.

This allows you to safely customize the email layout and logic without editing the plugin core files.

When YayMail loads a template, it passes the following variables to the template file.

#### `$template`

Contains the YayMail template instance used to render the email layout.

#### `$args`

An array containing the data used in the email template.

Depending on the email type, `$args` may include:

* Order information
* Customer data
* Email settings
* Other contextual data

Example usage:

```
$order = $args['order'];
```

You can use this data to customize the email content or display additional information.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.yaycommerce.com/yaymail/developer-zone/theme-integration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
