Bck to Basket
Delivery Address
"Cash on Delivery only. Thank you!" 😊
Order Summary
Subtotal:
£0.00
Delivery Fee:
£2.00
Total:
£2.00
function validateStep(step) {
if (step === 1) {
let partySize = document.querySelector('#step1 select').value;
let date = document.querySelector('#step1 #datePicker').value;
let time = document.querySelector('#step1 #time').value;
let formattedTime = new Date(time).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
if (!partySize || !date || !time) {
alert('Please fill in all the fields in Step 1.');
return;
}
// Populate Step 3 with details from Step 1
document.querySelector('#confirm-date').textContent = date;
document.querySelector('#confirm-time').textContent = formattedTime;
document.querySelector('#confirm-partySize').textContent = partySize;
document.getElementById('booking-date').value = date;
document.getElementById('booking-time').value = formattedTime;
document.getElementById('booking-partySize').value = partySize;
// Show Step 2
document.getElementById('step1').classList.remove('active');
document.getElementById('step2').classList.add('active');
}
if (step === 2) {
let firstName = document.querySelector('#firstName').value;
let lastName = document.querySelector('#lastName').value;
let phone = document.querySelector('#phone').value;
let email = document.querySelector('#email').value;
// Check if all fields are filled
if (!firstName || !lastName || !phone || !email) {
alert('Please fill in all the fields in Step 2.');
return;
}
// Populate Step 3 with details from Step 2
document.querySelector('#confirmName').textContent = firstName + ' ' + lastName;
document.querySelector('#confirmPhone').textContent = phone;
document.querySelector('#confirmEmail').textContent = email;
document.getElementById('booking-name').value = firstName + ' ' + lastName;;
document.getElementById('booking-phone').value = phone;
document.getElementById('booking-email').value = email;
// Special request is optional
let specialRequest = document.querySelector('#specialRequest').value;
document.querySelector('#confirmRequest').textContent = specialRequest ? specialRequest : 'No special requests';
document.getElementById('booking-message').value = specialRequest ? specialRequest : 'No special requests';
// Show Step 3
document.getElementById('step2').classList.remove('active');
document.getElementById('step3').classList.add('active');
//alert(document.querySelector('#confirmName').textContent)
}
}
function nextStep(step) {
document.getElementById("step" + step).classList.remove("active");
document.getElementById("step" + (step + 1)).classList.add("active");
document.getElementById("tab" + step).classList.remove("active");
document.getElementById("tab" + (step + 1)).classList.add("active");
}
function prevStep(step) {
document.getElementById("step" + step).classList.remove("active");
document.getElementById("step" + (step - 1)).classList.add("active");
document.getElementById("tab" + step).classList.remove("active");
document.getElementById("tab" + (step - 1)).classList.add("active");
}
$(document).ready(function () {
$("#datePicker").datepicker({
dateFormat: "dd-mm-yy",
minDate: 0,
maxDate: "+1Y",
showAnim: "fadeIn",
});
});
$(document).ready(function () {
// Handle form submission
$("#addressForm").submit(function (event) {
event.preventDefault();
let allFilled = true;
$(".required-field").each(function () {
if ($(this).val().trim() === "") {
allFilled = false;
$(this).addClass("is-invalid");
} else {
$(this).removeClass("is-invalid");
}
});
if (allFilled) {
const data = {
fullName: $("#fullName").val(),
phoneNumber: $("#phoneNumber").val(),
email: $("#email").val(),
address: $("#address").val(),
city: $("#city").val(),
zip: $("#zip").val(),
deliveryNotes: $("#deliveryNotes").val(),
_token: $('meta[name="csrf-token"]').attr("content")
};
$.ajax({
url: "https://saltmangotree.uk/checkout",
type: "POST",
data: data,
success: function (response) {
if (response.success) {
$("#addressBlock").slideUp(); // Hide address section
$("#otpblock").slideDown(); // Show OTP section
} else {
alert("Failed to save address.");
}
},
error: function () {
alert("Error saving address.");
}
});
}
});
// Back to edit address
$("#backToAddress").click(function () {
$("#otpblock").slideUp(); // Hide OTP section
$("#addressBlock").slideDown(); // Show address section
});
});
$(document).ready(function () {
$("#phoneForm").submit(function (event) {
event.preventDefault();
let phone = $("#phoneNumber").val().trim();
console.log(phone);
if (phone.length >= 10) {
$("#phoneBlock").hide();
$("#otpBlock").slideDown();
}
else {
alert("Please enter a valid email id.");
}
});
});
$(document).ready(function () {
$("#otpForm").submit(function (event) {
event.preventDefault();
let otpEntered = $(".otp-input").map(function () { return $(this).val(); }).get().join("");
if (otpEntered.length === 4) {
// alert("Order Confirmed!");
} else {
alert("Please enter a valid OTP.");
}
});
// Back to Edit Phone Number
$("#backToPhone").click(function () {
$("#otpBlock").hide();
$("#phoneBlock").fadeIn();
});
// Auto-move to next OTP input
$(".otp-input").on("input", function () {
if ($(this).val().length === 1) {
$(this).next(".otp-input").focus();
}
});
$(".otp-input").on("keydown", function (event) {
if (event.key === "Backspace" && $(this).val() === "") {
$(this).prev(".otp-input").focus().val(""); // Move back and clear previous field
}
});
});
$(document).ready(function () {
$(".tab").click(function () {
let tabId = $(this).attr("data-tab");
$(".tab, .tab-content").removeClass("active");
$(this).addClass("active");
$("#" + tabId).addClass("active");
});
});
$(document).ready(function () {
$(".open-cart").click(function () {
$(".mycartlayer, .cartoverlay").addClass("active"); // Show Cart
$("body").addClass("hidescroll")
});
$(".cartoverlay, .close-cart").click(function () {
$(".mycartlayer, .cartoverlay").removeClass("active"); // Hide Cart
$("body").removeClass("hidescroll")
});
});
$(document).ready(function () {
$(".add-to-cart").click(function () {
let button = $(this);
$.ajax({
url: "https://saltmangotree.uk/add-to-cart",
type: 'POST',
data: {
_token: '1Q4cHtxgXUREwXtpAsm396rjQHl9oiNIeMpNoQke',
id: button.data("id"),
name: button.data("name"),
price: button.data("price"),
image: button.data("image")
},
success: function (response) {
if(response.success) {
loadCart();
}
}
});
});
function loadCart() {
$.get('https://saltmangotree.uk/cart/items', function (html) {
$(".cartbody").html(html); // replace current cart items
});
}
loadCart(); // Load on page load too
});
$(document).ready(function () {
// Increase quantity
$(document).on("click", ".counter button.increase", function () {
const itemId = $(this).data("id");
const $counter = $(this).closest(".counter").find(".cart-items");
let curVal = parseInt($counter.text()) || 0;
let newVal = curVal + 1;
$counter.text(newVal);
updateCart(itemId, newVal, $(this));
});
// Decrease quantity
$(document).on("click", ".counter button.decrease", function () {
const itemId = $(this).data("id");
const $counter = $(this).closest(".counter").find(".cart-items");
let curVal = parseInt($counter.text()) || 0;
let newVal = curVal > 1 ? curVal - 1 : 1; // Prevent going below 1
$counter.text(newVal);
updateCart(itemId, newVal, $(this));
});
function updateCart(id, quantity, $button) {
$.ajax({
url: "/update-cart",
method: "POST",
data: {
_token: $('meta[name="csrf-token"]').attr('content'),
id: id,
quantity: quantity
},
success: function (response) {
$("#cart-total").text(response.total); // update subtotal
// Now update the item's total price
const itemElement = $button.closest(".itemcart");
// Get price per unit from hidden data
const unitPrice = parseFloat(itemElement.find(".rt").attr('data-unit-price'));
if (!isNaN(unitPrice)) {
const newItemTotal = (unitPrice * quantity).toFixed(2);
itemElement.find(".rt").text(`£${newItemTotal}`);
}
},
error: function () {
alert("Failed to update cart.");
}
});
}
});
$(document).on("click", ".delete-item", function () {
const button = $(this);
const itemId = button.data("id");
const url = button.data("url");
if (confirm("Are you sure you want to remove this item from the cart?")) {
$.ajax({
url: url,
method: "POST",
data: {
_token: $('meta[name="csrf-token"]').attr('content')
},
success: function (response) {
// Remove the item visually
button.closest(".itemcart").remove();
// Update subtotal
$("#cart-total").text('£' + response.total.toFixed(2));
},
error: function () {
alert("Failed to delete item.");
}
});
}
});
$('#phoneForm').on('submit', function(e) {
e.preventDefault();
const email = $('#email').val();
$.post("https://saltmangotree.uk/send-otp", {
_token: '1Q4cHtxgXUREwXtpAsm396rjQHl9oiNIeMpNoQke',
email: email
}, function(res) {
if (res.success) {
$('#phoneBlock').hide();
$('#otpBlock').removeClass('hidden');
} else {
alert('Failed to send OTP');
}
}).fail(function(err) {
alert('Error: ' + err.responseJSON.message);
});
});
$('#confirmOtpBtn').on('click', function(e) {
e.preventDefault();
const otp = $('.otp-input').map(function() {
return this.value;
}).get().join('');
$.post("https://saltmangotree.uk/verify-otp", {
_token: '1Q4cHtxgXUREwXtpAsm396rjQHl9oiNIeMpNoQke',
otp: otp
}, function(res) {
console.log("Response:", res);
if (res.success && res.redirect) {
window.location.href = res.redirect;
} else {
alert(res.message || 'Something went wrong.');
}
}).fail(function(xhr, status, error) {
console.error("AJAX Error:", status, error);
console.error("Response Text:", xhr.responseText);
alert('Server error occurred. Please try again.');
});
});