Hi, is it possible to modify the content of an email before sending?
Unfortunately I have a fairly complex use case.
in short:
Form = CPT (Products) + Number field.
After sending, the quantity of products will be adjusted. (work as needed)
after that a Post in CPT “ordres” will be created. (work as needed)
I would like the items ordered to be shown in the email. (no way found)
In the form, I only have quantities that are iterated over a CPT and the ID contains the post ID. I get the title {Post_title} and pass it to the label.
Tryings:
I thought I could create a hidden field in the form.
Assemble an HTML in the action “before_submit” and pass it to the field as a value.
but unfortunately it is not shown to me.
$produkt_details = "";
foreach ($form_data as $key => $value) {
if (strpos($key, 'form-field-pid-') !== false && !empty($value)) {
$product_id = str_replace('form-field-pid-', '', $key);
if (get_post_type($product_id) === 'produkt') {
$product_name = get_the_title($product_id);
$row = [
'produkt_id' => $product_id,
'produkt_name' => $product_name,
'menge' => $value,
];
add_row('produkte', $row, $order_post_id);
$produkt_details .= "<p><b>" . $product_name . " Menge: " . $value . "</b></p>";
}
}
}
$form_data['bestellte-positionen'] = $produkt_details;