Supermatic Docs

@supermatic/shopify/draft-order

create

Create a draft order.

create(
  storeName: string, // The name of your store.
  draftOrder: {
    appliedDiscount?: {
      amount?: string;
      description?: string;
      title?: string;
      value: number;
      valueType: "FIXED_AMOUNT" | "PERCENTAGE";
    };
    billingAddress?: {
      address1?: string;
      address2?: string;
      city?: string;
      company?: string;
      countryCode?: string;
      firstName?: string;
      lastName?: string;
      phone?: string;
      provinceCode?: string;
      zip?: string;
    };
    customAttributes?: {
      key: string;
      value: string;
    }[];
    customerId?: string;
    email?: string;
    lineItems?: {
      appliedDiscount?: {
        amount?: string;
        description?: string;
        title?: string;
        value: number;
        valueType: "FIXED_AMOUNT" | "PERCENTAGE";
      };
      customAttributes?: {
        key: string;
        value: string;
      }[];
      grams?: number;
      originalUnitPrice?: string;
      quantity: number;
      requiresShipping?: boolean;
      sku?: string;
      taxable?: boolean;
      title?: string;
      variantId?: string;
      weight?: {
        unit: "GRAMS" | "KILOGRAMS" | "OUNCES" | "POUNDS";
        value: number;
      };
    }[];
    localizationExtensions?: {
      key: "SHIPPING_CREDENTIAL_BR" | "SHIPPING_CREDENTIAL_CN" | "SHIPPING_CREDENTIAL_KR" | "TAX_CREDENTIAL_BR" | "TAX_CREDENTIAL_IT" | "TAX_EMAIL_IT";
      value: string;
    }[];
    metaFields?: {
      description?: string;
      id?: string;
      key?: string;
      namespace?: string;
      value?: string;
    }[];
    note?: string;
    privateMetaFields?: {
      description?: string;
      id?: string;
      key?: string;
      namespace?: string;
      value?: string;
    }[];
    shippingAddress?: {
      address1?: string;
      address2?: string;
      city?: string;
      company?: string;
      countryCode?: string;
      firstName?: string;
      lastName?: string;
      phone?: string;
      provinceCode?: string;
      zip?: string;
    };
    shippingLine?: {
      price?: string;
      shippingRateHandle?: string;
      title?: string;
    };
    tags?: string[];
    taxExempt?: boolean;
    useCustomerDefaultAddress?: boolean;
  }
): Promise<{
  id: string; // The ID of the created draft order.
}>

Example

import draftOrder from "@supermatic/shopify/draft-order";

await draftOrder.create(
  "examplestore",
  {
    lineItems: [
      {
        originalUnitPrice: "10",
        quantity: 1,
        title: "My product",
      },
    ],
  }
);

deleteOrder

Delete a draft order.

deleteOrder(
  storeName: string, // The name of your store.
  id: string // The global ID of the draft order.
): Promise<null>

Example

import draftOrder from "@supermatic/shopify/draft-order";

await draftOrder.deleteOrder(
  "examplestore",
  "gid://shopify/DraftOrder/123"
);