Prices are returned with every result
When you request products from the Search, Browse, Blocks, or Similar Products APIs, each item in the response carries its full price data by default. You do not need to hydrate prices separately from Shopify or another service before re-sorting. The relevant fields on each product:price_range— minimum and maximum variant prices for the product.variants— per-variantprice,compare_at_price, and availability.first_or_matched_variant— the variant most relevant to the request (matched against filters or facets), with its own price fields.
attributes parameter.
If you only need pricing for a subset of products, request the page size you actually plan to display. Layers paginates results — request page 1 with
limit: 24, run your A/B re-sort on those 24 results, and request page 2 only when the shopper scrolls. You do not need to pull the entire collection client-side.Sorting by price after an A/B price override
A common A/B testing pattern is to apply a dynamic discount (e.g., +5% on a treatment cohort) and then re-sort the visible page by the new price. Because Layers returns the originalprice on every result, the override can run entirely in your A/B platform or storefront code:
- Request the collection page from the Browse API with your normal sort order applied (e.g., relevance, best sellers).
- In your storefront, apply the cohort’s pricing transformation to each product’s
price_range.minand per-variantprice. - Re-sort the visible page by the transformed price before rendering.
- Render with the SDK’s reactive ProductCard, which exposes the selected variant’s price as a signal so the UI updates without re-fetching.
Running A/B tests on Layers itself
If the test is on Layers configuration (sort order, ranking weights, search rule, merchandising rule), you can run the experiment without storefront code changes:- Sort order A/B — assign cohort A and B to different sort order codes and pass
sortOrderon the API request based on cohort. The default sort order is configured per collection but always overridable via the API. - Search rule A/B — encode the cohort in
context(for examplecontext.experiment = "treatment") and write search rules that activate only for the treatment cohort. The rule can inject filters, swap sort orders, or apply expression-based boosts. - Block strategy A/B — when calling the Blocks API, choose between block strategies per cohort to test recommendation algorithms head-to-head.
Promotional and B2B price overrides
When prices vary by market, B2B catalog, or active promotion, Layers resolves the correct price server-side before returning the result — so sort-by-price and price-range facets stay accurate.- Shopify Markets — Layers applies market-specific pricing when a market is in the request context.
- B2B catalogs — when
identity.companyLocationIdis supplied, Layers applies catalog price list precedence before market and base variant pricing. - Abra Promotions — Layers natively integrates with Abra so flash-sale and discount entitlements feed into price sorting and price filtering automatically.
- Custom discount entitlements — for arbitrary discount logic, pass discount entitlements on the request and Layers applies them to the response prices.