| 1 |
<?php |
| 2 |
|
| 3 |
namespace TierPricingTable\Admin\Notifications\Notifications; |
| 4 |
|
| 5 |
/** |
| 6 |
* Class Notifications |
| 7 |
* |
| 8 |
* @package TierPricingTable\Admin\Notifications |
| 9 |
*/ |
| 10 |
abstract class BlackFriday extends Notification { |
| 11 |
public function getTemplate() : string { |
| 12 |
return 'admin/notifications/black-friday.php'; |
| 13 |
} |
| 14 |
|
| 15 |
public function getId() : string { |
| 16 |
return 'black-friday-' . $this->getBlackFridayDate(); |
| 17 |
} |
| 18 |
|
| 19 |
public abstract function getBlackFridayDate() : string; |
| 20 |
|
| 21 |
public function isBlackFriday() : bool { |
| 22 |
$blackFriday = $this->getBlackFridayDate(); |
| 23 |
$start = strtotime( "{$blackFriday} - 3 days" ); |
| 24 |
$end = strtotime( "{$blackFriday} + 4 days" ); |
| 25 |
return time() > $start && time() < $end; |
| 26 |
} |
| 27 |
|
| 28 |
public function passedRequirements() : bool { |
| 29 |
return $this->isBlackFriday(); |
| 30 |
} |
| 31 |
|
| 32 |
public function isActive() : bool { |
| 33 |
return $this->passedRequirements() && !$this->isSeen(); |
| 34 |
} |
| 35 |
|
| 36 |
} |
| 37 |
|