Modules:Magenx_Reward (points engine) and Magenx_RewardGraphQl (storefront API)
A reward points program. Customers earn points on paid orders and spend them at checkout. Points come back or are taken away when orders are cancelled or refunded. Every point movement is recorded once, with its cause, so a balance can always be rebuilt and checked.
Earns floor(earnable amount × earn rate), once. The points stay pending during the holding period.
Order placed
The points applied at checkout are deducted, the soonest-expiring first. If the balance no longer covers them, the order is refused.
Payment fails
The points come back with their original expiry.
Credit memo
Returns its share of redeemed points, and takes back earned points in proportion to the amount refunded.
Order cancelled
Returns the redeemed points of the part not yet invoiced.
Customer deleted
Remaining points are written off. The history stays, anonymised.
Earnable amount is the merchandise after cart discounts, plus shipping if configured, with or without tax as configured, minus the part paid with points. Earning and refunds use the same calculation, so a full refund brings an order’s points back to zero.
The points discount is applied after tax, like a payment: tax and other discounts don’t change.
Go to Stores > Configuration > Magenx > Reward Points. Settings are per website; the terms text is per store view.
Set the earn rate (points per 1.00) and the redeem rate (value of one point).
Set the holding period to your return window, so points for returned goods are never spent. Set an expiry longer than the holding period, or 0 for never.
Set per-order limits and the share of the cart points may pay.
If points can pay a whole order, enable Zero Subtotal Checkout (payment/free/active) on the website.
Enable the program.
Changes apply to points earned from then on. Points already earned keep the holding period and expiry they were given. Invoices paid before the module was installed never earn points.
Each customer gets a referral code and a share link (?ref=). A friend who uses it gets a single-use coupon, and the referrer earns bonus points. The bonus, the friend’s minimum subtotal, the time window and a monthly cap are set under Refer a Friend.
It needs a Cart Price Rule that can generate coupons: active, coupon type Specific Coupon with Use Auto Generation ticked, on the website. Each friend’s coupon is limited to one use, whatever the rule’s own limits.
A signed-in customer places an order. Nothing is earned yet.
The order is invoiced (paid). The system computes earnable money for that invoice and converts it to points at the earn rate, rounding down.
The points are recorded. If a holding period is set, they are pending; otherwise they are spendable at once.
Each further partial invoice earns once, on its own amount. Re-processing the same invoice earns nothing.
Holding period ends
When the holding period of pending points ends, whatever remains of them joins the spendable balance.
Points that expire before their holding period ends never become spendable; they are written off.
Redeem at checkout
The customer sees their spendable balance and the money it is worth.
They enter a number of points. The system checks: program on, signed in, positive whole number, within min/max, not above the spendable balance (after writing off anything already expired), and not worth more than the cart.
If the request is worth more than the cart, it is reduced to the largest whole number of points the cart can cover.
The discount appears as its own line in the cart totals. The customer can change or remove it.
If the cart later shrinks, the applied points shrink with it; they never discount below zero.
Order placement
At placement the applied points are deducted, points closest to expiry first.
Deduction is all or nothing: if the full amount can no longer be taken, nothing is taken and the order is not placed, with a clear message.
If placement fails after the deduction (for example payment declined), the points are given back automatically.
The redemption is frozen onto the order and carried onto its invoices and refunds.
Cancel an unpaid order
All redeemed points still outstanding on the order are returned.
Nothing is revoked: an order that was never invoiced never earned.
Partial or full refund
A refund document returns the share of redeemed points that it carries.
It revokes earned points in proportion to the earnable money it sends back, including goodwill credits and refund fees.
Revocation takes back the refunded order's own points first — including points still pending — before touching any other points.
A sequence of partial refunds can never return more than was redeemed or revoke more than was earned. The final refund settles any rounding remainder.
If the customer has already spent the points, the system takes back what it can, never goes below zero, and records the shortfall for the merchant.
Expiry
Points past their expiry date are written off, with a recorded movement for each expiry.
Expiry runs on a schedule and also immediately before any spend, refund or balance check that depends on it.
Optionally, customers are told before points expire, counting only points that are still unspent.
Refer a friend
Every customer can get one shareable referral code.
A newly registered customer enters a code within the allowed window and before their first order. They get a single-use welcome coupon.
When the friend's first order is invoiced at or above the minimum, the referrer earns bonus points, subject to the same holding period and expiry as any earned points.
If refunds take that order below the minimum, the unspent part of the bonus is revoked.
A monthly cap limits bonuses per referrer; referrals over it are recorded as rejected.
See my points
A signed-in customer opens the account.
The storefront asks for balance, pending, lifetime, money value and next expiry.
When the program is off, the answer is empty and the storefront hides the section.
Points expired since the last scheduled job are already excluded.
Browse history
The customer pages through history (page size 1–100).
Entries come newest first: type, signed points, balance and pending after, readable reason, expiry for earnings, date and order number.
Redeem at checkout
The cart shows applied points, their value and the most points applicable.
The customer applies points; the engine checks and caps them; the cart comes back with totals already reduced.
Applying again replaces the amount; removing clears it.
A refusal comes back as a message the storefront shows unchanged.
Refer a friend
The customer reads their referral card; the first read creates their code.
A newly registered customer enters a friend's code and receives a welcome coupon code.
Unknown and malformed codes get the same refusal.
Order documents
Orders, invoices and refunds show the points and discount they carry.
A customer's spendable balance always equals what their history of earnings, spends, expiries, returns and revocations says it should be. It can be proven at any time and recomputed if it is ever wrong.
A balance is never negative, and no single earning is ever spent more than once.
Point history is permanent: past movements are never edited or deleted; corrections are new movements.
Every movement records its type, signed points, resulting balance, reason, website, store, and the related order, invoice or refund.
Concurrent requests for the same customer never spend the same points twice and never lose an update.
An order can never carry a points discount whose points were not actually deducted.
Points are whole numbers. Every conversion to points rounds down: a partial point is never earned, redeemed or revoked (except the final remainder).
Every number equals what the engine reports for the same customer, website and moment.
The API never changes points itself; every change is an engine operation.
Identity comes only from the session.
A cart can only be read or changed by its owner.
Earnable money = paid merchandise amount after cart discounts (coupons, promotions), plus shipping if configured, in base currency. Money paid with points does not earn points. Whether the amount includes tax is a setting; default follows how the catalog shows prices.
Discount value = points × redemption rate, in base currency. The display-currency amount always matches it at the order's exchange rate.
The most points a cart can take = floor(cart value before the points discount ÷ redemption rate), further limited by the per-order maximum and percentage settings.
Points revoked by a refund = floor(points the order earned × refunded earnable money ÷ the order's earnable money), capped at what is not yet revoked. The refund that returns the last earnable money revokes the exact remainder.
Points returned by a refund = the share of the order's redeemed points that this refund reverses, capped at what is not yet returned. Each invoice and refund shows its share of the points discount; the shares add up to the order's discount, and no document's total goes below zero.
Money value = points × redemption rate, converted to display currency.
Most applicable = min(floor(cart value before points ÷ redemption rate), per-order maximum, percentage cap, spendable balance).
An order is refunded while the points it earned are still in the holding period.
Take back that order's own points first, pending ones included; other points are touched only for any remainder. Nothing from the refunded order activates later.
Points are given back after a cancel, failed payment or refund.
Returned points keep the expiry date they had; points already past expiry are not returned as spendable.
Points expire between scheduled job runs.
Shown and checked balances exclude them immediately.
Points that were partly spent reach their expiry.
Only the unspent part expires; a balance never goes below zero; any clamp to zero raises an alert.
Expiry reminders are sent.
They count only unspent points that will actually expire.
An order has several partial refunds.
Totals never exceed what was redeemed or earned; the final refund settles rounding exactly.
A refund consists only of a goodwill credit or a fee.
Points move in proportion to the money refunded.
The same refund is processed twice.
The second processing changes nothing.
An order is paid largely by discounts or by points.
Points are earned only on money actually paid.
Expiry is configured shorter than the holding period.
The configuration is refused.
The order is in a display currency other than the base currency.
Base currency is the authority.
Guest asks for cart points.
Empty, no error.
Customer uses another customer's cart reference.
Refused; that cart unchanged.
Program switched off while points are applied.
Cart points empty; no discount.
Points expired yesterday; job not run.
Excluded from the balance.
Page size 0 or 101.
Refused.
Code entered twice, by its owner, or after the first order.
Signed-in customers earn points when an invoice is paid and spend them at checkout as a deduction from the order total. Points, balances and settings are kept separately per website. Changes apply to points earned from now on; points already earned keep the holding period and expiry they were given.
Yes/No. Off: nothing is earned or redeemed on this website, and the storefront API returns no points. Existing balances and history are kept.
Program Terms magenx_reward/general/terms
empty
Store view
Text area. Shown when Enable Reward Points = Yes. Shown by the storefront next to the points balance (expiry, holding period, cash value). Plain text; translate per store view.
Earning
Setting
Default
Scope
Notes
Points per 1.00 of Base Currency magenx_reward/earning/rate
1
Website
Text. Points = floor(earnable money × this rate). 0 = nothing is earned.
Earn on Shipping magenx_reward/earning/include_shipping
No
Website
Yes/No. No: merchandise only. Yes: merchandise plus shipping. Money paid with points never earns points.
Earn on Tax magenx_reward/earning/tax_basis
catalog
Website
Dropdown. Whether earnable money includes tax. "Follow catalog price display" uses the website's Tax > Price Display Settings.
Holding Period (Days) magenx_reward/earning/hold_days
0
Website
Text. Days newly earned points stay pending (visible, not spendable). Set it to the return window. 0 = spendable at once.
Expiry (Days) magenx_reward/earning/expiry_days
0
Website
Text. Days after earning when unspent points are written off. 0 = never. Must be longer than the holding period when both are set.
Redemption
Setting
Default
Scope
Notes
Value of One Point (Base Currency) magenx_reward/redemption/rate
0.01
Website
Text. E.g. 0.01 makes 100 points worth 1.00. 0 = points cannot be redeemed.
Minimum Points per Order magenx_reward/redemption/min_points
0
Website
Text. 0 = no minimum.
Maximum Points per Order magenx_reward/redemption/max_points
0
Website
Text. 0 = no maximum. Must not be lower than the minimum.
Maximum Share of the Cart (%) magenx_reward/redemption/max_percent
100
Website
Text. The most of the cart value points may pay for. 100 = the whole cart.
Points May Pay for Shipping and Tax magenx_reward/redemption/cover_shipping_tax
Yes
Website
Yes/No. Yes: the cart value is the order total. No: the cart value is merchandise after discounts, excluding shipping and tax.
Cancellations and Refunds
Setting
Default
Scope
Notes
Return Redeemed Points on Refund magenx_reward/refund/return_redeemed
Yes
Website
Yes/No. A credit memo gives back the share of redeemed points it carries. Cancelled unpaid orders and failed placements always give points back.
Revoke Earned Points on Refund magenx_reward/refund/revoke_earned
Yes
Website
Yes/No. A credit memo takes back points in proportion to the earnable money it refunds (goodwill credits and fees included). The balance never goes below zero; anything not recovered is logged.
Refer a Friend
The friend enters the referrer's code soon after registering and gets a single-use coupon generated from the Cart Price Rule below. The referrer earns bonus points when the friend's first order is invoiced at or above the minimum.
Setting
Default
Scope
Notes
Enable Refer a Friend magenx_reward/referral/enabled
Dropdown. Shown when Enable Refer a Friend = Yes. An active Cart Price Rule with "Specific Coupon" and "Use Auto Generation" ticked. Each friend gets one generated coupon, usable once whatever the rule's own usage limits. No rule: codes are refused.
Minimum Qualifying Order (Base Currency) magenx_reward/referral/min_subtotal
0
Website
Text. Shown when Enable Refer a Friend = Yes. Earnable money the friend's first order must reach. If refunds take it below this, the unspent part of the bonus is revoked.
Code Entry Window (Days After Registration) magenx_reward/referral/window_days
30
Website
Text. Shown when Enable Refer a Friend = Yes.
Bonuses per Referrer per Month magenx_reward/referral/monthly_cap
0
Website
Text. Shown when Enable Refer a Friend = Yes. Referrals over the cap are recorded as rejected. 0 = no cap.
Cron expressions. Correctness never depends on these jobs: balances shown and checked always exclude expired points and include ended holding periods. The jobs write the expiry history, refresh cached balances and retry failed processing.
Setting
Default
Scope
Notes
Expiry Job magenx_reward/cron/expire_schedule
17 * * * *
Global
Text.
Activation Job (Holding Period Ends) magenx_reward/cron/activate_schedule
Everything here needs a customer token. A customer can only change their own cart. Cart mutations and referral codes are rate-limited, and unknown referral codes get the same message as malformed ones, so codes can’t be probed. Order, invoice and credit memo totals are already net of the points discount.
With GDPR installed, the personal data export includes reward points and their history.
Apply reward points to the signed-in customer's cart. Replaces any points already applied. A request worth more than the cart is reduced to the most points the cart can take.
Enter a friend's referral code and receive a single-use welcome coupon. Signed-in customers only, once, soon after registering and before their first order.
Argument
Type
Description
input
ApplyRewardReferralCodeInput!
The friend's code.
Fields added to Magento types
Field
Type
Description
Customer.reward_points
CustomerRewardPoints
The signed-in customer's reward points on the current website. Null when the program is off.
Cart.reward_points
CartRewardPoints
Reward points on this cart. Null for guest carts or when the program is off.
CustomerOrder.reward_points
SalesRewardPoints
Reward points redeemed on this order and the discount they gave. Null when none were used. total.grand_total is already net of it.
StoreConfig.reward_points_enabled
Boolean
Whether the reward points program runs on this store's website.
StoreConfig.reward_points_earn_rate
Float
Points earned per 1.00 of base currency of earnable money.
StoreConfig.reward_points_redeem_rate
Float
Base-currency value of one point.
StoreConfig.reward_points_min_per_order
Int
Minimum points per order; 0 = no minimum.
StoreConfig.reward_points_max_per_order
Int
Maximum points per order; 0 = no maximum.
StoreConfig.reward_points_max_cart_percent
Int
The most of the cart value points may pay for, in percent.
StoreConfig.reward_points_hold_days
Int
Days newly earned points stay pending; 0 = spendable at once.
StoreConfig.reward_points_expiry_days
Int
Days after earning when unspent points expire; 0 = never.
StoreConfig.reward_points_terms
String
Program terms text to show customers.
StoreConfig.reward_referral_enabled
Boolean
Whether refer-a-friend is switched on. Only effective when reward_points_enabled is true.
Types
type CustomerRewardPoints - A customer's reward points on one website.
Field
Type
Description
balance
Int!
Spendable points: earned, past their holding period, not expired and not spent.
pending
Int!
Points still in their holding period: visible, not yet spendable.
lifetime_earned
Int!
Total points ever earned on this website.
balance_value
Money!
What the spendable points are worth, in the store's display currency.
next_expiry
RewardPointsExpiry
The next date unspent points expire and how many, or null when none expire.
history
RewardPointsHistory
Every point movement, newest first.
referral
RewardReferral
The customer's refer-a-friend card. Null when refer-a-friend is off. The first read creates the customer's code.
type RewardPointsExpiry - Points that expire on a date.
Field
Type
Description
date
String!
Expiry date, YYYY-MM-DD (UTC).
points
Int!
Unspent points expiring that day.
type RewardPointsHistory - A page of point movements.
Field
Type
Description
items
[RewardPointsMovement!]!
Movements on this page, newest first.
total_count
Int!
Number of movements in the whole history.
page_info
SearchResultPageInfo!
Pagination metadata.
type RewardPointsMovement - One recorded change of a customer's points. Never edited after it is recorded.
Field
Type
Description
id
ID!
Movement ID.
type
RewardPointsMovementType!
What caused the movement.
points
Int!
Signed change of points held (pending plus spendable).
balance_after
Int!
Spendable points right after the movement.
pending_after
Int!
Pending points right after the movement.
reason
String!
Customer-readable reason, in the store's language, e.g. "Earned on order #1001".
expires_at
String
For earnings: when these points expire (UTC), or null when they never do.
created_at
String!
When the movement was recorded (UTC).
order_number
String
The related order number, when there is one.
enum RewardPointsMovementType - What caused a point movement.
Value
Description
EARN
Earned on a paid invoice.
REFERRAL_BONUS
Bonus for a referred friend's first order.
REDEEM
Spent as a discount on an order.
RETURN
Spent points given back: order cancelled, not placed, or refunded.
REVOKE
Earned points taken back because the money that earned them was refunded.
EXPIRE
Unspent points written off at expiry or account closure.
type RewardReferral - A customer's refer-a-friend card.
Field
Type
Description
code
String!
The customer's shareable code.
bonus_points
Int!
Points the customer earns when a friend's first qualifying order is invoiced.
invited_count
Int!
Customers who entered this customer's code.
rewarded_count
Int!
Referrals that paid this customer a bonus.
points_earned
Int!
Bonus points earned from referrals (revoked bonuses excluded).
received_coupon
String
The single-use coupon this customer received for entering a friend's code, if they did.
can_apply_code
Boolean!
Whether this customer can still enter a friend's code: once, soon after registering, before their first order.
type CartRewardPoints - Reward points applied to a cart, and how many more it could take.
Field
Type
Description
applied_points
Int!
Points applied; 0 when none.
applied_value
Money!
Discount the applied points give, in the cart currency. Already deducted from prices.grand_total.
max_applicable_points
Int!
The most points this cart can take right now: limited by the cart value, the per-order maximum and the customer's spendable balance.
type Invoice
Field
Type
Description
reward_points
SalesRewardPoints
The share of the order's points discount this invoice carries. Null when none.
type CreditMemo
Field
Type
Description
reward_points
SalesRewardPoints
The share of the points discount this credit memo gives back. Null when none.
type SalesRewardPoints - The points discount on an order, invoice or credit memo.
Field
Type
Description
points
Int!
Points the document carries.
amount
Money!
Discount value in the order currency.
type GdprPersonalDataExport
Field
Type
Description
reward_points
[GdprExportRewardPoints]
The customer's reward points balance and full point history on each website.
type GdprExportRewardPoints - Reward points on one website, for a personal data export.
Field
Type
Description
website_code
String!
Website the points belong to.
balance
Int!
Spendable points.
pending
Int!
Points in their holding period.
lifetime_earned
Int!
Total points ever earned.
history
[GdprExportRewardMovement!]!
Every point movement, oldest first.
type GdprExportRewardMovement - One point movement, for a personal data export.
Field
Type
Description
type
String!
earn, referral, redeem, return, revoke or expire.
points
Int!
Signed change of points held.
balance_after
Int!
Spendable points after.
pending_after
Int!
Pending points after.
reason
String!
Readable reason.
order_number
String
Related order number, if any.
created_at
String!
When it was recorded (UTC).
input ApplyRewardPointsToCartInput - Input of applyRewardPointsToCart.
Field
Type
Description
cart_id
String!
The masked ID of the signed-in customer's cart.
points
Int!
Whole number of points to apply, greater than zero.
type ApplyRewardPointsToCartOutput - Output of applyRewardPointsToCart.
Field
Type
Description
cart
Cart!
The updated cart.
input RemoveRewardPointsFromCartInput - Input of removeRewardPointsFromCart.
Field
Type
Description
cart_id
String!
The masked ID of the signed-in customer's cart.
type RemoveRewardPointsFromCartOutput - Output of removeRewardPointsFromCart.
Field
Type
Description
cart
Cart!
The updated cart.
input ApplyRewardReferralCodeInput - Input of applyRewardReferralCode.
Field
Type
Description
code
String!
The friend's referral code. Case, spaces and dashes are ignored.
type ApplyRewardReferralCodeOutput - Output of applyRewardReferralCode.
Field
Type
Description
coupon_code
String!
The single-use welcome coupon issued to the customer.