Introduction

E-commerce success isn’t just about getting new customers—it’s about retaining them. A well-designed loyalty and rewards program can dramatically increase customer lifetime value and repeat purchases. While WooCommerce has extensions for this, building a custom solution gives you full control over how points, tiers, and rewards function—perfect for unique business models.

In this article, we’ll walk through developing a custom loyalty program in WooCommerce, including points management, redemption rules, and user engagement tactics.

Why Build a Custom Loyalty Program?

  • Tailor rewards logic to your business (e.g., per-product points, referral bonuses)
  • Avoid subscription costs of 3rd-party plugins
  • Integrate with existing custom features, CRMs, or ERPs
  • Unlock more flexibility for gamification, tier systems, and real-time notifications

Key Components of a Loyalty System

  1. Points Earning Logic
    • Points per purchase
    • Bonus points on specific products or categories
    • Referral or review-based points
  2. Points Redemption Logic
    • Apply points as discounts
    • Minimum threshold to redeem
    • Fixed-point-to-currency ratio
  3. Customer Dashboard
    • Total points earned, redeemed, and available
    • History of transactions
    • Upcoming rewards/tiers
  4. Admin Tools
    • Points overview
    • Manual adjustment
    • Export/reporting

Step-by-Step Development Guide

1. Create Custom Meta for Points

// Award points after order is completed
add_action('woocommerce_order_status_completed', function ($order_id) {
    $order = wc_get_order($order_id);
    $user_id = $order->get_user_id();
    
    if (!$user_id) return;

    $total = $order->get_total();
    $points = floor($total); // 1 point per $1

    $existing = (int) get_user_meta($user_id, 'loyalty_points', true);
    update_user_meta($user_id, 'loyalty_points', $existing + $points);
});

2. Show Points on My Account Page

add_action('woocommerce_before_my_account', function () {
    $points = (int) get_user_meta(get_current_user_id(), 'loyalty_points', true);
    echo "<p><strong>Loyalty Points:</strong> $points</p>";
});

3. Apply Points as Discounts

add_action('woocommerce_cart_calculate_fees', function ($cart) {
    if (is_admin() || !is_user_logged_in()) return;

    $user_id = get_current_user_id();
    $points = (int) get_user_meta($user_id, 'loyalty_points', true);

    if ($points < 100) return; // Min 100 points to use

    $discount = min($points * 0.01, $cart->get_total() * 0.5); // Max 50% discount
    $cart->add_fee('Loyalty Points Discount', -$discount);
});

4. Deduct Points After Redeeming

add_action('woocommerce_checkout_order_processed', function ($order_id) {
    $order = wc_get_order($order_id);
    $user_id = $order->get_user_id();

    if (!$user_id) return;

    // Example logic: remove 100 points per order
    $existing = (int) get_user_meta($user_id, 'loyalty_points', true);
    if ($existing >= 100) {
        update_user_meta($user_id, 'loyalty_points', $existing - 100);
    }
});

Bonus Features to Add

  • Tiered Rewards (Bronze, Silver, Gold)
  • Referral Points (Invite friends)
  • Product-Specific Multipliers (e.g., double points on clearance items)
  • Email Notifications for Expiring Points
  • Admin Reports: Top loyal customers
  • Loyalty QR Code for in-store scanning

Security & Optimization Tips

  • Sanitize all point input/output
  • Test for edge cases: refunds, guest users, order cancellations
  • Use transient caching for heavy point queries
  • Hook into woocommerce_refund_created to reverse points