> For the complete documentation index, see [llms.txt](https://docs.yaycommerce.com/yaymail/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yaycommerce.com/yaymail/developer-zone/theme-integration.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
