Hi all
I need to calculate a delivery price based on a set of rules outline below and my head is boxed trying to figure out how to do it. I will try to keep it as brief as possible to keep you insterested.
I suspect in advance this will be one of those posts that never gets a reply! :o)
My basket contains a total weight. eg. 15kg.
I have a table which stores a range of data (from, to, price, type are the fields in the mysql table), and the values of those fields I have displayed below:
Row 1: from = 0, to = 20, price = 5.00, type =1
Row 2: from = 21, to = 300, price = 0.15, type = 2
Row 3: from = 301, to = 500, price = 48, type =1
So if the total weight of my basket is 15kg, I would charge the customer £5 delivery using the rule in Row 1 above. Simple!
HOWEVER, if the weight of the basket is 22kg, I need to charge the customer £5 (for the first 20kg) and then 0.15p per KG for the remaining 7 kilograms of weight. (type = 2 means charge per item in the range, type = 1 means a surcharge).
For the life of me I cannot get this calculation written in PHP successfully.
Any ideas (or wishes of good luck ;O)) will be appreciated.
KBC