Skip to main content

updateCategory

Update an existing category and its description.

Import

import { updateCategory } from "@evershop/evershop/catalog/services";

Syntax

updateCategory(uuid: string, data: CategoryData, context?: Record<string, any>): Promise<Category>

Parameters

uuid

Type: string

Category UUID to update.

data

Type: CategoryData

Category data to update. All fields are optional.

context

Type: Record<string, any> (optional)

Context object for hooks.

Return Value

Returns Promise<Category> with updated category data.

Examples

Update Name

import { updateCategory } from "@evershop/evershop/catalog/services";

await updateCategory('category-uuid-123', {
name: "Updated Category Name"
});

Update Status

import { updateCategory } from "@evershop/evershop/catalog/services";

await updateCategory('category-uuid-123', {
status: 0
});

Update Multiple Fields

import { updateCategory } from "@evershop/evershop/catalog/services";

const updated = await updateCategory('category-uuid-123', {
name: "New Electronics",
url_key: "new-electronics",
// `description` is an array of block-editor rows, not a string:
description: [{ id: 'r1', size: 12, columns: [{ id: 'c1', size: 12, data: { blocks: [] } }] }],
position: 10
});

See Also