| 1 |
<?php |
| 2 |
|
| 3 |
namespace TierPricingTable\Admin\Notifications\Notifications; |
| 4 |
|
| 5 |
use TierPricingTable\Core\ServiceContainerTrait; |
| 6 |
use TierPricingTable\TierPricingTablePlugin; |
| 7 |
/** |
| 8 |
* Class Notifications |
| 9 |
* |
| 10 |
* @package TierPricingTable\Admin\Notifications |
| 11 |
*/ |
| 12 |
class TwoMonthsUsingDiscount extends Notification { |
| 13 |
use ServiceContainerTrait; |
| 14 |
public function getMonthsNumberToUsePluginToSeeNotification() : int { |
| 15 |
return 2; |
| 16 |
} |
| 17 |
|
| 18 |
public function getId() : string { |
| 19 |
return 'two-months-using-discount'; |
| 20 |
} |
| 21 |
|
| 22 |
public function getTemplate() : string { |
| 23 |
return 'admin/notifications/feedback-discount.php'; |
| 24 |
} |
| 25 |
|
| 26 |
public function passedRequirements() : bool { |
| 27 |
if ( !$this->isPluginPage() ) { |
| 28 |
return false; |
| 29 |
} |
| 30 |
$activationDate = TierPricingTablePlugin::getPluginActivationDate(); |
| 31 |
if ( !$activationDate ) { |
| 32 |
return false; |
| 33 |
} |
| 34 |
// If activation date is more than {number} months ago |
| 35 |
return time() - $activationDate > MONTH_IN_SECONDS * $this->getMonthsNumberToUsePluginToSeeNotification(); |
| 36 |
} |
| 37 |
|
| 38 |
public function isActive() : bool { |
| 39 |
return $this->passedRequirements() && !$this->isSeen(); |
| 40 |
} |
| 41 |
|
| 42 |
} |
| 43 |
|