Skip Navigation

[Assigned] Issue about the date range filter.

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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/Hong_Kong (GMT+08:00)

This topic contains 17 replies, has 2 voices.

Last updated by lesleeM 1 year, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#2569815

OK, this issue with the phone field is resolved, but I realized that I started this ticket with the issue about the date range filter. That one hasn't been resolved yet. So should we keep that in this ticket or split it off as well?

The date range filter is an issue on this page:

hidden link

That page is built with two views:

hidden link
hidden link

The parent view is the first one and the child view is the second one. The child view provides the counts of rides where each ride leader is selected in our rides.

The date range filter isn't working on this due to the complexity of what Waqar set up to accomplish this. If we cannot have a date range filter on the page itself for our director to use because it won't work with how Waqar set up the counts to work, then plan B would be to set up a new view for each calendar year. So we'd have a count of 2022 rides separate from a count of 2023 rides, etc. But if one date filter doesn't work then the other may not work either. Please let me know on this.

#2569891

Hello,

I have done below modifications in your website:
Add a custom code snippet "ride-leader-date-filter":
hidden link
with below codes:

add_filter('wpv_filter_query', function($query, $setting, $view_id){
    if($view_id == 2830 && isset($query['meta_query'])){
            foreach($query['meta_query'] as $k=> $v){
                 if($v['key'] == 'wpcf-start-date-and-time'){
                      unset($query['meta_query'][$k]);
                      break;
                 }
            }
    }
    return $query;
}, 99, 3);

Please test again, check if it is what you want.

More helps:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

#2570071

Something isn't right with that. The results on the initial page load look like they are correct here:

Ride Leader Name Number of Rides Led
Asher Aremband 5
Athena Bouvier 3
Brian Zinnamosca 1
Bud Brooks 4
Don Martyny 1
Donna Lyons 4
Howard Wiedman 4
Joan Toro 5
Karen Manglardi 6
Lorraine Zinnamosca 1
Mary Kostenbauder 2
Mike Bouvier 2
Rich Toro 2

I'll have to do deeper study into what our director set up with all his rides to be certain this is 100% perfect, but these counts look like they'd be right from what I have looked at. The only questionable ones are the ones with a count of one as I don't recall seeing them as Ride Leaders when I was establishing all the Relationships the right way. But I'd guess there is something I missed seeing there and those are likely correct.

But when I apply a date filter with a start date of March 26, 2023 and an end date of March 31, 2023, MANY more ride leaders appear and the ride counts increase. That should not be the case. The numbers should go down when limiting it to just those days. When doing that, it looks like the results are giving a 7 count to every ride leader and then increasing the number for the ride leaders with real counts beyond that. So something definitely isn't right there.

Give me a bit and I'll go through every ride in the system to compile with 100% certainty what the counts should be for both the initial page load and filtering by March 26, 2023 to March 31, 2023. I'll post the results it should be returning here once I have that put together.

#2570203

OK, I've trashed all of our older test rides and left it to where only the March rides our Director entered are present. The counts displaying here:

hidden link

are confirmed to be 100% correct.

Those counts are:

Donna Lyons - 4
Asher Aremband - 5
MIke Bouvier - 2
Athena Bouvier - 3
Karen Manglardi - 6
Joan Toro - 3
Howard Wiedman - 4
Bud Brooks - 4
Mary Kostenbauder - 2
Don Martyny - 1
Lorraine Zinnamosca - 1
Brian Zinnamosca - 1

If we apply a filter from March 26, 2023 to March 31, 2023, the results should change to the following:

Donna Lyons - 1
Asher Aremband - 1
MIke Bouvier - 1
Karen Manglardi - 1
Howard Wiedman - 1
Bud Brooks - 1
Mary Kostenbauder - 1

So if we get those results with that specific date filter range, then everything will be working.

#2571807

I have done below modifications in your website:
Edit the child post view "Ride Leader Number of Rides List Count Field":
hidden link

1) In section "Query Filter", add the post type relationship filter:
Select posts in a Ride Leaders relationship that are a related to the current post in the loop.

2) In section "Loop Editor", add line 5~8:

			<li>
				[wpv-post-link]
				[types field="start-date-and-time"][/types]
			</li>

You can remove above codes if it is confirmed.

3) Test it in frontend:
hidden link

In section "Donna Lyons", there are four related "Rides" posts, and it does output correct result: 4.

Can you check it again?

#2572289

The starting ride numbers when you first go to the page here:

hidden link

and do not try to filter by date are all correct as before.

But when I apply a date filter from March 26 to March 31, the counts now are not changing.

That's a good idea to add the ride names and dates for testing purposes to see what results are actually being returned. The filter doesn't seem to be applying.

I'm seeing there are date filters in both views now.

hidden link
hidden link

Is this not working because the date filter on the main page isn't applying to the results from the child view? That's what I was worried about happening to prevent us from being able to do this with the very complex structure Waqar come up with to accomplish the basic count feature. After he/we got that working, our director asked if I could add a date filter to it, which led me to filing another ticket after my effort failed. I don't know if there is a way to make a date filter apply to the results from both views.

If the date range filter won't work because of this structure, let me know if there is a way to break down the results here by year. That's the plan B option. I can set up a separate view for each year and then set up a page that shows the Views for all years. But doing that might run into the same problem because it is still trying to filter results by the date, but in a different way.

Sorry again that this is proving to be so difficult.

#2572435

Thanks for the details, checking it in your website, will update here if find anything

#2572827

Note that when you apply the date filter for March 26 - March 31, the Donna Lyons result should be 1 ride, not 4. it's working if filtering on March 26 - March 31 shows these results:

Donna Lyons - 1
Asher Aremband - 1
MIke Bouvier - 1
Karen Manglardi - 1
Howard Wiedman - 1
Bud Brooks - 1
Mary Kostenbauder - 1

#2574021

I can see the problem in your website, and I have tried it in my localhost with a fresh WP installation, it works fine.
Please provide a database only duplicator package of your website in below private message box:
https://toolset.com/faq/provide-supporters-copy-site/

#2574921

I am downloading the files, will update here if find anything

#2576327

Thanks. Did I do it correctly? Did you get the files? Let me know if you need anything else.

#2578189

Yes, you did it correctly, I need time to debug this issue, will update here if find anything

#2578975

Cool. Sorry again about the difficulty this is causing.

#2582283

Checking it, update here ASAP if locate the problem

#2583315

No rush. We're still working on another issue where we're trying to map form fields provided by a 3rd party plugin with Toolset custom user fields, so we won't be ready to launch the site until that project is complete. This date range filter issue on the Ride Leader Ride Counts page is not something that will delay us from launching. It will be *great* to have, but it is an admin only feature to help our director with a project where we provide ride jerseys to leaders after they lead a certain number of rides within a time frame. This count feature will let him determine who to give jerseys to without having to manually count every ride for every leader.

When I get this project done with mapping the form fields to Toolset user fields, I'll share what was done with you guys in case it would be helpful to you or other Toolset users for you to know how/what we did. We're creating a form that attaches to a Woocommerce product where end users supply data we want to associate with their user accounts. Once this field data correctly and automatically maps to the custom User fields we created in Toolset, then we'll be able to automate the process of setting up a full member profile list page using their form response data as fields in the profile. And the form submission is accomplished in one step with the product purchase process. We're also setting it up to where the user account itself will be created using username and password fields in this form to pass to Woocommerce to use in creating the customer account for any user that is not logged in as a user when they complete the purchase. So filling out the Membership form, purchasing the Membership product, creating the user account and providing all the data for the Member Profile is being accomplished within the same step. Fingers crossed that we get everything we're trying to do here. I'm thinking we should have everything done in a few more days, maybe 2 weeks.