diff --git commerce_vat.module commerce_vat.module index eec3593..9bc9d6c 100644 --- commerce_vat.module +++ commerce_vat.module @@ -343,9 +343,14 @@ function commerce_vat_rate_apply($vat_rate, $line_item) { if ($component['price']['amount']) { $nonzero_components[] = &$component; } - $amount_to_reduce_current = commerce_vat_rate_round_amount($component['price']['amount'] / $amount * $amount_to_reduce_total); - $component['price']['amount'] -= $amount_to_reduce_current; - $amount_to_reduce_left -= $amount_to_reduce_current; + + $division = $amount * $amount_to_reduce_total; + // Avoid division-by-zero warning from PHP + if ($division > 0) { + $amount_to_reduce_current = commerce_vat_rate_round_amount($component['price']['amount'] / $division); + $component['price']['amount'] -= $amount_to_reduce_current; + $amount_to_reduce_left -= $amount_to_reduce_current + } } // Change components only if there was a nonzero-one. if (!empty($nonzero_components)) {