не передается скрытое поле в письмо заказа wp+wc
передаю скрытое поле ajax'ом в functions.php:
<script type="text/javascript">
jQuery(document).ready(function () {
var present2 = jQuery("#present2").val();
jQuery.ajax({
type: "POST",
url: "/wp-admin/admin-ajax.php",
data: {
action : "ajax_present",
"present2" : present2
},
success: function(data){
console.log(data)
}
});
});
</script>
functions.php
add_action( 'wp_ajax_ajax_present', 'ajax_form' );
add_action( 'wp_ajax_nopriv_ajax_present', 'ajax_form' );
function ajax_form(){
add_action( 'woocommerce_email_order_details', 'display_applied_present', 10, 4 );
function display_applied_present( $order, $sent_to_admin, $plain_text, $email ) {
$present_code = $_POST['present2'];
echo '+Подарок' .$present_code;
};
}
в письме почему то ничего не приходит, подскажите пожалуйста решение