Cognito-forms – Adding Calculator to Cognito Form to create delivery charge line item

calculatorcognito-forms

I created an order form for my bakery. It has a radio button to select order pickup or delivery, and a repeating section with fields to select flavors and quantity. If the customer chooses order delivery, I want to have a graduated local delivery fee added to the order. For example: Order total up to $60 – add $5 delivery fee, Order Total $61 to $120 – add $10 delivery fee, $121 to $180 – add $15 delivery fee. How do I create a calculator in my form to add this conditional line item to the payment section?

Best Answer

To do this:

  1. Add a Price field to your form called Delivery Fee.
  2. Under the Show This Field option, set the field to only appear when a customer selects Delivery from your Choice field:

enter image description here

  1. Add an Order Total field (if you don't have one already). You can calculate an order total from repeating sections by summing the Item Total from each section: =MyOrder.Sum(ItemTotal)
  2. In the Amount section of your Price field, reference your Order Total with a series of if/then statements:

=(if OrderTotal <=60 then 5 else 0) + (if OrderTotal >= 61 and OrderTotal <= 120 then 10 else 0) + (if OrderTotal >=121 and OrderTotal<=180 then 15 else 0)

  1. Now, when a customer selects Delivery from the Choice field, it will automatically apply a delivery fee of $5.00, which increases incrementally with the Order Total.