Add an attachment to workflow emails

Attach a local file after AutomateWoo builds a workflow email. Change the path and keep the readability check so a missing file does not generate a mailer warning.

Developer note:

Add custom PHP in a small custom plugin or child theme, and test it on a staging site before production. This example requires ongoing maintenance when extension APIs change.

functions.php

<?php

add_filter( 'automatewoo/workflow/mailer', 'my_store_add_workflow_email_attachment' );

/**
 * Add a PDF attachment to AutomateWoo workflow emails.
 *
 * @param AutomateWoo\Mailer_Abstract $mailer Workflow mailer.
 * @return AutomateWoo\Mailer_Abstract
 */
function my_store_add_workflow_email_attachment( $mailer ) {
	$attachment = get_stylesheet_directory() . '/documents/terms.pdf';

	if ( is_readable( $attachment ) ) {
		$mailer->attachments[] = $attachment;
	}

	return $mailer;
}
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.