Go to: /wp-content/plugins/gdlr-hotel/include
then copy the gdlr-utility-mart-backup.php file in the folder or edit this code:
<?php
/*
* Goodlayers Utility File
*/
// retrieve all posts as a list
if (!function_exists('gdlr_hotel_get_post_list')) {
function gdlr_hotel_get_post_list($post_type)
{
$post_list = get_posts(array('post_type' => $post_type, 'numberposts' => 1000));
$ret = array();
if (!empty($post_list)) {
foreach ($post_list as $post) {
$ret[$post->ID] = $post->post_title;
}
}
return $ret;
}
}
// format date
if (!function_exists('gdlr_hotel_date_format')) {
function gdlr_hotel_date_format($date, $format = '', $time = false)
{
if (empty($format)) {
$format = get_option('date_format');
if (!empty($time)) {
$format .= ' ' . get_option('time_format');
}
}
$date = is_numeric($date) ? $date : strtotime($date);
return date_i18n($format, $date);
}
}
// send the mail
if (!function_exists('gdlr_hotel_mail')) {
function gdlr_hotel_mail($recipient, $title, $message, $reply_to = '')
{
global $hotel_option;
$headers = 'From: ' . $hotel_option['recipient-name'] . ' <' . $hotel_option['recipient-mail'] . '>' . "\r\n";
if (!empty($reply_to)) {
$headers = $headers . 'Reply-To: ' . $reply_to . ' <' . $reply_to . '>' . "\r\n";
}
// HTML headers for email
$headers = $headers . 'Content-Type: text/html; charset=UTF-8 ' . " \r\n";
wp_mail($recipient, $title, $message, $headers);
}
}
// HTML email content for booking
if (!function_exists('gdlr_hotel_mail_content')) {
function gdlr_hotel_mail_content($contact, $data, $payment_info, $price)
{
$content = '<div style="font-family:Arial,sans-serif; font-size:14px; color:#333;">';
// Logo
$content .= '<p><img src="https://marielisuites.com/wp-content/uploads/2025/06/logo-brown-1.png" alt="Hotel Logo" style="max-width:200px;"></p>';
// Custom intro message
$content .= '<p style="font-size: 25px;">We’re checking availability for your dates and will get back to you shortly. <br>';
$content .= 'If the dates are available, we’ll send a secure payment link to finalize your booking.</p>';
$content .= '<hr>';
// Contact Info
$content .= '<h2>Contact Info</h2>';
$content .= 'Name: ' . $contact['first_name'] . '<br>';
$content .= 'Last Name: ' . $contact['last_name'] . '<br>';
$content .= 'Phone: ' . $contact['phone'] . '<br>';
$content .= 'Email: ' . $contact['email'] . '<br>';
$content .= 'Address: ' . $contact['address'] . '<br>';
$content .= 'Additional Note: ' . $contact['additional-note'] . '<br>';
$content .= 'Coupon: ' . $contact['coupon'] . '<br>';
if (!empty($data['gdlr-hotel-branches'])) {
$term = get_term_by('id', $data['gdlr-hotel-branches'], 'room_category');
$content .= 'Branches: ' . $term->name . '<br>';
$category_meta = get_option('gdlr_hotel_branch', array());
if (!empty($category_meta[$term->slug]['content'])) {
$content .= 'Location: ' . $category_meta[$term->slug]['content'] . '<br>';
}
}
// Room Info
$content .= '<h2>Room Information</h2>';
for ($i = 0; $i < intval($data['gdlr-room-number']); $i++) {
$room_num = $i + 1;
$content .= 'Room ' . $room_num . ': ' . get_the_title($data['gdlr-room-id'][$i]) . '<br>';
$content .= 'Adult: ' . $data['gdlr-adult-number'][$i] . '<br>';
$content .= 'Children: ' . $data['gdlr-children-number'][$i] . '<br>';
}
$content .= 'Check In: ' . $data['gdlr-check-in'] . '<br>';
if (!empty($data['gdlr-checkin-hour']) && !empty($data['gdlr-checkin-min'])) {
$content .= 'Check In Time: ' . $data['gdlr-checkin-hour'] . ':' . $data['gdlr-checkin-min'] . '<br>';
}
$content .= 'Check Out: ' . $data['gdlr-check-out'] . '<br>';
// Additional Services
if (!empty($data['service']) || !empty($data['service-room'])) {
$content .= '<h2>Additional Services</h2>';
if (!empty($data['service'])) {
$services_price = gdlr_calculate_service_price($data);
foreach ($services_price as $key => $service_price) {
if ($key == 'total') continue;
$service_title = str_replace('<span class="gdlr-sep">/</span>', ' ', $service_price['title']);
$content .= $service_title . '<br>';
}
}
if (!empty($data['service-room'])) {
$room_services_price = gdlr_calculate_room_service_price($data);
foreach ($room_services_price as $room_id => $services) {
if ($room_id == 'total') continue;
foreach ($services as $service_id => $service_price) {
$service_title = str_replace('<span class="gdlr-sep">/</span>', ' ', $service_price['title']);
$content .= $service_title . '<br>';
}
}
}
}
// Payment Info
$content .= '<h2>Payment Information</h2>';
$content .= 'Total Price: ' . gdlr_hotel_money_format($price['total_price']) . '<br>';
$content .= 'Paid Amount: ' . gdlr_hotel_money_format($price['pay_amount']) . '<br>';
if (!empty($price['booking_code'])) {
$content .= 'Booking Code: ' . $price['booking_code'] . '<br>';
}
if (!empty($contact['payment-method']) && !empty($payment_info)) {
if ($contact['payment-method'] == 'stripe') {
$content .= 'Payment Method: Stripe<br>';
$content .= 'Transaction ID: ' . $payment_info['balance_transaction'] . '<br>';
} else if ($contact['payment-method'] == 'paypal') {
$content .= 'Payment Method: Paypal<br>';
$content .= 'Transaction ID: ' . $payment_info['txn_id'] . '<br>';
} else if ($contact['payment-method'] == 'authorize') {
$content .= 'Payment Method: Authorize<br>';
$content .= 'Transaction ID: ' . $payment_info->transaction_id . '<br>';
}
}
$content .= '</div>';
return apply_filters('gdlr_hotel_mail_content', $content, $contact, $data, $payment_info, $price);
}
}
// format the currency
if (!function_exists('gdlr_hotel_money_format')) {
function gdlr_hotel_money_format($amount, $format = '', $digit = 2)
{
if (empty($format)) {
global $hotel_option;
$format = $hotel_option['booking-money-format'];
}
if (strpos($format, 'NUMBER') === false) {
$format .= 'NUMBER';
}
return str_replace('NUMBER', number_format_i18n($amount, $digit), $format);
}
}
// validate the contact form fields
if (!function_exists('gdlr_validate_contact_form')) {
function gdlr_validate_contact_form($contact)
{
if (
empty($contact['first_name']) || empty($contact['last_name']) ||
empty($contact['email']) || empty($contact['phone'])
) {
return __('Please fill all required fields.', 'gdlr-hotel');
}
if (!is_email($contact['email'])) {
return __('Email is invalid.', 'gdlr-hotel');
}
return false;
}
}
if (!function_exists('gdlr_sanitize_contact_fields')) {
function gdlr_sanitize_contact_fields($fields)
{
if (!empty($fields)) {
foreach ($fields as $key => $value) {
if (is_array($value)) {
$fields[$key] = gdlr_sanitize_contact_fields($value);
} else {
$fields[$key] = sanitize_textarea_field($value);
}
}
}
return $fields;
}
}
// save the booking any payment to database
if (!function_exists('gdlr_insert_booking_db')) {
function gdlr_insert_booking_db($options)
{
if (!empty($options['data'])) {
$options['data'] = gdlr_sanitize_contact_fields($options['data']);
}
if (!empty($options['contact'])) {
$options['contact'] = gdlr_sanitize_contact_fields($options['contact']);
}
global $wpdb, $hotel_option;
$pricing = gdlr_get_booking_total_price($options['data'], $options['contact']['coupon']);
if ($pricing['total_price'] == 0) {
$options['payment_status'] = 'paid';
}
if ($options['payment_status'] == 'booking') {
$pricing['pay_amount'] = 0;
}
$customer_code = $hotel_option['booking-code-prefix'];
$customer_code .= mb_substr($options['contact']['first_name'], 0, 1);
$customer_code .= mb_substr($options['contact']['last_name'], 0, 1);
$code_count = get_option('gdlr-customer-code-count', 0);
update_option('gdlr-customer-code-count', $code_count + 1);
$customer_code = strtoupper($customer_code . $code_count);
$result = $wpdb->insert(
$wpdb->prefix . 'gdlr_hotel_payment',
array(
'total_price' => $pricing['total_price'],
'pay_amount' => $pricing['pay_amount'],
'booking_date' => current_time('mysql'),
'checkin_date' => $options['data']['gdlr-check-in'],
'booking_data' => serialize($options['data']),
'contact_info' => serialize($options['contact']),
'payment_status' => $options['payment_status'],
'customer_code' => $customer_code
),
array('%f', '%f', '%s', '%s', '%s', '%s', '%s', '%s')
);
if ($result > 0) {
$payment_id = $wpdb->insert_id;
for ($i = 0; $i < $options['data']['gdlr-room-number']; $i++) {
$wpdb->insert(
$wpdb->prefix . 'gdlr_hotel_booking',
array(
'payment_id' => $payment_id,
'room_id' => $options['data']['gdlr-room-id'][$i],
'start_date' => $options['data']['gdlr-check-in'],
'end_date' => $options['data']['gdlr-check-out'],
'date_list' => implode(',', gdlr_hotel_list_dates($options['data']['gdlr-check-in'], $options['data']['gdlr-check-out']))
),
array('%s', '%s', '%s', '%s')
);
do_action('gdlr_hotel_add_booking', $payment_id, $options);
do_action('gdlr_update_room_availability', $options['data']['gdlr-room-id'][$i]);
}
}
return array(
'invoice' => $payment_id,
'total-price' => $pricing['total_price'],
'pay-amount' => $pricing['pay_amount'],
'code' => $customer_code
);
}
}