Question:
[Assistance in building an automated tour calculation App]
Product:
[Wix Editor.]
What are you trying to achieve:
[Eliminating in preparing tour calculation in time, what i need is to put a user input then the app calculate the total costs.]
What have you already tried:
[I have started but stuck on the way and using this wix site to see if I can proceed or collaborate with some one to do so.]
Additional information:
[Just a tour consultant in Tanzania and willing to overcome this challenge in the tourism field in Tanzania.]
Here’s a basic structure to calculate total tour costs:
$w.onReady(function () {
// Add event listener for calculate button
$w(‘#calculateButton’).onClick(() => {
calculateTourCost();
});
});
function calculateTourCost() {
// Get user inputs
const travelers = Number($w(‘#inputTravelers’).value);
const days = Number($w(‘#inputDays’).value);
const accommodationType = $w(‘#dropdownAccommodation’).value;
const activities = ;
// Collect selected activities
if ($w('#checkboxSafari').checked) activities.push("Safari");
if ($w('#checkboxHiking').checked) activities.push("Hiking");
// Pricing logic
const prices = {
accommodation: {
luxury: 200,
midRange: 100,
budget: 50
},
activities: {
Safari: 150,
Hiking: 100
},
transport: 50 // Per person per day
};
let accommodationCost = prices.accommodation[accommodationType] * travelers * days;
let activityCost = activities.reduce((total, activity) => total + prices.activities[activity], 0) * travelers;
let transportCost = prices.transport * travelers * days;
// Calculate total cost
let totalCost = accommodationCost + activityCost + transportCost;
// Display the result
$w('#totalCostText').text = `Total Cost: $${totalCost.toFixed(2)}`;
}