This simple script allows you to provide your affiliates with a different percentage for your products.
Product 1, 3, 5, 6 and 7 are in category 1.
If a customer buys any of those products your affiliate will get a 20% commision.
Product 2, 4, and 8 are in category 2.
If a customer buys any of those products your affiliate will get a 10% commision.
If Product 1, 2, 3, 4 and 5 are ordered then your affiliate will get the commision for that according to however the different commisions add up.