redfoxbuilders
Forum Replies Created
-
Hello @codepeople
Thank you for the great feedback, your coding definitley makes it easier to run. We had to code it the original way to handle the complex scenarios where ceilings and skirting boards can be selected either with or without room selections, to make sure the costs are calculated correctly. Since almost all rooms in the UK usually have skirting boards we had to times it by bedrooms, bathrooms, and the other areas of the property. However there is also the option that if a customer just wants to have their ceilings painted only and also only have their skirting boards painted they can chooses those options.
So the original drop down bedrooms, bathrooms, other rooms of the property only include prices for walls making it easier to split the cost calculator for other types of painting.
Our code also includes parsing to handle undefined or zero values, logging for easier debugging, specific adjustments for bedroom costs, and iterative calculations for dynamic pricing based on selected options. These features make sure the costs are calculated accurately and allows some flexibility
Please check the final build here, we are still working out the kinks
Instant Price Calculator Residential Painting and Decorating (redfoxbuilders.co.uk)
Your plugin is amazing and I can’t wait to spread it to more people!!
Thank you Author!
Okay I got it working except for one last thing. Still fixing a few issues
This is the final code after hours trying to get it to work. So if anyone wants to use it for calculating trade work, they can.
(function(){
var baseAmount = 250;
var totalPrice = baseAmount;
// Get field values directly by their names and parse as needed
var bedrooms = parseFloat(fieldname16|v) || 0;
var bathrooms = parseFloat(fieldname47|v) || 0;
var propertyType = parseFloat(fieldname18|v) || 0;
var occupied = parseFloat(fieldname17|v) || 0;
var additionalRooms = fieldname20|v || [];
var extraPainting = fieldname21|v || [];
var doors = parseInt(fieldname25|v) || 0;
var windows = parseInt(fieldname29|v) || 0;
var repairs = parseFloat(fieldname22|v) || 0;
var congestionZone = parseFloat(fieldname44|v) || 0;
var parkingAvailable = parseFloat(fieldname45|v) || 0;
// Adjust bedroom cost
var bedroomCost = 0;
if (bedrooms == 300) {
bedroomCost = 180;
} else {
bedroomCost = bedrooms;
}
// Log field values to the console
console.log("Bedrooms: ", bedroomCost);
console.log("Bathrooms: ", bathrooms);
console.log("Property Type: ", propertyType);
console.log("Occupied: ", occupied);
console.log("Additional Rooms: ", additionalRooms);
console.log("Extra Painting: ", extraPainting);
console.log("Doors: ", doors);
console.log("Windows: ", windows);
console.log("Repairs: ", repairs);
console.log("Congestion Zone: ", congestionZone);
console.log("Parking Available: ", parkingAvailable);
/* Calculate bedrooms cost */
totalPrice += bedroomCost;
/* Calculate bathrooms cost */
totalPrice += bathrooms;
/* Calculate property type cost */
totalPrice += propertyType;
/* Calculate occupied cost */
totalPrice += occupied;
/* Calculate additional rooms cost */
if (additionalRooms.length > 0) {
for (var i = 0; i < additionalRooms.length; i++) {
totalPrice += parseFloat(additionalRooms[i]) || 0;
}
}
/* Calculate extra painting cost */
var numBedrooms = bedroomCost ? 1 : 0;
var numBathrooms = bathrooms ? 1 : 0;
var numAdditionalRooms = additionalRooms.length;
var totalRooms = numBedrooms + numBathrooms + numAdditionalRooms;
// Adjust for ceiling and skirting board if no other rooms are selected
if (totalRooms === 0 && extraPainting.length > 0) {
if (extraPainting.includes("80")) totalRooms += 1;
if (extraPainting.includes("40")) totalRooms += 1;
}
var ceilingCost = 80 * totalRooms;
var skirtingBoardCost = 40 * totalRooms;
if (extraPainting.length > 0) {
for (var j = 0; j < extraPainting.length; j++) {
if (extraPainting[j] == "80") {
totalPrice += ceilingCost;
} else if (extraPainting[j] == "40") {
totalPrice += skirtingBoardCost;
}
}
}
/* Calculate doors cost */
totalPrice += 45 * doors;
/* Calculate windows cost */
totalPrice += 35 * windows;
/* Calculate repairs cost */
totalPrice += repairs;
/* Calculate congestion zone cost */
totalPrice += congestionZone;
/* Calculate parking available cost */
totalPrice += parkingAvailable;
// Log the final total price
console.log("Total Price: ", totalPrice);
return totalPrice;
})()How do I hide the numbers/hashtags symbols under phone number? I can’t seem to hide it without messing up that field. At the moment am using website phone number its not ideal
Thank you let me try that