Skip to content

why allow_backorder and manage_inventory is forced here to be false and true respectively #573

@aliakr3m

Description

@aliakr3m

for vendors creating a product, they are obligated to manage the stock, while the reverses are in Medusa admin, where admin can choose freely.

export type CreateProductVariantType = z.infer<typeof CreateProductVariant>;
export const CreateProductVariant = z
  .object({
    title: z.string(),
    sku: z.string().optional(),
    ean: z.string().optional(),
    upc: z.string().optional(),
    barcode: z.string().optional(),
    hs_code: z.string().optional(),
    mid_code: z.string().optional(),
    allow_backorder: z.literal(false).optional().default(false),
    manage_inventory: z.literal(true).optional().default(true),
    variant_rank: z.number().optional(),
    weight: z.number().optional(),
    length: z.number().optional(),
    height: z.number().optional(),
    width: z.number().optional(),
    origin_country: z.string().optional(),
    material: z.string().optional(),
    metadata: z.record(z.unknown()).optional(),
    prices: z.array(CreateVariantPrice),
    options: z.record(z.string()).optional(),
    inventory_items: z
      .array(
        z.object({
          inventory_item_id: z.string(),
          required_quantity: z.number(),
        })
      )
      .optional(),
  })
  .strict();

file : https://github.com/mercurjs/mercur/blob/main/packages/modules/b2c-core/src/api/vendor/products/validators.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions