@asstio-dev/storefront 0.42.0 → 0.43.0
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/README.md +18 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,8 +10,8 @@ npm install @asstio-dev/storefront
|
|
|
10
10
|
```
|
|
11
11
|
|
|
12
12
|
Setting a shop up in the first place — the Asstio-side MCP calls, the API key kinds, CORS, the filter and
|
|
13
|
-
price model —
|
|
14
|
-
served publicly at <https://api.storefront.asstio.com/docs/onboarding>. This file is only about using the
|
|
13
|
+
price model — starts at [`docs/PUBLIC_STOREFRONT_ONBOARDING.md`](../../docs/PUBLIC_STOREFRONT_ONBOARDING.md) (with the checkout and
|
|
14
|
+
contract-reference parts beside it), served publicly at <https://api.storefront.asstio.com/docs/onboarding>. This file is only about using the
|
|
15
15
|
package.
|
|
16
16
|
|
|
17
17
|
```ts
|
|
@@ -178,6 +178,22 @@ for (const a of product.attributes) {
|
|
|
178
178
|
}
|
|
179
179
|
```
|
|
180
180
|
|
|
181
|
+
A variant has its own `attributes[]` of the same shape, holding only what that variant has of its own (a shade, a
|
|
182
|
+
strength): it inherits nothing, is always an array and is `[]` on a single product. Read the selected variant's list
|
|
183
|
+
first and the product's after it. The merchant maps these in Asstio, so branch on `type` and, if you want a special
|
|
184
|
+
widget, on a `key` you have seen in a response. `facetKey` and `valueKeys` are always `null` on a variant, and a value is
|
|
185
|
+
free text the platform does not validate:
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
const own = variant.attributes ?? []; // [] when the variant has none
|
|
189
|
+
const isSwatch = (a: (typeof own)[number]) =>
|
|
190
|
+
a.key === "storefront-color" && /^#[0-9a-f]{6}(,#[0-9a-f]{6})*$/i.test(a.value ?? "");
|
|
191
|
+
for (const a of own) {
|
|
192
|
+
if (isSwatch(a)) renderSwatch(a.value!.split(",")); // several colours are comma-separated
|
|
193
|
+
else renderRow(a.label, a.value ?? a.values?.join(", ")); // anything else, a free-text colour included
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
181
197
|
`facetKey` and `valueKeys` turn an attribute's values into filter links — `filter[facetKey]=valueKeys[i]`, aligned
|
|
182
198
|
index-for-index with `values` (or carrying the single `value`'s key). `valueKeys` is absent entirely when any one
|
|
183
199
|
value has no key of its own: a list is either fully linkable or not linkable at all.
|