Appearance
useCheckout ​
Definition ​
Composable to manage checkout process
Basic usage ​
ts
const { 
 shippingMethods,
 paymentMethods,
 shippingAddress,
 billingAddress,
 selectedShippingMethod,
 selectedPaymentMethod,
 getShippingMethods,
 getPaymentMethods,
 createOrder,
 setShippingMethod,
 setPaymentMethod 
} = useCheckout();
Signature ​
ts
export function useCheckout(): UseCheckoutReturn 
Return type ​
See UseCheckoutReturn
ts
export type UseCheckoutReturn = {
  /**
   * Fetches all available shipping methods
   */
  getShippingMethods(options?: {
    forceReload: boolean;
  }): Promise<ComputedRef<Schemas["ShippingMethod"][]>>;
  /**
   * List of available shipping methods
   */
  shippingMethods: ComputedRef<Schemas["ShippingMethod"][]>;
  /**
   * Fetches all available payment methods
   */
  getPaymentMethods(options?: {
    forceReload: boolean;
  }): Promise<ComputedRef<Schemas["PaymentMethod"][]>>;
  /**
   * List of available payment methods
   */
  paymentMethods: ComputedRef<Schemas["PaymentMethod"][]>;
  /**
   * Creates order based on the current cart
   */
  createOrder(
    params?: RequestParameters<"createOrder">,
  ): Promise<Schemas["Order"]>;
  /**
   * Shipping address for the current session
   */
  shippingAddress: ComputedRef<Schemas["CustomerAddress"] | undefined>;
  /**
   * Billing address for the current session
   */
  billingAddress: ComputedRef<Schemas["CustomerAddress"] | undefined>;
  /**
   * Selected shipping method for the current session
   * Sugar for {@link useSessionContext.selectedShippingMethod}
   */
  selectedShippingMethod: ComputedRef<Schemas["ShippingMethod"] | null>;
  /**
   * Sets shipping method for the current session
   * Sugar for {@link useSessionContext.setShippingMethod}
   */
  setShippingMethod(shippingMethod: { id: string }): Promise<void>;
  /**
   * Selected payment method for the current session
   * Sugar for {@link useSessionContext.selectedPaymentMethod}
   */
  selectedPaymentMethod: ComputedRef<Schemas["PaymentMethod"] | null>;
  /**
   * Sets payment method for the current session
   * Sugar for {@link useSessionContext.setPaymentMethod}
   */
  setPaymentMethod(paymentMethod: { id: string }): Promise<void>;
};
Properties ​
| Name | Type | Description | 
|---|---|---|
| shippingMethods | ComputedRef<Array<>>  | List of available shipping methods | 
| paymentMethods | ComputedRef<Array<>>  | List of available payment methods | 
| shippingAddress | ComputedRef< | undefined>  | Shipping address for the current session | 
| billingAddress | ComputedRef< | undefined>  | Billing address for the current session | 
| selectedShippingMethod | ComputedRef< | null>  | Selected shipping method for the current sessionSugar for {@link useSessionContext.selectedShippingMethod} | 
| selectedPaymentMethod | ComputedRef< | null>  | Selected payment method for the current sessionSugar for {@link useSessionContext.selectedPaymentMethod} | 
Methods ​
| Name | Type | Description | 
|---|---|---|
| getShippingMethods | Promise<ComputedRef<Array<>>>  | Fetches all available shipping methods | 
| getPaymentMethods | Promise<ComputedRef<Array<>>>  | Fetches all available payment methods | 
| createOrder | Promise<>  | Creates order based on the current cart | 
| setShippingMethod | Promise<void>  | Sets shipping method for the current sessionSugar for {@link useSessionContext.setShippingMethod} | 
| setPaymentMethod | Promise<void>  | Sets payment method for the current sessionSugar for {@link useSessionContext.setPaymentMethod} |