Skip Navigation

[Closed] View to show Woocommerce orders with a query filter on an attribute option?

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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 10 replies, has 2 voices.

Last updated by lesleeM 1 year ago.

Assisted by: Nigel.

Author
Posts
#2668437

We're trying to set up a view that will display Woocommerce orders, but only ones with a specific product attribute chosen.

The fields that should be shown are First Name, Last Name and a value for a different product attribute. I have my Loop Item set up as follows:

[wpv-post-field name="_billing_first_name"] [wpv-post-field name="_billing_last_name"] - [wpv-post-field name="attribute_pa_rv-site"]<br>

But that is showing No Items Found as the result. When I remove the query filter from the view, the names on all orders display as expected, but the option on the second product attribute does not display. So I'm having 2 problems with using Woocommerce attributes on this view.

I can provide admin access and provide the URLs to all Views and the page where the views are displayed.

#2668811

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Sorry, I'm not sure what you are describing here.

You have a View that queries and displays orders?

And you are trying to filter that View by product attributes, and in the output to display product attributes?

I assume there is something else going on here, as that doesn't sound right, if you could please clarify.

#2669037

Yeah, this will likely run into the same barrier as you explained to me in this ticket:

https://toolset.com/forums/topic/query-filter-in-view-based-on-all-woocommerce-product-titles-in-store/

We have a registration product where there is an option that is a product attribute to register for a 3-day event or a 6-day event. We just want to display a list of all people that registered for the 3-day event in one view, then all people that registered for the 6-day event in another view.

Maybe this can be better done through conditional output instead of a query filter. I just tried that as well after removing the query filter and it is not displaying any results either. I'm not understanding why this isn't working.

Here's the code I tried:

[wpv-conditional if="( $(attribute_pa_number-of-days) eq '3-Day Safari' )"][wpv-post-field name="_billing_first_name"] [wpv-post-field name="_billing_last_name"] - [wpv-post-field name="attribute_pa_rv-site"]<br>[/wpv-conditional]

[wpv-conditional if="( $(attribute_pa_number-of-days) eq '6-Day Safari' )"][wpv-post-field name="_billing_first_name"] [wpv-post-field name="_billing_last_name"] - [wpv-post-field name="attribute_pa_rv-site"]<br>[/wpv-conditional]

The billing names are working fine on their own, but when I add the conditional, it isn't working and the attribute-pa-rv-site attribute field isn't working at all. So I'm having problems getting things to work based on attributes completely.

#2669039

If you go to this page, you'll see what I'm trying to do.

hidden link

The Volunteers functionality is fine because those are generated through a Toolset post form. But the Riders functionality is pulling from Woocommerce orders.

If I remove the conditionals from the 3-day and 6-day Rider views, then it is showing the names of all people that have ordered anything in our store. If the conditionals would be working, there should only be one name under the 6 day list right now.

#2669627

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

The problem is the same as in the other ticket.

Your View is querying—and iterating over—orders, not products.

Product attributes are assigned to products, not to orders.

It isn't possible to modify a WP_Query polling order posts to filter by a property of something else.

Nor can you use a conditional shortcode to test product attributes when the current post being iterated over is an order, because orders don't have product attributes.

As I suggested in the other ticket you could run custom logic to determine which orders contain the relevant products and then use the post__in parameter to limit the order query to only those orders. (The logic for the query will be bespoke, but you can still take advantage of Views to generate the output for the matching orders.)

Alternatively, if you wanted to go down the wpv-conditional route, you could register a custom shortcode to test whether any of the products of the current order have the specified product attribute assigned and then use that custom shortcode for your conditional tests.

But, again, that means writing custom PHP.

#2670037

OK, I haven't received a reply from Beda Schmid yet. I'll add mention of this ticket to what I asked him about. If he doesn't reply, is there any other approach we can do to get these two tickets done? I'm reluctant to approach any of your other contractors absent a ratings/reviews system in place. I can get a quote from Codeable though. We'd MUCH rather pay someone with your team to handle this though as we've always been very happy with the results on the tickets where you have been able to provide custom code for us.

#2670973

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

I'm sorry, but company policy is that time off is time off, and doesn't permit taking on additional work outside of normal hours.

If you don't get anywhere with Beda using a reputable coder for a non-Toolset solution is not a bad idea, given the changes in WooCommerce relating to order database storage. Otherwise you will always need to run WC in legacy/compatibility mode so that it can work with Toolset.

#2671903

Noted. I guess we can mark this one as resolved then.

#2671945

Question. I've contacted Codeable about the matters where you advised to get a contractor. They have asked me to send them the Toolset plugin for them to analyze what needs to be done before providing a cost estimate. Is it OK for me to get that to them? I don't want to run afoul of our license use with you.

#2672033

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

It is not something that is explicitly prohibited in the terms and conditions, and were you to make your site available to them (which I expect you will need to if you proceed) they would have access to all of your themes and plugins in any case.

Please do what you need to be able to reach a solution for this.

#2672165

They just want to look at it on their side and asked me to send the .zip file. I'll tell them to make sure to delete it when done. It won't be connected to our account/their development site. Thanks.

The topic ‘[Closed] View to show Woocommerce orders with a query filter on an attribute option?’ is closed to new replies.