Formula comparison
A comparison across up to four products, measured on rows you define — strength, texture, frequency, pairing, or anything else. On a product template it leads with the product being viewed and lets the customer choose what to compare it against.
- Merchant-addable
- Yes
- Settings
- 42
- Block types
- 2
- Max blocks
- 10
- File
sections/formula-comparison.liquid
Used by default on: Product
When to use it
When customers ask "which one is right for me" and the answer depends on more than price. Works as a fixed comparison on a collection or landing page, and as a per-product comparison on a product template.
Setting it up
- Add the section and write the heading and intro under Content.
- Define your measures under Comparison rows. These become the rows and apply to every column, so pick measures every product can actually answer.
- Give each row a Value source so it fills from each product's category attributes rather than typed text. The first three rows ship pointed at real attributes already. See Per-product content.
- Decide where the columns come from with Column products under Comparison columns. Leave it on formula blocks for a fixed comparison; switch it to the product being viewed on a product template.
- For a fixed comparison, add one Formula block per product, up to four — each picks a product and answers each row.
- For a per-product comparison, set Collection customers compare within and size it with Columns to compare. Every row then needs a value source, because a product the customer swaps in has no block to type into.
- Pick an Image ratio and check it on a phone — the comparison becomes a swipeable deck, one product per slide.
Where the content comes from
Product references, images, and prices come from Shopify product data. The measures are section content, and in the fixed mode each product's answers are block content, because they are specific to this comparison rather than facts on the product record.
Notes and cautions
- Four columns is the maximum and three is usually better. A comparison a customer cannot hold in their head does not help them decide.
- On a product template, two columns beside the product being viewed is the practical desktop maximum — the row labels plus four product columns need about 1140px and scroll sideways below that.
- Rows still on Manual value are hidden once the columns come from the product, rather than showing an empty cell in every column. The editor names them.
- It is not an HTML table. Each column is its own card so it can carry its own shadow, and every value carries a hidden row label, so screen readers still hear "Best for: dry, sensitive" without a table to navigate.
Two ways to fill the columns
A comparison built from product pickers has one problem on a product template: the template is shared. Pick three serums in the blocks and every product page in your store shows those same three serums — including the pages of the serums themselves.
So the section reads its columns from one of two places, set by Column products under Comparison columns.
| Mode | What fills the columns | Where to use it |
|---|---|---|
| Product picked in each formula block (default) | The products you picked, the same on every page | Home page, a collection page, a dedicated comparison page |
| Product being viewed, plus the customer’s choice | The product on the page, then products the customer picks | Product templates |
The second mode does two things at once: it puts the product being viewed in the first column automatically, and it lets the customer choose what to compare it against from a dropdown on each of the other columns.
It needs a product on the page. On a home page there is nothing being viewed, so the section falls back to your formula blocks and the theme editor tells you so.
The full walkthrough
Step 1 — switch the source
On your product template, open the section and set Column products to Product being viewed, plus the customer’s choice.
The formula blocks stop being used at this point. They are not deleted — switching back restores them — but hiding or reordering them changes nothing while this mode is on, and the editor says as much.
Step 2 — choose what customers compare within
Collection customers compare within sets the pool the dropdowns offer.
Pick the collection that holds comparable products — your serums, your moisturizers. Leave it blank and the section uses the smallest collection the product belongs to, on the reasoning that the smallest is usually the most specific: better to compare within “Vitamin C serums” than within “All products” or “Sale”.
Leave Compare only products of the same type on to keep a comparison to one kind of product. It reads Shopify’s Product type field, and is ignored on a product that has none — so if your comparison is offering unrelated products, that field is usually empty in admin.
Step 3 — give every row a source
This is the step that catches people out. A product the customer swaps in has no block to type a value into, so every row you want visible needs a Value source under Comparison rows.
Rows left on Manual value are hidden in this mode. They are not shown as empty — an empty comparison row is worse than no row — and the editor lists exactly which rows dropped and why.
See Per-product content for how value sources work and which attributes exist.
Step 4 — size the comparison
| Setting | What it does |
|---|---|
| Columns to compare | How many columns sit beside the product being viewed. 1–3. |
| Products customers can choose from | How long each dropdown list is. 2–8. |
| Current product label | The wording on the first column’s chip. Blank hides it. |
Two columns is the practical maximum on a desktop. The row-label column plus the product being viewed plus three more needs about 1140px, so three columns is permanently scrolled sideways at normal page widths.
What the customer sees
The first column is the product they are already looking at, marked with the label from Current product label and given a quiet ring so it reads as theirs.
Every other column carries a dropdown naming the product in it. Opening it lists the pool, where:
- the column’s own product is ticked
- a product already shown in another column is greyed out with a dash, because two columns showing the same product is not a comparison
- choosing one swaps that column, and only that column
Nothing reloads. Every choice is rendered with the page and swapped in place, so the comparison changes instantly and no images are fetched until a choice is actually made.
What renders in each situation
| The situation | What a customer sees |
|---|---|
| The collection has plenty of products | The full comparison, with dropdowns |
| The collection has fewer products than Columns to compare | Fewer columns, and the editor says how many it found |
| The collection has nothing to compare against | Nothing — the section is hidden |
| The product being viewed has no collection | Falls back to the smallest collection it belongs to; hidden if there is none |
| The section sits where no product is being viewed | Your formula blocks, as normal |
| A row has no value source | That row is hidden, in every column |
A product with nothing comparable hides the section rather than showing a one-column table. Every one of these states explains itself in the theme editor — if the section looks short or empty while editing, read the note under it.
How the choices are ordered
The dropdown offers the first products in the collection’s own sort order, skipping the product being viewed and anything filtered out by product type.
That means the collection’s sort order in Shopify admin is the ranking. There is no relevance scoring. If you want a particular product to be the default comparison, sort that collection manually and put it first.
Two things it deliberately does not do: it does not exclude sold-out products, because a comparison is still informative for something out of stock, and it does not narrow by tag or price.
Keeping the cards aligned
Rows only read as a comparison when they line up across the columns, so the section holds the media and the titles to a fixed shape:
- Image ratio — Portrait, Square, or Landscape — applies at every screen size, so every column’s image occupies identical space. Square keeps cards shortest on a phone, where the comparison becomes a swipeable deck one card at a time.
- Two lines are always reserved for a product title, so a short name and a long one do not offset the rows beneath them. Titles are never truncated, so a name long enough to need three lines will still push its own column down.
Using it well
- Two columns beside the product, not three. A comparison a customer cannot see at once does not help them decide.
- Point every row at an attribute before switching modes. Otherwise the comparison arrives three rows shorter than you designed it.
- Keep the choice list short. Every option is prepared with the page, so eight choices is more page weight than four for a list most customers never open.
- Set Product type on your products. It is what keeps a wax out of a serum comparison.
- Test on two products — one in the collection with attributes filled in, and one with nothing. The second is how you confirm the section hides itself instead of showing an empty table.
When a column shows dashes
Work down this list:
- The product has no category. Value sources read category attributes, and those do not exist until the product has a category. This is the cause most of the time.
- The attribute is empty on that product. Assigning a category creates the field; it does not fill it in.
- The row is still on Manual value. In this mode that row is hidden rather than filled.
- The category does not carry that attribute. A cleanser category will not offer SPF level.
- You are looking at a product outside the collection. The comparison is built from the collection pool, and the product being viewed is always the first column regardless.
The fastest check is the product in Shopify admin. If the value is blank there, the theme has nothing to show.
Section settings
Every setting on the section itself, in the order it appears in the theme editor. Group headings match the editor's own grouping.
Content
Comparison columns
Applies when column products is set to the product being viewed. Customers choose from the first products in the collection's own sort order, skipping the one they are viewing. Leave blank to use the smallest collection the product belongs to.
Marks the first column as the product the customer is viewing. Leave blank to hide it.
Keeps a comparison to one kind of product. Ignored when the product being viewed has no product type.
Shown beside the product being viewed. Fewer columns show if the collection holds fewer products.
The length of each column's list. Every choice is prepared with the page, so a shorter list keeps the page lighter.
Comparison rows
Optional text shown at the top of the left column.
Extra tags collapse behind a control that customers can expand. Applies to rows using the tags style.
Call to action
Style
Show a decorative line illustration at the top of the label column.
Use a transparent PNG line illustration. 400 x 720px recommended.
Applies on every screen size. Square keeps cards shortest on a phone.
Reveal the comparison as it scrolls into view. Respects the theme motion settings.
Padding
Blocks
Blocks are added, reordered, duplicated, and removed inside the section. Each type has its own settings.
Comparison row row max 6
Names the row in the label column. A row with no heading is hidden.
Fills this row from each product automatically. The typed value for a product is used when it has no data for the attribute.
Formula formula max 4
Title, image, link, and price are read from this product.
Feature this product with a short label, such as Most loved. Leave blank for none.
Shown after the price, such as / 30 ml.