Developer / API
Twig variable
craft.rewardpoints (registered via CraftVariableBehavior) exposes read-only helpers for
templates. All of them respect the plugin's enabled/display settings and return null when
the relevant display setting is off:
| Method | Returns |
|---|---|
getRuleLabel(ruleId) | The customer-facing label for a rule, or the default "Deducted points from order" string. Requires Show on product page. |
getProductPoint(productId) | Points a product earns, for logged-in customers. Requires Show on product page. |
getQuotePoints(cartId) | Points the current cart would earn. Requires Show on cart/checkout page. |
Site & CP routes
Registered in plugin/Routes.php:
| Route | Purpose |
|---|---|
rewardpoints / rewardpoints/dashboard | CP dashboard |
rewardpoints/points, rewardpoints/points/list | Customer point balances overview |
rewardpoints/history | Point transaction history |
rewardpoints/orders | Orders processed by the plugin |
rewardpoints/rules, rewardpoints/rules/new, rewardpoints/rules/<id> | Rule list/create/edit |
rewardpoints/settings | Plugin settings form |
rewardpoints/license/* | License activation/redeem/revoke/copy-token panel |
rewardpoints/account/status (site) | Customer-facing points & history page |
Events consumed
Reward Points hooks into shared yStore events rather than defining its own:
BaseOrdersService::EVENT_AFTER_ORDER_STATUS_CHANGE— applies earning rules and processes refunds when an order's status changes to one of the configured approve/refund statuses.CheckoutService::EVENT_AFTER_PURCHASE_SUCCESS— records the order and deducts any points the customer chose to spend.CheckoutService::EVENT_AFTER_QUOTE_QUICK_SAVE/EVENT_AFTER_QUOTE_CALCULATE_DISCOUNTS— persists the customer's chosen redemption amount on the cart and folds it into the cart's discount total.CustomerService::EVENT_AFTER_CUSTOMER_SIGN_UP— applies customer-behavior rules (e.g. the registration rule) after sign-up.Elements::EVENT_AFTER_SAVE_ELEMENT— persists per-product rule overrides submitted through the Product Reward Points field.
It also injects markup via two view hooks: account-nav-links (site, the "Reward Points" link in
account navigation) and before-checkout-sidebar-summary (site, the redemption slider), plus a
View::EVENT_BEFORE_RENDER_TEMPLATE listener on yui/customers/_edit that registers a dedicated
Reward Points tab, and the cp-customer-extra-panels hook (CP) that renders the points summary
panel behind that tab.
Product Reward Points field
RewardPointsField is a custom field type that can be added to a product's field layout. It
renders the enabled order-behavior rules that have Customized by Product on, letting an admin
override that rule's steps/points values for the specific product. Overrides are stored per rule
per element and looked up by RulesService::getExtendedRule().
MCP tools
Registered on yui\mcp\Plugin::EVENT_REGISTER_TOOLS when the MCP plugin is installed:
| Tool | Permission | Purpose |
|---|---|---|
rewards_get_balance | read | Current/total/spent points for a customer. |
rewards_get_history | read | A customer's point transaction history, newest first (limit, default 50). |
rewards_list_rules | read | List rules, optionally filtered by rule_type (order/customer) or enabled_only. |
rewards_get_order_points | read | Preview how many points an order would earn under a given rule. |
rewards_add_points | write | Add or deduct points for a customer, optionally tied to a rule and with an audit comment. Requires the PRO edition. |
Console commands
Registered under the rewardpoints module:
# Import point balances from a source (type e.g. csv/json, source e.g. a file path)
php craft rewardpoints/import/points --type=<type> --source=<path> [--validate=1]
Required columns per row: email, total_points, current_points, spent_points. Rows are
matched to an existing customer by email — customers not found are skipped and reported. Existing
point accounts for the same customer are updated in place rather than duplicated. Pass
--validate=1 to check the source without writing any data.
# Reset stored data (interactive confirmation, then flushes Craft's cache)
php craft rewardpoints/reset/points # clears points, orders, history, and extended (per-product) rules
php craft rewardpoints/reset/rules # clears rules
Both reset commands are destructive and irreversible — use them only in non-production environments or when intentionally clearing test data.