The early discount is calculated to whole date and the code is wrong in function “early_discount_amount”. You are comparing the dates so that it always is yesterdays date that is valid. Please change the code, eg:
Sorry for the delay getting to this as it was not a priority item.
The code is actually correct.
if ((strlen($eventdata[0]->early_disc) > 0) && (strtotime($eventdata[0]->early_disc_date) > strtotime(date(“Y-m-d”) . ” -1 day”))) {
// apply earley bird discount here
}
What this code is saying is:
IF early_disc value exists AND early_disc start date IS GREATHER THAN yesterday THEN apply early bird discount.
So let’s examine that last part “AND early_disc start date is GREATHER THAN yesterday” a little bit more, by actually throwing a date in there.
If we wanted our early bird discount to start on November 10, 2012, then that last bit of code would read like this:
AND Nov 10, 2012 IS GREATHER THAN Nov 9, 2012
which would be TRUE and your discount would be applied.
IF we did NOT subtract a day then it would read
AND Nov 10, 2012 IS GREATHER THAN Nov 10, 2012
which would be FALSE and your discount would NOT be applied, and would NOT be applied until Nov 11, 2012, which of course is not when we want it to begin.
Instead of subtracting a day, it maybe would have been easier to understand if it had been coded using >= “greater than or equals” ala:
AND Nov 10, 2012 IS GREATHER THAN OR EQUAL TO Nov 10, 2012
but ultimately it all reads the same.
Make sense now?
Viewing 4 reply threads
The support post ‘Early discount’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.
Support forum for Event Espresso 3 and Event Espresso 4.