this is my code, in mail body display: [optional], but not output (in frontend work ok):
Add_action( 'wpcf7_init', 'custom_add_form_tag_clock' );
function custom_add_form_tag_clock() {
wpcf7_add_form_tag( 'optional', 'custom_clock_form_tag_handler' );
}
function custom_clock_form_tag_handler( $tag ) {
global $product;
$modello = $product->get_attribute( 'Optional' );
if ($modello != ""){
$optional = explode(",", $modello);
$html.= '<label>Scegli uno o più optional</label><select id="myFilter" class="multiple_select" multiple>';
foreach ($optional as &$value) {
$html.='<option data-size="large" value="'.$value.'">'.$value.'</option>';
}
$html.='</select>';
}
return $html;
}
The code get atttribute from woocommerce product with a multiple select.
2
Answers
i have used: optional[] and work it!
To make your tag show in the email, you either need to add a name attribute to the form tag
[optional]
and include it as a variable and then update this line:The email will read the "NAME" attribute of the input field or select