I want to calculate pricing based on location, destination & weight.
For example, if a user wants to send a shipment from Austria to Ireland and the weight is up to 10 kg then the price will be $27 and if up to 20 kg then $29 and so on up to 50 kg.
I have From & To fields for location & destination and I have a repeating section which includes a weight field and at the end I have a calculation field.
How can I achieve this?
Best Answer
There are two ways to write conditional if/then calculations in Cognito Forms.
if <condition> then <true result> else <false result>
<condition> ? <true result> : <false result>
For your specific example, lets assume you create a calculation outside your repeating section called
Total Weight
with the calculation=Packages.Sum(Weight)
that sums up the weight of the items in thePackages
repeating section.You can then write the following calculation to based on your example:
=if Location = "Austria" and Destination = "Ireland" then if Weight <= 10 then $27 else if Weight < 20 then $29 else ... else ...
If you have a ton of options like this, I suspect this would be very difficult to work through. It sounds like you want to be able to look up a value from a very long table of potential values. Please provide feedback to this answer and I will be glad to refine my response.