Check Reservation
public function onCheckReservationSelfConfirmation( object $reservation ) : bool
Fires while checking whether the self-confirmation is allowed for the specified reservation.
Description
This filter can be used to apply additional conditions to the self-confirmation restrictions. Applies only for restaurant reservations.
When this hook is triggered, the system already validated the standard conditions and the confirmation has been approved for the usage.
In case of allowed confirmation, the customer will be able to self-confirm a PENDING reservation through an apposite link received via e-mail.
Parameters
- $reservation
-
(VREOrderRestaurant) An object containing the details of the reservation that is going to be confirmed.
Return Value
Boolean. Use false to deny the self-confirmation.
Example
The example below prevents the confirmation for those customers that never booked a table. In summary, the confirmation will be allowed starting from the second table booking.
/**
* This filter can be used to apply additional conditions to the
* confirmation restrictions. When this hook is triggered, the
* system already validated the standard conditions and the
* confirmation has been approved for the usage.
*
* @param object $reservation The restaurant reservation to check.
*
* @return bool Use false to deny the confirmation.
*/
public function onCheckReservationSelfConfirmation($reservation)
{
if ($reservation->id_user <= 0) {
// only registered user can self-confirm reservation
return false;
}
$dbo = JFactory::getDbo();
$q = $dbo->getQuery(true)
->select(1)
->from($dbo->qn('#__vikrestaurants_reservation'))
->where($dbo->qn('status') . ' IN ("C", "P")')
->where($dbo->qn('id') . ' <> ' . $reservation->id)
->where($dbo->qn('id_parent') . ' <> ' . $reservation->id)
->andWhere(array(
$dbo->qn('id_user') . ' = ' . $reservation->id_user,
$dbo->qn('craeted_by') . ' = ' . $reservation->id_user,
), 'OR');
$dbo->setQuery($q, 0, 1);
$dbo->execute();
// prevent confirmation in case of no existing reservations
// assigned to this customer
return $dbo->getNumRows() ? true : false;
}
Changelog
Version | Description |
---|---|
1.8 | Introduced. |