em = $em; } public function getID() { return 'discount'; } public function compute($criteria, &$total) { $items = []; // set the discount to the total selling price $discount = $total['sell_price']; $qty = 1; $price = bcmul(-1, $discount, 2); $items[] = [ 'title' => $this->getTitle(), 'qty' => $qty, 'price' => $price, ]; $total['discount'] = $discount; $total['total_price'] = bcsub($total['total_price'], $discount, 2); return $items; } public function validatePromo($criteria, $promo_id) { // only applies to battery sales if ($criteria->getServiceType() != ServiceType::BATTERY_REPLACEMENT_NEW) return null; // only applies if this is a subscription order if ($criteria->isSubscription() === false) return null; return false; } public function validateInvoiceItems($criteria, $invoice_items) { return null; } protected function getTitle() { $title = 'Waived for subscription'; return $title; } }