30 days free. No credit card. Full access from the moment you connect your site.

Start free trial

Set Product Categories and Tags

store/set-product-taxonomy sets a product’s categories and tags, either replacing what is there or adding to it.

It goes through WooCommerce’s own save path, which does two things a direct term write does not.

At a glance

Abilitystore/set-product-taxonomy
ToolsetWooCommerce — toolset/woocommerce
GroupWooCommerce › Products & Variations
RequiresWooCommerce, active on the site
Capabilitymanage_options
SafetyWrites data
RepeatableIdempotent — running it twice leaves the same result
Ships inAcrossAI Abilities Manager 0.0.34 and later

Two things the save path does

The first is the default category. WooCommerce will not leave a product with no category — if the list would empty, it applies the store’s default. Writing terms directly can leave a product uncategorised, which is a state the catalogue does not really expect and which shows up as a product missing from every category listing.

The second is the hidden product-visibility terms. WooCommerce filters the catalogue on terms like exclude-from-catalog and outofstock, and those are maintained during the save. Terms written directly leave them stale, and the catalogue keeps filtering on what used to be true.

The mode input is the usual replace-or-add question. Replacing is the default because it is unambiguous; adding is what people usually mean when they say “also put it in”.

Categories and tags are handled separately, so you can change one and leave the other.

Input

NameTypeRequiredWhat it is
idintegerYesProduct ID.
category_idsarrayNoProduct category term IDs.
tag_idsarrayNoProduct tag term IDs.
modestringNo — defaults to replaceWhether to replace the current terms or add to them.

What comes back

NameTypeWhat it is
productobjectThe product after the write.
lookup_stateobjectWhether the product lookup table still agrees with the product after the write. A mismatch means the shop is answering SKU searches, price sorts and on-sale queries with stale values.
successbooleanWhether the call completed.
messagestringA one-line summary of what happened, suitable for showing a human.
error_codestringPresent only on failure — a stable machine-readable reason, such as a missing field, a wrong field type or an unmet confirmation.

Example

Ask your assistant:

Also add product 812 to the sale category.

It resolves to one call:

{
  "ability": "store/set-product-taxonomy",
  "parameters": {
    "id": 812,
    "category_ids": [96],
    "mode": "add"
  }
}

Worth knowing

  • Default mode is replace. Say add when you mean add.
  • A product cannot end up with no category — the store default is applied.
  • Omitting tag_ids leaves tags alone, and vice versa.
  • Idempotent.

Related abilities


Get the plugins:
AcrossAI Abilities Manager · AcrossAI MCP Manager

Browse the rest: Every ability, by category


Keep reading