Pricing updates

This commit is contained in:
Chris Smith
2019-03-31 18:58:50 -05:00
parent 6f045b5180
commit 22605b96cc
5 changed files with 86 additions and 12 deletions

View File

@@ -1,5 +1,9 @@
EVENT_TICKET_PRICE="55"
TABLE_TICKET_PRICE="350"
EVENT_TICKET_PRICE_1="55"
TABLE_TICKET_PRICE_1="350"
EVENT_TICKET_PRICE_2="65"
TABLE_TICKET_PRICE_2="450"
EVENT_TICKET_PRICE_3="75"
TABLE_TICKET_PRICE_3="500"
ENHANCER_TICKET_PRICE="20"
CHILDCARE_PRICE="25"
CABANA_PRICE="250"

View File

@@ -21,6 +21,47 @@ function getInteger($variable, $postiveOnly = true)
return $variable;
}
/**
* Calculate Event Pricing based on date
*
* @param DateTime $date
* @return array
* @throws Exception
*/
function getEventPricing($date = null)
{
$priceIncrease1 = new DateTime('4/1/2019', new DateTimeZone('America/Chicago'));
$priceIncrease2 = new DateTime('5/1/2019', new DateTimeZone('America/Chicago'));
if (empty($date)) {
return [
$_SERVER['EVENT_TICKET_PRICE_1'],
$_SERVER['TABLE_TICKET_PRICE_1'],
];
}
$interval = $date->diff($priceIncrease1);
if ($interval->invert !== 0) {
return [
$_SERVER['EVENT_TICKET_PRICE_2'],
$_SERVER['TABLE_TICKET_PRICE_2'],
];
}
$interval = $date->diff($priceIncrease2);
if ($interval->invert !== 0) {
return [
$_SERVER['EVENT_TICKET_PRICE_3'],
$_SERVER['TABLE_TICKET_PRICE_3'],
];
}else {
return [
$_SERVER['EVENT_TICKET_PRICE_1'],
$_SERVER['TABLE_TICKET_PRICE_1'],
];
}
}
/**
* Converts possible float or string to cents
*
@@ -69,9 +110,9 @@ function eventPricing($qty)
// If pricing is 8 or more then we need to factor in table reservations
if ($qty > 7) {
$tableQty = (int) ($qty / 8);
$tableQty = (int)($qty / 8);
$eventQty = $qty - ($tableQty * 8);
}else {
} else {
$eventQty = $qty;
}
@@ -86,13 +127,14 @@ function shoppingCartTotal($price)
</li>';
}
function checkIfTicketsAreOnSale() {
function checkIfTicketsAreOnSale()
{
$todaysDate = new DateTime('now', new DateTimeZone('America/Chicago'));
$dateOnSale = new DateTime('3/15/2019 8:00am', new DateTimeZone('America/Chicago'));
$interval = $todaysDate->diff($dateOnSale);
if($interval->days >= 0 && $interval->invert === 0) {
header('Location: /notify?d='.$dateOnSale->format('c'));
if ($interval->days >= 0 && $interval->invert === 0) {
header('Location: /notify?d=' . $dateOnSale->format('c'));
}
}