Files are sometimes attached and sometimes not to mail
-
add_filter('woocommerce_email_attachments', 'add_flexible_checkout_fields_attachments_to_vendor_email', 10, 3);
function add_flexible_checkout_fields_attachments_to_vendor_email($attachments, $email_id, $order) {
if ($email_id === 'new_order') {
$order_id = $order->get_id();
$uploaded_files = get_post_meta($order_id, '_billing_datei_upload', true);
if (!empty($uploaded_files)) {
if (is_string($uploaded_files)) {
$uploaded_files = explode(',', $uploaded_files);
}
if (is_array($uploaded_files)) {
foreach ($uploaded_files as $file) {
$file_path = get_attached_file($file);
if ($file_path && file_exists($file_path)) {
$attachments[] = $file_path;
}
}
} else {
$file_path = get_attached_file($uploaded_files);
if ($file_path && file_exists($file_path)) {
$attachments[] = $file_path;
}
}
}
}
return $attachments;
}I used this code, but there are sometimes files attached and sometimes don’t
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- You must be logged in to reply to this topic.