Last active
August 29, 2015 14:18
-
-
Save sunnysideup/b0442bf738236e7347fa to your computer and use it in GitHub Desktop.
Function to work out if a coupon is valid .... Returns false if the coupon is invalid and true if the coupon is valid.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getIsValid() { | |
//we go through all the options that would make it invalid... | |
if(! $this->NumberOfTimesCouponCanBeUsed) { | |
return false; | |
} | |
if($this->getUseCount() > $this->NumberOfTimesCouponCanBeUsed) { | |
return false; | |
} | |
$now = strtotime("now"); | |
$startDate = strtotime($this->StartDate); | |
if($now < $startDate) { | |
return false; | |
} | |
//include the end date itself. | |
$endDate = strtotime($this->EndDate)+(60*60*24); | |
if($now > $endDate) { | |
return false; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment