MP_Addon_Payoff_Callback::ajax_calculator_callback()
Callback AJAX calculate.
Source Source
File: calculator-mortgage-payoff-add-on/inc/MP_Addon_Payoff_Callback.php
public function ajax_calculator_callback() {
MP_Callback::check_nonce( $_GET['nonce'], MortgagePlatform::$prefix . 'nonce' );
$json = file_get_contents( 'php://input' );
$data = json_decode( $json, true );
$email = new MP_Email();
$response['email'] = $email->emailSend( $data );
$lead_update = new MP_Addon_Payoff_Searches();
$response['lead'] = $lead_update->lead_update( $data, $response );
$calcCookies = array(
'lead' => $response['lead']['lead'],
'first_name' => $data['email']['firstname'],
'second_name' => $data['email']['secondname'],
'phone' => $data['email']['phone'],
'email' => $data['email']['email'],
'zipcode' => $data['email']['zipcode'],
'yearofbirth' => $data['email']['yearofbirth'],
'investment_amount' => $data['email']['investmentamount']
);
if ( $this->settings['enable_cookie'] ) {
add_action( 'init', MP_Cookies::set_cookies( "mortgagecalculator_lead", $calcCookies ) );
add_action( 'init', MP_Cookies::set_cookies( "mortgagelead", 'success' ) );
} else {
MP_Cookies::delete_cookies( "mortgagecalculator_lead" );
MP_Cookies::delete_cookies( "mortgagelead" );
}
header( 'Access-Control-Allow-Origin: *' );
wp_send_json( $response );
}
Changelog Changelog
| Version | Description |
|---|---|
| 1.0.0 | Introduced. |