@souldi/try-on 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -8,6 +8,8 @@
8
8
  - **Removed: the size screen.** "How size X sits on you" and its 3D mannequin are gone from the dialog, and the size in the dialog is no longer a button. The mannequin's standalone build is still published, for older bundles that load it.
9
9
  - **Removed: Refine.** The dialog has no Refine control, and the button handle's `refine()` is gone. `onError` no longer reports `operation: 'refine'`, and `onGenerationSuccess` / `onResultShown` no longer carry `refinable`. Refine stays in the Souldi API; the widget never sends a `refinement_prompt`.
10
10
  - `openSize()` on the button handle still opens the dialog on the customer's size. Before a try-on it now shows the garment and **Try on** there.
11
+ - **New: between two sizes, the customer picks.** When the customer is between two neighbouring sizes, the dialog shows "Your size: between M and L" with two options, M for a closer fit and L for a looser one, the recommended one preselected, and "Both will fit you." under them. **Add size X to cart** follows the choice; a new recommendation (edited measurements, another colour) resets it. Shown only where there is a cart button; otherwise the dialog names one size and gives the same advice in words. A customer whose second size is not a neighbour still sees one size, now captioned "This one is harder to call." alone (it used to follow "From your measurements.").
12
+ - **`onAddToCart` gains `recommendedSize` and `recommendationId`** beside `size`, which is the size the customer chose. Additive: a handler that reads `size` alone keeps working. See [`onAddToCart`](README.md#onaddtocart).
11
13
 
12
14
  ## 0.5.0
13
15
 
package/README.md CHANGED
@@ -165,17 +165,29 @@ address, or body measurements.
165
165
  #### `onAddToCart`
166
166
 
167
167
  The widget knows a customer's size; only you know your cart. Supply
168
- `onAddToCart` and the dialog draws an **Add size X to cart** button on both its
169
- screens. Leave it out and there is no cart control at all.
168
+ `onAddToCart` and the dialog draws an **Add size X to cart** button under the
169
+ customer's size. Leave it out and there is no cart control at all.
170
+
171
+ When the customer is between two neighbouring sizes, the dialog says so ("Your
172
+ size: between M and L") and lets them pick which one goes in the cart: the
173
+ smaller for a closer fit, the larger for a looser one, with the recommended size
174
+ preselected. The button follows their choice, and any new recommendation (edited
175
+ measurements, another colour) resets it. Without `onAddToCart` there is nothing
176
+ to pick for, so the dialog shows the one recommended size and says the same
177
+ advice in words.
170
178
 
171
179
  It is called with one `intent` and must **resolve** (never reject) to an
172
180
  outcome:
173
181
 
174
182
  ```js
175
- onAddToCart: async ({ buttonId, size, sizeRun }) => {
176
- // buttonId — the containerId of the button this is about
177
- // size — the size the customer chose, e.g. "M"
178
- // sizeRun — every size the garment's chart offers, e.g. ["S", "M", "L"]
183
+ onAddToCart: async ({ buttonId, size, sizeRun, recommendedSize, recommendationId }) => {
184
+ // buttonId — the containerId of the button this is about
185
+ // size — the size to add: the customer's choice, e.g. "L"
186
+ // sizeRun — every size the garment's chart offers, e.g. ["S", "M", "L"]
187
+ // recommendedSize — the size the widget recommended, e.g. "M". It differs
188
+ // from `size` only when the customer picked the other of
189
+ // two neighbouring sizes
190
+ // recommendationId — the id of the recommendation on screen, or null
179
191
  const variant = resolveVariant(buttonId, size);
180
192
  if (!variant) return { ok: false, message: 'That size is not available in this colour.' };
181
193
  await addLineToCart(variant.id);
@@ -191,6 +203,13 @@ onAddToCart: async ({ buttonId, size, sizeRun }) => {
191
203
  | `quantity` | `ok: true` | Optional. How many of this line the cart now holds, for a repeat add |
192
204
  | `notice` | `ok: true` | Optional. A caveat when the add was adjusted on the way in (short stock, a cart limit) |
193
205
 
206
+ `recommendedSize` and `recommendationId` are new in this release, and only
207
+ added beside the fields you already read. A handler that reads `size` alone
208
+ keeps working and adds what the customer chose. Keep `recommendationId` with the
209
+ line item if you want to match a purchase to the recommendation behind it. The
210
+ widget records each recommendation in the background and nothing waits for
211
+ that record, so it may arrive after the add or not at all.
212
+
194
213
  Two rules the widget keeps for you: nothing is stated in the past tense until
195
214
  you have resolved `{ ok: true }`, and nothing reaches your handler without a
196
215
  click on the button — opening the dialog, a new result landing, and changing