Skip to main content
Glama

Create a coupon

wp_wc_create_coupon

Create a published WooCommerce coupon with a validated code, amount, discount type, and optional expiry date. Refuses duplicate codes, unknown discount types, or invalid dates before saving.

Instructions

WooCommerce: create a published coupon with a new, unused code, an amount, a discount type and an optional expiry date. Everything is checked before the coupon exists: a code already in use, an unknown discount type or an impossible date is refused. Returns created, id and the code as WooCommerce stores it (normally lower-cased). A repeated call with the same code after the first has finished is refused, since the code is then in use; two calls that overlap (a retry while the first still runs) are not guarded against and can create two coupons. wp_wc_list_coupons lists the existing coupons; changing or deleting one is done in WooCommerce. Needs manage_woocommerce. Requires WooCommerce.

Input Schema

NameRequiredDescriptionDefault
codeYesCoupon code customers enter. WooCommerce normalises it (sanitised, lower-cased); a backslash is refused.
amountYesA number of at least 0: a percentage or an amount in shop currency, depending on discount_type. WooCommerce refuses a percentage over 100.
expiresNoExpiry date, YYYY-MM-DD. Omitted: the coupon does not expire.
discount_typeNopercent, fixed_cart or fixed_product. Default percent.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv4.10.0

TDQS

A4.6/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Goes well beyond the annotations: validation happens before the coupon exists (duplicate code, unknown discount type, impossible date all refused), the return shape is described, and the non-idempotency declared in annotations is explained concretely — sequential retries are refused but overlapping/parallel retries are NOT guarded against, a real duplicate-creation risk. Slightly short of 5 because it doesn't say what a refusal looks like to the caller (error vs. empty result).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the action and its required inputs, then validation, return, retry caveat, and routing. Every sentence carries distinct information, though the closing auth/ecosystem requirements are a touch terse-compressed for the density of the preceding sentences.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 4-parameter mutation with no output schema, everything an agent needs is present: required inputs, validation refusals, return values, retry/duplicate hazard, permission requirement, and the boundary against sibling tools.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the schema already carries the parameter semantics and a 3 is the baseline. The description adds validation meaning on top — an unknown discount type or impossible date is refused, and the code comes back as WooCommerce stores it (lower-cased) — which is not derivable from the schema alone.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('create a published coupon') plus the shape of what gets created (new unused code, amount, discount type, optional expiry). It also names the sibling it is not — wp_wc_list_coupons — so an agent can route between create and list without opening either schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit about when to use it and, crucially, when not to: listing goes to wp_wc_list_coupons and 'changing or deleting one is done in WooCommerce' tells the agent no update/delete coupon tool exists. Also names the precondition (manage_woocommerce, WooCommerce required).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools