# A quantity calculator on your Shopify product pages

> Put a free tile, paint or flooring quantity calculator on Shopify product pages with a Custom Liquid section. Exact clicks, Liquid code, fixes.

Page: https://craftquantities.com/embeds/shopify/ (embed guide). This is the page's Markdown copy; the HTML page is the canonical version.

A customer looking at a box of tiles wants to know how many boxes the bathroom takes. A **Custom Liquid** section puts the answer next to the Add to cart button: the calculator works out the quantity with waste, in metric and imperial, and nothing is added to your checkout or your apps.

- Custom Liquid Theme element
- Allowed Fitting script
- Under 3 KB Code size
- None App to install

**On this page Before you start**

## Before you start

- An **Online Store 2.0** theme such as Dawn. Most current themes offer a Custom Liquid section; if yours does not, its own documentation says where custom code goes.
- Permission to edit themes in your Shopify admin.
- For the product-page code: product types spelled the same way on every product (for example `Tile`, `Paint`, `Flooring`).

## Step by step

1. Open the theme editor

   In your Shopify admin go to **Online Store**, then **Themes**, and click **Customize** on the theme you want to change. Working on a duplicate first lets you check everything before customers see it.
2. Choose the page

   Use the drop-down at the top of the editor: **Products**, then **Default product** for every product page, or a page or the home page for a single calculator.
3. Add a Custom Liquid section

   In the sidebar's **Template** area click **Add section** and pick **Custom Liquid**. On a product page you can instead add a **Custom Liquid** block inside the product information section, so it sits beside the price and the buy buttons.
4. Paste the code

   Click the new section, paste the code below into its **Liquid** box, and the editor's preview shows the calculator in place.
5. Place it

   Drag the section or block by its handle: under the description, or just below the quantity selector, is where shoppers look while deciding how many to buy.
6. Save and check a product

   Click **Save**, open a product of each type in a private window, and change a measurement to see the result update.

## Your code

_Custom Liquid: one calculator_

```
<iframe src="https://craftquantities.com/embed/?calc=floor-tile-calculator&ev=1&fmt=compact" width="100%" height="460" loading="lazy" style="border:1px solid #e4e4e7;border-radius:12px;max-width:100%" title="Floor &amp; Wall Tile Calculator — Craft Quantities"></iframe>
<p style="margin:4px 0 0;font:12px/1.4 system-ui,sans-serif">Calculator by <a href="https://craftquantities.com/calculators/renovation-construction/floor-tile-calculator/">Craft Quantities</a></p>
<script>(function(){if(window.cqEmbedFit)return;window.cqEmbedFit=1;window.addEventListener("message",function(e){var d=e.data;if(!d||d.source!=="craft-quantities"||d.type!=="size"||typeof d.height!=="number"||!isFinite(d.height))return;var f=document.getElementsByTagName("iframe");for(var i=0;i<f.length;i++){if(f[i].contentWindow!==e.source)continue;var a=document.createElement("a");a.href=f[i].src;if(a.protocol+"//"+a.host!==e.origin)return;f[i].style.height=Math.min(6000,Math.max(200,Math.ceil(d.height)))+"px";return}})})();</script>
```

The calculator you pick above, the visible credit line, and a short script that fits the frame's height to its content.

_Custom Liquid: the calculator that matches the product_

```
{%- liquid
  assign cq_calc = blank
  if product.type contains 'Tile'
    assign cq_calc = 'floor-tile-calculator'
    assign cq_page = 'https://craftquantities.com/calculators/renovation-construction/floor-tile-calculator/'
  elsif product.type contains 'Paint'
    assign cq_calc = 'paint-calculator'
    assign cq_page = 'https://craftquantities.com/calculators/renovation-construction/paint-calculator/'
  elsif product.type contains 'Flooring'
    assign cq_calc = 'flooring-calculator'
    assign cq_page = 'https://craftquantities.com/calculators/renovation-construction/flooring-calculator/'
  endif
-%}
{%- if cq_calc != blank -%}
<iframe src="https://craftquantities.com/embed/?calc={{ cq_calc }}&ev=1&fmt=compact" width="100%" height="460" loading="lazy" style="border:1px solid #e4e4e7;border-radius:12px;max-width:100%" title="{{ product.type | escape }} calculator — Craft Quantities"></iframe>
<p style="margin:4px 0 0;font:12px/1.4 system-ui,sans-serif">Calculator by <a href="{{ cq_page }}">Craft Quantities</a></p>
<script>(function(){if(window.cqEmbedFit)return;window.cqEmbedFit=1;window.addEventListener("message",function(e){var d=e.data;if(!d||d.source!=="craft-quantities"||d.type!=="size"||typeof d.height!=="number"||!isFinite(d.height))return;var f=document.getElementsByTagName("iframe");for(var i=0;i<f.length;i++){if(f[i].contentWindow!==e.source)continue;var a=document.createElement("a");a.href=f[i].src;if(a.protocol+"//"+a.host!==e.origin)return;f[i].style.height=Math.min(6000,Math.max(200,Math.ceil(d.height)))+"px";return}})})();</script>
{%- endif -%}
```

For the default product template. It reads `product.type`: a tile product shows the tile calculator, paint the paint calculator, flooring the flooring calculator, and every other product shows nothing. Edit the words in quotes to match your own product types.

Every other option is in the [full builder](https://craftquantities.com/embeds/#calculator=floor-tile-calculator).

## What visitors see

Your product page · Description · Add to cart

Calculator by [Craft Quantities](https://craftquantities.com/calculators/renovation-construction/floor-tile-calculator/)

## On product pages: tile, paint and flooring

The product-page code is one block for the whole catalogue. Liquid runs on Shopify's side before the page is sent, so a product whose type does not match draws no frame at all, and the shopper downloads nothing extra.

Shopify's `contains` is case-sensitive: `Tile` does not match `tile`. Check the types in **Products** and copy their spelling into the code.

If only some products should have a calculator, make a template for them instead: in the theme editor open **Products**, choose **Create template**, base it on the default product, add the Custom Liquid block there, then assign the template under **Products**, the product, **Theme template**. **Bulk edit** has a template column for many products at once.

Compact is the format for a product page: the inputs, the answer in both unit systems, and a link to the full calculator for anyone who wants the breakdown. Shopify limits a Liquid setting to 50 KB, and this code is a few percent of that.

## Troubleshooting

**There is no Custom Liquid in Add section**

Your theme is not an Online Store 2.0 theme, or it leaves the section out. Check the theme's documentation for where custom code goes, or move to a current theme such as Dawn.

**The calculator shows on every product**

It was added to the default product template without the product-type code. Use the second snippet, or a separate template assigned to the products that need it.

**A tile product shows nothing**

Its product type does not contain the word in the code, letter for letter. Open the product in **Products** and compare the spelling, capitals included.

**The frame is cut off at the bottom**

Something removed the fitting script. Leave the script line in, or raise the `height` value in the iframe tag until the whole calculator shows.

**It works in the editor but not on the store**

The changes were not saved, or you edited a theme that is not the published one. Save, then publish the theme or make the same change on the live theme.

## Why it helps

- The question "how many boxes do I need?" is answered on the product page, at the moment the shopper chooses a quantity, instead of in an email to your support inbox.
- Each result includes a waste allowance and is shown in metric and imperial, so a shopper measuring in feet and a pack sold by the square metre still agree.
- No app subscription and nothing added to checkout: the code is a frame and a link, and it sets no cookies and runs no tracking of its own.
- The maths and its sources sit on one public page per calculator, which the credit line links to, so a shopper who doubts a figure can check how it was worked out.

## Sources

Checked against these help pages on 26 November 2026.

1. [Shopify Help Center: Customizing sections and blocks](https://help.shopify.com/en/manual/online-store/themes/customizing-themes/theme-editor/customizing-sections)
2. [Shopify Help Center: Templates (creating and assigning)](https://help.shopify.com/en/manual/online-store/themes/theme-structure/templates)
3. [Shopify Help Center: Dawn page types](https://help.shopify.com/en/manual/online-store/themes/os20/themes-by-shopify/dawn/page-types)
4. [Shopify Developer docs: Input settings (the liquid setting type)](https://shopify.dev/docs/storefronts/themes/architecture/settings/input-settings)

On this page

At a glance

**Theme element**

Custom Liquid

**Fitting script**

Allowed

**Code size**

Under 3 KB

**App to install**

None

Official links

- [The plugin on WordPress.org](https://wordpress.org/plugins/craft-quantities-calculators/)
- [Developer hub](https://craftquantities.com/developers/)
- [Static JSON API](https://craftquantities.com/api/)
- [Remote MCP server](https://craftquantities.com/developers/mcp/)
- [npm package](https://craftquantities.com/developers/npm/)

The one rule

Keep the visible credit line under the frame: it is the one condition of the free embed.

**Open:** the engine’s answers (its JSON API, MCP server and npm package), the data files under /api/v1/ and the formula library (/formulas/) are published under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/): reuse them, commercially too, crediting “Craft Quantities” with a link. **Reserved:** the page text, the design and the software, the engine’s code included. [The terms of use](https://craftquantities.com/terms/)

[The terms, in full](https://craftquantities.com/embeds/#terms)

[Home](https://craftquantities.com/)

Embed & integrations

Pages

- [Overview and builder](https://craftquantities.com/embeds/)
- [WordPress plugin](https://craftquantities.com/embeds/wordpress/)
- [Shopify](https://craftquantities.com/embeds/shopify/)
- [Wix](https://craftquantities.com/embeds/wix/)
- [Squarespace](https://craftquantities.com/embeds/squarespace/)
- [Webflow](https://craftquantities.com/embeds/webflow/)
- [Google Sites](https://craftquantities.com/embeds/google-sites/)
- [Blogger](https://craftquantities.com/embeds/blogger/)
- [Any HTML page](https://craftquantities.com/embeds/html/)

Developers & integrations

- [Overview and live call](https://craftquantities.com/developers/)
- [API reference](https://craftquantities.com/developers/api-reference/)
- [Static JSON API](https://craftquantities.com/api/)
- [Remote MCP server](https://craftquantities.com/developers/mcp/)
- [npm package](https://craftquantities.com/developers/npm/)
- [Command line](https://craftquantities.com/developers/cli/)
- [WebMCP in the browser](https://craftquantities.com/developers/webmcp/)
- [Claude and ChatGPT](https://craftquantities.com/ai/)
- [Embeds and WordPress](https://craftquantities.com/embeds/)
- [Browser extension](https://craftquantities.com/tools/browser-extension/)
- [Changelog](https://craftquantities.com/developers/changelog/)
- [Service status](https://craftquantities.com/status/)

On this page

- Before you start
- Step by step
- Your code
- What visitors see
- On product pages: tile, paint and flooring
- Troubleshooting
- Why it helps
- Sources

---
Source: https://craftquantities.com/embeds/shopify/
Craft Quantities: free to read, cite and link to; the pages are not licensed for republication. Quantities only: no prices, no design and no certification.
