'+json.neighborhood +' - '+ json.city + ' - ' + json.zone); if($('.second-step-address').length && $('.onestepcheckout-checkout').length){ $('.osc-address-load').hide(); /* update_three_block(); */ $('.btn-open-payment').removeClass('disabled').html('Continue'); } $('.edit_address').click(function(){ $('.return_all').hide(); $('.return_all_content').html(''); $('.field-complete').show(); }); }else{ if(json.notify_cep) { $('.text_cep_obs').html('
City code not found in our database
'); } else { $('#input-zone').addClass('select-disabled'); } if(json.notify_cep && json.block_cep) { $('#include_address_content > .text-center > .btn-primary').hide(); $('.osc-address-load').hide(); return; } $('.return_all').hide(); $('.return_all_content').html(''); $('.field-complete').show(); $('.osc-address-load').hide(); if($('.second-step-address').length && $('.onestepcheckout-checkout').length){ $('.osc-address-load').hide(); /* update_three_block(); */ $('.btn-open-payment').removeClass('disabled').html('Continue'); } } }else{ $('.second-step-address').fadeOut(); $('
City code not found in our database
').insertAfter('#text_cep_obs'); } $('.second-step-address').fadeIn(function(){ if($('.second-step-address').length && $('.onestepcheckout-checkout').length){ if (String(typeof (json.address)) == 'string' && json.address != '' && json.address != ' ') { $(`input[name="${checkout_name}[number_home]"]`).get(0).focus(); } else { $(`input[name="${checkout_name}[address_1]"]`).get(0).focus(); } } }); }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log(XMLHttpRequest.responseText); } }); } else { $('.second-step-address').fadeOut(); $('
City Code invalid! Verify that it was typed correctly
').insertAfter('#text_cep_obs'); } } $('button[id^=\'button-upload\']').click(function (event) { var node = $(this); var customer_id = 0; $('#form-upload').remove(); $('body').prepend(''); $('#form-upload input[name=\'file\']').trigger('click'); timer = setInterval(function () { if ($('#form-upload input[name=\'file\']').val() != '') { clearInterval(timer); $.ajax({ url: 'index.php?route=tool/upload&upload-option-id=' + node.data('upload-option-id'), type: 'post', dataType: 'json', data: new FormData($('#form-upload')[0]), cache: false, contentType: false, processData: false, beforeSend: function () { $(node).button('loading'); }, success: function (json) { $('.text-danger').remove(); $('.alert-success').remove(); if (json['error']) { $(node).button('reset'); $(node).parent().find('input').after('' + json['error'] + '
'); } if (json['success']) { var str = json.filename; console.log(str.length); var res = str.slice(-4); var res2 = str.slice(0, (str.length / 2)); console.log($(node).html(res2 + '(...)' + res)); /*$(node).parent().html('success');*/ $(node).html(res2 + '(...)' + res).addClass('btn btn-success').removeClass('disabled').removeAttr('disabled'); $(node).parent().find('input').attr('value', json['code']); } }, error: function (xhr, ajaxOptions, thrownError) { console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); } }); } }, 500); }); var data = new Date(); $('.mask-date').mask('99/99/9999'); $('.mask-datetime').mask('99/99/9999 00:00'); $('.mask-time').mask('00:00'); $('#input-postcode').mask('99999-999'); $(function () { $('#date').datetimepicker({ pickTime: false, format:'DD/MM/YYYY', defaultDate: data, }); }); $(function () { $('#time').datetimepicker({ pickDate: false, defaultDate: data.getHours() + ':' + data.getMinutes(), format:'HH:mm', minuteStep: 15, autoclose: true, minView: 0, maxView: 1, startView: 1, icons : { time: "fa fa-clock-o", date: "fa fa-calendar", up: "fa fa-arrow-up", down: "fa fa-arrow-down" } }); }); $(function () { $('#datetime').datetimepicker({ defaultDate: data, format:'DD/MM/YYYY HH:mm', minuteStep: 15, autoclose: true, minView: 0, maxView: 1, startView: 1, icons : { time: "fa fa-clock-o", date: "fa fa-calendar", up: "fa fa-arrow-up", down: "fa fa-arrow-down" } }); }); $('select[name=\'country_id\']').on('change', function() { $.ajax({ url: 'index.php?route=account/account/country&country_id=' + this.value, dataType: 'json', beforeSend: function() { $('select[name=\'country_id\']').after(' '); }, complete: function() { $('.fa-spin').remove(); }, success: function(json) { /* Antiga função de verificar a obrigatoriedade do CEP if (json['postcode_required'] == '1') { $('input[name=\'postcode\']').parent().parent().addClass('required'); } else { $('input[name=\'postcode\']').parent().parent().removeClass('required'); } */ if (json['postcode_required'] != '1') { $('#label-postcode').append('(opcional)'); } else { $('#label-postcode .optional').remove(); } html = ''; if (json['zone'] != '') { for (i = 0; i < json['zone'].length; i++) { html += ''; } } else { html += ''; } $('select[name=\'zone_id\']').html(html); }, error: function(xhr, ajaxOptions, thrownError) { alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText); } }); }); $(document).ready(function(e) { $('.second-step-address').hide(); }); $('textarea[id^="input-custom-field"], input[id^="input-custom-field"]').on("keyup", function (e) { $(this).val($(this).val().replace(/[^a-zA-Z0-9-./\//-záàâãéèêíïóôõöúçñÁÀÂÃÉÈÍÏÓÔÕÖÚÇÑ ]/gm, '')); }); function pessoaFisica(discount_physical_person,discount_legal_person,display_message_physical){ $('.osc-error').remove(); $('#label-rg_ie').css('display','none'); $('input[name=rg_ie]').css('display','none'); $('#label-cpf_cnpj').html('CPF'); $('#input-cpf_cnpj').mask("999.999.999-99"); $('#input-rg_ie').mask('AAAAAAAAAAAAAAA'); $('#input-cpf_cnpj').attr('placeholder','Digite seu CPF (Somente números)'); $('#label-firstname').html('Nome Completo'); $('input[name=firstname]').attr('placeholder','Digite seu nome completo'); $('#field-rg_ie').css('margin-bottom', '0px'); $('#field-lastname').css('display','none'); $('#ie_checked').css('display','none'); $('#field-cnpj_contact').css('display', 'none'); $('.sex-group').css('display', 'block'); if(screen.width < 768){ $('#label-cellphone').html('Celular / WhatsApp'); } else { $('#label-cellphone').html('Celular'); } $('#label-birthday .optional').remove(); $('input[name=cellphone]').attr('placeholder','Digite seu celular (Somente números)'); $('input[name=tellphone]').attr('placeholder','Digite seu telefone (Somente números)'); $('#label-telephone').html('Telefone(opcional)'); $('#buy-wholesale-field').hide(); if (discount_physical_person){ $('#buy-wholesale-field').show(); } if(display_message_physical === undefined) { display_message_physical = 0; } if(display_message_physical) { $('#info-analysis').show(); }else{ $('#info-analysis').hide(); } } function pessoaJuridica(discount_physical_person,discount_legal_person,display_message_legal){ $('.osc-error').remove(); $('#label-cpf_cnpj').html('CNPJ'); $('#input-cpf_cnpj').mask("99.999.999/9999-99"); $('#input-cpf_cnpj').attr('placeholder','Digite seu CNPJ (Somente números)'); $('#label-firstname').html('Razão Social'); $('input[name=firstname]').attr('placeholder','Digite sua razão social'); $('#input-rg_ie').mask('99999999999999999999'); $('#label-rg_ie').css('display','block'); $('input[name=rg_ie]').css('display','block'); $('#label-rg_ie').html('Inscrição Estadual'); $('input[name=rg_ie]').attr('placeholder','Digite sua Inscrição Estadual'); $('input[name=rg_ie]').attr('onKeyUp','this.value=this.value.replace(\/[^\\d]*\/gi,"");'); $('input[name=rg_ie]').parent('div').removeClass('col-sm-9'); $('input[name=rg_ie]').parent('div').addClass('col-sm-4'); $('#field-rg_ie').css('margin-bottom', '15px'); $('#field-lastname').css('display','block'); $('#field-cnpj_contact').css('display', 'block'); $('#ie_checked').css('display','block'); $('.sex-group').css('display', 'none'); $('#label-cellphone').html('Telefone / Celular'); $('input[name=cellphone]').attr('placeholder','Digite seu telefone ou seu celular (Somente números)'); $('input[name=tellphone]').attr('placeholder','Digite seu telefone adicional (Somente números)'); $('#label-telephone').html('Telefone Adicional(opcional)'); $('#label-birthday').append('(opcional)'); $('#buy-wholesale-field').hide(); if (discount_legal_person){ $('#buy-wholesale-field').show(); } if(display_message_legal === undefined) { display_message_legal = 0; } if(display_message_legal){ $('#info-analysis').show(); }else { $('#info-analysis').hide(); } } pessoaFisica('',''); if($('select[name=\'country_id\']').length){ $('select[name=\'country_id\']').trigger('change'); } $('#input-zone').on('change', function(){ var val = $(this).val(); $('#input-zone option').removeAttr('selected'); $('#input-zone').find('option[value='+val+']').prop('selected',true).attr('selected', true); }); $('#input-ie_checked').on('click',function(){ if($(this).is(':checked')){ $('input[name=rg_ie]').val('ISENTO'); }else{ $('input[name=rg_ie]').val(''); } }); zipCode = $('#input-postcode').val(); zipCodeInterval = 2500; $('#input-postcode').on('keypress click', function() { zipCodeInterval = 2500; }); setInterval(() => { if (zipCode != $('#input-postcode').val()) { zipCode = $('#input-postcode').val(); if (zipCode.replace(/\D/g, "").length == 8) { $('#btn-ok-cep').click(); } } }, zipCodeInterval);