Can I add my custom File Upload field as email attachment? (Flexible Checkout Fields PRO WooCommerce)

I don't know why, but uploaded files are attached, when the customer gets the mail, but not when the shopadmin gets it, that's why I tried this code. For single files, it works, but to for more than one file. The check for Display On > Pages/Emails > Emails is set. 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 tried multiple versions of this code, but can't find the error and the docs from Flexible Checkout Fields PRO WooCommerce don't help.

Comment (0)

You’ll be in good company