The problem is this method in the calculationh.php helper file in administrator
protected function couponHandler($_code)
There is this peice of code:
for($i = 0; $i < $sizeof_cartitems_by_product; $i++){
if( (!empty($allowed_product_ids) and in_array($this->_cart->cartPrices[$i]['virtuemart_product_id'],$allowed_product_ids)) || (!empty($allowed_productcat_ids) and array_intersect($this->_cart->products[$i]->categories, $allowed_productcat_ids))){
$coupon_discount += ($this->_cart->cartPrices[$i]['salesPriceTt'] * ($_data->coupon_value / 100));
}
}
this is pretty buggy because the cart doesn't always start at the 0 index.. So i changed this code to this:
foreach ($this->_cart->products as $i => $product) {
if ((!empty($allowed_product_ids) && in_array($this->_cart->cartPrices[$i]['virtuemart_product_id'], $allowed_product_ids)) || (!empty($allowed_productcat_ids) && array_intersect($product->categories, $allowed_productcat_ids))) {
$coupon_discount += ($this->_cart->cartPrices[$i]['salesPriceTt'] * ($_data->coupon_value / 100));
}
}
Now it works beautifully! This should be implemented in the core code.