2.0 Beta

Smootify 2.0 is in public beta. Your 1.x store keeps working. Move when you want.

What changed

draft_order_data

The draft order about to be created (Draft Orders, server plan): a quote, or a checkout or buy now with a custom price. An error a filter throws shows in the cart or the form.

v2.0 beta
Open .md
On this page
  1. Types
  2. DraftOrderData
  3. DraftOrderContext
  4. FilterAnswer

The draft order about to be created (Draft Orders, server plan): a quote, or a checkout or buy now with a custom price. An error a filter throws shows in the cart or the form.

Add it with Smootify.addFilter: answer the value changed, nothing to keep it, or false to stop.

draft_order_data: ( data: DraftOrderData, context: DraftOrderContext, ) => FilterAnswer<DraftOrderData> | Promise<FilterAnswer<DraftOrderData>>

Types

DraftOrderData

/** A draft order as Smootify creates it (Draft Orders): what `getCartAsDraftOrderData` answers, what `draft_order_data` filters. */
export interface DraftOrderData {
  input: {
    lineItems: Record<string, unknown>[];
    customAttributes?: { key: string; value: string }[];
    note?: string;
    presentmentCurrencyCode?: string;
  };
  customerId?: string;
  email?: string;
}

DraftOrderContext

export interface DraftOrderContext {
  reason: "quote" | "checkout" | "buy-now";
}

FilterAnswer

/** What a filter answers: the value changed, nothing (`undefined`) to keep it, `false` to stop. */
export type FilterAnswer<T> = T | false | undefined;

    ↑ ↓ to moveEnter to openEsc to close