I am looking to set a default value and hide the following listing attributes so they can’t be edited by the user and won’t be shown to them when creating a listing.
BOOKING AVAILABLE FROM
BOOKING AVAILABLE TO
BOOKING SLOT DURATION
BOOKING SLOT INTERVAL
I would also like to have BOOKING REQUESTS always checked for “Manually accept new bookings” and hide that as well.
The default values worked great thank you for that but the filter doesn’t seem to be hiding the attributes. I added the add_filter code to functions.php
I need to remove the queries “booking slot duration” & “booking slot interval” and assign both queries constant values (60 & 0, respectively) so that all users will have the same two values.
Thanks for the details. Please make sure that you do not have any restrictions on booking categories, as shown in this documentation: How to restrict booking to specific listing categories - HivePress Help Center. We also recommend creating a new listing and testing this snippet on it, as auto-drafts may have been saved in old listings, which may cause it to not work.
Additionally, please clarify what exactly you mean by “items” in this sentence: “I want the booking_max_quantity to equal the quantity of items instead of 10.” Then we can provide a solution or a workaround.
Hello! Here’s a clarification: when I use this snippet, the booking_max_quantity is automatically set to 20 because I hard-coded it, which works perfectly. However, is there a way to dynamically set booking_max_quantity equal to the quantity the user specifies when creating the listing, instead of hard-coding “20”?
Please note that if you are using Bookings and Marketplace, you need to disable the quantity feature and use only the guests feature. The quantity feature does not work with the Bookings extension, only with Marketplace. As for your snippets, it should work as expected, booking_max_quantity will be 20 and will not be available for editing by the user.
The easiest way is renaming the Maximum Guests per Booking label to Quantity using Loco Translate plugin and removing the custom Quantity field, then users can simply flll in this field when they add a listing. If there’s another reason for hiding the default field and using a custom Quantity field’s value, you can accept the listing object as the second parameter of the function and get any custom field value this way:
Please note that Quantity is probably not available on the listing creation yet, so it may be better to use the hivepress/v1/models/listing/update hook instead and check if the quantity is already set for a listing.