I'm creating a property rental site and wish to display a table of seasonal rental prices for each property (see attached image).
For each property, I'd enter:
- From Date
- To Date
- Minimum stay
- Number of bedrooms (as the guest might rent the property with one bedroom closed off)
- Price
I realise this will be using repeating groups and a view, but can't figure it out. I got as far as displaying a basic view of the data but can't understand how to add more than 2 columns to the table. Is this possible?
And is it possible to display the data in the way I've shown, where there's an optional additional column for properties that can be booked at a different price with different number of bedrooms? I'm assuming the solution for this is a repeating field within a repeating group, which doesn't seem possible.
Hope this makes sense, would love to hear your thoughts on how to achieve this (or if it's even possible). Thanks!
Creating and designing tables for the output of a View block is admittedly a bit tricky.
To add additional columns you need to select the Table Row block, and then you can adjust the column count in the sidebar settings (screenshot).
(If you are comfortable working with HTML, you might find it useful to explore using the legacy Views editor in this case, which gives you more control over the output and when the structure is perhaps more transparent. You would use the Loop Wizard and choose table output to generate the scaffolding for the table. See https://toolset.com/course-lesson/enabling-legacy-version-of-toolset-views/.)
Regarding the multiple prices. I take it that the issue is that some properties would need multiple prices (a normal price, a second price for if one room is closed off, possibly a third price if two rooms are closed off?), but not all properties will.
If you are using a table structure this is problematic if you wanted to display each price variant in its own column (like your spreadsheet), because that would mean your table having a variable number of columns depending on which property was being displayed.
There isn't any way to do that with the tables you output with a View.
But you could have a single column for price, and where there are price variants they could be displayed within the same table cell, each variant on a new line.
The variants would have to be worded to include the rooms, the "per night" could be in the column title, so prices would say
Price per night
------
5 rooms 90 USD
4 rooms 75 USD
So you are using repeatable groups of fields, and the price field within that group can accept multiple values.
Thanks for taking the time to understand the requirement.
I'm more than comfortable working with HTML and will check out Legacy Views, thanks.
When you say "and the price field within that group can accept multiple values", do you mean as field type "multiple lines" or something else? Ideally, I'd still be saving the price as a number but it doesn't allow multiple instances of a field within a repeating group.
Even within a Repeatable Field Group individual fields can have multiple instances (screenshot).
A single value of a custom field is stored in a row of wp_postmeta, with the ID of the post it belongs to, and the key that identifies the field. With a "repeating" field, it just means adding more rows to wp_postmeta with the same key and same post ID.
The topic ‘[Closed] Creating and displaying a repeating group of property rental prices’ is closed to new replies.