I figured, that following SQL gives me what I need to know:
select sum(products_quantityfinal_price(products_tax/100+1)) as sum from zen_orders_products where orders_id=27 and orders_products_id in (select orders_products_id from zen_orders_products_attributes where orders_products_id in (select orders_products_id from zen_orders_products where orders_id=27) and Products_options='Tyyppi' and product_attribute_is_free=1);
So, basically that SQL gives me the sum-value of the products ordered, where I want to apply group discount. ie. those products have been selected with certain attributes by purchaser.
in ot_group_pricing.php I found following line:
$discount = ($order_total - $gift_vouchers) * $group_discount->fields['group_percentage'] / 100;
Now, the only thing what I seem to need to do is to replace $order_total with the output of my SQL clause.
The only last problem is that I am not able figure out which variable contains the orders_id in ot_group_pricing.php
Ideas?