Last active
March 9, 2024 05:36
-
-
Save alexstandiford/f5ecf6916f9d52ebd2c184581933851d to your computer and use it in GitHub Desktop.
Adds sales revenue to affiliate area.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Adds a section showing the total sales earned by the affiliate to the AffiliateWP affiliate area's statistics tab. | |
*/ | |
add_action( 'affwp_affiliate_dashboard_after_earnings', function( $affiliate_id ) { | |
// You can add or remove statuses here. Any status shown in this array will be included in the calculation. | |
// Supported statuses are paid, unpaid, pending, and rejected. | |
$statuses = [ 'paid', 'unpaid', 'pending', ]; | |
// This will retrieve the sales total number. | |
$revenue = affiliate_wp()->referrals->sales->get_revenue_by_referral_status( $statuses, $affiliate_id ); | |
// This will convert the number into a readable format. | |
$revenue = affwp_currency_filter( affwp_format_amount( $revenue ) ); | |
// This HTML is based on how the markup is written in affiliate-wp/templates/dashboard-tab-stats.php | |
?> | |
<table class="affwp-table affwp-table-responsive"> | |
<thead> | |
<tr> | |
<th>Distributed Sales</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr> | |
<td data-th="Revenue"><?php echo $revenue; ?></td> | |
</tr> | |
</tbody> | |
</table> | |
<?php | |
} ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Let me know only code need to add or add this files into plugin....
Thank you in advance.