Hi, Getting a little frustrated with something that seemed simple enough. I have created the additional field as shown in the documentation and it appears on the booking page,
Once the form is submitted, there is no value in the database. I have also asked AI to check the code, with the following response. “The custom field not appearing in the database, even though it is visible on the booking form, indicates that the Hotelier plugin is not successfully processing or saving the data. The problem is not with your code, which correctly defines and adds the field to the form, but with how the plugin handles the submitted data.”
This is the booking form, the additional field Recommended by can be seen. But once the booking form is submitted, there is no corresponding field or value in the database that can be used.
This reply was modified 1 month, 2 weeks ago by trevgreguk.
Ok, the code works automatically if you use the “hotelier_booking_default_address_fields” filter. To update the reservation meta when you use the “hotelier_booking_additional_information_fields” filter, you can use this code:
Thank you π I can now see zswcustom_field with a value in the database, but the code to display the value in the admin reservation screen also does not display the custom field and it does not use the guest_ as stated in your documentations.
Can you please advise the correct code I should now use to display the custom field on the Admin Reservation Screen. This is the code I tried to use.
// Display the "Recommended by" custom field in the admin reservation details function custom_fields_in_reservation_data() { global $post; $reservation = htl_get_reservation( $post->ID ); if ( $reservation->zswcustom_field ) { $field = array( 'id' => 'zswcustom_field', 'label' => esc_html__( 'Recommended by', 'text-domain' ), 'value' => $reservation->zswcustom_field, ); HTL_Meta_Boxes_Helper::text_input( $field ); } } add_action( 'hotelier_reservation_after_guest_special_requests', 'custom_fields_in_reservation_data' );
Yes, the current action has a typo, “requets”. I will fix it in the next update. That’s why my code has two lines, because the new action will be “hotelier_reservation_after_guest_special_requests”. So you will be ready.