PHP Classes

File: assets/js/frontend/autofill-address.min.js

Recommend this page to a friend!
  Classes of Julio Cezar Kronbauer   PHP WooCommerce Correios   assets/js/frontend/autofill-address.min.js   Download  
File: assets/js/frontend/autofill-address.min.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: PHP WooCommerce Correios
Woocommerce plugin for shipping via Correios
Author: By
Last change:
Date: 7 years ago
Size: 1,626 bytes
 

Contents

Class file image Download
/*! * WooCommerce Correios Autofill Brazilian 2016. * * Autofill address with postcodes. * * Version: 3.0.0 */ jQuery(function(a){var b={init:function(){this.autofill("billing",!0),a(document.body).on("blur","#billing_postcode",function(){b.autofill("billing")}),a(document.body).on("blur","#shipping_postcode",function(){b.autofill("shipping")})},block:function(){a("form.checkout, form#order_review").addClass("processing").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},unblock:function(){a("form.checkout, form#order_review").removeClass("processing").unblock()},autofill:function(c,d){if(d=d||!1,a("#"+c+"_postcode").length){var e=a("#"+c+"_postcode").val().replace(".","").replace("-",""),f=a("#"+c+"_country").val(),g=a("#"+c+"_address_1").val(),h="yes"===WCCorreiosAutofillAddressParams.force?!0:0===g.length;""!==e&&8===e.length&&"BR"===f&&h&&(b.block(),a.ajax({type:"GET",url:WCCorreiosAutofillAddressParams.url+"&postcode="+e,dataType:"json",contentType:"application/json",success:function(a){if(a.success&&(b.fillFields(c,a.data),d)){var e="billing"===c?"shipping":"billing";b.fillFields(e,a.data)}b.unblock()}}))}},fillFields:function(b,c){a("#"+b+"_address_1").val(c.address).change(),a("#"+b+"_neighborhood").length?a("#"+b+"_neighborhood").val(c.neighborhood).change():a("#"+b+"_address_2").val(c.neighborhood).change(),a("#"+b+"_city").val(c.city).change(),a("#"+b+"_state option:selected").attr("selected",!1).change(),a("#"+b+'_state option[value="'+c.state+'"]').attr("selected","selected").change(),a("#"+b+"_state").trigger("liszt:updated").trigger("chosen:updated")}};b.init()});