function ExcludeInDiscountCalculation(DiscountCouponModifier $modifier) { $coupon = $modifier->DiscountCouponOption(); return !$coupon->canBeDiscounted($this->owner->Product()); }
/** *@return float **/ protected function LiveCalculatedTotal() { if (!self::$calculated_total) { $this->actualDeductions = 0; $this->DebugString = ""; $subTotal = $this->LiveSubTotalAmount(); if ($coupon = $this->myDiscountCouponOption()) { if ($coupon->MinimumOrderSubTotalValue > 0 && $subTotal < $coupon->MinimumOrderSubTotalValue) { $this->actualDeductions = 0; $this->DebugString .= "<hr />sub-total is too low to offer any discount: " . $this->actualDeductions; } else { if ($coupon->DiscountAbsolute > 0) { $this->actualDeductions += $coupon->DiscountAbsolute; $this->DebugString .= "<hr />using absolutes for coupon discount: " . $this->actualDeductions; } if ($coupon->DiscountPercentage > 0) { $this->actualDeductions += $coupon->DiscountPercentage / 100 * $subTotal; $this->DebugString .= "<hr />using percentages for coupon discount: " . $this->actualDeductions; } } if ($coupon->MaximumDiscount > 0) { if ($this->actualDeductions > $coupon->MaximumDiscount) { $this->DebugString .= "<hr />actual deductions (" . $this->actualDeductions . ") are greater than maximum discount (" . $coupon->MaximumDiscount . "): "; $this->actualDeductions = $coupon->MaximumDiscount; } } } if ($subTotal < $this->actualDeductions) { $this->actualDeductions = $subTotal; } $this->DebugString .= "<hr />final score: " . $this->actualDeductions; if (isset($_GET["debug"])) { print_r($this->DebugString); } $this->actualDeductions = -1 * $this->actualDeductions; self::$calculated_total = $this->actualDeductions; } return self::$calculated_total; }
function getUseCount() { if ($this->ID) { return DiscountCouponModifier::get()->filter(array("DiscountCouponOptionID" => $this->ID))->count(); } return 0; }