- 25 Jun 2019, 18:04
#82540
Olá gostaria de saber se alguém já teve a experiência do formulário do checkout/checkout no tema default não aparecer os dados para inserir os dados de endereço.
Ao abrir o checkout/checkout e o cliente ainda não tiver cadastrado um endereço, o formulário que pertence ao arquivo payment_address iria aparecer para que fosse cadastrado um novo endereço.
De que maneira este formulário é chamado?
checkout/checkout.tpl
Ao abrir o checkout/checkout e o cliente ainda não tiver cadastrado um endereço, o formulário que pertence ao arquivo payment_address iria aparecer para que fosse cadastrado um novo endereço.
De que maneira este formulário é chamado?
checkout/checkout.tpl
Código: Selecionar todos
<?php echo $header; ?>
<?php if(!empty($hd_ct23)||($hd_ct13)) { ?>
<div class="container">
<div class="row">
<div class="col-sm-8"><?php echo $hd_ct23; ?></div>
<div class="col-sm-4 pull-right flip"><?php echo $hd_ct13; ?></div>
</div>
</div>
<?php } ?>
<div class="container">
<ul class="breadcrumb">
<?php foreach ($breadcrumbs as $breadcrumb) { ?>
<li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
<?php } ?>
</ul>
<?php if ($error_warning) { ?>
<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> <?php echo $error_warning; ?>
<button type="button" class="close" data-dismiss="alert">×</button>
</div>
<?php } ?>
<div class="row"><?php echo $column_left; ?>
<?php if ($column_left && $column_right) { ?>
<?php $class = 'col-sm-6'; ?>
<?php } elseif ($column_left || $column_right) { ?>
<?php $class = 'col-sm-9'; ?>
<?php } else { ?>
<?php $class = 'col-sm-12'; ?>
<?php } ?>
<div id="content" class="<?php echo $class; ?> pagina-checkout"><?php echo $content_top; ?>
<h1><?php echo $heading_title; ?></h1>
<div class="panel-group" id="accordion">
<!-- <div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title"><?php echo $text_checkout_option; ?></h4>
</div>
<div class="panel-collapse collapse" id="collapse-checkout-option">
<div class="panel-body"></div>
</div>
</div> -->
<div class="col-sm-8 col-xs-12 checkout-guias">
<div class="col-sm-6 col-xs-12 endereco-fatura-entrega">
<?php if (!$logged && $account != 'guest') { ?>
<div class="panel panel-default painel-checkout">
<div class="panel-heading">
<h4 class="panel-title"><?php echo $text_checkout_account; ?></h4>
</div>
<div class="panel-collapse collapse" id="collapse-payment-address">
<div class="panel-body"></div>
</div>
</div>
<?php } else { ?>
<div class="panel panel-default painel-checkout endereco-para-fatura col-sm-12 col-xs-12"><!-- Endereço Principal -->
<div class="panel-heading">
<h4 class="panel-title panel-title-endereco-principal"><span class="checkout-passo-a-passo"> 1 </span> <?php echo $text_checkout_payment_address; ?></h4>
</div>
<div class="panel-collapse collapse" id="collapse-payment-address">
<div class="panel-body paineis-int-checkout"></div>
</div>
<div class="panel-heading">
<h4 class="panel-title panel-title-endereco-entrega "><span class="checkout-passo-a-passo">2</span>
<?php echo $text_checkout_shipping_address; ?></h4>
</div>
<div class="panel-collapse collapse" id="collapse-shipping-address"><!-- Endereço para entrega -->
<div class="panel-body paineis-int-checkout col-sm-12"></div>
</div>
</div>
<?php } ?>
<?php if ($shipping_required) { ?><!-- Endereço para entrega -->
<!-- <div class="panel panel-default painel-checkout endereco-para-entrega col-sm-6 col-xs-12">
</div> -->
</div>
<div class="col-sm-6 col-xs-12 detalhe-frete-pagamento">
<div class="panel panel-default painel-checkout detalhes-do-frete col-sm-12 col-xs-12"><!--Detalhes do frete -->
<div class="panel-heading">
<h4 class="panel-title panel-title-detalhes-frete"><span class="checkout-passo-a-passo">3</span> <?php echo $text_checkout_shipping_method; ?></h4>
</div>
<div class="panel-collapse collapse" id="collapse-shipping-method">
<div class="panel-body paineis-int-checkout"></div>
</div>
</div>
<?php } ?>
</div>
<div class="col-sm-6 col-xs-12 detalhe-frete-pagamento">
<div class="panel panel-default painel-checkout detalhes-do-pagamento col-sm-12 col-xs-12"> <!-- Detalhes do pagamento -->
<div class="panel-heading">
<h4 class="panel-title"><span class="checkout-passo-a-passo">4</span> <?php echo $text_checkout_payment_method; ?></h4>
</div>
<div class="panel-collapse collapse" id="collapse-payment-method">
<div class="panel-body paineis-int-checkout"></div>
</div>
</div>
</div>
</div>
<div class="panel panel-default painel-checkout resumo col-sm-4 col-xs-12"><!--Resumo do pedido geral-->
<div class="panel-heading" style="background-color: #1c4869; padding-left: 10px;">
<h4 class="panel-title"><?php echo $text_checkout_confirm; ?></h4>
</div>
<div class="panel-collapse collapse" id="collapse-checkout-confirm">
<div class="panel-body paineis-int-checkout"></div>
</div>
</div>
<div id="divResumoFixa">
<div class="panel panel-default painel-checkout resumoTempoReal col-sm-4 col-xs-12">
<div class="resumocarrinho resumoestilo">
<div class="panel-heading" style="background-color: #1c4869; padding-left: 10px;">
<h4 class="panel-title"><?php echo $text_checkout_confirm; ?></h4>
</div>
<div class="panel-body paineis-int-checkout"></div>
</div>
<div class="resumoendereco resumoestilo" style="display: none;">
<div class="panel-body">
<div>
<h2>Endereço para entrega</h2>
<p></p>
</div>
</div>
</div>
<div class="resumofrete resumoestilo" style="display: none;">
<div class="panel-body">
<h2>Frete</h2>
<p></p>
</div>
</div>
</div>
</div>
</div>
<?php echo $content_bottom; ?></div>
<?php echo $column_right; ?></div>
</div>
<script type="text/javascript"><!--
$(document).on('change', 'input[name=\'account\']', function() {
if ($('#collapse-payment-address').parent().find('.panel-heading .panel-title > *').is('a')) {
if (this.value == 'register') {
$('#collapse-payment-address').parent().find('.panel-heading .panel-title').html('<a href="#collapse-payment-address" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><?php echo $text_checkout_account; ?> <i class="fa fa-caret-down"></i></a>');
} else {
$('#collapse-payment-address').parent().find('.panel-heading .panel-title').html('<a href="#collapse-payment-address" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><?php echo $text_checkout_payment_address; ?> <i class="fa fa-caret-down"></i></a>');
}
} else {
if (this.value == 'register') {
$('#collapse-payment-address').parent().find('.panel-heading .panel-title').html('<?php echo $text_checkout_account; ?>');
} else {
$('#collapse-payment-address').parent().find('.panel-heading .panel-title').html('<?php echo $text_checkout_payment_address; ?>');
}
}
});
<?php if (!$logged) { ?>
$(document).ready(function() {
$.ajax({
url: 'index.php?route=checkout/login',
dataType: 'html',
success: function(html) {
$('#collapse-checkout-option .panel-body').html(html);
$('#collapse-checkout-option').parent().find('.panel-heading .panel-title').html('<a href="#collapse-checkout-option" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><?php echo $text_checkout_option; ?> <i class="fa fa-caret-down"></i></a>');
$('a[href=\'#collapse-checkout-option\']').trigger('click');
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
<?php } else { ?>
$(document).ready(function() {
$.ajax({
url: 'index.php?route=checkout/payment_address',
dataType: 'html',
success: function(html) {
$('#collapse-payment-address .panel-body').html(html);/*1° passo*/
$('#collapse-payment-address').parent().find('.panel-heading .panel-title-endereco-principal').html('<a href="#collapse-payment-address" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><span class="checkout-passo-a-passo">1</span> <?php echo $text_checkout_payment_address; ?> <i class="fa fa-caret-down"></i></a>');
$('a[href=\'#collapse-payment-address\']').trigger('click');
/* Marcos - Mostrar carrinho */
$(".painel-checkout.resumo").hide();
$.ajax({
url: 'index.php?route=checkout/resumocart',
dataType: 'html',
success: function(html) {
$('.resumoTempoReal .resumocarrinho .panel-body').html(html);
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
/* Marcos - Mostrar carrinho */
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
<?php } ?>
// Checkout
$(document).delegate('#button-account', 'click', function() {
$.ajax({
url: 'index.php?route=checkout/' + $('input[name=\'account\']:checked').val(),
dataType: 'html',
beforeSend: function() {
$('#button-account').button('loading');
},
complete: function() {
$('#button-account').button('reset');
},
success: function(html) {
$('.alert, .text-danger').remove();
$('#collapse-payment-address .panel-body').html(html);
if ($('input[name=\'account\']:checked').val() == 'register') {
$('#collapse-payment-address').parent().find('.panel-heading .panel-title').html('<a href="#collapse-payment-address" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><?php echo $text_checkout_account; ?> <i class="fa fa-caret-down"></i></a>');
} else {
$('#collapse-payment-address').parent().find('.panel-heading .panel-title').html('<a href="#collapse-payment-address" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><?php echo $text_checkout_payment_address; ?> <i class="fa fa-caret-down"></i></a>');
}
$('a[href=\'#collapse-payment-address\']').trigger('click');
setTimeout(function(){
$("#label_campo_firstname").html("Nome")
$("#input-payment-firstname").attr("placeholder", "Nome");
$("#label_campo_4").html("CPF")
$("#input-payment-custom-field4").attr("placeholder", "CPF");
$("#radio_pessoa_2").prop( "checked", true );
mascara_cpf_cnpj("input-payment-custom-field4", "CPF");
}, 1000);
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
// Login
$(document).delegate('#button-login', 'click', function() {
$.ajax({
url: 'index.php?route=checkout/login/save',
type: 'post',
data: $('#collapse-checkout-option :input'),
dataType: 'json',
beforeSend: function() {
$('#button-login').button('loading');
},
complete: function() {
$('#button-login').button('reset');
},
success: function(json) {
$('.alert, .text-danger').remove();
$('.form-group').removeClass('has-error');
if (json['redirect']) {
location = json['redirect'];
} else if (json['error']) {
$('#collapse-checkout-option .panel-body').prepend('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + json['error']['warning'] + '<button type="button" class="close" data-dismiss="alert">×</button></div>');
// Highlight any found errors
$('input[name=\'email\']').parent().addClass('has-error');
$('input[name=\'password\']').parent().addClass('has-error');
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
// Register
$(document).delegate('#button-register', 'click', function() {
$.ajax({
url: 'index.php?route=checkout/register/save',
type: 'post',
data: $('#collapse-payment-address input[type=\'text\'], #collapse-payment-address input[type=\'date\'], #collapse-payment-address input[type=\'datetime-local\'], #collapse-payment-address input[type=\'time\'], #collapse-payment-address input[type=\'password\'], #collapse-payment-address input[type=\'hidden\'], #collapse-payment-address input[type=\'checkbox\']:checked, #collapse-payment-address input[type=\'radio\']:checked, #collapse-payment-address textarea, #collapse-payment-address select'),
dataType: 'json',
beforeSend: function() {
$('#button-register').button('loading');
},
success: function(json) {
$('.alert, .text-danger').remove();
$('.form-group').removeClass('has-error');
if (json['redirect']) {
location = json['redirect'];
} else if (json['error']) {
$('#button-register').button('reset');
if (json['error']['warning']) {
$('#collapse-payment-address .panel-body').prepend('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + json['error']['warning'] + '<button type="button" class="close" data-dismiss="alert">×</button></div>');
}
for (i in json['error']) {
var element = $('#input-payment-' + i.replace('_', '-'));
if ($(element).parent().hasClass('input-group')) {
$(element).parent().after('<div class="text-danger">' + json['error'][i] + '</div>');
} else {
$(element).after('<div class="text-danger">' + json['error'][i] + '</div>');
}
}
// Highlight any found errors
$('.text-danger').parent().addClass('has-error');
} else {
<?php if ($shipping_required) { ?>
var shipping_address = $('#payment-address input[name=\'shipping_address\']:checked').prop('value');
if (shipping_address) {
$.ajax({
url: 'index.php?route=checkout/shipping_method',
dataType: 'html',
success: function(html) {
// Add the shipping address
$.ajax({
url: 'index.php?route=checkout/shipping_address',
dataType: 'html',
success: function(html) {
$('#collapse-shipping-address .panel-body').html(html);
$('#collapse-shipping-address').parent().find('.panel-heading .panel-title').html('<a href="#collapse-shipping-address" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><?php echo $text_checkout_shipping_address; ?> <i class="fa fa-caret-down"></i></a>');
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
$('#collapse-shipping-method .panel-body').html(html);
$('#collapse-shipping-method').parent().find('.panel-heading .panel-title').html('<a href="#collapse-shipping-method" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><?php echo $text_checkout_shipping_method; ?> <i class="fa fa-caret-down"></i></a>');
$('a[href=\'#collapse-shipping-method\']').trigger('click');
/* $('#collapse-shipping-method').parent().find('.panel-heading .panel-title').html('<?php echo $text_checkout_shipping_method; ?>');
$('#collapse-payment-method').parent().find('.panel-heading .panel-title').html('<?php echo $text_checkout_payment_method; ?>');
$('#collapse-checkout-confirm').parent().find('.panel-heading .panel-title').html('<?php echo $text_checkout_confirm; ?>'); */
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
} else {
$.ajax({
url: 'index.php?route=checkout/shipping_address',
dataType: 'html',
success: function(html) {
$('#collapse-shipping-address .panel-body').html(html);
$('#collapse-shipping-address').parent().find('.panel-heading .panel-title').html('<a href="#collapse-shipping-address" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><?php echo $text_checkout_shipping_address; ?> <i class="fa fa-caret-down"></i></a>');
$('a[href=\'#collapse-shipping-address\']').trigger('click');
/* $('#collapse-shipping-method').parent().find('.panel-heading .panel-title').html('<?php echo $text_checkout_shipping_method; ?>');
$('#collapse-payment-method').parent().find('.panel-heading .panel-title').html('<?php echo $text_checkout_payment_method; ?>');
$('#collapse-checkout-confirm').parent().find('.panel-heading .panel-title').html('<?php echo $text_checkout_confirm; ?>'); */
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
<?php } else { ?>
$.ajax({
url: 'index.php?route=checkout/payment_method',
dataType: 'html',
success: function(html) {
$('#collapse-payment-method .panel-body').html(html);
$('#collapse-payment-method').parent().find('.panel-heading .panel-title').html('<a href="#collapse-payment-method" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><span class="checkout-passo-a-passo">4</span> <?php echo $text_checkout_payment_method; ?> <i class="fa fa-caret-down"></i></a>');
$('a[href=\'#collapse-payment-method\']').trigger('click');
// $('#collapse-checkout-confirm').parent().find('.panel-heading .panel-title').html('<?php echo $text_checkout_confirm; ?>');
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
<?php } ?>
$.ajax({
url: 'index.php?route=checkout/payment_address',
dataType: 'html',
complete: function() {
$('#button-register').button('reset');
},
success: function(html) {
$('#collapse-payment-address .panel-body').html(html);
$('#collapse-payment-address').parent().find('.panel-heading .panel-title').html('<a href="#collapse-payment-address" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><?php echo $text_checkout_payment_address; ?> <i class="fa fa-caret-down"></i></a>');
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
// Payment Address
$(document).delegate('#button-payment-address', 'click', function() {
$.ajax({
url: 'index.php?route=checkout/payment_address/save',
type: 'post',
data: $('#collapse-payment-address input[type=\'text\'], #collapse-payment-address input[type=\'date\'], #collapse-payment-address input[type=\'datetime-local\'], #collapse-payment-address input[type=\'time\'], #collapse-payment-address input[type=\'password\'], #collapse-payment-address input[type=\'checkbox\']:checked, #collapse-payment-address input[type=\'radio\']:checked, #collapse-payment-address input[type=\'hidden\'], #collapse-payment-address textarea, #collapse-payment-address select'),
dataType: 'json',
beforeSend: function() {
$('#button-payment-address').button('loading');
},
complete: function() {
$('#button-payment-address').button('reset');
},
success: function(json) {
$('.alert, .text-danger').remove();
if (json['redirect']) {
location = json['redirect'];
} else if (json['error']) {
if (json['error']['warning']) {
$('#collapse-payment-address .panel-body').prepend('<div class="alert alert-warning" id="alerta-validacao">' + json['error']['warning'] + '<button type="button" class="close" data-dismiss="alert">×</button></div>');
$([document.documentElement, document.body]).animate({
scrollTop: $(".panel-heading").offset().top
}, 2000);
}
for (i in json['error']) {
var element = $('#input-payment-' + i.replace('_', '-'));
if ($(element).parent().hasClass('input-group')) {
$(element).parent().after('<div class="text-danger">' + json['error'][i] + '</div>');
} else {
$(element).after('<div class="text-danger">' + json['error'][i] + '</div>');
$([document.documentElement, document.body]).animate({
scrollTop: $(".panel-heading").offset().top
}, 2000);
}
var element2 = $('#input-' + i.replace('_', '-'));// mostrar validação do firstname, lastname, telephone
if ($(element2).parent().hasClass('input-group')) {
$(element2).parent().after('<div class="text-danger">' + json['error'][i] + '</div>');//********
} else {
$(element2).after('<div class="text-danger">' + json['error'][i] + '</div>');
}
}
// Highlight any found errors
$('.text-danger').parent().parent().addClass('has-error');
} else {
//Marcos - Preenche endereço no resumo
var endereco = $("#payment-existing select option:selected").html();
$(".resumoendereco").show();
$(".resumoendereco p").html(endereco);
//Marcos - Preenche endereço no resumo
<?php if ($shipping_required) { ?>
$.ajax({
url: 'index.php?route=checkout/shipping_address',
dataType: 'html',
success: function(html) {
$('#collapse-shipping-address .panel-body').html(html);/* 2°passo - endereço para entrega*/
$('#collapse-shipping-address').parent().find('.panel-heading .panel-title-endereco-entrega').html('<a href="#collapse-shipping-address" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><span class="checkout-passo-a-passo">2</span> <span id="endereco-entrega-checkout"><?php echo $text_checkout_shipping_address; ?></span> <i class="fa fa-caret-down"></i></a>');
$('a[href=\'#collapse-shipping-address\']').trigger('click');
/*
$('#collapse-shipping-method').parent().find('.panel-heading .panel-title').html('<?php echo $text_checkout_shipping_method; ?>');
$('#collapse-payment-method').parent().find('.panel-heading .panel-title').html('<?php echo $text_checkout_payment_method; ?>');
$('#collapse-checkout-confirm').parent().find('.panel-heading .panel-title').html('<?php echo $text_checkout_confirm; ?>'); */
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
<?php } else { ?>
$.ajax({
url: 'index.php?route=checkout/payment_method',
dataType: 'html',
success: function(html) {
$('#collapse-payment-method .panel-body').html(html);
$('#collapse-payment-method').parent().find('.panel-heading .panel-title').html('<a href="#collapse-payment-method" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><span class="checkout-passo-a-passo">4</span> <?php echo $text_checkout_payment_method; ?> <i class="fa fa-caret-down"></i></a>');
$('a[href=\'#collapse-payment-method\']').trigger('click');
// $('#collapse-checkout-confirm').parent().find('.panel-heading .panel-title').html('<?php echo $text_checkout_confirm; ?>');
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
<?php } ?>
$.ajax({
url: 'index.php?route=checkout/payment_address',
dataType: 'html',
success: function(html) {
$('#collapse-payment-address .panel-body').html(html);
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
setTimeout(function(){
$("#button-payment-address, #collapse-payment-address").hide();
}, 1000);
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
// Shipping Address
$(document).delegate('#button-shipping-address', 'click', function() {
$.ajax({
url: 'index.php?route=checkout/shipping_address/save',
type: 'post',
data: $('#collapse-shipping-address input[type=\'text\'], #collapse-shipping-address input[type=\'date\'], #collapse-shipping-address input[type=\'datetime-local\'], #collapse-shipping-address input[type=\'time\'], #collapse-shipping-address input[type=\'password\'], #collapse-shipping-address input[type=\'checkbox\']:checked, #collapse-shipping-address input[type=\'radio\']:checked, #collapse-shipping-address textarea, #collapse-shipping-address select'),
dataType: 'json',
beforeSend: function() {
$('#button-shipping-address').button('loading');
},
complete: function() {
$('#button-shipping-address').button('reset');
},
success: function(json) {
$('.alert, .text-danger').remove();
if (json['redirect']) {
location = json['redirect'];
} else if (json['error']) {
$('#button-shipping-address').button('reset');
if (json['error']['warning']) {
$('#collapse-shipping-address .panel-body').prepend('<div class="alert alert-warning">' + json['error']['warning'] + '<button type="button" class="close" data-dismiss="alert">×</button></div>');
}
for (i in json['error']) {
var element = $('#input-shipping-' + i.replace('_', '-'));
if ($(element).parent().hasClass('input-group')) {
$(element).parent().after('<div class="text-danger">' + json['error'][i] + '</div>');
} else {
$(element).after('<div class="text-danger">' + json['error'][i] + '</div>');
$([document.documentElement, document.body]).animate({
scrollTop: $(".panel-heading").offset().top
}, 2000);
}
var element2 = $('#input-' + i.replace('_', '-'));// mostrar validação do firstname, lastname, telephone
if ($(element2).parent().hasClass('input-group')) {
$(element2).parent().after('<div class="text-danger">' + json['error'][i] + '</div>');//********
} else {
$(element2).after('<div class="text-danger">' + json['error'][i] + '</div>');
}
}
// Highlight any found errors
$('.text-danger').parent().parent().addClass('has-error');
//$('#button-shipping-address').button('loading');
} else {
$.ajax({
url: 'index.php?route=checkout/shipping_method',
dataType: 'html',
complete: function() {
$('#button-shipping-address').hide();
},
success: function(html) {
$('#collapse-shipping-method .panel-body').html(html);/*3° passo - detalhes do frete*/
$('#collapse-shipping-method').parent().find('.panel-heading .panel-title-detalhes-frete').html('<a href="#collapse-shipping-method" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><span class="checkout-passo-a-passo">3</span> <?php echo $text_checkout_shipping_method; ?> <i class="fa fa-caret-down"></i></a>');
$('a[href=\'#collapse-shipping-method\']').trigger('click');
/* $('#collapse-payment-method').parent().find('.panel-heading .panel-title').html('<?php echo $text_checkout_payment_method; ?>');
$('#collapse-checkout-confirm').parent().find('.panel-heading .panel-title').html('<?php echo $text_checkout_confirm; ?>'); */
$([document.documentElement, document.body]).animate({
scrollTop: $("#collapse-shipping-method").offset().top
}, 2000);
/* $.ajax({
url: 'index.php?route=checkout/shipping_address',
dataType: 'html',
success: function(html) {
$('#collapse-shipping-address .panel-body').html(html);
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
*/
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
/*
$.ajax({
url: 'index.php?route=checkout/payment_address',
dataType: 'html',
success: function(html) {
$('#collapse-payment-address .panel-body').html(html);
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
*/
}
setTimeout(function(){
$("#button-payment-address, #collapse-payment-address").hide();/*troca nome para 2° passo*/
//$("#button-shipping-address").button('loading');
}, 1000);
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
// Guest
$(document).delegate('#button-guest', 'click', function() {
$.ajax({
url: 'index.php?route=checkout/guest/save',
type: 'post',
data: $('#collapse-payment-address input[type=\'text\'], #collapse-payment-address input[type=\'date\'], #collapse-payment-address input[type=\'datetime-local\'], #collapse-payment-address input[type=\'time\'], #collapse-payment-address input[type=\'checkbox\']:checked, #collapse-payment-address input[type=\'radio\']:checked, #collapse-payment-address input[type=\'hidden\'], #collapse-payment-address textarea, #collapse-payment-address select'),
dataType: 'json',
beforeSend: function() {
$('#button-guest').button('loading');
},
success: function(json) {
$('.alert, .text-danger').remove();
if (json['redirect']) {
location = json['redirect'];
} else if (json['error']) {
$('#button-guest').button('reset');
if (json['error']['warning']) {
$('#collapse-payment-address .panel-body').prepend('<div class="alert alert-warning">' + json['error']['warning'] + '<button type="button" class="close" data-dismiss="alert">×</button></div>');
}
for (i in json['error']) {
var element = $('#input-payment-' + i.replace('_', '-'));
if ($(element).parent().hasClass('input-group')) {
$(element).parent().after('<div class="text-danger">' + json['error'][i] + '</div>');
} else {
$(element).after('<div class="text-danger">' + json['error'][i] + '</div>');
}
}
// Highlight any found errors
$('.text-danger').parent().addClass('has-error');
} else {
<?php if ($shipping_required) { ?>
var shipping_address = $('#collapse-payment-address input[name=\'shipping_address\']:checked').prop('value');
if (shipping_address) {
$.ajax({
url: 'index.php?route=checkout/shipping_method',
dataType: 'html',
complete: function() {
$('#button-guest').button('reset');
},
success: function(html) {
// Add the shipping address
$.ajax({
url: 'index.php?route=checkout/guest_shipping',
dataType: 'html',
success: function(html) {
$('#collapse-shipping-address .panel-body').html(html);
$('#collapse-shipping-address').parent().find('.panel-heading .panel-title').html('<a href="#collapse-shipping-address" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><?php echo $text_checkout_shipping_address; ?> <i class="fa fa-caret-down"></i></a>');
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
$('#collapse-shipping-method .panel-body').html(html);
$('#collapse-shipping-method').parent().find('.panel-heading .panel-title').html('<a href="#collapse-shipping-method" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><?php echo $text_checkout_shipping_method; ?> <i class="fa fa-caret-down"></i></a>');
$('a[href=\'#collapse-shipping-method\']').trigger('click');
/* $('#collapse-payment-method').parent().find('.panel-heading .panel-title').html('<?php echo $text_checkout_payment_method; ?>');
$('#collapse-checkout-confirm').parent().find('.panel-heading .panel-title').html('<?php echo $text_checkout_confirm; ?>'); */
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
} else {
$.ajax({
url: 'index.php?route=checkout/guest_shipping',
dataType: 'html',
complete: function() {
$('#button-guest').button('reset');
},
success: function(html) {
$('#collapse-shipping-address .panel-body').html(html);
$('#collapse-shipping-address').parent().find('.panel-heading .panel-title').html('<a href="#collapse-shipping-address" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><?php echo $text_checkout_shipping_address; ?> <i class="fa fa-caret-down"></i></a>');
$('a[href=\'#collapse-shipping-address\']').trigger('click');
/* $('#collapse-shipping-method').parent().find('.panel-heading .panel-title').html('<?php echo $text_checkout_shipping_method; ?>');
$('#collapse-payment-method').parent().find('.panel-heading .panel-title').html('<?php echo $text_checkout_payment_method; ?>');
$('#collapse-checkout-confirm').parent().find('.panel-heading .panel-title').html('<?php echo $text_checkout_confirm; ?>'); */
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
<?php } else { ?>
$.ajax({
url: 'index.php?route=checkout/payment_method',
dataType: 'html',
complete: function() {
$('#button-guest').button('reset');
},
success: function(html) {
$('#collapse-payment-method .panel-body').html(html);
$('#collapse-payment-method').parent().find('.panel-heading .panel-title').html('<a href="#collapse-payment-method" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><span class="checkout-passo-a-passo">4</span> <?php echo $text_checkout_payment_method; ?> <i class="fa fa-caret-down"></i></a>');
$('a[href=\'#collapse-payment-method\']').trigger('click');
// $('#collapse-checkout-confirm').parent().find('.panel-heading .panel-title').html('<?php echo $text_checkout_confirm; ?>');
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
<?php } ?>
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
// Guest Shipping
$(document).delegate('#button-guest-shipping', 'click', function() {
$.ajax({
url: 'index.php?route=checkout/guest_shipping/save',
type: 'post',
data: $('#collapse-shipping-address input[type=\'text\'], #collapse-shipping-address input[type=\'date\'], #collapse-shipping-address input[type=\'datetime-local\'], #collapse-shipping-address input[type=\'time\'], #collapse-shipping-address input[type=\'password\'], #collapse-shipping-address input[type=\'checkbox\']:checked, #collapse-shipping-address input[type=\'radio\']:checked, #collapse-shipping-address textarea, #collapse-shipping-address select'),
dataType: 'json',
beforeSend: function() {
$('#button-guest-shipping').button('loading');
},
success: function(json) {
$('.alert, .text-danger').remove();
if (json['redirect']) {
location = json['redirect'];
} else if (json['error']) {
$('#button-guest-shipping').button('reset');
if (json['error']['warning']) {
$('#collapse-shipping-address .panel-body').prepend('<div class="alert alert-danger">' + json['error']['warning'] + '<button type="button" class="close" data-dismiss="alert">×</button></div>');
}
for (i in json['error']) {
var element = $('#input-shipping-' + i.replace('_', '-'));
if ($(element).parent().hasClass('input-group')) {
$(element).parent().after('<div class="text-danger">' + json['error'][i] + '</div>');
} else {
$(element).after('<div class="text-danger">' + json['error'][i] + '</div>');
}
}
// Highlight any found errors
$('.text-danger').parent().addClass('has-error');
} else {
$.ajax({
url: 'index.php?route=checkout/shipping_method',
dataType: 'html',
complete: function() {
$('#button-guest-shipping').button('reset');
},
success: function(html) {
$('#collapse-shipping-method .panel-body').html(html);
$('#collapse-shipping-method').parent().find('.panel-heading .panel-title').html('<a href="#collapse-shipping-method" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><?php echo $text_checkout_shipping_method; ?> <i class="fa fa-caret-down"></i>');
$('a[href=\'#collapse-shipping-method\']').trigger('click');
/* $('#collapse-payment-method').parent().find('.panel-heading .panel-title').html('<?php echo $text_checkout_payment_method; ?>');
$('#collapse-checkout-confirm').parent().find('.panel-heading .panel-title').html('<?php echo $text_checkout_confirm; ?>'); */
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
$(document).delegate('#button-shipping-method', 'click', function() {/*detalhe do frete*/
$.ajax({
url: 'index.php?route=checkout/shipping_method/save',
type: 'post',
data: $('#collapse-shipping-method input[type=\'radio\']:checked, #collapse-shipping-method textarea'),
dataType: 'json',
beforeSend: function() {
$('#button-shipping-method').button('loading');
},
success: function(json) {
$('.alert, .text-danger').remove();
if (json['redirect']) {
location = json['redirect'];
} else if (json['error']) {
$('#button-shipping-method').button('reset');
if (json['error']['warning']) {
$('#collapse-shipping-method .panel-body').prepend('<div class="alert alert-danger">' + json['error']['warning'] + '<button type="button" class="close" data-dismiss="alert">×</button></div>');
}
} else {
//Marcos - Preenche frete no resumo
var frete = $('input[name=shipping_method]:checked').parent().find('.texto-frete').html();
$(".resumofrete").show();
$(".resumofrete p").html(frete);
$("#button-shipping-method, #collapse-shipping-address, #collapse-shipping-method").hide();
//Marcos - Preenche frete no resumo
$.ajax({
url: 'index.php?route=checkout/payment_method',
dataType: 'html',
complete: function() {
$('#button-shipping-method').button('reset');
},
success: function(html) {
$('#collapse-payment-method .panel-body').html(html);
$('#collapse-payment-method').parent().find('.panel-heading .panel-title').html('<a href="#collapse-payment-method" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><span class="checkout-passo-a-passo">4</span> <?php echo $text_checkout_payment_method; ?> <i class="fa fa-caret-down"></i></a>');
$('a[href=\'#collapse-payment-method\']').trigger('click');
/* $('#collapse-checkout-confirm').parent().find('.panel-heading .panel-title').html('<?php echo $text_checkout_confirm; ?>'); */
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
$(document).delegate('#button-payment-method', 'click', function() {
$.ajax({
url: 'index.php?route=checkout/payment_method/save',
type: 'post',
data: $('#collapse-payment-method input[type=\'radio\']:checked, #collapse-payment-method input[type=\'checkbox\']:checked, #collapse-payment-method textarea'),
dataType: 'json',
beforeSend: function() {
$('#button-payment-method').button('loading');
},
success: function(json) {
$('.alert, .text-danger').remove();
if (json['redirect']) {
location = json['redirect'];
} else if (json['error']) {
$('#button-payment-method').button('reset');
if (json['error']['warning']) {
$('#collapse-payment-method .panel-body').prepend('<div class="alert alert-danger">' + json['error']['warning'] + '<button type="button" class="close" data-dismiss="alert">×</button></div>');
}
} else {
/* MARCOS - Remove a div resumo auxiliar e mostra o resumo verdadeiro */
$("#divResumoFixa").remove();
$(".painel-checkout.resumo").show();
$([document.documentElement, document.body]).animate({
scrollTop: $(".painel-checkout.resumo").offset().top
}, 2000);
$("#button-payment-method").hide();
/* MARCOS - Remove a div resumo auxiliar e mostra o resumo verdadeiro */
$.ajax({
url: 'index.php?route=checkout/confirm',
dataType: 'html',
complete: function() {
$('#button-payment-method').button('reset');
},
success: function(html) {
$('#collapse-checkout-confirm .panel-body').html(html);
$('#collapse-checkout-confirm').parent().find('.panel-heading .panel-title').html('<a href="#collapse-checkout-confirm" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><?php echo $text_checkout_confirm; ?> <i class="fa fa-caret-down"></i></a>');
$('a[href=\'#collapse-checkout-confirm\']').trigger('click');
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
//--></script>
<?php echo $footer; ?>