На вашем estimate.php
добавьте этот код:
add_action( 'wp_enqueue_scripts', 'wi_enqueue_scripts' );
function wi_enqueue_scripts(){
wp_localize_script( 'wi-ajax-script', 'wi_ajax_params',
array(
'wi_ajax_nonce' => wp_create_nonce( 'wi_ajax_nonce' ),
'wi_ajax_url' => admin_url( 'admin-ajax.php' )
)
);
}
Затем в файле javascript используйте это:
$("#submit_button").click(function(e, features, totalcost) {
e.preventDefault();
console.log('clicked')
$.ajax({
type: "POST",
//url: wi_ajax_params.wi_ajax_url,
url: "http://yourdomain.com/wp-admin/admin-ajax.php",
data: {
action: 'submitWizard',
// add your parameters here
features: features,
total: totalcost,
email: $("#exampleInputEmail1").value,
name: $("#exampleInputPassword1").value,
message: $("#exampleFormControlTextarea1").value,
},
success: function(response) {
console.log(response);
}
});
});
Наконец, добавьте этот код снова в файл плагина:
add_action( 'wp_ajax_submitWizard', 'process_estimate' );
add_action( 'wp_ajax_nopriv_submitWizard', 'process_estimate' );
function process_estimate(){
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$features = $_POST['features'];
$total = $_POST['total'];
wp_mail( 'charlespettisappdevelopment@gmail.com', 'New Submission!', "
$name,
$email,
$message,
$features,
$total,
");
}
Не проверено, но должно работать. Дайте мне знать.