How to override templates

Important

This method is considered customization. We are happy to provide guidance, but we are unable to provide support or help to suit your store under our Support Policy.
Only use it if you are comfortable with PHP and custom coding and troubleshooting on your own.

Affiliate for WooCommerce plugin helps you to add, manage affiliates, and track performance from a single place – commissions, sales, payouts, leaderboard, etc. Earn money without hard work. Increase your brand outreach, and get potential customers.

Overriding templates allows you to customize various areas of the plugin to better suit your theme and branding.

Just like WooCommerce allows you to customize templates, this process is straightforward and mirrors the template override method used by WooCommerce.

This documentation outlines how to override the default templates via another template file (Upgrade-safe) provided by the Affiliate for WooCommerce plugin.

Notes

1. Editing template files directly in the plugin creates the risk of causing errors, and any changes made will disappear when the plugin is updated, as it entirely deletes the old version and replaces it with a fresh, updated copy. So, we recommend override the default templates via another template file.
2. Also, it applies to themes. Whenever a theme is updated, it deletes all the customizations in the old version and replaces it with an updated copy of the theme, so it’s always recommended to set up a child theme and use it for overriding templates, where you will keep the templates inside the child theme directory.

Template list

↑ Back to top

The Affiliate for WooCommerce plugin provides several customizable templates.

All the plugin template files are inside the wp-content/plugins/affiliate-for-woocommerce/templates/ directory.

You can find it via an FTP client or your hosting’s file manager.

How to override templates?

↑ Back to top

To override and customize any template, copy the file and put it inside the wp-content/themes/{your-active-theme}/woocommerce/affiliate-for-woocommerce/ directory keeping the same directory structure but removing the templates subdirectory, and customize it as per your needs.

It’s important to maintain the directory structure to ensure the override works correctly.

Steps for Overriding Templates

↑ Back to top
  1. Locate the Template File: Identify the template file you wish to override.
  2. Copy the Template File: Copy the template file from the plugin’s templates directory to the appropriate directory within your theme. Maintain the directory structure to ensure the override works correctly.
  3. Modify the Template: Open the copied template file in your theme directory and make your desired changes. You can edit the HTML, PHP, and styles as needed to fit your design requirements.
  4. Save and Test: Save the modified template file and test the changes on your website. Ensure that the overrides are working as expected and that there are no issues with the modified templates.

The copied file will now override the template and the plugin will use your template file (if found).

Note – Open your themes folder and check if you have a folder named woocommerce. If not, create a folder named woocommerce. This is to ensure template override works correctly.

Example to override the Affiliate – Welcome Email

You will find the “Affiliate – Welcome Email” template (filename: afwc-welcome-affiliate-email.php) inside the wp-content/plugins/affiliate-for-woocommerce/templates/ directory.

To override that template, copy it to wp-content/themes/{your-active-theme}/woocommerce/affiliate-for-woocommerce/ directory.

The copied file will now override the default affiliate welcome email and the plugin will use your template file (if found).

Example to override the My Account > Affiliate > Reports tab

The template of the My Account > Affiliate > Reports tab (filename: affiliate-reports.php) is inside the wp-content/plugins/affiliate-for-woocommerce/templates/my-account/ directory.

To override that template, copy that file to wp-content/themes/{your-active-theme}/woocommerce/affiliate-for-woocommerce/my-account/ directory.

The copied file will now override the default my account > affiliate > reports tab and the plugin will use your template file (if found).

Troubleshooting

↑ Back to top
  • Template Not Loading: Ensure the override path in your theme matches the required directory structure. Double-check that you have copied the file to the correct location.
  • Errors in Templates: If you encounter errors, review your modifications to ensure there are no syntax errors or compatibility issues with your theme.
  • Caching Issues: If you don’t see your changes immediately, try clearing your site’s cache and browser cache.

Feature request

↑ Back to top

Have a feature request or enhancement suggestion for Affiliate For WooCommerce? Submit a request or send it to us from here.

Use of your personal data
We and our partners process your personal data (such as browsing data, IP Addresses, cookie information, and other unique identifiers) based on your consent and/or our legitimate interest to optimize our website, marketing activities, and your user experience.