Get the most out of Logic, variables, and scores (while ordering pizza!)
Branching and calculation, variables, and scores let you use the whole arsenal of the Logic tools that Typeform has to offer. You can add multiple custom variables to your typeform, use recall information, skip irrelevant questions and calculate scores and price. Read on to find out how.
Note: Logic isn't available on our mobile builder just yet. Edit your typeform on desktop to get the full power of Logic!
In this example we’ll show you how to create a pizza order form that lets people choose the size of their pizza, add extra toppings, and optionally select a drink. Then we’ll let Branching and calculations do the math, and add up everything in a neat Payment question.
First, add your questions to your typeform:
1. Start with a Welcome Screen:
2. Next, let’s ask people what size pizza they’d like with a Multiple Choice question:
3. Then we’ll ask people what kind of dough they’d like with another Multiple Choice question.
4. Now it’s time to choose topping with the help of another Multiple Choice question. You can enable Multiple selection in question settings to let people choose up to 3 toppings:
5. Let’s add a Yes/No question to ask people to confirm their choices. You can type @ to use Recall information and show them what they selected:
6. Add another Yes/No question to ask people whether they want extra toppings for an additional fee.
7. Now people can pick their additional toppings from a Multiple Choice question with Multiple selection enabled, where they can choose as many additional toppings as they want:
8. Next we’ll use a Yes/No question to ask people to confirm their selection, and show them which toppings they chose and how much it will cost them with Recall information:
9. Next, we’ll ask people if they want to order a drink for an additional fee with a Yes/No question:
10. If they say Yes, they can choose what they want from the drink menu with a Multiple Choice question, where they can only select one option.
11. Let’s add a final Yes/No question where people can review their order with Recall information:
Tip: Use Question Groups to easily duplicate sets of related questions. That way, you can give respondents the option to add multiple pizzas to their order.
12. Now we can ask people for their delivery address with a Short Text question:
13. Then we’ll ask for their number with a Phone Number question:
14. We’ll ask for their name with another Short Text question:
15. Finally we’ll create a Payment question where people can provide their credit card details and pay for their order. We’ll also show them the final price with Recall information:
16. Now when people hit Submit, they’ll see an Ending screen letting them know that their order is on its way:
Now that we’ve asked everything, it’s time to use the magic of Logic!
1. Go to the Logic panel and click Variables:
2. Use + Add variable to create your own, then hit Save when you’re ready. For this typeform, we’ll add a custom drink, size and toppings variable:
3. Go back to the Logic tab and click Branching and calculations to change your variable values based on how customers order their pizzas. First, let’s add values to the size variable depending on which size of pizza the customer chooses, like so:
4. Then add the size variable to the final price:
5. Add Logic to your Yes/No question on toppings, where people can confirm which toppings they'd like. Take people back to the previous question if they say No and to the next question if they say Yes.
6. Then add Logic to the Yes/No question on additional toppings to take people to the additional topping selection, or let them skip it if they don’t want additional toppings:
7. Repeat the process for size with the toppings variable - for every topping chosen, add 1 to the variable. The difference here is that each topping costs the same, but people can choose multiple toppings which will then be added to the final price.
Then, add the toppings variable to price:
8. Add Logic to the Yes/No question confirming the additional toppings. Customers who answer No will go back to the previous question and can change their topping choices, while customers who answer Yes will move on to the drink ordering question.
9. Add Logic to the Yes/No question asking about adding a drink - customers who say they want a drink will see the drink selection question, and customers who don't want to add a drink can review their final order:
10. On the drink selection question, use Logic to add 1 to the drink variable for any drink chosen.
Then, add the drink variable to the price variable.
11. Add your final Logic to the Yes/No question where customers can confirm their order. This way when people see a mistake in their order details, they’ll be taken back to the first question, and if they confirm their order, they’ll be asked to add their contact details:
That’s it, your order form is ready! You better start heating up the oven and chopping your ingredients to bake all that delicious pizza.
If you feel like one pizza is not enough, you can check out our article about how to multiply by quantity selected here.