Files
platform/packages/commerce/README.md
T

31 lines
1.2 KiB
Markdown

# @blade-and-brawn/commerce
Printful and Webflow API clients, plus the `ProductSyncer` that keeps Webflow
CMS products/SKUs in sync with Printful's catalog.
## Exports
- `PrintfulClient` — `new PrintfulClient({ storeId, token, webhookSecret })`;
products, webhooks.
- `WebflowClient` — `new WebflowClient({ siteId, collectionIds: { products, skus }, token, webhookSecret })`;
CMS products/SKUs, webhooks.
- `ProductSyncer` — `new ProductSyncer(printful, webflow)`; `syncApparel(options)`
pulls Printful products and upserts them into the Webflow collections,
respecting the naming conventions below.
- Shared `Printful`/`Webflow` request/response types (`util/types.ts`) and misc
helpers (`util/misc.ts`, e.g. `formatSlug`).
## Printful product naming conventions
- "Color-grouped" products follow the format `Product Name [color]`.
Constraints:
1. A color-grouped product should have no more than *one* Printful color variant.
2. That single color-grouped product's variant should match `[color]`.
3. Printful product names should be unique.
See `apps/api/src/scripts/register-webhooks.ts` for how webhooks are
registered against the API's domain, and `apps/api/src/services/commerce.ts`
for how `ProductSyncer` is invoked.