Affiliate Mini Plugin for WooCommerce: A Lightweight Referral and Store Credit System
Turn word‑of‑mouth into repeat purchases with a simple cookie‑based referral flow, automatic store credit, and a shareable link—without the complexity of traditional affiliate stacks.
What Is the Affiliate Mini Plugin?
The Affiliate Mini Plugin is a compact WordPress plugin designed specifically for WooCommerce merchants who want a simple, privacy‑aware referral mechanism. Instead of managing complicated affiliate dashboards, payout schedules, and third‑party integrations, this plugin lets you reward customers with store credit whenever their referred contacts place orders. It tracks a referrer via a short URL parameter, stores that information in a cookie, and automatically adds a fixed store credit reward—by default €5.00—for each completed order from the referred customer.
The plugin also enhances the customer experience by automatically applying available credit as a discount at checkout. Customers can view their accumulated balance in their My Account dashboard and copy or share their personal referral link in one click (including share buttons for Facebook and WhatsApp). For store owners, a network admin report gives a quick overview of affiliates, their earned totals, and who they referred.
- Cookie‑based referral tracking using a simple ?aff= parameter
- Automatic fixed store credit per completed order (default: €5.00)
- Auto‑apply credit as a negative fee at checkout (no coupon needed)
- Balance and shareable link shown in My Account
- Lightweight, minimal configuration, and WooCommerce‑native hooks
Why Your WooCommerce Store Benefits from This Plugin
Encourage Word‑of‑Mouth Growth
Happy customers are your best marketers. Give them a clear, instant incentive—store credit—to share your store with friends and colleagues, turning casual recommendations into measurable growth.
Frictionless Checkout Savings
Available credit is automatically applied as a discount at checkout. No coupon codes to remember. Shoppers see their rewards and savings without extra steps, which can improve conversion rates.
Zero Heavy Infrastructure
Skip complex affiliate stacks, third‑party dashboards, and payout reconciliations. This plugin focuses on store credit—kept inside WooCommerce—so you can launch quickly and maintain easily.
Transparent Reporting
A built‑in report (Network Admin) lists top affiliates, total earned, current balances, and referred users—helping you spot advocates and reward them appropriately.
How the Referral Flow Works
1) Tracking with a Cookie
The plugin sets a cookie when a visitor arrives with a URL parameter like ?aff=123 (or a username/email). This cookie persists for 30 days by default, ensuring that if the visitor registers or places an order during that period, the correct referrer is recognized.
2) Attribution on Registration or Checkout
If a new customer registers, the plugin saves the referrer’s ID to their user profile. If a guest proceeds directly to checkout, the referrer is saved to the order’s metadata. The plugin prevents self‑referrals and validates that the referrer actually exists.
3) Rewarding the Referrer
When an order is paid or marked completed, the referrer receives a fixed credit—out of the box, €5.00 per order. This credit increases their total earned and available balance. Safeguards prevent double‑crediting the same order.
4) Auto‑Applying Store Credit
If a customer has a positive balance, the plugin automatically adds a negative fee to the cart called “Slof‑winkel tegoed,” effectively discounting the order up to the available credit. The used amount is recorded on the order and deducted from their balance to prevent reuse.
Key Features and Capabilities
Cookie‑Based Referral Tracking
- Affiliate parameter: ?aff= accepts a numeric user ID, username, slug, or email.
- Cookie lifetime: 30 days by default (adjustable in code).
- Domain handling respects COOKIE_DOMAIN or falls back to site host.
Safe and Consistent Attribution
- Referrer stored on registration as user meta referred_by.
- For guests, referrer stored on the order meta _amp_referred_by.
- Self‑referrals are ignored; referrer must be an existing user.
Automatic Store Credit Rewards
- Default reward: €5.00 per completed order (constant AMP_CREDIT_PER_ORDER).
- Referrer totals: affiliate_total_earned and current affiliate_balance.
- Double‑grant prevention with _amp_affiliate_credit_granted.
Seamless Checkout Discounts
- Auto‑applies credit as a negative fee (no coupons or manual steps).
- Caps discount to the cart total to avoid negative order amounts.
- Thorough order meta bookkeeping (_amp_credit_used, _amp_credit_deducted, etc.).
Customer‑Friendly My Account Enhancements
- Displays current balance and a personal referral link.
- One‑click “Copy link,” plus Facebook and WhatsApp share buttons.
- Clear, concise explainer content to boost participation.
Admin Visibility and Multisite Support
- Network admin submenu: “Affiliate Links” reports affiliates and referred users.
- Sortable overview of total earned and available balances.
- Helpful notice if WooCommerce is not active.
Installation and Basic Configuration
Requirements
- WordPress with WooCommerce active
- Logged‑in customers to accumulate and spend credit
- HTTPS recommended for secure cookies and best practices
Setup Steps
- Install and activate the plugin in your WordPress network (it’s network‑aware).
- Confirm WooCommerce is active. The plugin displays a network admin notice if it’s missing.
- Optionally adjust constants in code:
- AMP_COOKIE_DAYS to change cookie lifespan.
- AMP_CREDIT_PER_ORDER to change the fixed reward amount.
- Update the referral landing/registration URL if needed:
The default link shown in My Account points to https://slof-winkel.com/registreer/. Replace this with your own registration or landing page URL in the code so customers share the right destination.
- Test the flow end‑to‑end (described below) before going live.
Recommended Test Flow
- Create a test user to act as the referrer. Copy their personal link from My Account (or manually append ?aff=USER_ID to your registration URL).
- Open a private/incognito window and visit your referral link to set the cookie.
- Register a new account or proceed as a guest and place an order.
- Complete payment (or mark the order completed as admin) and verify the referrer’s balance increased.
- Log in as the referred customer, add products to the cart, and ensure available credit is auto‑applied at checkout.
Use Cases Where This Plugin Shines
Direct‑to‑Consumer (D2C) Stores
If your brand thrives on community and repeat purchases, store credit for referrals is a natural fit. It encourages loyal customers to spread the word while keeping rewards inside your ecosystem.
Membership or Subscription‑Adjacent Stores
Even if you don’t run a subscription, you can nudge customers to make that next purchase by letting them accumulate credit as their referrals complete orders.
Local and Niche Retailers
Small teams often can’t justify heavyweight affiliate software. This plugin delivers the essentials—tracking, rewarding, and spending—without operational overhead.
Technical Notes for Developers
Core Constants
- AMP_COOKIE: the cookie name (amp_referrer by default).
- AMP_COOKIE_DAYS: cookie lifespan (default 30 days).
- AMP_CREDIT_PER_ORDER: fixed reward per completed order (default €5.00).
Important Hooks
- init: set the affiliate cookie and ensure WooCommerce session when needed.
- user_register: attach referred_by to the new user.
- woocommerce_checkout_create_order: store referrer on the order for guests.
- woocommerce_payment_complete / woocommerce_order_status_completed: grant referrer credit.
- woocommerce_cart_calculate_fees: auto‑apply available balance as a negative fee.
- woocommerce_checkout_update_order_meta and status hooks: persist used credit and deduct from balance.
Metadata Used
- User meta: referred_by, affiliate_balance, affiliate_total_earned
- Order meta: _amp_referred_by, _amp_affiliate_credit_granted, _amp_affiliate_referrer, _amp_affiliate_credit_amount, _amp_credit_used, _amp_credit_user
- Session key: amp_credit_applied to carry discount info across checkout.
Security and Privacy Considerations
- Inputs are sanitized and referrer IDs validated. The plugin avoids self‑referrals.
- For best practice, run your store over HTTPS and consider setting Secure and SameSite flags on cookies at the server level.
- Amounts are stored and displayed as formatted numbers; if you need accounting‑grade precision or multi‑currency, consider storing amounts in “cents” (integers) and formatting at display time.
Multisite Reporting
The plugin includes a network admin page listing affiliates and their referred users. For large user bases, consider adding pagination or export options to keep the UI responsive.
Frequently Asked Questions
Does the plugin pay out cash?
No. It awards store credit that is automatically used as a discount during checkout. This keeps rewards in your store and simplifies operations—no bank transfers or external payouts required.
Can I change the reward amount?
Yes. Edit the constant AMP_CREDIT_PER_ORDER in the plugin. The default is €5.00 per completed order. You can also change the cookie lifetime via AMP_COOKIE_DAYS.
How is the referrer identified?
Through the ?aff= URL parameter. It accepts a numeric user ID, username, slug, or email. The plugin stores this in a cookie to attribute future registrations or orders within the cookie window.
What happens at checkout?
If a logged‑in customer has a positive balance, the plugin automatically adds a negative fee, reducing the order total up to the available credit. The deducted amount is recorded on the order and subtracted from the user’s balance to prevent reuse.
Can guests participate?
Guests referred by a link are tracked via the cookie. If they order without registering, the order still captures the referrer in metadata so the store owner can see attribution, and the referrer receives credit once the order completes.
Is WooCommerce required?
Yes. The plugin relies on WooCommerce hooks and sessions. It will display a network admin notice if WooCommerce is inactive.
Conclusion: A Practical, Low‑Overhead Way to Reward Referrals
The Affiliate Mini Plugin gives WooCommerce merchants a pragmatic, low‑maintenance path to grow via referrals. Customers get a clear incentive to recommend your store; you get more repeat purchases without bolting on complex affiliate software. With cookie‑based tracking, automatic rewards, and frictionless checkout discounts, you can launch a referral loop that’s easy to understand, simple to run, and built on top of WooCommerce.
If you’re ready to turn word‑of‑mouth into measurable results—minus the overhead—this plugin is a strong, lightweight choice.
