Source of file Discount.php
Size: 1,018 Bytes - Last Modified: 2021-12-23T10:11:33+00:00
/var/www/docs.ssmods.com/process/src/code/calculator/Discount.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 | <?php namespace EventRegistration\Calculator; class Discount { // TODO: move away to config of some sort public static function available_discounts() { return [ (new GroupDiscount(0.1))->setMinSize(10), new FamilyDiscount(0.2) ]; } public $amount; public $name = "Discount"; public function __construct($amount, $name = null) { $this->amount = $amount; $this->name = $name ? $name : $this->name; } /** * Check if a registration qualifies for this discount */ public function registrationQualifies(\EventRegistration $reg) { return true; } /** * Check if an attendee qualifies for this discount */ public function attendeeQualifies(\EventAttendee $attendee) { return true; } public function applyTo($amount) { return $amount * $this->amount; } public function getDiscountableAttendees(\EventRegistration $reg) { return $reg->Attendees() ->innerJoin("EventTicket", "\"EventAttendee\".\"TicketID\" = \"EventTicket\".\"ID\"") ->where("PriceAmount > 0"); } } |