Skip to content

Commit

Permalink
Fix: Site fees not getting deduct from admin/instructor earning
Browse files Browse the repository at this point in the history
  • Loading branch information
shewa12 committed Nov 19, 2024
1 parent c54e878 commit ce34a2f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions classes/Earnings.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ public function prepare_earning_data( $total_price, $course_id, $order_id, $orde

$course_price_grand_total = $total_price;

// Site maintenance fees.
$fees_amount = 0;

// Deduct predefined amount (percent or fixed).
if ( $enable_fees_deducting ) {
$fees_name = tutor_utils()->get_option( 'fees_name', '' );
Expand All @@ -166,6 +169,8 @@ public function prepare_earning_data( $total_price, $course_id, $order_id, $orde
);
}

list( $admin_fees, $instructor_fees ) = array_values( tutor_split_amounts( $fees_amount ) );

// Distribute amount between admin and instructor.
$sharing_enabled = tutor_utils()->get_option( 'enable_revenue_sharing' );
$instructor_rate = $sharing_enabled ? tutor_utils()->get_option( 'earning_instructor_commission' ) : 0;
Expand All @@ -178,15 +183,16 @@ public function prepare_earning_data( $total_price, $course_id, $order_id, $orde
// (Use Pro Filter - Start)
// The response must be same array structure.
// Do not change used variable names here, or change in both of here and pro plugin
$pro_arg = array(
$pro_arg = array(
'user_id' => $user_id,
'instructor_rate' => $instructor_rate,
'admin_rate' => $admin_rate,
'instructor_amount' => max( 0, $instructor_amount ),
'admin_amount' => max( 0, $admin_amount ),
'instructor_amount' => max( 0, $instructor_amount - $instructor_fees ),
'admin_amount' => max( 0, $admin_amount - $admin_fees ),
'course_price_grand_total' => $course_price_grand_total,
'commission_type' => $commission_type,
);

$pro_calculation = apply_filters( 'tutor_pro_earning_calculator', $pro_arg );
extract( $pro_calculation ); //phpcs:ignore
// (Use Pro Filter - End).
Expand Down

0 comments on commit ce34a2f

Please sign in to comment.