modules/phyto_loyalty/
Direct path in the repo โ all PHP, SQL, templates, and assets
Overview
A full-featured loyalty points programme. Customers earn points on every purchase, redeem them in the cart as a discount, and progress through four tiers that unlock better earn rates and perks. Admins can view the full transaction ledger and manually adjust points per customer.
Tiers
| Tier | Name | Points Threshold | Earn Rate |
|---|---|---|---|
| 1 | Seedling | 0 | 1ร |
| 2 | Cutting | 500 | 1.25ร |
| 3 | Grower | 2,000 | 1.5ร |
| 4 | Specimen | 5,000 | 2ร |
Customer Experience
- Points balance shown in account dashboard and cart
- “Redeem X points for โนY off” widget in cart (configurable conversion rate)
- Tier badge displayed on account page
- Transaction history: earned, redeemed, expired, admin-adjusted
Admin Features
- Per-customer ledger view
- Manual point adjustment (add/deduct) with reason note
- Configurable: points per โน1 spent, redemption rate, tier thresholds
- Bulk export of loyalty balances
Source Layout
| Path | Purpose |
|---|---|
phyto_loyalty.php | Module entry + hooks |
classes/PhytoLoyaltyAccount.php | ORM for customer point balances |
classes/PhytoLoyaltyLedger.php | ORM for individual transactions |
classes/PhytoTierCalculator.php | Tier and earn-rate logic |
controllers/admin/AdminPhytoLoyaltyController.php | Admin ledger + adjustments |
sql/install.sql | Creates accounts + ledger tables |
views/templates/hook/cart_redeem.tpl | Cart redemption widget |
views/templates/hook/account_balance.tpl | Account dashboard balance card |