tys.recommendation()
The shopper’s recommended size for a product, in your size labels, without mounting anything (a hidden frame on our origin answers). Sizes only.
A visitor in the A/B holdout always gets unavailable, so you show them no size either. The call never starts a simulation.
recommendation(product: string): Promise<Recommendation>;Parameters
Section titled “Parameters”productstringRequiredYour product ID or SKU, as synced to TryYourSize.
Returns
Section titled “Returns”Promise<Recommendation>: The shopper’s recommended size for the product.
productstringRequiredstatusRecommendationStatusRequiredready (size is set), computing (a try-on the shopper started is still running), none (no size of this garment can be worn on this body), signed_out (no TryYourSize session on your site) or unavailable (no size for this product yet).
sizestring | nullRequiredThe recommended size in the store's own label (its size map), or null.
studioSizestring | nullRequiredThe same size as entered in TryYourSize Studio, or null.
wearableSizesstring[]OptionalSizes that can be worn on this body, in the store's labels (when simulated).
Example
Section titled “Example”const rec = await tys.recommendation("SKU-123");if (rec.status === "ready") { sizePicker.value = rec.size; // "M", in your own labels}import { useTryYourSize } from "@tryyoursize/react";
function usePreselect(product: string, select: (size: string) => void) { const tys = useTryYourSize(); useEffect(() => { tys?.recommendation(product).then((r) => r.status === "ready" && r.size && select(r.size)); }, [tys, product]);}See also
Section titled “See also”Was this page helpful?
Thank you. We read every answer.