UNPKG

@medusajs/core-flows

Version:

Set of workflow definitions for Medusa

164 lines 5.36 kB
import { AdditionalData, PricingTypes, ProductTypes } from "@medusajs/framework/types"; import { WorkflowData } from "@medusajs/framework/workflows-sdk"; /** * The data to update one or more product variants, along with custom data that's passed to the workflow's hooks. */ export type UpdateProductVariantsWorkflowInput = ({ /** * A filter to select the product variants to update. */ selector: ProductTypes.FilterableProductVariantProps; /** * The data to update in the product variants. */ update: ProductTypes.UpdateProductVariantDTO & { /** * The product variant's prices. */ prices?: Partial<PricingTypes.CreateMoneyAmountDTO>[]; }; } | { /** * The product variants to update. */ product_variants: (ProductTypes.UpsertProductVariantDTO & { /** * The product variant's prices. */ prices?: Partial<PricingTypes.CreateMoneyAmountDTO>[]; })[]; }) & AdditionalData; export declare const updateProductVariantsWorkflowId = "update-product-variants"; /** * This workflow updates one or more product variants. It's used by the [Update Product Variant Admin API Route](https://docs.medusajs.com/api/admin#products_postproductsidvariantsvariant_id). * * This workflow has a hook that allows you to perform custom actions on the updated product variants. For example, you can pass under `additional_data` custom data that * allows you to update 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 update. * * :::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 * To update product variants by their IDs: * * ```ts * const { result } = await updateProductVariantsWorkflow(container) * .run({ * input: { * product_variants: [ * { * id: "variant_123", * prices: [ * { * amount: 10, * currency_code: "usd", * } * ] * }, * { * id: "variant_321", * title: "Small Shirt", * }, * ], * additional_data: { * erp_id: "123" * } * } * }) * ``` * * You can also update product variants by a selector: * * ```ts * const { result } = await updateProductVariantsWorkflow(container) * .run({ * input: { * selector: { * product_id: "prod_123" * }, * update: { * prices: [ * { * amount: 10, * currency_code: "usd" * } * ] * }, * additional_data: { * erp_id: "123" * } * } * }) * ``` * * @summary * * Update one or more product variants. * * @property hooks.productVariantsUpdated - This hook is executed after the product variants are updated. You can consume this hook to perform custom actions on the updated product variants. */ export declare const updateProductVariantsWorkflow: import("@medusajs/framework/workflows-sdk").ReturnWorkflow<UpdateProductVariantsWorkflowInput, { price_set: PricingTypes.PriceSetDTO | undefined; 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<"productVariantsUpdated", { product_variants: WorkflowData<{ price_set: PricingTypes.PriceSetDTO | undefined; 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=update-product-variants.d.ts.map