Fix
This commit is contained in:
@@ -27,7 +27,12 @@ $(document).ready(function() {
|
||||
$('.products-total').text(productsTotal + ' ₽');
|
||||
$('.summary-count').text(totalCount);
|
||||
$('.total-count').text(totalCount + ' шт.');
|
||||
$('.cart-count').text(totalCount);
|
||||
if ($('.cart-count').length) {
|
||||
$('.cart-count').text(totalCount);
|
||||
}
|
||||
if ($('#cartCount').length) {
|
||||
$('#cartCount').text(totalCount);
|
||||
}
|
||||
|
||||
const finalTotal = productsTotal + cart.delivery - cart.discount;
|
||||
$('.final-total').text(finalTotal + ' ₽');
|
||||
@@ -282,13 +287,46 @@ $(document).ready(function() {
|
||||
return;
|
||||
}
|
||||
|
||||
$(this).prop('disabled', true).text('ОБРАБОТКА...');
|
||||
const $btn = $(this);
|
||||
$btn.prop('disabled', true).text('ОБРАБОТКА...');
|
||||
|
||||
setTimeout(() => {
|
||||
showMessage('#order-success', 5000);
|
||||
$(this).prop('disabled', false).text('ОФОРМИТЬ ЗАКАЗ');
|
||||
// Собрать данные заказа
|
||||
const orderData = {
|
||||
full_name: $('#fullname').val().trim(),
|
||||
phone: $('#phone').val().trim(),
|
||||
email: $('#email').val().trim(),
|
||||
region: $('#region').val().trim(),
|
||||
address: $('#address').val().trim(),
|
||||
delivery_method: $('input[name="delivery"]:checked').val(),
|
||||
comment: $('#comment').val().trim()
|
||||
};
|
||||
|
||||
}, 2000);
|
||||
// Отправить на сервер
|
||||
$.ajax({
|
||||
url: 'api/process_order.php',
|
||||
method: 'POST',
|
||||
data: orderData,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
showMessage('#order-success', 5000);
|
||||
$('#order-success').text('Заказ успешно оформлен! Номер заказа: ' + (response.order_id || ''));
|
||||
// Очистить корзину и форму
|
||||
setTimeout(() => {
|
||||
window.location.href = 'catalog.php';
|
||||
}, 2000);
|
||||
} else {
|
||||
showMessage('#form-error', 5000);
|
||||
$('#form-error').text(response.message || 'Ошибка оформления заказа').removeClass('success').addClass('error');
|
||||
$btn.prop('disabled', false).text('ОФОРМИТЬ ЗАКАЗ');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
showMessage('#form-error', 5000);
|
||||
$('#form-error').text('Ошибка сервера. Попробуйте позже.').removeClass('success').addClass('error');
|
||||
$btn.prop('disabled', false).text('ОФОРМИТЬ ЗАКАЗ');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#phone').on('input', function() {
|
||||
|
||||
@@ -226,7 +226,7 @@ $(document).ready(function() {
|
||||
$('.login-btn').on('click', function() {
|
||||
showMessage('warning', 'Переход к форме входа...');
|
||||
setTimeout(() => {
|
||||
window.location.href = 'вход.php';
|
||||
window.location.href = 'login.php';
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user