Index: branches/5.2.x/units/affiliates/affiliates_event_handler.php =================================================================== diff -u -N -r14594 -r14767 --- branches/5.2.x/units/affiliates/affiliates_event_handler.php (.../affiliates_event_handler.php) (revision 14594) +++ branches/5.2.x/units/affiliates/affiliates_event_handler.php (.../affiliates_event_handler.php) (revision 14767) @@ -1,6 +1,6 @@ GetDBField('OrderDate'); $period_starts = $this->getPeriodStartTS( $period_ends, $affiliate_plan->GetDBField('ResetInterval') ); - $sql = 'SELECT AffiliateCommission, (SubTotal+ShippingCost+VAT) AS TotalAmount, OrderId FROM '.$order->TableName.' WHERE OrderDate >= %s AND OrderDate <= %s'; + $sql = 'SELECT AffiliateCommission, (SubTotal+ShippingCost+VAT) AS TotalAmount, OrderId FROM '.$order->TableName.' WHERE OrderDate >= %s AND OrderDate <= %s AND AffiliateId = ' . $affiliate_id; $amount_to_pay_before = 0; $amount_to_pay_after = 0;