Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Diego Versiani

    (@diegoversiani)

    Hi @caiopiva1234,

    Thanks for the feedback!

    We had other users report issues with the plugin “Autocomplete Address for WooCommerce by Fernando Acosta”, we tried to fix these compatibility issues but changes are needed on their side for it to work properly with Fluid Checkout.

    However, being honest with you, it is very unlikely that we’ll consider pursuing to add compatibility with that plugin any time soon.

    As an alternative, you could try our plugin Google Address Autocomplete for WooCommerce which is 100% compatible with Fluid Checkout and all other add-ons.

    With it, your customers will be able to autocomplete their addresses with data from the Google Places API or Brasil API, using the Street Address field or CEP field respectively.

    I’m closing this topic for now.

    Best,
    Diego.

    Add this code to your functions.php and watch the magic happen:

    function?via_cep_autocomplete_script_fluid_checkout()?{

    ????if?(is_checkout())?{

    ?????????>

    ????????<script?type="text/javascript">

    ????????????jQuery(document).ready(function($)?{

    ????????????????function?buscarCep(cepField,?addressFieldPrefix)?{

    ????????????????????var?cep?=?cepField.val().replace(/\D/g,?'');

    ????????????????????if?(cep?!=?"")?{

    ????????????????????????var?validacep?=?/^[0-9]{8}$/;

    ????????????????????????if?(validacep.test(cep))?{

    ????????????????????????????$.getJSON("https://viacep.com.br/ws/"?+?cep?+?"/json/?callback=?",?function(dados)?{

    ????????????????????????????????if?(!("erro"?in?dados))?{

    ????????????????????????????????????$('input[name="'+addressFieldPrefix+'address_1"]').val(dados.logradouro);

    ????????????????????????????????????$('input[name="'+addressFieldPrefix+'neighborhood"]').val(dados.bairro);

    ????????????????????????????????????$('input[name="'+addressFieldPrefix+'city"]').val(dados.localidade);

    ????????????????????????????????????$('input[name="'+addressFieldPrefix+'state"]').val(dados.uf).change();

    ????????????????????????????????}?else?{

    ????????????????????????????????????alert("CEP?n?o?encontrado.");

    ????????????????????????????????}

    ????????????????????????????});

    ????????????????????????}?else?{

    ????????????????????????????alert("Formato?de?CEP?inválido.");

    ????????????????????????}

    ????????????????????}

    ????????????????}

    ????????????????function?initCepAutocomplete()?{

    ????????????????????$('body').on('blur',?'input[name="billing_postcode"]',?function()?{

    ????????????????????????buscarCep($(this),?'billing_');

    ????????????????????});

    ????????????????????$('body').on('blur',?'input[name="shipping_postcode"]',?function()?{

    ????????????????????????buscarCep($(this),?'shipping_');

    ????????????????????});

    ????????????????}

    ????????????????$(document.body).on('updated_checkout',?function()?{

    ????????????????????initCepAutocomplete();

    ????????????????});

    ????????????????initCepAutocomplete();

    ????????????});

    ????????</script>

    ????????<?php

    ????}

    }

    add_action('wp_footer',?'via_cep_autocomplete_script_fluid_checkout');
    Thread Starter caiopiva1234

    (@caiopiva1234)

    @lucasaffonso0 You’re the man. People like this in the WP community move us forward.Tks

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.