Navigation überspringen

[Gelöst] Search for working hours

This support ticket is created vor 5 Jahren, 7 Monaten. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Dieses Thema enthält 10 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von reimundH vor 5 Jahren, 7 Monaten.

Assistiert von: Waqar.

Author
Artikel
#1244149

Dear Lady or Sir,

I´d like to create a search for the working hours as to the following scheme.

- Dropdown for the days (Monday / Tuesday / and so on)
- Dropdown for the hours (00:00 / 01:00 / 02:00 / and so on)

How is it possible to do this, that it´s related together?

Best regards
Reimund

#1244406

Hi Reimund,

Thank you for contacting us and I'll be happy to assist.

To create an hour long, slot based search for the working hours, you can follow these steps:

1. Register a new post type "Working hours" which will hold each slot or entry of available working hours.
( ref: https://toolset.com/documentation/getting-started-with-toolset/structure-your-data-with-custom-post-types-fields-and-taxonomies/#create-custom-post-types-from-the-toolset-dashboard )

2. Next, you can create two "Select" type custom fields for this new post type:
( ref: https://toolset.com/documentation/user-guides/using-custom-fields/ )

a). The first one will be for the days of the week,
e.g. Monday, Tuesday, Wednesday ... and so on

b). The second one will be for each hourly slot in the day,
e.g. 00:00 - 01:00, 01:00 - 02:00, 02:00 - 03:00 ... and so on

3. You'll be able to add each available working hour slot, in the new post type from step 1, with the relevant day and the hour custom field value.

4. As the last step, you'll create a new post view with a search form, so that visitors can filter the working hours based on these two custom fields.
( ref: https://toolset.com/documentation/user-guides/front-page-filters/ )

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1244488
Bildschirmfoto 2019-05-16 um 11.24.09.png

Hello Waqar,

thank you for your guidance.
I have not fully understood it yet.
I've done all the steps to point 3 (see attached screen shot of the post type form).
Now I can only choose a day and a respective time.
What do I have to do to select several days and the corresponding hourly period.
e.g.
Monday 18:00-22:00
Tuesday 15:00-21:00
Wednesday 22:00-03:00
And so on...

The search should allow to choose a day and a hour via dropdown:
e.g.
Dropdown-DAY: Monday
Dropdorn-HOUR: 20:00
or
Dropdown-DAY: Wednesday
Dropdorn-HOUR:01:00

Best regards
Reimund

#1244943

Hi Reimund,

Thanks for writing back.

The approach suggested in my last message would work, if:

a). the working hours that you're offering consists of an hour-long timeslot and
b). in the search form, you'd like to offer a field to pick a day of the week and the hour of the day

If both points mentioned above accurately describe your requirement, then you can continue on with this approach.

Suppose that you have to offer the following working hours, to your visitors:

Monday 18:00-22:00
Tuesday 15:00-21:00

In this case, you'll add the following individual posts in your "Working hours" post type:

Monday 18:00
Monday 19:00
Monday 20:00
Monday 21:00
Monday 22:00

Tuesday 15:00
Tuesday 16:00
Tuesday 17:00
Tuesday 18:00
Tuesday 19:00
Tuesday 20:00
Tuesday 21:00

The same can be repeated for the working hours for the other days of the week and note that for each hourly timeslot, you'll be adding a new post item in the "Working hours" post type.

When the visitor will perform the search, by selecting a day and the hour, he/she will be able to see if that desired timeslot is available or not.

I hope this clarifies and let me know if you have any question related to this approach or have a different requirement.

regards,
Waqar

#1245228

Hi Waqar,

thank you again for your guidance.

An hour-long timeslot isn´t what Im looking for.
I need a solution for a time periode.

E.g.
Monday 18:00-22:00
Tuesday 15:00-21:00

However I think the last instruction will not work in my case. Please correct me if I am wrong.

Let me explain my case in detail.
I´ve created a Post Type for Models. So I add each Model as a Post into the Models Post Type. In addition I´ve created Custom Fields to choose all detailed information for each Model. So my plan is, that the visitor are able to choose a Day and a Hour with the Custom Search Form, to display all available Models according to the chosen Day and Hour.

For example:
- Model A are available on Monday from 10:00-18:00
- Model B are available on Monday from 15:00-18:00
- Model C are available on Monday from 18:00-00:00

The visitor choose:
- Day: Monday
- Hour: 17:00

Displayed search-results:
- Model A
- Model B

Thanks in advance for your further support.
Looking forward to your reply.

Best regards
Reimund

#1245700

Hi Reimund,

Thanks for writing back and for sharing these details.

For model's availability search, based on the selected Day and Hour, you can follow these steps:

1. Please create a "Repeating Field Group" named "Model Schedule" for the post type "Models".
( ref: https://toolset.com/documentation/getting-started-with-toolset/creating-and-displaying-repeatable-field-groups/ )
Screenshot: versteckter Link

2. In this new repeating field group, add a "Select" type custom field named "Model Day", with all 7 days of the week.
Screenshot: versteckter Link

3. In the same repeating field group, also add another "select" type custom field named "Model Hour" and include all hours of the day.
Screenshot: versteckter Link

4. After that, you can go to each model's edit screen and attach the working hour and day entries as grouped repeating fields.
Screenshot: versteckter Link

5. Next, create a new post view and set it to show the results from the repeatable field groups "Model Schedule".
Screenshot: versteckter Link

6. In the view's "Query Filter" section, add the custom field filters for the "Model Day" and the "Model Hour" fields, with values to compare coming from the URL parameters "model-day" and "model-hour", respectively.
Screenshot: versteckter Link

7. In the "Search and Pagination" section, include the code to show the front-end search filter fields, to select the day and the hour:
Screenshot: versteckter Link


[wpv-filter-start hide="false"]
[wpv-filter-controls]
<div class="form-group">
	<label>[wpml-string context="wpv-views"]Model Day[/wpml-string]</label>
	[wpv-control-postmeta field="wpcf-model-day" url_param="model-day" default_label="Select Day"]
</div>
<div class="form-group">
	<label>[wpml-string context="wpv-views"]Model Hour[/wpml-string]</label>
	[wpv-control-postmeta field="wpcf-model-hour" url_param="model-hour" default_label="Select Hour"]
</div>
[wpv-filter-submit output="bootstrap"][wpv-filter-reset output="bootstrap"]
[/wpv-filter-controls]
[wpv-filter-end]

8. To show the information of the model, whose "Model Schedule" post is being shown in the view, you can use the item attribute item="@model-schedule.parent" in the loop item's content template like this:
( ref: https://toolset.com/documentation/user-guides/views-shortcodes/item-attribute/ )
Screenshot: versteckter Link


[wpv-post-link item="@model-schedule.parent"]

Please follow these steps and let me know how it goes.

regards,
Waqar

#1245735

Hi Waqar,

thanks for the instruction.
I understand all steps. Now I have one more question. What I have to do if I have several Model-Post-Type? In my case it was necessary to create four different Model-Post-Types.

Thanks in advance.

Best regards
Reimund

#1245770

Hi Reimund,

Any field group, which includes a "repeating field group", can be attached to only a single post type.

Is there any specific reason for distributing your models into multiple post types? Would it work if you keep them in a single post type, but group them using a custom taxonomy/category (instead of splitting them into separate post types)?

If it is an absolute requirement that they'll be spread across multiple post types, you'll need to create a separate field group with an independent repeating field group for each of those post types.

regards,
Waqar

#1245826

Hi Waqar,

okay. So if I create a separate field group with an independent repeating field group for each of those post types.
I have to do all the steps of your instruction. Right?
I use the code of POINT 7. unchanged. Right?
What about: [wpv-post-link item="@model-schedule.parent"] ? I assume this part needs to be adapted or extended. Right?

Best regards
Reimund

#1245878

Hi Reimund,

Yes, your understanding is correct, on all accounts.

>> I have to do all the steps of your instruction. Right?

- Yes, all the steps will need to be repeated for each post type.

>> I use the code of POINT 7. unchanged. Right?

- The code from point# 7 can be used unchanged and only text that will need to be updated will be field slugs "wpcf-model-day" and "wpcf-model-hour" since you won't be able to use the same fields slug again in other field groups.

>> What about: [wpv-post-link item="@model-schedule.parent"] ? I assume this part needs to be adapted or extended. Right?

- Yes, "model-schedule" text, in this case, is coming from the repeating field group's slug.
Screenshot: versteckter Link

As this slug will be different for each post type's repeating field group, you'll update that in point# 8, accordingly.

regards,
Waqar

#1247119

My issue is resolved now. Thank you!