campagnolo1
Technical User
Greetings,
I'm chasing my tail here trying to come up with a way to calculate a shipping fee.
Here is my situation: I need to calculate a fee for shipping an item. right now I have an if/else statement that checks if the cost of an order is between a certain amount (let's say 3k to 4k) and then return the shipping fee for that range. That's all fine since there are only 10 ranges that have individual fees. But if the order amount is over $5k then you add $6.25 to the last stated fee of 80.25 and then for each additional $1k you add $6.25. So if your order is between $1.6k to $5k the fee is 80.25. If the order is between $5k and $6k you add $6.25 to the 80.25 (=$86.50). If it's between $6k and $7k you add $6.25 to the $86.50.
Make sense? I hope! Now I'm trying to come up with a loop that will do this for me without having to write line after line until I get to $500,000. I'm doing baby steps at the moment, and this is where I'm at right now:
local numberVar bamount := 80.85;
local numberVar addamount = 6.25;
if Sum ({@ItemCost}) <= 20 then bamount := 0
else if Sum ({@ItemCost}) in 20 to 40 then 7.00
else if Sum ({@ItemCost}) in 40 to 100 then 19.45
else if Sum ({@ItemCost}) in 100 to 200 then 29.00
else if Sum ({@ItemCost}) in 200 to 350 then 45.60
else if Sum ({@ItemCost}) in 350 to 500 then 51.20
else if Sum ({@ItemCost}) in 500 to 750 then 58.20
else if Sum ({@ItemCost}) in 750 to 1000 then 65.15
else if Sum ({@ItemCost}) in 1000 to 1250 then 72.10
else if Sum ({@ItemCost}) in 1250 to 1600 then 76.65
else if Sum ({@ItemCost}) in 1600 to 5000 then 80.85
else if Sum ({@ItemCost}) in 5000 to 6000 then bamount := bamount + addamount
else if Sum ({@ItemCost}) in 6000 to 7000 then bamount := bamount + (addamount*2)
else if Sum ({@ItemCost}) in 7000 to 8000 then bamount := bamount + (addamount*3)
else if Sum ({@ItemCost}) in 8000 to 9000 then bamount := bamount + (addamount*4)
else if Sum ({@ItemCost}) in 9000 to 10000 then bamount := bamount + (addamount*5)
else if Sum ({@ItemCost}) in 10000 to 11000 then bamount := bamount + (addamount*6)
else if Sum ({@ItemCost}) in 12000 to 13000 then bamount := bamount + (addamount*7)
I know this is not a loop, but I can't figure out how to structure the loop.
Any help is greatly appreciated!
Chris
I'm chasing my tail here trying to come up with a way to calculate a shipping fee.
Here is my situation: I need to calculate a fee for shipping an item. right now I have an if/else statement that checks if the cost of an order is between a certain amount (let's say 3k to 4k) and then return the shipping fee for that range. That's all fine since there are only 10 ranges that have individual fees. But if the order amount is over $5k then you add $6.25 to the last stated fee of 80.25 and then for each additional $1k you add $6.25. So if your order is between $1.6k to $5k the fee is 80.25. If the order is between $5k and $6k you add $6.25 to the 80.25 (=$86.50). If it's between $6k and $7k you add $6.25 to the $86.50.
Make sense? I hope! Now I'm trying to come up with a loop that will do this for me without having to write line after line until I get to $500,000. I'm doing baby steps at the moment, and this is where I'm at right now:
local numberVar bamount := 80.85;
local numberVar addamount = 6.25;
if Sum ({@ItemCost}) <= 20 then bamount := 0
else if Sum ({@ItemCost}) in 20 to 40 then 7.00
else if Sum ({@ItemCost}) in 40 to 100 then 19.45
else if Sum ({@ItemCost}) in 100 to 200 then 29.00
else if Sum ({@ItemCost}) in 200 to 350 then 45.60
else if Sum ({@ItemCost}) in 350 to 500 then 51.20
else if Sum ({@ItemCost}) in 500 to 750 then 58.20
else if Sum ({@ItemCost}) in 750 to 1000 then 65.15
else if Sum ({@ItemCost}) in 1000 to 1250 then 72.10
else if Sum ({@ItemCost}) in 1250 to 1600 then 76.65
else if Sum ({@ItemCost}) in 1600 to 5000 then 80.85
else if Sum ({@ItemCost}) in 5000 to 6000 then bamount := bamount + addamount
else if Sum ({@ItemCost}) in 6000 to 7000 then bamount := bamount + (addamount*2)
else if Sum ({@ItemCost}) in 7000 to 8000 then bamount := bamount + (addamount*3)
else if Sum ({@ItemCost}) in 8000 to 9000 then bamount := bamount + (addamount*4)
else if Sum ({@ItemCost}) in 9000 to 10000 then bamount := bamount + (addamount*5)
else if Sum ({@ItemCost}) in 10000 to 11000 then bamount := bamount + (addamount*6)
else if Sum ({@ItemCost}) in 12000 to 13000 then bamount := bamount + (addamount*7)
I know this is not a loop, but I can't figure out how to structure the loop.
Any help is greatly appreciated!
Chris