I am trying to resolve a calculation in my Ticket Template and I am looking for help please.
UK Post Code = AA1 2ZZ
Order Amount = 4.75
Minimum order = 5.00 within AA1 area
Minimum order outside AA1 area is calculated on distance
Distance : {ENTITY DATA:Customer:Distance}
PostCode : {ENTITY DATA:Customer:PostCode}
Total Bill : {TICKET TOTAL}
I have these which work but I am finding it difficult to combine them
I can extract the 1st 3 Characters of the Post Code:
[="{ENTITY DATA:Customer:PostCode}".substr(0,3)] = AA1
I can Check the value of sale, if less tan 5.00 then 5.00 or else the Total:
[={TICKET TOTAL} < 5.00 ? “5.00” : “{TICKET TOTAL}” ]
What I am trying to do is this to combine them like below.
If
Postcode = AA1 and Total less than 5.00
then print 5.00
else
if
distance More than 3 and Total less than (value of Distance x 5)
then print (value of Distance x 5)
else
print amount
endif
endif
Hope that makes sense and someone can help me.
Thank you.
How does distance come from postcode ?
I missed explaining that this is for deliveries. Distance is calculated from the shop to the customers address.
So you have the distance as a number? Or list of postcodes you can calculate using?
A formula is pointless without a way to turn postcode to a number, postcode obviously doesn’t multiply.
You just say value of distance. Which isn’t a calculation
I have the distance in field {ENTITY DATA:Customer:Distance} I use the maps.googleapis.com to calculate it from the post code.
I have worked it out by chance what I needed was the & NOT and.
Total:|[=("{ENTITY DATA:Customer:PostCode}".substr(0,3) == “AA1”) & ("{TICKET TOTAL}" < 5 ) ? “Minimum 5.00” : “{ENTITY DATA:Customer:Distance}”.substr(0,2)*5 > {TICKET TOTAL} ? “{ENTITY DATA:Customer:Distance}”.substr(0,2)*5 : “{TICKET TOTAL}” ]
I have another issue with this, the format of the result displays as a rounded figure, no trailing zero’s, eg 20 instaed of 20.00.
I am sure that this must be easy but cannot see how.
Thanks