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

Start free trial

Adjust Stock

store/adjust-stock sets, increases or decreases a stock level, and returns the level before and after.

It routes through WooCommerce’s own stock handling, which does five things a direct write does not.

At a glance

Abilitystore/adjust-stock
ToolsetWooCommerce — toolset/woocommerce
GroupWooCommerce › Inventory
RequiresWooCommerce, active on the site
Capabilitymanage_options
SafetyWrites data
RepeatableNot idempotent — each call changes the row set, so re-running is not a no-op
Ships inAcrossAI Abilities Manager 0.0.34 and later

What the proper path does

It finds the record that actually holds the number — the parent product, for a variation managed there — rather than writing the field you happened to name.

It updates without losing a concurrent change. Stock is the one number on a shop that two processes genuinely do write at the same moment: a customer checking out while an assistant adjusts. A read-modify-write loses one of them; WooCommerce’s path does not.

It recalculates whether the product counts as in stock, which is a derived value that depends on the quantity, the backorder setting and the low-stock threshold together.

It refreshes the hidden term the catalogue uses to hide sold-out products. Without that, a product restocked to twenty stays hidden from the shop.

And it fires the events inventory integrations listen for — the hooks a stock synchronisation plugin or an accounting integration is waiting on.

Increase and decrease are the right operations for most real adjustments. Setting an absolute value is correct after a stock count and wrong after a delivery, because the number you read a minute ago may already have moved.

Input

NameTypeRequiredWhat it is
idintegerYesProduct or variation ID.
quantityintegerYesThe amount to set, add or remove.
operationstringNo — defaults to setset, increase or decrease.

What comes back

NameTypeWhat it is
beforeintegerThe level before the change.
afterintegerThe level after it.
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:

Twelve more of product 812 arrived today.

It resolves to one call:

{
  "ability": "store/adjust-stock",
  "parameters": {
    "id": 812,
    "quantity": 12,
    "operation": "increase"
  }
}

Worth knowing

  • Use increase or decrease for deliveries and breakages; set only after a count.
  • Not idempotent when increasing or decreasing — running it twice applies it twice.
  • The write lands on the authoritative record, not necessarily the ID you passed.
  • Restocking a hidden sold-out product makes it visible again automatically.

Related abilities


Get the plugins:
AcrossAI Abilities Manager · AcrossAI MCP Manager

Browse the rest: Every ability, by category


Keep reading