Skip to content

Commit

Permalink
fix: if percent commission rate is not set while using combine commis…
Browse files Browse the repository at this point in the history
…sion calculation is not correct is fixed #687 (#690)

* fix: if percent commission rate is not set while using combine commission calculation is not correct is fixed #687

* fix: if percent commission rate is not set while using combine commission calculation is not correct
  • Loading branch information
saimonh3 authored and sabbir1991 committed Nov 7, 2019
1 parent 3520f55 commit c98588b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions includes/class-commission.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,6 @@ public function prepare_for_calculation( $callable, $product_id = 0, $product_pr
$commission_rate = $this->$func_rate( $product_id );
}

if ( is_null( $commission_rate ) ) {
return null;
}

$earning = null;

// get[product,category,vendor,global]_wise_type
Expand Down Expand Up @@ -510,6 +506,10 @@ public function prepare_for_calculation( $callable, $product_id = 0, $product_pr
}

if ( 'flat' === $commission_type ) {
if ( is_null( $commission_rate ) ) {
return $commission_rate;
}

if ( $this->get_order_qunatity() ) {
$commission_rate *= apply_filters( 'dokan_commission_multiply_by_order_quantity', $this->get_order_qunatity() );
}
Expand All @@ -525,6 +525,10 @@ public function prepare_for_calculation( $callable, $product_id = 0, $product_pr
}

if ( 'percentage' === $commission_type ) {
if ( is_null( $commission_rate ) ) {
return $commission_rate;
}

$earning = ( (float) $product_price * $commission_rate ) / 100;
$earning = (float) $product_price - $earning;

Expand Down

0 comments on commit c98588b

Please sign in to comment.