I am trying to add a second add to cart button at the bottom page opencart 3.x.
js:
Code: Select all
<script type="text/javascript"><!--
$('#button-cart1').on('click', function() {
$.ajax({
url: 'index.php?route=extension/soconfig/cart/add',
type: 'post',
data: $('#product input[type=\'text\'], #product input[type=\'hidden\'], #product input[type=\'radio\']:checked, #product input[type=\'checkbox\']:checked, #product select, #product textarea'),
dataType: 'json',
beforeSend: function() {
$('#button-cart1').button('loading');
},
complete: function() {
$('#button-cart1').button('reset');
},
success: function(json) {
$('.alert').remove();
$('.text-danger').remove();
$('.form-group').removeClass('has-error');
if (json['error']) {
if (json['error']['option']) {
for (i in json['error']['option']) {
var element = $('#input-option' + i.replace('_', '-'));
if (element.parent().hasClass('input-group')) {
element.parent().after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
} else {
element.after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
}
}
}
if (json['error']['recurring']) {
$('select[name=\'recurring_id\']').after('<div class="text-danger">' + json['error']['recurring'] + '</div>');
}
// Highlight any found errors
$('.text-danger').parent().addClass('has-error');
}
if (json['success']) {
$('.text-danger').remove();
$('#wrapper').before('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="fa fa-close close" data-dismiss="alert"></button></div>');
$('#cart .total-shopping-cart ').html(json['total'] );
$('#cart > ul').load('index.php?route=common/cart/info ul li');
timer = setTimeout(function () {
$('.alert').addClass('fadeOut');
}, 4000);
$('.so-groups-sticky .popup-mycart .popup-content').load('index.php?route=extension/module/so_tools/info .popup-content .cart-header');
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
//--></script>
Code: Select all
<input type="button" value="{{ button_cart }}" data-loading-text="{{ text_loading }}" id="button-cart1" class="btn btn-mega btn-lg">
I want to use in a div that appears at the bottom of the page when you scroll past the add to cart button on the page so there is always one in view for the customer.
thanks in advance