/**
  * Checks revocation form and sends Email to customer and Admin
  */
 public static function gzd_revocation()
 {
     check_ajax_referer('woocommerce-revocation', 'security');
     wp_verify_nonce($_POST['_wpnonce'], 'woocommerce-revocation');
     $data = array();
     $fields = WC_GZD_Revocation::get_fields();
     if (!empty($fields)) {
         foreach ($fields as $key => $field) {
             if ('sep' !== $key) {
                 if ($key == 'address_mail') {
                     if (!is_email($_POST[$key])) {
                         wc_add_notice('<strong>' . $field['label'] . '</strong> ' . _x('is not a valid email address.', 'revocation-form', 'woocommerce-germanized'), 'error');
                     }
                 } elseif ($key == 'address_postal') {
                     if (!WC_Validation::is_postcode($_POST[$key], $_POST['address_country']) || empty($_POST[$key])) {
                         wc_add_notice(_x('Please enter a valid postcode/ZIP', 'revocation-form', 'woocommerce-germanized'), 'error');
                     }
                 } else {
                     if (isset($field['required']) && empty($_POST[$key])) {
                         wc_add_notice('<strong>' . $field['label'] . '</strong> ' . _x('is not valid.', 'revocation-form', 'woocommerce-germanized'), 'error');
                     }
                 }
                 if (!empty($_POST[$key])) {
                     if ($field['type'] == 'country') {
                         $countries = WC()->countries->get_countries();
                         $country = wc_clean($_POST[$key]);
                         $data[$key] = isset($countries[$country]) ? $countries[$country] : '';
                     } else {
                         $data[$key] = wc_clean($_POST[$key]);
                     }
                 }
             }
         }
     }
     $error = false;
     if (wc_notice_count('error') == 0) {
         wc_add_notice(_x('Thank you. We have received your Revocation Request. You will receive a conformation email within a few minutes.', 'revocation-form', 'woocommerce-germanized'), 'success');
         // Send Mail
         if ($mail = WC_germanized()->emails->get_email_instance_by_id('customer_revocation')) {
             $mail->trigger($data);
             // Send to Admin
             $data['mail'] = get_bloginfo('admin_email');
             $mail->trigger($data);
         }
     } else {
         $error = true;
     }
     ob_start();
     wc_print_notices();
     $messages = ob_get_clean();
     if ($error) {
         echo '<!--WC_START-->' . json_encode(array('result' => 'failure', 'messages' => isset($messages) ? $messages : '')) . '<!--WC_END-->';
     } else {
         if (is_ajax()) {
             echo '<!--WC_START-->' . json_encode(array('result' => 'success', 'messages' => isset($messages) ? $messages : '')) . '<!--WC_END-->';
         }
     }
     exit;
 }
<?php

/**
 * Customer revocation confirmation
 *
 * @author Vendidero
 * @version 1.0.0
 */
if (!defined('ABSPATH')) {
    exit;
}
// Exit if accessed directly
$fields = WC_GZD_Revocation::get_fields();
?>

<?php 
do_action('woocommerce_email_header', $email_heading);
?>

<p><?php 
echo _x('By sending you this email we confirm your Revocation. Please review your data.', 'revocation-form', 'woocommerce-germanized');
?>
</p>

<table cellspacing="0" cellpadding="0" style="width: 100%; vertical-align: top;" border="0">

	<?php 
if (!empty($fields)) {
    ?>

		<?php