handleError(new Exception(sprintf("Coupon type '%s' not supported", $type))); } $this->type = $type; $this->label = $code; $this->code = wc_format_coupon_code($code); $this->value = floatval($value); $this->ruleId = $ruleId; } public function equals(AdpCouponInterface $coupon): bool { if (!$coupon instanceof CouponCart) { return false; } return $this->type === $coupon->getType() && $this->code === $coupon->getCode() && $this->value === $coupon->getValue() && $this->ruleId === $coupon->getRuleId(); } /** * @return string */ public function getType() { return $this->type; } /** * @param string $type * * @return bool */ public function isType($type) { return $this->type === $type; } /** * @param string $code */ public function setCode($code) { $this->code = (string)$code; } /** * @return string */ public function getCode() { return $this->code; } /** * @param float $value */ public function setValue($value) { $this->value = floatval($value); } /** * @return float */ public function getValue() { return $this->value; } /** * @return int */ public function getRuleId() { return $this->ruleId; } /** * @param float $amount */ public function setMaxDiscount($amount) { $this->maxDiscount = $amount; } /** * @return float */ public function getMaxDiscount() { return $this->maxDiscount; } /** * @param string $label */ public function setLabel($label) { $this->label = $label; } /** * @return string */ public function getLabel() { return $this->label; } /** * @return bool */ public function isMaxDiscountDefined() { return isset($this->maxDiscount) && $this->maxDiscount > 0; } }