@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
/** Computes a form's total price as the sum of its elements' prices. */
|
||||
/** Computes a form's total price as the sum of its elements' prices, reduced by membership discount. */
|
||||
class RsvFormPriceCalculator {
|
||||
public function calculate(RsvFormDefinition $definition, RsvFormData $data): float {
|
||||
global $rsv_form_price_registry;
|
||||
@@ -16,6 +16,7 @@ class RsvFormPriceCalculator {
|
||||
$total += (float) $calculator($element, $data->getValue($element->getName()));
|
||||
}
|
||||
|
||||
return $total;
|
||||
$pct = (new RsvMembershipService())->discount_for($definition, $data);
|
||||
return $total * (1.0 - max(0.0, min(100.0, $pct)) / 100.0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user