Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.uselayers.com/llms.txt

Use this file to discover all available pages before exploring further.

Recipes are built-in Function templates you can apply from the Function editor. Use them when you want a reliable starting point for a common computed attribute. To use a recipe, create a Computed Attribute, open Templates, choose the recipe, preview it on a product, and save.
Description: The percentage discount calculated from compare-at price to current price. Returns 0 if no discount is available.Use case: Sort products by discount amount or filter for products on sale. Create “Biggest Discounts” collections or exclude heavily discounted items from premium merchandising.Input used: Price range.Output: Number.Example: A product with a compare-at price of 100andcurrentpriceof100 and current price of 75 has a discount percentage of 25.
Description: The total number of variants for this product. Useful for filtering or sorting by product complexity.Use case: Identify products with many options (high variant count) or single-variant products. Filter out products with too many variants from certain collections.Input used: Variants.Output: Number.Example: A t-shirt available in 5 colors and 4 sizes (20 combinations) has a variant count of 20.
Description: Average profit margin across variants, calculated as (price - cost) / price for each variant with cost data. Excluded from the product if no variants have cost information (the formula evaluates to null).Use case: Sort products by profitability or filter for high-margin items. Create “Best Margin” collections for merchandising or exclude low-margin products from promotional campaigns.Input used: Variant price and cost.Output: Number.Example: A product with two variants (price=10,cost=10, cost=5 and price=20,cost=20, cost=10) has an average margin of 0.5 (50%).
Description: Ratio between available variants and total variants. Returns null when a product has no variants.Use case: Identify products that are partially unavailable or need catalog cleanup.Input used: Variant availability.Output: Number.Example: A product with 3 available variants out of 4 total variants has SKU coverage of 0.75.
Description: The number of days since the product became available, based on the product published date.Use case: Build “new arrivals” rules, identify aging products, or sort by freshness.Input used: Published date.Output: Number.Example: A product published on 2026-04-01 returns 40 on 2026-05-11.
Description: The number of days since the newest variant was created.Use case: Identify products with recently added variants or updated options.Input used: Variant creation dates.Output: Number.Example: If the newest variant was created on 2026-05-01, the value is 10 on 2026-05-11.

Troubleshooting

The template result looks empty

Preview the Function and check Received data. If the product does not have the data the recipe needs, such as variant cost or compare-at price, the recipe may return 0 or null.

The recipe is not available as a storefront filter

Confirm the attribute is marked as filterable and that Enable as Storefront Facet is turned on. For multi-field outputs, configure the generated sub-field instead of the parent attribute.

See also