Shopify theme snippet

Most themes take the FitMyType app block in the theme editor. Use this snippet when your theme cannot (older or custom themes), or when your store does not have the FitMyType app. It shows the size button, selects the recommended size in your theme's size picker and, if you want, adds it to the cart.

1. Add the snippet

  1. In the FitMyType back-office, open Integration and copy the Shopify theme snippet. It already holds your client id.
  2. In Shopify, open Online Store › Themes › Edit code, add a snippet named fmt-size-recommender.liquid and paste the code.
  3. In your product template or product section, inside the product form, add this line where the button should appear:
{% render 'fmt-size-recommender', product: product %}

Try it in a theme preview first. In the theme editor the snippet shows a placeholder button only.

2. Settings

Settings go in the settings object of the config block the snippet writes (<script id="fmt-config" type="application/json">), or at its top level. A value that is not allowed is ignored and the default is used.

SettingValuesDefault
logoStyledefault, s, ruler, scale, nonedefault
tooltipPositionbottom, bottom-left, bottom-right, left, upper, upper-left, upper-rightbottom-left
unitSystemmetric, imperial—
endBehaviorclose, select-size, select-size-add-to-cartselect-size
buttonTextyour own button text—
fontFamilyfont family name—
fontFallbackfallback font—
fontFaceCssURL of a @font-face stylesheet—
channelselling channel for your reportsshopify
braInputMandatorytrue or false—
autoSelectOnAutoRecotrue or false: pre-select the size we remember for a returning shopperfalse
autoRecotrue or false: show the remembered size on the buttontrue
autoSelecttrue or false: select the size in your theme's pickertrue
cartEventtrue or false: send add-to-cart events (only for a store with no FitMyType pixel)false
debugtrue or false: console warnings about the configfalse

endBehavior: close only shows the recommendation, select-size also selects it in your size picker, select-size-add-to-cart also adds it to the cart and opens your cart drawer (or goes to the cart page).

3. Config schema

The config block follows this JSON schema.

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.fitmytype.com/schemas/shopify-theme-config.json",
  "title": "FitMyType Shopify theme config (fmt-config)",
  "type": "object",
  "required": [
    "clientId",
    "productId",
    "availableSizes",
    "sizeOptionName",
    "variants"
  ],
  "properties": {
    "clientId": {
      "description": "FitMyType client id",
      "oneOf": [
        {
          "type": "integer",
          "minimum": 1
        },
        {
          "type": "string",
          "pattern": "^[1-9][0-9]{0,14}$"
        }
      ]
    },
    "productId": {
      "description": "Product id by the source's product ID strategy",
      "type": [
        "string",
        "integer"
      ]
    },
    "productImage": {
      "type": [
        "string",
        "null"
      ]
    },
    "language": {
      "type": [
        "string",
        "null"
      ]
    },
    "shopCountry": {
      "type": [
        "string",
        "null"
      ]
    },
    "availableSizes": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "minItems": 1,
      "uniqueItems": true
    },
    "sizeOptionName": {
      "type": "string"
    },
    "sizeOptionIndex": {
      "type": "integer",
      "minimum": 0,
      "maximum": 2
    },
    "variants": {
      "type": "object",
      "additionalProperties": {
        "type": "integer"
      }
    },
    "variantsDetail": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "required": [
          "id",
          "available",
          "options"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "available": {
            "type": "boolean"
          },
          "options": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      }
    },
    "productIdStrategy": {
      "type": "string",
      "pattern": "^(shopify_product_id|handle|sku_prefix:.+|metafield:[^.]+\\..+)$"
    },
    "selectedVariant": {
      "type": [
        "integer",
        "null"
      ]
    },
    "productUrl": {
      "type": "string"
    },
    "primaryLocale": {
      "type": "boolean"
    },
    "sizeData": {},
    "settings": {
      "type": "object"
    },
    "buttonText": {
      "type": "string"
    },
    "logoStyle": {
      "enum": [
        "default",
        "s",
        "ruler",
        "scale",
        "none"
      ]
    },
    "tooltipPosition": {
      "enum": [
        "bottom",
        "bottom-left",
        "bottom-right",
        "left",
        "upper",
        "upper-left",
        "upper-right"
      ]
    },
    "fontFamily": {
      "type": "string"
    },
    "fontFallback": {
      "type": "string"
    },
    "fontFaceCss": {
      "type": "string"
    },
    "channel": {
      "type": "string"
    },
    "unitSystem": {
      "enum": [
        "metric",
        "imperial"
      ]
    },
    "braInputMandatory": {
      "type": "boolean"
    },
    "endBehavior": {
      "enum": [
        "close",
        "select-size",
        "select-size-add-to-cart"
      ]
    },
    "autoSelectOnAutoReco": {
      "type": "boolean"
    },
    "autoReco": {
      "type": "boolean"
    },
    "autoSelect": {
      "type": "boolean"
    },
    "cartEvent": {
      "type": "boolean"
    },
    "debug": {
      "type": "boolean"
    }
  }
}