'Add static pdf to an email based on language - WooCommerce
I need to add to the attachment of the confirmation mail after successful checkout static pdf attachment, but changing the source route of the file based on language he chose on my website. I use this code to attach the static pdf to the attachment:
add_filter( 'woocommerce_email_attachments', 'wphelp_email_files_woo', 10, 4 );
function wphelp_email_files_woo( $attachments, $email_id, $order, $email ) {
$email_ids = array( 'new_order', 'customer_processing_order' );
if ( in_array ( $email_id, $email_ids ) ) {
$upload_dir = wp_upload_dir();
$attachments[] = $upload_dir['basedir'] . "/2021/12/FORMULAR_NA_ODSTUPENIE_OD_ZMLUVY-1.pdf"; //Change the route and name for yours
}
return $attachments;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
