2.0 Beta

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

What changed

checkout_url

Where the visitor goes to check out: the checkout url (or the invoice of a draft order), from the cart's checkout button, a buy now or `Smootify.checkout()`. Answer another url (parameters added, another checkout) or `false` to keep the visitor here (terms not accepted, a minimum order); the message of an error a filter throws shows in the cart. `smootify:initiate_checkout` goes out only when the visitor leaves.

v2.0 beta
Open .md
On this page
  1. Types
  2. CheckoutContext
  3. FilterAnswer

Where the visitor goes to check out: the checkout url (or the invoice of a draft order), from the cart’s checkout button, a buy now or Smootify.checkout(). Answer another url (parameters added, another checkout) or false to keep the visitor here (terms not accepted, a minimum order); the message of an error a filter throws shows in the cart. smootify:initiate_checkout goes out only when the visitor leaves.

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

checkout_url: ( url: string, context: CheckoutContext, ) => FilterAnswer<string> | Promise<FilterAnswer<string>>

Types

CheckoutContext

/**
 * What checks out. `cart`: the cart, or null for a buy now with a custom price, which skips the cart; `draftOrder`: the
 * url is the invoice of a draft order, whose data (after `draft_order_data`) is `draftOrderData`.
 */
export interface CheckoutContext {
  cart: Cart | null;
  draftOrder: boolean;
  draftOrderData?: DraftOrderData | undefined;
}

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