Skip to content
Coupon Affiliates
  • Features
  • Pricing
  • Testimonials
  • Support
    • Support Ticket
    • Sales Support
    • Documentation
    • Roadmap
    • Feature Request
    • Changelog
    • Plugin Demo
    • Setup Services
    • Account
  • Contact Us
  • Blog
  • Trusted by 5800+ businesses to power their affiliate program.
  • Try for free
Coupon Affiliates

Plugin Documentation

Setup

4
  • Setup Guide – How to get started!
  • How to install the Coupon Affiliates Plugin
  • How to assign users to coupons.
  • Shortcodes

Commission + Payouts

31
  • (PRO) Commission Tracking and Payouts
  • Flexible Commission Settings
  • Set custom commission per affiliate / coupon.
  • Set custom commission per product
  • Set custom commission per user role.
  • Set per-affiliate product-level commission rates.
  • Set a custom referrer for orders.
  • (PRO) Invoices
  • (PRO) Statements
  • (PRO) Scheduled Payout Requests
  • (PRO) Automatic Payouts
  • (PRO) Payouts – How to Pay Affiliates
  • (PRO) Lifetime Commission
  • (PRO) User Registrations as Lifetime Referral
  • (PRO) User-Role Specific Payout Methods
  • Maximum Commission Per Order
  • Hide Commission for Non-Affiliate Coupons.
  • How to edit an affiliates “unpaid commission”?
  • Manual Admin Payouts Requests
  • (FREE) How to pay affiliates with the FREE version.
  • Never update the saved “commission” value for past orders.
  • Unpaid Commission is “0” even though there are referred orders.
  • Method: PayPal Payouts
    • (PRO) PayPal Payouts
    • (PRO) PayPal Payouts – Setup
    • (PRO) PayPal Payouts – Error Messages
  • Method: Stripe Payouts
    • (PRO) Stripe Payouts
    • (PRO) Stripe Payouts – Setup Guide
    • (PRO) Stripe Payouts – Standard vs Express
  • Method: Store Credit
    • (PRO) Store Credit Payouts
    • (PRO) Store Credit Payouts – Integrations
  • Method: Bank Transfer
    • (PRO) Bank Transfer Payouts

Affiliate Dashboard

8
  • Affiliate Portal
  • Affiliate Dashboard Statistics
  • Recent Orders Table
  • (PRO) Monthly Summary Table
  • (PRO) Export to Excel
  • (PRO) Line Graphs
  • (PRO) Product Rates Table
  • (PRO) Custom Tabs

Referral URLs

12
  • Referral URLs
  • Referral URL Click History (Visits)
  • (PRO) Referral URL Campaigns
  • (PRO) Creatives
  • (PRO) Dynamic Creatives
  • (PRO) Affiliate Landing Pages
  • (PRO) Dynamic Landing Pages
  • (PRO) Social Sharing for Referral URLs
  • (PRO) Short URL Generator for Referral URLs
  • (PRO) QR Code Generator for Referral URLs
  • (PRO) Direct Link Tracking
  • Tracking URL Conversions Without Coupon

Affiliate Registration

12
  • Affiliate Registration
  • Create Affiliate Registrations Manually
  • Template Coupon Code
  • Registration Form CAPTCHA (Spam Prevention)
  • (PRO) Dynamic Coupon Generation
  • (PRO) Multiple Template Coupons
  • (PRO) Custom Fields for Affiliate Registration
  • (PRO) Automatically Accept Affiliate Registrations
  • (PRO) Auto Affiliate Registration for New Users
  • How to Prevent Spam Submissions on Your Affiliate Registration Form
  • (PRO) Affiliate Registration on Checkout
  • Mailing List Integrations

Reporting

2
  • Admin Reports & Analytics
  • (PRO) Affiliate Email Reports

Multi-Level Affiliates

6
  • Multi-Level Affiliates – Overview
  • (PRO) MLA – How to edit a user’s parents
  • (PRO) MLA – How to edit the MLA “unpaid commission” for a parent
  • (PRO) MLA – Make MLA invite links a normal referral link.
  • (PRO) MLA – Make MLA Dashboard “Invite Only”
  • (PRO) MLA – Auto-assign referred customers as an MLA sub-affiliate.

Integrations

7
  • WooCommerce – Integration Guide
  • LifterLMS – Integration Guide
  • LearnDash – Integration Guide
  • TutorLMS – Integration Guide
  • MemberPress – Integration Guide
  • Paid Memberships Pro – Integration Guide
  • (PRO) Store Credit Payouts – Integrations

Admin Tools

7
  • Import/Export Custom Tables
  • Bulk Create: Affiliate Coupons
  • Bulk Assign: Coupons to Orders
  • Bulk Edit: Product Settings
  • Bulk Edit: Coupon Settings
  • Signup Promo Page Generator
  • Affiliate Terms of Use Generator

Other Features

15
  • Affiliate Groups
  • (PRO) Performance Bonuses
  • (PRO) Affiliate Leaderboards
  • Affiliate Fraud Prevention Features
  • Email Notifications
  • Multi-Currency Support & Setup
  • (PRO) Automated Conversion Rates
  • Admin – List of all ‘Affiliate Dashboard’ Links
  • Admin – Assign affiliate users to coupons
  • Limit coupons to new customers only (first order)
  • Subscriptions (Recurring Referrals)
  • Tax/VAT Calculations
  • Vanity Coupon Codes
  • Show “Affiliate” link on “My Account” Page
  • Automatically send emails when affiliates reach certain goals

General Questions + Help

39
  • How do I get support?
  • Translations & Localization
  • How to refresh statistics for past orders
  • Select which order statuses to show on the affiliate dashboard
  • How to “Quick Edit” your WooCommerce Coupon Codes
  • How to manually assign referral coupons to “completed” orders
  • Set additional email addresses for affiliate notifications.
  • Set the coupon history start date
  • How to customise the email templates
  • My PRO features and settings are not showing. How do I fix this?
  • How do I only show “completed” orders on affiliate dashboard?
  • How do I change commission rates for new orders only?
  • How do I apply custom tax adjustments to stats and commission?
  • How do I include or exclude tax/VAT from stats and commission?
  • What happens when an order is refunded or partially refunded?
  • Are shipping costs excluded from stats and calcuations?
  • How can I prevent the calculated commission for past orders from changing if I update commission rates?
  • Can I assign affiliate users to multiple coupons?
  • How do I manually connect an affiliate to an existing customer as a lifetime affiliate?
  • Change the “Affiliate” text to say something else such as “Refer a Friend”.
  • Can I use this plugin for coupon marketing campaigns?
  • How to migrate from other affiliate plugins?
  • How to Delete A WordPress User
  • How to Remove an Affiliate User
  • How to migrate my data to a new website?
  • Will more features be added in the future?
  • What’s the difference between Yearly and Lifetime plan?
  • Using One License for Live / Production, Staging, Dev and Localhost Sites
  • Users can not login after their affiliate registration is accepted.
  • Does the plugin work with WooCommerce High-Performance Order Storage?
  • How to Check if Cron Jobs are Working in WordPress
  • Replace WP-Cron with a Real Cron Job
  • Limit WooCommerce coupons to only be used on certain products
  • Apply coupon field is not showing on cart / checkout
  • How to join the beta program.
  • Do you have a demo site where I can try the PRO version?
  • My PRO version will not activate, it stays on the free version.
  • Using One License for Live & Staging Sites
  • Switch PRO license to another website or domain

Errors and Issues

15
  • Why referral links / URLs may not work, and how to fix them.
  • My email notifications are not working. How do I fix this?
  • Short URLs are not working, how do I fix them?
  • Affiliate dashboard is not showing, or it doesn’t stop saying “loading”. How do I fix this?
  • The stats/content isn’t loading on my dashboard. How can I fix this?
  • How to fix empty admin reports (showing as “0”).
  • Hosted with Cloudways? How to fix ajax loading error on affiliate dashboard.
  • How to fix “ERROR: Failed to load ajax request.”
  • How to Fix “404 Error on Posts or Pages” in WordPress
  • Dashboard link is showing a 404 error?
  • WooCommerce password reset link shows “page not found”.
  • How to fix “Invalid Post Type” error.
  • How to Increase “PHP Time Limit” on a WordPress Site
  • How to increase PHP “Max Input Vars” Limit
  • How to Check WP_DEBUG Logs in WordPress

Developers

2
  • Developers: Code Snippets & Resources
  • How to auto-apply coupon when a certain product is in WooCommerce cart
  • Home
  • Docs
  • Developers
  • Developers: Code Snippets & Resources
View Categories

Developers: Code Snippets & Resources

3 min read

We do not currently have in-depth developer documentation available, but here are some useful code snippets and resources for developers.

Database Tables

The plugin does have its own database tables that you can get certain data from:

wcusage_activity – Activity log.

wcusage_campaigns – Referral URL campaigns.

wcusage_clicks – Referral URL clicks log.

wcusage_directlinks – Direct link tracking domains.

wcusage_mlainvites – Multi-Level affiliates invites.

wcusage_payouts – Commission Payouts

wcusage_register – Affiliate registration applications.

Affiliate Orders

Get all affiliate orders for a coupon, without certain data range. This returns an array of data including the total calculations for all the orders, and all the individual orders.

$orders = wcusage_wh_getOrderbyCouponCode( $coupon_code, $start_date, $end_date, '', 1 );

Order Data

You can get an array of affiliate related data for a certain order via this function. This returns an array of data including the commission earnings.

$order_data = wcusage_calculate_order_data( $order_id, $coupon_code, 0, 1 );

To get the commission from the order for example:

$commission = $order_data['totalcommission'];

Affiliate URL

Get the affiliate URL for a coupon via the following function:

$coupon_code = ""; // Set the coupon code name here.
$affiliate_url = wcusage_get_affiliate_url($coupon_code);

Or if you want to build your own custom URL here’s an example:

$coupon_code = ""; // Set the coupon code name here.
$prefix = wcusage_get_setting_value('wcusage_field_urls_prefix', 'coupon');
$affiliate_url = get_home_url() . "?" . $prefix . "=" . $coupon_code;

Total Sales and Commission

Get the total sales and commission earned by a certain coupon, without a certain date range. Leave $start_date empty to get all sales.

$orders = wcusage_wh_getOrderbyCouponCode( $coupon_code, $start_date, $end_date, '', 1 );
$total_orders = $orders['total_orders']; // Total Sales
$total_discounts = $orders['full_discount']; // Total Discounts
$total_commission = $orders['total_commission']; // Total Commission
$order_count = $orders['total_count']; // Orders Count

Unpaid Commission

Get the total unpaid commission for an affiliate coupon.

$coupon_id = ""; // Set the coupon code ID here.
$unpaid_commission = get_post_meta( $coupon_id, 'wcu_text_unpaid_commission', true );

Hook (Action): New Affiliate Registration

When there is a new affiliate registration, it will run the “wcusage_hook_registration_new” hook that will pass the registration ID, user ID, and coupon code.

You could therefore call this hook to automatically accept the registration under certain conditions with the “wcusage_set_registration_status” function. For example this will automatically accept the registration if the users role is “example”:

add_action( 'wcusage_hook_registration_new', 'trigger_wcusage_hook_registration_new', 10, 3 );
function trigger_wcusage_hook_registration_new( $registration_id, $user_id, $coupon_code ) {
    $user_info = get_userdata( $user_id );
    $roles = $user_info->roles;

    if ( in_array( 'example', $roles ) ) {
        wcusage_set_registration_status( 'accepted', $registration_id, $user_id, $coupon_code, '', '' );
    }
}

Hook (Action): New Affiliate Accepted

When a new affiliate is accepted and added to your program, it will run the “wcusage_hook_affiliate_register_accepted” that will pass the following:

  • $id – Registration ID.
  • $userid – User ID.
  • $coupon_code – Coupon Code.
  • $message – The registration acceptance message.
  • $status – The status of their registration.
add_action( 'wcusage_hook_affiliate_register_accepted', 'trigger_wcusage_hook_registration_accepted', 10, 5 );
function trigger_wcusage_hook_registration_accepted( $id, $userid, $coupon_code, $message, $status ) {
// Your code here.
}

API Endpoint: Coupon Info

The Coupon Info API endpoint allows you to retrieve details about a specific coupon by its ID. This includes the coupon’s name, unpaid commission, and pending payouts, making it an essential tool for tracking coupon performance and payout status. Only administrators can access this endpoint.

To use the API, send a GET request to /wp-json/woo-coupon-usage/v1/coupon-info with the required parameter coupon_id (the ID of the coupon you want to query). The response will include an array containing the coupon_name, unpaid_commission, and pending_payouts.

API Endpoint: Users Coupons

The User's Coupons API endpoint allows you to retrieve a list of coupon IDs assigned to a specific user, along with their associated unpaid commission. This functionality is useful for monitoring and managing user-specific coupon assignments and commissions. Access to this endpoint is limited to administrators.

To use the API, send a GET request to /wp-json/woo-coupon-usage/v1/users-coupons with the required parameter user (the login name of the user whose coupons you want to retrieve). The API will return an array of coupon IDs along with their unpaid commission, providing an overview of the user’s coupon activity.

API Endpoint: Request Payout

The Request Payout API endpoint allows you to trigger payout requests for a specific coupon. It verifies the user requesting the payout and checks if the coupon’s unpaid commission is valid and ready for processing.

To use the API, make a POST request to /wp-json/woo-coupon-usage/v1/request-payout with two required parameters: coupon_id (the ID of the coupon) and user (the login name of the user requesting the payout). Ensure that the calling user has administrator permissions. Upon successful validation, the system processes the payout request and returns 1 for success or 0 for failure.

—

Need help with a custom function? Feel free to contact us and we may be able to point you in the right direction.

Need help with something?

Create a support ticket >>
What are your Feelings

Increase your revenue with the #1 coupon-based affiliate plugin for WooCommerce... risk-free!

7 Day Trial 14 Day Money Back Guarantee No Extra Fees

Free 7 Day Trial

Product

  • Plugin Features
  • Pricing
  • Roadmap
  • Changelog
  • Feature Requests

Resources

  • Documentation
  • Plugin Demo
  • Blog
  • Testimonials
  • Comparisons

Support

  • PRO Support
  • Community Forums
  • Setup Guide
  • Enterprise Support
  • Customer Login

Company

  • About The Founder
  • Our Affiliate Program
  • Terms and Conditions
  • Privacy Policy
  • Cookies Policy

RelyWP Services

  • Plugin Setup & Customisation
  • WordPress Care Plans
  • Managed WordPress Hosting
  • Custom Coding Services
  • Website Tweaks & Fixes

Copyright © 2025 RelyWP Ltd.

Registered in England & Wales with registration number: 11865883

Twitter Facebook-f Youtube

Woo® and WooCommerce® are trademarks of WooCommerce, Inc. Coupon Affiliates is not affiliated with or endorsed by WooCommerce, Inc.

logo
  • Features
  • Pricing
  • Testimonials
  • Support
    • Support Ticket
    • Sales Support
    • Documentation
    • Roadmap
    • Feature Request
    • Changelog
    • Plugin Demo
    • Setup Services
    • Account
  • Contact Us
  • Blog
  • Trusted by 5800+ businesses to power their affiliate program.
  • Try for free