{"id":1935,"date":"2022-08-11T11:54:07","date_gmt":"2022-08-11T09:54:07","guid":{"rendered":"https:\/\/www.areaweb.sk\/?p=1935"},"modified":"2022-09-27T09:28:05","modified_gmt":"2022-09-27T07:28:05","slug":"overenie-ic-dph-v-systeme-veis-cez-ajax-a-jquery","status":"publish","type":"post","link":"https:\/\/www.areaweb.sk\/cs\/overenie-ic-dph-v-systeme-veis-cez-ajax-a-jquery\/","title":{"rendered":"Overenie  IC DPH v syst\u00e9me VEIS cez AJAX a jQuery"},"content":{"rendered":"<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.areaweb2.pppcreative.sk\/wp-content\/uploads\/2022\/08\/ajax-jquery-1024x576.png\" alt=\"ajax jquery\" class=\"wp-image-1936\" width=\"656\" height=\"369\" srcset=\"https:\/\/www.areaweb.sk\/wp-content\/uploads\/2022\/08\/ajax-jquery-1024x576.png 1024w, https:\/\/www.areaweb.sk\/wp-content\/uploads\/2022\/08\/ajax-jquery-300x169.png 300w, https:\/\/www.areaweb.sk\/wp-content\/uploads\/2022\/08\/ajax-jquery-768x432.png 768w, https:\/\/www.areaweb.sk\/wp-content\/uploads\/2022\/08\/ajax-jquery-1536x864.png 1536w, https:\/\/www.areaweb.sk\/wp-content\/uploads\/2022\/08\/ajax-jquery-533x300.png 533w, https:\/\/www.areaweb.sk\/wp-content\/uploads\/2022\/08\/ajax-jquery-310x174.png 310w, https:\/\/www.areaweb.sk\/wp-content\/uploads\/2022\/08\/ajax-jquery-150x84.png 150w, https:\/\/www.areaweb.sk\/wp-content\/uploads\/2022\/08\/ajax-jquery.png 1800w\" sizes=\"auto, (max-width: 656px) 100vw, 656px\" \/><figcaption>ajax jquery<\/figcaption><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;script&gt;\nif (document.querySelector('.woocommerce-checkout') ){\nconsole.log('woocomerce-checkout');\n\njQuery(document).ready(function( $ ){\n    \/\/ Your code in here\n\n\tvar form2 = $(\"#woocommerce_eu_vat_number\");\n\tvar form3 = $(\"#billing_company_wi_id\");\n\t\/\/var form2 = $(\"#billing_dic\");\n\n\toverenie();\n\tform2.on('change', overenie);\n\tform3.on('change', overenie);\n\n\tfunction overenie (event) {\n\t\t\tconsole.log('spustene');\n\t\t\t  var req = $.ajax({\n\t\t\t\t\t\turl: \"https:\/\/domena.sk\/veis\/veis2.php\",\n\t\t\t\t\t\ttype: 'POST',\n\t\t\t\t\t\tdata: form2.serialize(),\n\t\t\t\t\t   error: function() {\n\t\t\t\t\t\t\t\tconsole.log('erroor')\n\t\t\t\t\t\t\t\tif(form2.val().length &gt; 0){\n\t\t\t\t\t\t\t\t\t$('#place_order').attr(\"disabled\", true);\n\t\t\t\t\t\t\t\t\tform2.css(\"border\",\"1px solid red\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t  \t\telse{\n\t\t\t\t\t\t\t\t\t $('#place_order').attr(\"disabled\", false);\n\t\t\t\t\t\t   \t\t\tform2.css(\"border\",\"1px solid #ddd\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t  success: function(data, status, xhr) {\n\t\t\t\t\t\t\t\/\/ handle success\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\n\t\t\t\treq.done(function bbb(data) {\n\t\t\t\t\tvar hodnota = $.parseJSON(data);\n\t\t\t\t\tconsole.log(hodnota)\n\t\t\t\t\tconsole.log(hodnota&#91;'valid'])\n\t\t\t\t\tif(hodnota&#91;'valid']==true){\n\t\t\t\t\t\tconsole.log('ideme')\n\t\t\t\t\t\t\/\/$('#billing_company').val(hodnota&#91;'name'])\n\t\t\t\t\t\t\/\/var mesto = hodnota&#91;'address'].split('\\n')&#91;1].split(\" \")\n\t\t\t\t\t\t\/\/$('#billing_address_1').val(hodnota&#91;'address'].split('\\n')&#91;0])\n\t\t\t\t\t\t\/\/$('#billing_city').val(mesto&#91;0])\n\t\t\t\t\t\t\/\/$('#billing_postcode').val(mesto&#91;1])\n\t\t\t\t\t\t$('#place_order').attr(\"disabled\", false);\n\t\t\t\t\t\tform2.css(\"border\",\"1px solid #ddd\");\n\t\t\t\t\t}\n\t\t\t\t\telse{\n \t\t\t\t\t\tconsole.log('neideme')\n\t\t\t\t\t\tform2.css(\"border\",\"1px solid #ddd\");\n\n\t\t\t\t\t\tif(form2.val().length &gt; 0){\n\t\t\t\t\t\t\t$('#place_order').attr(\"disabled\", true);\n\t\t\t\t\t\t\tform2.css(\"border\",\"1px solid red\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\n\t\n});\n\n}\n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n$ico = $_POST&#91;'billing_vat_number'];\n$icoKod = substr($ico,0,2);\n$icoCislo =substr($ico,2);\n\n$client = new SoapClient(\"http:\/\/ec.europa.eu\/taxation_customs\/vies\/checkVatService.wsdl\");\n\n\/\/ var_dump($client-&gt;checkVat(array(\n\/\/   'countryCode' =&gt; 'SK',\n\/\/   'vatNumber' =&gt; 2121115601\n\/\/ )));\n\n\n$request= $client-&gt;checkVat(array(\n    'countryCode' =&gt; $icoKod,\n    'vatNumber' =&gt; $icoCislo\n));\n\n\/\/print_r($request);\necho json_encode($request);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">N\u00e1hodn\u00e9 platn\u00e9 EU VAT \u010d\u00edsla na testovanie: <\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>SK2121115601<\/li><li>PL6292465417<\/li><li>HU12461660<br>CZ27903745<\/li><li>CZ530125060<\/li><li>RO14399840<\/li><li>RO11607939<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Na str\u00e1nke vyu\u017e\u00edvam plugin <strong><a href=\"https:\/\/woocommerce.com\/products\/eu-vat-number\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">WooCommerce EU VAT Number<\/a><\/strong>, ktor\u00fd po overen\u00ed di\u010d automaticky odr\u00e1ta da\u0148.<br>Na profi valid\u00e1ciu ostatn\u00fdch \u00fadajov v pokladni odpor\u00fa\u010dam foxentry.com<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Viac jQuery AJAX met\u00f3d n\u00e1jde\u0161 na : <a href=\"https:\/\/www.w3schools.com\/jquery\/jquery_ref_ajax.asp\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">https:\/\/www.w3schools.com\/jquery\/jquery_ref_ajax.asp <\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>ajax jquery <script data-no-auto-translation=\"\"> if (document.querySelector('.woocommerce-checkout') ){ console.log('woocomerce-checkout'); jQuery(document).ready(function( $ ){ \/\/ Your code in here var form2 = $(\"#woocommerce_eu_vat_number\"); var\u2026<\/p>","protected":false},"author":1,"featured_media":1936,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28,29,26],"tags":[],"class_list":["post-1935","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-js","category-php","category-woocomerce"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/www.areaweb.sk\/cs\/wp-json\/wp\/v2\/posts\/1935","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.areaweb.sk\/cs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.areaweb.sk\/cs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.areaweb.sk\/cs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.areaweb.sk\/cs\/wp-json\/wp\/v2\/comments?post=1935"}],"version-history":[{"count":0,"href":"https:\/\/www.areaweb.sk\/cs\/wp-json\/wp\/v2\/posts\/1935\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.areaweb.sk\/cs\/wp-json\/wp\/v2\/media\/1936"}],"wp:attachment":[{"href":"https:\/\/www.areaweb.sk\/cs\/wp-json\/wp\/v2\/media?parent=1935"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.areaweb.sk\/cs\/wp-json\/wp\/v2\/categories?post=1935"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.areaweb.sk\/cs\/wp-json\/wp\/v2\/tags?post=1935"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}