Skip Navigation

[Resolved] How to Build a FE for staff to view WooCom Orders of members

This support ticket is created 4 years, 11 months ago. 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: Africa/Casablanca (GMT+01:00)

Tagged: 

This topic contains 17 replies, has 2 voices.

Last updated by rickM-7 4 years, 10 months ago.

Assisted by: Jamal.

Author
Posts
#1759701
Capture.JPG

Tell us what you are trying to do? I want to be able to present a view of past orders in Woocommerce similar to the Show Orders function with Woocommerce but display it on a Page that staff can see when reviewing User information. We are passing UserIDs to the page and so we would need to look up orders and display different values in a table format and be able to click to go to the order in woocommerce to make changes or update the order if needed.

Is there any documentation that you are following?
No not yet, but any direction or advice along with what modules I would need would be handy.

Is there a similar example that we can see?
Yes - see attached image of transaction display that we do a lookup with Access to a reporting database where we have copied the orders out. We are setting up a similar view in a WP Page with tabs and pulling data in from wp_user_meta and passing the user_ID as a parameter which is working for everything but orders.

What is the link to your site?
I don't think that would help at this point since the point of this is that it is not for online members although we may tap into that next.

#1760301

Hello and thank you for contacting the Toolset support.

So, you want to allow your staff to view a user's orders in the frontend right?
You can create a view to display orders, the view will need two filters, one on the "post author" equal to the user_id passed to the view.
A second filter on the order status. By default, views will lookup for posts with the "Publish" status. Orders do not use the default WordPress statuses, that's why you will need to have a filter on the view on the post status.

For each post in the loop, you can put and edit link that will take users to edit the order on the backend.

I hope this answers your question. Let me know if you have any other questions.

#1761797

I installed the plug-ins types.3.3.13, toolset-blocks.1.2.2, woocommerce-views.2.8.1.1, and cred-frontend-editor.2.5.8 which looked like the plug-ins I would need for creating the view for my website.

I went to to the Dashboard and selected the Views Post Type and clicked on the Create Content Template. I selected Posts and Orders for Usage: Single pages. And created a Transactions heading for the page.

I went looking for the Filter Query following instruction from this page and could not find the section referenced here as this was the closest doc I could find for adding a filter that was some what close --- https://toolset.com/learn/create-an-ecommerce-wordpress-site/displaying-more-information-from-woocommerce/how-to-display-woocommerce-orders-on-the-front-end/
I did see where there was other documentation on just adding a straight content page and adding a Toolset View to the content page but I couldn’t get that to work either.

Once I get past adding the two filters it looks like the rest of it should work following the above link. Can you advise on what I am missing.

#1763187

My apologies for the late reply, but I do not work on Mondays.

Please check our glossary to distinguish the difference between a view and a content template.
https://toolset.com/glossary/

A content template is meant to display only one post, be it a post, page, order or any custom post type post. A view is meant to display a list.

You will need to create a view to display a list of the user's orders instead of a content template.

Because you are activating the Block editor in Toolset->Settings->General->Editting experience, you don't have the menu entry "Toolset->Views". Currently, the block editor is creating a view from within the editor(when editing a page, a content template, etc.) In the coming release, the block editor will be able to create views without being already in the editor.

I created a private page page and a view inside of it. You can see the content template in action on this page: hidden link
The page is: hidden link

Check the configuration of the view here hidden link

I hope this helps. Let me know if you have any questions.

#1763949

This was very helpful. I was able to display some of the same fields you displayed.

I am seeing an issue with the filter. The post_author is not always the person that entered the order. Now, we do have a field in post meta associated with the post that references the _customer_user which is the user ID I need to pull the post but this is a circular reference. Not sure how to get around this.

I also need to be able to get to the post_meta for the order showing the _order_total, _paid_date, _payment_method_title. In addition, I need to get to the wp_woocommerce_order to pick up the products that were ordered since they may have multiple products that make up the total. There appears to be a way to pick up the post_meta data but I can't see how that will work either.

#1764455

Is "_customer_user" a field in the order? Or in another custom post type?
I understand that you want to filter the orders list by this field, right?

Let's fix this, first, then continue with the other details to display.

#1765523
Capture postmeta2.JPG
Capture postmeta.JPG

It is in the post_meta for the associated post for the order as is most of the data I am looking for - see attached.

#1765541

I do need the _customer_user to filter based on the UserID of the member, not the person that created the order. I actually that information too but in the body of the order that I want to display in the view. That shows me who created it which is not always the online member.

#1765579

The custom fields that start with an underscore (_) are called hidden fields, and they are not automatically detected by Toolset. We need to tell Toolset which of these custom fields should be available in the views query filters. Check this article https://toolset.com/course-lesson/using-third-party-hidden-fields/

I wanted to create a view in the block editor, but I faced some issues. The page is opened randomly on the block editor and on the classic editor. So, I enabled the legacy editor and created a test.

Once, I activate the "_customer_user" field in Toolset settings, I was able to use it in the query filter. Check the query filter of this view hidden link

Because we can't actually test a custom field value to the current user ID, we have to pass the user ID to the view in a shortcode argument. Check this article https://toolset.com/documentation/user-guides/views/passing-arguments-to-views/#controlling-the-filter-with-shortcode-attributes

Regarding the displaying of a field, you can use the wpv-post-field shortcode. And it is not required to have that field added in Toolset Settings. https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-153444

[wpv-post-field name='_customer_user']

I hope this helps. Let me know if you have any questions.

#1768477

Thanks Jamal. With the long weekend I am just now getting back to this now. Please do not close this as of yet - I am still working on it.

#1768543

Hi Jamal,

Making progress. I was able to create the view and get most of the data I needed. A couple of questions. It appears that the view is pulling in four orders which are associated with my current user ID does have but the orders are not from my account. Here is a link to the page where I am trying to pass a different user_ID parameter but it always yields the same four transactions for my userid that is currently logged in as me.

hidden link

I also noticed that the performance is very slow. Is there anything we can do to speed this up.

#1769139

I understood that you want to display the orders of the current logged in user, so the query filter for the view was set on the field to equal the current user.
If you need to pass the user ID on the URL parameter, the query filter should be updated to test against that query parameter instead of the current user ID. Check this article https://toolset.com/documentation/user-guides/views/passing-arguments-to-views/#filters-by-custom-fields
Note, that you can use URL parameter to pass the value (user id).

#1774209

OK - so I got this to work once. but when i added other fields to the view trying to get headings to appear on the table I am getting an out of memory error when I try to open the page. I upped the memory for WP to 512Mb and I completely removed Toolset and re-added it but I am still seeing the issue. Plus since I am using the Classic editor (which I really don't intend to use going forward for obvious design reasons - not an HTML guy) I am concerned about what I am running into. The View is Orders New and the page is Order History.

DEBUG Display ------ Fatal error: Allowed memory size of 805306368 bytes exhausted (tried to allocate 16777224 bytes) in /home/customer/www/staging5.tsra.com/public_html/wp-includes/wp-db.php on line 2000

I am encouraged that I got this far but am stuck for now. I have a more current staging copy I can go to but trying to understand what is going on. Thanks!

#1775137

Well I was able to determine at great hardship that saving changes frequently while building the OrdersII page where the transactions are being displayed seemed to help address the issue of failed saves. However I could not set the table view for the orders to be displayed. That option does not appear when i set the Loop style of display after going to a bullet list or numbered list, though the training says you can.

Staging5 is really screwed up so I've given you access to staging10.tsra.com.

(Credentials removed)

Here is a link to the display page to a user ID that is working ===== > hidden link

The display though is going to be a problem now. I think the table view is what is causing the problems with the pages not being saved. Not sure. As a side note - I am not an effective developer with html so I will depend on a better interface to manipulate the pages so the beta version maybe what i need.

#1775167

Please remove the ID and password in the last post - I have already disabled it.