1. Home
  2. Knowledge Base
  3. Advanced Calculations for Add-Ons Ultimate
  4. Getting Started with Advanced Calculations
  5. Use select fields to retrieve values from lookup tables

Use select fields to retrieve values from lookup tables

This article covers how to use a select-type field as one of the inputs for a lookup table in Advanced Calculations. Select-type fields include select, select box, radio and even image swatch fields.

For a full overview of lookup tables and how to connect a calculation field to one, see Getting started with Advanced Calculations. For how to create and edit the tables themselves, see creating and editing lookup tables.

Why use a select field as a lookup input?

Select fields let you look up a value from a choice the customer makes, not just from numeric fields like width or height. Each option’s value can be text or a number. This is useful when the result depends on a category or a fixed set of options rather than a measurement the customer enters.

For example, you can look up a value based on a material (Oak, Pine, Walnut), a finish (Matte, Gloss) or a size label (Small, Medium, Large) that doesn’t follow a predictable numeric scale.

Which option values can you match against?

Each option on a select-type field has two values set in the product editor:

  • Label: the value for that option, which can be text or a number, such as ‘Oak’ or ‘120’. This is the value you’ll usually enter as a matching axis header in your lookup table.
  • Price: a numeric value set for that option. It’s usually a price adjustment, but it doesn’t have to be – you can use the values in the ‘Price’ column purely as numbers for the lookup, without affecting the product price.

When you use a select field as a lookup axis, you choose which of these two values the lookup table matches against.

How do you set up a select field as an axis input?

If you have a limited number of preset options for the user to choose from, you can create one or more select fields. The user picks an option from each and the values are used to return a value from the lookup field.

In this example the user can pick from a list of preset width and drop sizes. The sizes are passed to the lookup table and a price is returned.

WooCommerce lookup table with select fields as inputs

Step #1: Follow the steps here to create your lookup table. You can choose either a grid with two axes or a flat, list-style table with more than 2 axes. We’ll cover both in this document.

Here’s an example 2d grid.

Lookup table that uses select field as inputs

Step #2: Add the select-type field and its options to the product, with each option’s ‘Label’ text entered. Your lookup table’s axis headers need to match this text exactly.

Options setting for select field

Step #3: Set up your calculation field with the formula {look_up_table}, as described in Getting started with Advanced Calculations.

Step #4: Choose the select field under ‘Field for X’ or ‘Field for Y’ for a grid table, or in the ‘Axis Fields’ list for a flat table.

Calculation field settings for lookup table with select fields as inputs

Each eligible select field appears twice:

  • Field Name (option label): matches the axis against the text of the option the customer selected, such as ‘Oak’.
  • Field Name (option price): matches the axis against that option’s price instead.

Choose the one that matches how your lookup table’s axis is built. This is usually ‘(option label)’, unless you’ve built a table that looks up by price.

Your select field is now one of the inputs for the lookup table, so the calculation field returns the matching value whenever the customer changes their choice.

Using a flat, list-style lookup table with select fields as options

To create a more complex lookup table that allows for more than two input fields, follow the steps above with the following differences.

Your table will be formatted differently. Flat tables have three or more axes, each stored as a list of rows. Each row holds one value for every axis plus a result value – and a row is only used when every axis value matches the customer’s input exactly. See this document for more details.

WooCommerce product page using a lookup table with three select fields as inputs

The lookup table itself will look like this:

WooCommerce flat lookup table with three inputs

When specifying the input fields in your calculation fields setting, you can add as many inputs as you like.

Calculation field settings for multiple inputs to lookup table

Was this article helpful?

Related Articles