Проверено в порядке с WooCommerce 3.5.4
add_filter('woocommerce_email_attachments', 'attach_terms_conditions_pdf_to_email', 10, 3);
function attach_terms_conditions_pdf_to_email($attachments, $id, $object) {
$your_pdf_path = 'https://smagdansk.dk/wp-content/uploads/2018/08/SMAGdansk-Fortrydelsesformular.pdf';
if (!class_exists('WP_Http'))
include_once( ABSPATH . WPINC . '/class-http.php' );
$http = new WP_Http();
$response = $http->request($your_pdf_path);
if ($response['response']['code'] != 200) {
return false;
}
$upload = wp_upload_bits(basename($your_pdf_path), null, $response['body']);
if (!empty($upload['error'])) {
return false;
}
$file_path = $upload['file'];
$attachments[] = $file_path;
return $attachments;
}