Skip to content

Instantly share code, notes, and snippets.

@NateWr
Last active August 23, 2019 08:46
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save NateWr/00ee083db4d357aeab68 to your computer and use it in GitHub Desktop.
Save NateWr/00ee083db4d357aeab68 to your computer and use it in GitHub Desktop.
Automatically confirm new booking requests for Restaurant Reservations.
<?php
/**
* Plugin Name: Auto-confirm New Bookings for Restaurant Reservations
* Plugin URI: http://themeofthecrop.com
* Description: Automatically confirm new booking requests.
* Version: 1.0
* Author: Theme of the Crop
* Author URI: http://themeofthecrop.com
* License: GNU General Public License v2.0 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU
* General Public License as published by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU General Public License along with this program; if not, write
* to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
if ( ! defined( 'ABSPATH' ) )
exit;
/**
* Automatically confirm new bookings when they are added to the
* database.
*/
add_filter( 'rtb_insert_booking_data', 'rtbcnb_confirm_new_bookings', 10, 2 );
function rtbcnb_confirm_new_bookings( $args, $booking ) {
if ( empty( $booking->ID ) ) {
$args['post_status'] = 'confirmed';
}
return $args;
}
@wendigox
Copy link

Hi!
When I install this plugin, this is the error I get:

Fatal error: Cannot redeclare rtbcnb_confirm_new_bookings() ...... wp-content/plugins/confirm-new-bookings-for-rtb.php on line 30

How can I fix this?
/Marco

@NateWr
Copy link
Author

NateWr commented Aug 3, 2015

Hi @wendigox. Sorry I'm just seeing this now. Gist doesn't give me any notification of new comments.

This error means that the function is being declared twice. Maybe you copied the code in twice by accident? Maybe you've already added it to your theme's functions.php file or something? Maybe you've got two copies of the plugin activated?

Copy link

ghost commented Oct 14, 2016

Hi NateWr

it is me mumbomedia you've help me in the support forum of wordpress.
@see https://wordpress.org/support/topic/change-date-and-timepicker-to-jquery-ui/

Our client want that the reservations would be automatically confirm if there is a free table available.
The max-size of this is stored in the max_partysize -setting of your plugin.
This should be no problem to get this information.
Actualy I have some issues with this plugin:

  1. The plugin doesn't change the message provided after the request is submitted.
    It is

Thanks, your booking request is waiting to be confirmed. Updates will be sent to the email address you provided.
but in this case it doesn't make any sense, because of the accepting of the reservation.
So I need to change this.
Are there a hook which I can use to alter the message regarding to the status I am setting up.

  1. A confirm email isn't send to the guest of the restaurant. So the guest doesn't know that the reservation is confirmed or rejected.
    I need to change this also and need the hook to alter this behaviour.

Kind regards

mumbomedia

@JsKsathiya
Copy link

JsKsathiya commented Dec 24, 2016

I added this plugin, but still get the 'Pending' status???

@NateWr
Copy link
Author

NateWr commented Dec 24, 2016

Hi @ColanInfotech, thanks for letting me know. The conditional expression was reversed on accident. Line 32 should read:

if ( empty( $booking->ID ) ) {

I've updated the gist now so anyone else coming along should get a working copy.

@MiriShehu
Copy link

Hi @NateWr,

The plugin is working. it automatically marks as completed all new booking requests. The issue I'm having is with e-mail confirmation to clients.
Is is possible to send the confirmation e-mail immediately after the form submission? thanks

@iWebbers
Copy link

iWebbers commented Apr 11, 2019

@MiriShehu @NateWr

If I understand correctly the system only sets the reservation as COMPLETED/CONFIRMED but does NOT send the confirm notification email?

If so, in that case this nice little plugin would be pretty useless in my opinion..?

@NateWr
Copy link
Author

NateWr commented Jul 1, 2019

@MiriShehu and @iWebbers, sorry for the late reply. GitHub doesn't send notifications about comments in gists.

The plugin will still send the "New Request Email" under Bookings > Settings > Notifications. So you can adjust that email to reflect that the booking has been accepted.

@marcellocarrabba
Copy link

marcellocarrabba commented Aug 22, 2019

@NateWr
So, the email issue I have is that the administrator is not getting emails.
Everything else works fine, client gets email notification, and the reservation is auto-confirmed.
Configuration seems perfect. I have no clue why the "restaurant" does not receive emails.

Problem solved: it was NOT a plugin issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment