Skip to main content

Computed quantities for stackable items

What's new

Items accept an optional quantity_expression — a math expression that computes how much of a stackable item to grant, instead of the fixed quantity integer. The expression reuses the MathExpression shape already used by campaign conditions and persistent campaign attributes: a name plus a list of tokens, where each token has a type (attribute, custom_attribute, event_attribute, custom_event_attribute, operator, number, date, string, boolean, list, variable, or virtual_currency) and a value.

Impact

A single item can now scale its grant to the player. Previously a reward of "10% of the player's coin balance" needed a separate item per tier or a campaign to compute it; now the item itself carries the formula, and the platform evaluates it when the item is granted.

Because quantity_expression lives on ItemRead, it also surfaces on every response that embeds an item — nested items, fallback items, store item bonuses, coupon grants, and order line items.

Changes

ResourceChange
create_item, update_item, bulk_create_or_update_items, bulk_update_itemsOptional quantity_expression accepted in the item request body
get_items, get_item, translate_itemquantity_expression returned on the item, its fallback_item, and each nested_items_read entry
get_all_store_items, get_store_items, create_store_item, update_store_item, bulk_update_store_itemsquantity_expression returned on item, bonus_items, and dynamic_nested_items_read
get_coupons, get_coupon, get_user_coupons, create_coupon, update_coupon, bulk_update_couponquantity_expression returned on each entry of the coupon items array
create_order, get_order, update_orderquantity_expression returned on the item behind each order line item

Upgrade

  • No action required. quantity_expression is optional, and items that set only quantity behave exactly as before.
  • If you read item quantities to decide what to grant in game, handle the case where quantity_expression is present — the effective amount comes from the expression, not from quantity.

Need help?
Contact our integration team at integration@aghanim.com