getEligibleRule() !== null; } public function getReminderMessage(): string { $rule = $this->getEligibleRule(); return $rule ? (string)__('Subscribe now to receive your %1 coupon.', $this->discountFormatter->format($rule)) : ''; } public function getDiscountLabel(): string { $rule = $this->getEligibleRule(); return $rule ? $this->discountFormatter->format($rule) : ''; } private function getEligibleRule(): ?Rule { if ($this->ruleResolved) { return $this->eligibleRule; } $this->ruleResolved = true; if (!$this->promotionConfig->isCampaignActive() || !$this->promotionConfig->isRegistrationNewsletterCouponPromotion() ) { return null; } $store = $this->storeManager->getStore(); $ruleId = $this->couponConfig->getRegistrationSubscriptionRuleId((int)$store->getId()); if ($ruleId <= 0) { return null; } /** @var Rule $rule */ $rule = $this->ruleFactory->create()->load($ruleId); $websiteId = (int)$store->getWebsiteId(); $defaultGroupId = (int)$this->scopeConfig->getValue( self::XML_PATH_DEFAULT_CUSTOMER_GROUP, ScopeInterface::SCOPE_STORE, (int)$store->getId() ); $eligible = (bool)$rule->getId() && (bool)$rule->getIsActive() && ((int)$rule->getCouponType() === Rule::COUPON_TYPE_AUTO || (bool)$rule->getUseAutoGeneration()) && in_array($websiteId, array_map('intval', $rule->getWebsiteIds()), true) && in_array($defaultGroupId, array_map('intval', $rule->getCustomerGroupIds()), true) && $this->timezone->isScopeDateInInterval($store, $rule->getFromDate(), $rule->getToDate()); $this->eligibleRule = $eligible ? $rule : null; return $this->eligibleRule; } }