@medusajs/core-flows
Version:
Set of workflow definitions for Medusa
144 lines • 5.29 kB
TypeScript
import { AdditionalData, PricingTypes, ProductTypes } from "@medusajs/framework/types";
import { WorkflowData } from "@medusajs/framework/workflows-sdk";
/**
*
* The data to create one or more product variants, along with custom data that's passed to the workflow's hooks.
*
* @privateRemarks
* TODO: Create separate typings for the workflow input
*/
export type CreateProductVariantsWorkflowInput = {
/**
* The product variants to create.
*/
product_variants: (ProductTypes.CreateProductVariantDTO & {
/**
* The product variant's prices.
*/
prices?: PricingTypes.CreateMoneyAmountDTO[];
} & {
/**
* The inventory items to associate with managed product variants.
*/
inventory_items?: {
/**
* The inventory item's ID.
*/
inventory_item_id: string;
/**
* The number of units a single quantity is equivalent to. For example, if a customer orders one quantity of the variant,
* Medusa checks the availability of the quantity multiplied by the value set for `required_quantity`.
* When the customer orders the quantity, Medusa reserves the ordered quantity multiplied by the value
* set for `required_quantity`.
*/
required_quantity?: number;
}[];
})[];
} & AdditionalData;
export declare const createProductVariantsWorkflowId = "create-product-variants";
/**
* This workflow creates one or more product variants. It's used by the [Create Product Variant Admin API Route](https://docs.medusajs.com/api/admin#products_postproductsidvariants).
*
* This workflow has a hook that allows you to perform custom actions on the created product variants. For example, you can pass under `additional_data` custom data that
* allows you to create custom data models linked to the product variants.
*
* You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around product-variant creation.
*
* :::note
*
* Learn more about adding rules to the product variant's prices in the Pricing Module's
* [Price Rules](https://docs.medusajs.com/resources/commerce-modules/pricing/price-rules) documentation.
*
* :::
*
* @example
* const { result } = await createProductVariantsWorkflow(container)
* .run({
* input: {
* product_variants: [
* {
* product_id: "prod_123",
* sku: "SHIRT-123",
* title: "Small Shirt",
* prices: [
* {
* amount: 10,
* currency_code: "USD",
* },
* ],
* options: {
* Size: "Small",
* },
* },
* ],
* additional_data: {
* erp_id: "123"
* }
* }
* })
*
* @summary
*
* Create one or more product variants.
*
* @property hooks.productVariantsCreated - This hook is executed after the product variants are created. You can consume this hook to perform custom actions on the created product variants.
*/
export declare const createProductVariantsWorkflow: import("@medusajs/framework/workflows-sdk").ReturnWorkflow<CreateProductVariantsWorkflowInput, {
prices: PricingTypes.MoneyAmountDTO[];
id: string;
title: string;
sku: string | null;
barcode: string | null;
ean: string | null;
upc: string | null;
allow_backorder: boolean;
manage_inventory: boolean;
requires_shipping: boolean;
hs_code: string | null;
origin_country: string | null;
mid_code: string | null;
material: string | null;
weight: number | null;
length: number | null;
height: number | null;
width: number | null;
options: ProductTypes.ProductOptionValueDTO[];
metadata: Record<string, unknown> | null;
product?: ProductTypes.ProductDTO | null;
product_id: string | null;
variant_rank?: number | null;
created_at: string | Date;
updated_at: string | Date;
deleted_at: string | Date;
}[], [import("@medusajs/framework/workflows-sdk").Hook<"productVariantsCreated", {
product_variants: WorkflowData<{
prices: PricingTypes.MoneyAmountDTO[];
id: string;
title: string;
sku: string | null;
barcode: string | null;
ean: string | null;
upc: string | null;
allow_backorder: boolean;
manage_inventory: boolean;
requires_shipping: boolean;
hs_code: string | null;
origin_country: string | null;
mid_code: string | null;
material: string | null;
weight: number | null;
length: number | null;
height: number | null;
width: number | null;
options: ProductTypes.ProductOptionValueDTO[];
metadata: Record<string, unknown> | null;
product?: ProductTypes.ProductDTO | null;
product_id: string | null;
variant_rank?: number | null;
created_at: string | Date;
updated_at: string | Date;
deleted_at: string | Date;
}[]>;
additional_data: ((Record<string, unknown> | WorkflowData<Record<string, unknown> | undefined>) & Record<string, unknown>) | undefined;
}, unknown>]>;
//# sourceMappingURL=create-product-variants.d.ts.map