Ir al contenido

tys.orders.create()

Esta página aún no está disponible en tu idioma.

Methodtryyoursize

Record an order (idempotent by order id; re-sending updates it). No customer data.

def create(order: OutcomeOrderInput, *, idempotency_key: Optional[str] = None) -> OutcomeOrderResult
orderOutcomeOrderInputObligatorio
Propiedades
idstringObligatorio

Your order ID.

ordered_atstringObligatorio
currencystringOpcional

ISO 4217, e.g. EUR.

visitor_idstringOpcional

The SDK's anonymous visitor ID ((await tys.experiment())?.visitorId), saved with the cart. TryYourSize recomputes the A/B arm from it and stores only its hash. Never a customer ID.

experiment_arm"treatment" | "holdout"Opcional

The arm, when you cannot send visitor_id.

linesOutcomeLineInput[]Obligatorio
Propiedades
idstringObligatorio

Your order line ID (unique within the order).

productstringObligatorio

Your product ID (the one you pass to the SDK).

variantstringOpcional
sizestringObligatorio

The size bought, in your labels.

quantityintegerObligatorio
unit_price_minorintegerOpcional

Price of one unit in minor units (5995 = 59.95). Optional; used for the refund value estimate.

tys_shownbooleanOpcional

A TryYourSize element was shown for this purchase.

recommended_sizestringOpcional

The size TryYourSize recommended (the SDK's recommendation event, or the _tys_size cart line property).

attribution"cart_attribute" | "sdk" | "api"Opcional

Where recommended_size came from.

idempotency_keyOptional[str]Opcional= None

OutcomeOrderResult: What was recorded.

idstringObligatorio
external_idstringObligatorio
createdbooleanObligatorio

False when the order already existed and was updated.

experiment_arm"treatment" | "holdout"Opcional
linesintegerObligatorio
from datetime import datetime, timezone
tys.orders.create({
"id": "1001",
"ordered_at": datetime.now(timezone.utc).isoformat(),
"currency": "EUR",
"visitor_id": visitor_id,
"lines": [{"id": "1", "product": "TEE-001", "size": "M", "quantity": 1,
"recommended_size": "M", "tys_shown": True}],
})

¿Te ha resultado útil esta página?