File "verificare-anaf.php"
Full path: /home/kosmetik/public_html/wp-content/plugins/custom-dbx/modules/verificare-anaf.php
File
size: 1.5 B
MIME-type: text/x-php
Charset: utf-8
Download Open Edit Advanced Editor Back
<?php
add_action('wp_footer', 'change_checkout_fields_script');
function change_checkout_fields_script()
{
if (is_checkout() && !is_wc_endpoint_url()) {
?>
<script type="text/javascript">
jQuery(function($){
var tip_pers = 'pers-jur';
var cui_field = $('#cui');
cui_field.on('change', function () {
$('body').trigger('update_checkout');
var reg_com = $('#nr_reg_com');
var nume_firma = $('#billing_company');
var address = $('#billing_address_1');
var cod_postal = $('#billing_postcode');
var url = 'https://api.openapi.ro/api/companies/';
url += cui_field.val();
request = $.ajax({
type: 'GET',
headers: {"x-api-key": "uocP79wP6Eo4S32CKHR5dFVsMDxJJFC56GuoiyoNqGCruQ1TYw"},
url: url });
request.done(function (response, textStatus, jqXHR){
console.log(response);
if(response.cif){
reg_com.val(response.numar_reg_com);
r//eg_com.prop('disabled', true);
nume_firma.val(response.denumire);
//nume_firma.prop('disabled', true);
address.val(response.adresa);
//cod_postal.val(response.cod_postal);
}
});
});
});
</script>
<?php
}
}