Add attachment to WooCommerce mail for certain products

Lets say you want an attachment.pdf added to an completed order mail in WooCommerce if certain products are in the order. How do you add and attachment in that case?

With the following code you be able to select one of the mails send in the proces and add the attachment if one of the predefined products is in that order.

If you add the code to your functions.php of your theme and add the attachment.pdf in the same folder, then change the product numbers to your requirements and test.

Variation ID

Product ID

Leave a Reply

Your email address will not be published. Required fields are marked *