Your cart is empty!
Calculate Total Deposit
apply_filters( 'vikrestaurants_calculate_total_deposit', float $deposit, float $total, array $args )
Fires while calculating the deposit amount to use for restaurant reservations.
Description
This filter can be used to alter at runtime the total deposit to leave for confirming a restaurant reservation.
Parameters
- $deposit
-
(float|null) The new deposit amount. Leave null to use the default deposit.
- $total
-
(float) The default deposit amount.
- $args
-
(array) An associative array containing the query arguments.
date
- the check-in date, formatted according to the configuration of the plugin;hourmin
- the check-in time, always in 24H format;people
- the number of participants;table
- the table that will be assigned to the reservation.
Example
The example below uses a different deposit depending on the room that has been selected.
<?php
/**
* This filter can be used to alter the total deposit at runtime.
*
* @param float $deposit The new deposit amount.
* @param float $total The default deposit.
* @param array $args The searched arguments.
*/
add_filter('vikrestaurants_calculate_total_deposit', function($deposit, $total, $args)
{
// fetch table details
$table = JModelVRE::getInstance('table')->getItem((int) $args['table'], $blank = true);
switch ($table->id_room) {
case 1:
// leave amount as it is for "main room"
break;
case 2:
// unset deposit for "garden"
$deposit = 0;
break;
case 3:
// double deposit for "private room"
$deposit = $total * 2;
break;
}
return $deposit;
}, 10, 3);
Changelog
Version | Description |
---|---|
1.0 | Introduced. |
Last Update: 2024-05-22
Helpful?