I’ve gone through a few topics to see if there was anything I can find relating to auto surcharges on specific days(Such as weekends) but could not find much.
Only thing I found close was the use of triggers.
I will share my progress here, but I just wanted to know, what would be the easiest way to deal with auto surcharge applications?
For example I’d like to apply a surcharge of 10% on weekends or special holidays such as valentines day etc.
Would the use of triggers be an easier way, or use of order tags with custom constraint rules, maybe a button that triggers a price change for the day upon press, which I can create an auto command to switch on & off type of thing.
Just would like to get some ideas to figure out the best way to go about this.
Lately it’s been a hot topic among a few of our clients so I figured I’d ask.
I imagine you could set-up an JavaScript array of dates in a script and then use a {CALL:} in a contrainst to have some JS logic to return “ChargeTheBuggers” or “BeNice” depending on if today’s date is either in the array or if the day of the current week equals a certain value.
If the contraint returns true, then use an action to add an Order Tag with a rate specified.
// The various functions here will be used
// in rules to handle surchaging on certain days
function whatDayIsToday(){
var d = new Date();
var n = d.getDay();
return n
}
Ultimately you probably want all the logic inside your script… This should mean that the script will either give a return value of “ChargeThem” or “DontChargeThem”… You will need to look at various generic JS tutorials (wider than just here within SambaPOS) to see how you would build out this logic.
I am thinking (psuedo code)…
today = new date = today
day = day from today
set ReturnVal = DontChargeThem
set arrats
set array BadDays [Sat, Sun]
set array BadDateMonths [25/12, 14/02, 01/01]
set array BadDateMonthYears [04/03/2019, 06/03/2020, 10/03/2021]
If day is in BayDays then ReturnVal = ChargeThem
If datemonth(today) is in BadDateMonths then ReturnVal = ChargeThem
If today is in BadDateMonthYears then ReturnVal = ChargeThem
return ReturnVal
The reason I have used two different arrays to hold the dates is that some dates are chargable every year (valentines day)… But others might move year-by-year (easter - or even Friday and Saturday nights near valentines day).
Also even if you don’t go down the order tag route, this script idea is probably going to be pretty important to actually build out the underlying logic of whether or not the surcharge should be applied.
You shouldn’t need a script, even simpler than that.
You can just use constraint with date based constraints.
Look for happy hour tutorial without triggers, think it was one of Qs.
Along the lines of
{DATE:ddd} = Mon|Tue|Wed etc
Or {DATE:ddMM} = 1302
Here it is.
His setup was a little more complicated than any happy hours I have done which just used price list and update price list on order added with time and date constraints.
The key part I refer to is like in this screenshot. Just the constraints not the rest.
Hmmm Im more confident with rules and constraints, i may take Q’s approach, but I think for the sake of learning too, I may try scripts too. I’ll try to put something together in next few days, see what I can come up with.
Would triggers not be a good method to use?