Index: affiliates_event_handler.php =================================================================== --- affiliates_event_handler.php (revision 14733) +++ affiliates_event_handler.php (working copy) @@ -257,7 +257,7 @@ // process only orders of current affiliate from period start to this order date $period_ends = $order->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;