Manage cart rules and voucher codes

ps_manage_cart_rules

Write · preview + approveCommerce · switch, until turned offTellMyShop Pro onlySaves: Commerce switch (until turned off)Visible right after install

Creates discount codes, including batches of single-use codes, and switches them on or off. New codes start switched off.

TellMyShop Free: No. This tool is only in TellMyShop Pro. TellMyShop Free has only ready reports that read your store.

Ask Claude

„Create code WELCOME10: 10% off orders over 200 PLN, valid until the end of the year, once per customer.”

Example preview

New cart rule "Welcome 10%", code WELCOME10, 10%, min. 200 PLN gross, 2026-10-05 to 2026-12-31, 1 per customer, 1000 uses. Created as INACTIVE: switch it on with set_active after checking.

Technical details

Discount codes (cart rules). action=list (with number of uses) and action=get (details with restrictions). action=create makes one code: percentage, amount or free shipping, minimum cart value, dates, total uses and uses per customer, optional restrictions to categories, products or manufacturers, customer groups, exclusive (doesn't combine with other codes), exclude_discounted, and for percentage discounts apply_to (whole order, selected products or the cheapest product). action=generate makes a series of unique SINGLE-USE codes with a prefix (for example 200 newsletter codes, count up to 500) with the same conditions. action=update changes code, dates, limits, value or name. action=set_active switches a code on or off. action=delete removes a code that was NEVER used in an order (a used code can only be switched off). New codes start INACTIVE unless activate=true. A rule without a code applies to every customer automatically and needs auto_apply=true.

Parameters

NameTypeRequiredDescription
actionenum: list | get | create | update | set_active | generate | deleteyeslist | get | create | update | set_active | generate | delete.
shop_idintegernoShop ID in a multistore installation. Defaults to the shop in the connector address. IDs are listed by ps_get_shop_info.
cart_rule_idintegerwhen: action=get, update, set_active or deleteget/update/set_active/delete: ID from action=list.
namestringnocreate/generate/update: name shown in the customer's cart (for example "Autumn sale -10%"). Max 254 characters.
codestringnocreate/update: the code to type in the cart (letters, digits, - and _).
auto_applybooleannocreate: true = a rule WITHOUT a code, applied automatically to everyone who meets the conditions. Default false.
reduction_percentnumbernodiscount in % (create/generate/update). Max 100.
reduction_amountnumbernoamount discount in the shop currency (create/generate/update). Max 1,000,000.
amount_tax_includedbooleannocreate/generate: the amount discount is gross (default).
free_shippingbooleannofree shipping (create/generate/update).
minimum_amountnumbernominimum gross cart value, 0 = no minimum (create/generate/update).
date_fromstring (YYYY-MM-DD)novalid from (create/generate: default today), YYYY-MM-DD.
date_tostring (YYYY-MM-DD)when: action=create or generatevalid to (create/generate: required), YYYY-MM-DD.
quantityintegerwhen: action=createcreate: total number of uses (required); update: remaining number of uses. Range 0 to 1,000,000.
quantity_per_userintegernouses per customer (default 1). Range 1 to 1000.
category_idsarray of integernocreate/generate: the code works only when the cart has a product from these categories (IDs from ps_get_category_tree). Max 50 items.
productsarray of stringnocreate/generate: the code works only with these products. Max 100 items.
manufacturer_idsarray of integernocreate/generate: the code works only with products of these manufacturers. Max 50 items.
min_productsintegernocreate/generate: how many such products must be in the cart. Range 1 to 1000. Default 1.
apply_toenum: order | selected_products | cheapestnocreate/generate (percentage discount only): order = whole cart, selected_products = only the restricted products, cheapest = the cheapest product. Default order.
exclude_discountedbooleannocreate/generate/update: the discount skips products that are already discounted.
customer_group_idsarray of integernocreate/generate: only for these customer groups. Max 20 items.
exclusivebooleannocreate/generate: can't be combined with other discount codes. Default false.
highlightbooleannocreate/update: suggest the code in the cart when the customer meets the conditions.
partial_usebooleannocreate/update (amount discount): the unused part of the amount stays as a new code for the customer.
descriptionstringnocreate/generate/update: internal description (back office only). Max 254 characters.
activatebooleannocreate/generate: active right away (default no: you switch it on after checking).
countintegerwhen: action=generategenerate: how many codes (each single use). Range 1 to 500.
prefixstringwhen: action=generategenerate: code prefix (for example NEWS10 -> NEWS10-7KQ3XW9P).
code_lengthintegernogenerate: length of the random part of the code. Range 6 to 16. Default 8.
activebooleanwhen: action=set_activeset_active: true = switch on, false = switch off.
only_activebooleannolist: active only. Default false.
searchstringnolist: fragment of the name or code. Max 100 characters.
limitintegernoMaximum rows (default 50, max 200).
offsetintegernoRows to skip, for paging (default 0).
confirmbooleannofalse (default) returns a preview and saves nothing. true executes, only after the user approved the preview, together with change_token.
change_tokenstringwhen: confirm=trueToken from the preview. Required with confirm=true. Valid 30 minutes, single use, bound to the previewed arguments and data state.

Limits

New codes start inactive unless activate=true. generate: up to 500 single-use codes per call. delete only for codes never used in an order. Rule without a code needs auto_apply. List max 200 rows (default 50). It is a write tool, so without an active licence it is hidden, list included; changes need the Commerce switch. Permission checked per action (AdminCartRules). Revertible with ps_revert_change.

What you see before anything is saved

Claude first calls the tool without confirming it. The module returns a preview (current and new values) and a single-use token valid for 30 minutes. Claude shows you the preview and saves the change only after your yes.

Related tools

Use cases with this tool

Last updated: 2026-10-11