Answer the question
In order to leave comments, you need to log in
How to make sure that there is always one product in the cart by default in Opencart?
A site with one product, redirection to the cart is now implemented when you click on the buy button. Like this:
function addToCartQuick(product_id, quantity) {
$('.js-btn-buy').html('Переадресация в корзину...');
quantity = typeof (quantity) != 'undefined' ? quantity : 1;
$.ajax({
url: 'index.php?route=checkout/cart/add',
type: 'post',
data: 'product_id=' + product_id + '&quantity=' + quantity,
dataType: 'json',
success: function(json) {
$('.success, .warning, .attention, .information, .error').remove();
window.location.href = 'index.php?route=checkout/simplecheckout';
}
});
}
onclick="addToCartQuick('50');"
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question