function valide_checkout_fields() { $billing_persontype = isset($_POST['billing_persontype']) ? $_POST['billing_persontype'] : 0; if ($billing_persontype == 1) { if (empty($_POST['billing_cpf'])) { wc_add_notice(sprintf('<strong>%s</strong> %s.', __('CPF', $domain), __('é um campo obrigatório', $domain)), 'error'); } if (!empty($_POST['billing_cpf']) && !WooCommerceNFe_Format::is_cpf($_POST['billing_cpf'])) { wc_add_notice(sprintf('<strong>%s</strong> %s.', __('CPF', $domain), __('informado não é válido', $domain)), 'error'); } } if ($billing_persontype == 2) { if (empty($_POST['billing_cnpj'])) { wc_add_notice(sprintf('<strong>%s</strong> %s.', __('CNPJ', $domain), __('é um campo obrigatório', $domain)), 'error'); } if (empty($_POST['billing_company'])) { wc_add_notice(sprintf('<strong>%s</strong> %s.', __('Empresa', $domain), __('é um campo obrigatório', $domain)), 'error'); } if (!empty($_POST['billing_cnpj']) && !WooCommerceNFe_Format::is_cnpj($_POST['billing_cnpj'])) { wc_add_notice(sprintf('<strong>%s</strong> %s.', __('CNPJ', $domain), __('informado não é válido', $domain)), 'error'); } } }