Table ticket pricing
This commit is contained in:
@@ -39,11 +39,13 @@ $router->post('/', function () {
|
|||||||
|
|
||||||
// Calculate totals
|
// Calculate totals
|
||||||
$additionalContribution = convertPossibleFloatToCents($_POST['additionalContribution']);
|
$additionalContribution = convertPossibleFloatToCents($_POST['additionalContribution']);
|
||||||
|
list($tableTicketQty, $eventTicketQty) = eventPricing($eventTicketQty);
|
||||||
$eventTicketPrice = convertPossibleFloatToCents($eventTicketQty * $_SERVER['EVENT_TICKET_PRICE']);
|
$eventTicketPrice = convertPossibleFloatToCents($eventTicketQty * $_SERVER['EVENT_TICKET_PRICE']);
|
||||||
|
$tableTicketPrice = convertPossibleFloatToCents($tableTicketQty * $_SERVER['TABLE_TICKET_PRICE']);
|
||||||
$ticketEnhancerPrice = convertPossibleFloatToCents($ticketEnhancerQty * $_SERVER['ENHANCER_TICKET_PRICE']);
|
$ticketEnhancerPrice = convertPossibleFloatToCents($ticketEnhancerQty * $_SERVER['ENHANCER_TICKET_PRICE']);
|
||||||
|
|
||||||
// Sum the cart totals
|
// Sum the cart totals
|
||||||
$cartTotal = $eventTicketPrice + $ticketEnhancerPrice + $additionalContribution;
|
$cartTotal = $eventTicketPrice + $tableTicketPrice + $ticketEnhancerPrice + $additionalContribution;
|
||||||
include 'views/common/head.php';
|
include 'views/common/head.php';
|
||||||
include 'views/step2.php';
|
include 'views/step2.php';
|
||||||
include 'views/common/footer.php';
|
include 'views/common/footer.php';
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
EVENT_TICKET_PRICE="55"
|
EVENT_TICKET_PRICE="55"
|
||||||
|
TABLE_TICKET_PRICE="350"
|
||||||
ENHANCER_TICKET_PRICE="20"
|
ENHANCER_TICKET_PRICE="20"
|
||||||
DB_HOST="localhost"
|
DB_HOST="localhost"
|
||||||
DB_USER="root"
|
DB_USER="root"
|
||||||
|
|||||||
@@ -49,16 +49,38 @@ function shoppingCartLineItem($name, $price, $description = '')
|
|||||||
<h6 class="my-0">' . $name . '</h6>
|
<h6 class="my-0">' . $name . '</h6>
|
||||||
<small class="text-muted">' . $description . '</small>
|
<small class="text-muted">' . $description . '</small>
|
||||||
</div>
|
</div>
|
||||||
<span class="text-muted">' . '$' . number_format(($price/100), 2) . '</span>
|
<span class="text-muted">' . '$' . number_format(($price / 100), 2) . '</span>
|
||||||
</li>';
|
</li>';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate table ticket price and event tickets based on quantity
|
||||||
|
*
|
||||||
|
* @param $qty integer Quantity of event tickets purchased
|
||||||
|
* @param $price integer Price of event tickets
|
||||||
|
* @param $tablePrice integer Price of table
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function eventPricing($qty)
|
||||||
|
{
|
||||||
|
$tableQty = 0;
|
||||||
|
$eventQty = 0;
|
||||||
|
|
||||||
|
// If pricing is 8 or more then we need to factor in table reservations
|
||||||
|
if ($qty > 7) {
|
||||||
|
$tableQty = (int) ($qty / 8);
|
||||||
|
$eventQty = $qty - ($tableQty * 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [$tableQty, $eventQty];
|
||||||
|
}
|
||||||
|
|
||||||
function shoppingCartTotal($price)
|
function shoppingCartTotal($price)
|
||||||
{
|
{
|
||||||
echo '<li class="list-group-item d-flex justify-content-between">
|
echo '<li class="list-group-item d-flex justify-content-between">
|
||||||
<span>Total</span>
|
<span>Total</span>
|
||||||
<strong>' . '$' . number_format(($price/100), 2) . '</strong>
|
<strong>' . '$' . number_format(($price / 100), 2) . '</strong>
|
||||||
</li>';
|
</li>';
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
<span class="text-muted">Your cart</span>
|
<span class="text-muted">Your cart</span>
|
||||||
</h4>
|
</h4>
|
||||||
<ul class="list-group mb-3">
|
<ul class="list-group mb-3">
|
||||||
|
<?=shoppingCartLineItem('Table', $tableTicketPrice, $tableTicketQty . ' x table');?>
|
||||||
<?=shoppingCartLineItem('Dinner', $eventTicketPrice, $eventTicketQty . ' x tickets');?>
|
<?=shoppingCartLineItem('Dinner', $eventTicketPrice, $eventTicketQty . ' x tickets');?>
|
||||||
<?=shoppingCartLineItem('Ticket Enhancers', $ticketEnhancerPrice, $ticketEnhancerQty . ' x enhancers');?>
|
<?=shoppingCartLineItem('Ticket Enhancers', $ticketEnhancerPrice, $ticketEnhancerQty . ' x enhancers');?>
|
||||||
<?=shoppingCartLineItem('Additional Contribution', $additionalContribution);?>
|
<?=shoppingCartLineItem('Additional Contribution', $additionalContribution);?>
|
||||||
|
|||||||
Reference in New Issue
Block a user