Wix Functions: Using Variables
6 min
In this article
- Adding a variable to your function
- Example of using variables in a function
- FAQs
Create variables to act as placeholders for information you use repeatedly in your function. Instead of adding or calculating the same details over and over, you set up a variable once and can reuse it as many times as you need. If you ever want to update the variable, you only need to do so in one place and it updates throughout your function.
For example, if you have an online store you can create a variable to keep track of the total items in a customer's cart or the heaviest item for shipping purposes. This way, your site stays accurate and efficient, making things easier for both you and your customers.

Adding a variable to your function
Add a variable in the function builder by adding a new step. Make sure you add a variable before the point in the flow where you want to use it. For example, if you want to use a variable in a condition, you must create the variable before adding the condition step.
To add a variable to a function:
- Go to Functions in your site's dashboard.
- Edit an existing function or select a template to create a new one.
- Click the Add Step icon
in the function builder.
- Click Variable.
- Add your variable info:
- Variable name: Add an easily identifiable name.
- Data type: Select the appropriate data type (text, number, boolean, date-time).
- Value: Enter the variable's value. You can also click Customize to create a more complex calculation using properties, functions and values.

- (Optional) Click + Add Variable to add another variable.
- Click Apply.
- Continue building your function by adding your variable to conditions and/or the function output.
Tip: To find your variables, click Select a property in a condition step, or Customize in the function output. Available variables are listed at the top.

Example of using variables in a function
Let's take a look at how a Wix Stores user includes variables in a function.
Stella runs an online store and wants to offer free delivery for orders over $100. She can achieve this by creating a minimum order subtotal function.
In the function builder, instead of entering the exact minimum order amount ($100) throughout the expression, Stella can create a 'minimum order subtotal' variable. If she needs to update the minimum order amount in the future, she can simply adjust the variable instead of changing it everywhere in the function. This simplifies her workflow and reduces the function's overall complexity.
View step-by-step instructions of how to set up this example
Example of a function without a variable:

Example of a function with a variable:

FAQs
Click a question below to learn more about using variables.
What are the benefits of using variables?
How can I access all my variables?
How do I update a variable's value?
Can I add variables anywhere in the function flow?
What are some tips for using variables effectively?