Skip Navigation

[Gelöst] List all orsers related to a product

This support ticket is created vor 2 Jahre. 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.

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 14 Antworten, has 2 Stimmen.

Last updated by Minesh vor 2 Jahre.

Assisted by: Minesh.

Author
Artikel
#2318111

Pat

Hello,

I would like to use Views to list all orders related to a specific product (ie : the specific product is part of the order, but the order can have several other products) and then, some specific custom fields of each order (author, price, date)
How can I achieve this thanks to Toolset
Regards
Pat

#2318215

Minesh
Supporter

Languages: Englisch (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Here is the official doc about how you can display the order (in block)
- https://toolset.com/course-lesson/how-to-display-woocommerce-orders-on-the-front-end/

To display related products belongs to order, you will have to create nested views. You can use the view's shortcode: [wpv-ordered-product-ids] to get all product ID's belongs to current order:
=> https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-555686

First I would like to know, do you want to display orders with product?
- Order 1
-- product 1
-- product 2
-- product 3
- Order 2
-- product 4
-- product 2
-- product 5

#2318429

Pat

Hi Minesh,

The site has been designed 3 years ago and I have used the Views plugin. Is it possible to manage orders with Views or do I need to install Blocks plugin?
If I need to install Blocks, what about all the other Views that have been already created?
Regards
Pat

#2318447

Pat

Hi Minesh,

Some complementory info :
Concerning the display, I want to add the Views in the product single page like this :
Order1 => ordernumber, author, date, price
Order2 => ordernumber, author, date, price ...

Second point, the products are variable products. So, I think we need another step in order to retrieve the ID of the variables and not the global productID?
Regards
Pat

#2318453

Pat

Minesh,

Another point : it seems that the posts related to an order are recorded with the admin ID as author. So, this means that all info related to the user that have placed the order should be retrieve by another way?
Regards
Pat

#2318467

Pat

I'm progressing. Just tried the [wpv-ordered-product-ids] shortcode. It returns the single product (or the global product ID in case of variable product). How can I get the option that have been chosen by the customer in an order?
Regards
Pat

#2318475

Minesh
Supporter

Languages: Englisch (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please share problem URL where you want to display the orders and admin access details?

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2319113

Pat

Hi Minesh,

Thanks for your return.
It could be difficult to give you access as I want to display the Views inside a product page which is defined thanks to a template (and which is used by all other products in the site !).

Best solution to me would be to work on a Views with a query filter based on a product ID (this will enable thenafter to integrate it in the product template and use the post_ID shortcode in the query filter? In a first time, it will be easy to test it by using a fixed product ID).

This product ID should correspond to the ID of the global variable product :
- Global_product
o Variant1
o Variant2
o Variant3 …
The Views should output the list of order lines that are related to the variants linked to the global product
What is needed in terms of information on each line is :
- Last name
- First name
- Email
- Order number
- Date
- Price of the order line (not the total order)

Let me know if you need additional info.

Regards
Pat

#2319165

Minesh
Supporter

Languages: Englisch (English )

Timezone: Asia/Kolkata (GMT+05:30)

What you mean by global product?

It it possible for you to create a test product that I can use it and I'll try to create another content template for test purpose so that it will not affect your live site and I'll try to build solution on your site as required by you. If yes, you can send me admin access details and tell me what orders you would like to see with the test product you shared.

We have conditional settings feature available for content template so that I'll set the content template I'll create for testing purpose and that content template will be applied to test product only.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2320739

Pat

Hi Minesh,

In the between, I have digged into the database and found some interesting info.

In the wp_woocommerce_order_itemeta table, we can find :
- order_item_id
- product_id (what I call generic product, meaning, the product to which all variations are linked)
- variation_id (the variation that have been chosen by the user)
- line_total

Then, in the wp_postmeta table, we can select all meta with post_id = variation_id (of the previews table) and we can find all needed info :
- _billing_first_name
- _billing_last_name
- _billing_address_1
- _billing_city
- _billing_postcode
- _billing_emaiul
- _billing_phone
- _paid_date
- attribute_pa_tarif-cannes-conference

Last, in the wp_woocommerce_order_items table, we have :
- order_id

So, it seems the best way to achieve what I need would be to :
1. list all items from the wp_woocommerce_order_itemeta table
2. Select all items with product_id = ID of the current product page
3. For each item, extract the variation_id, line_total and order_item_id
4. Extract all needed info from the wp_postmeta table using the post_id = variation_id
5. Extract the order_id from the wp_woocomerce_order_items table
6. Output the line with order_id + all info from the wp_postmeta table listed before

Does that make sense for you?
If yes, what's the best way to achieve this thanks to Toolset? Can we use the loop in order to manage points 3 to 6?

Regards
Pat

#2322705

Minesh
Supporter

Languages: Englisch (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - Toolset or even WordPress works based on the post types not on database tables.

To display the orders information you will have to query the post type Order and to display the information related to products you will have to query the post type product.

I've created the following test site for you, you can auto-login using the following link:
=> hidden link

As you can see there is one completed order there:
- hidden link

So, to display the orders, I've created the following view, that also holds the nested view that will display the product information belongs to order: [wpv-view name="products-belongs-to-order" ids="[wpv-ordered-product-ids]"]
=> hidden link

And to display the products belongs to order, I've created the following view:
=> hidden link

You can see how order information and product information is displayed.
=> hidden link

#2323663

Pat

Hi Minesh,

Thanks, this is a good first step.
Now, I need to move a little forward as my initial was concerning a variable product (and your example is based on a single product).
So, I need to get the same kind of result with variable products, and display in addition to the customer info, the product variation that have been chosen on the order line.
Regards
Pat

#2323801

Minesh
Supporter

Languages: Englisch (English )

Timezone: Asia/Kolkata (GMT+05:30)

The solution I shared is the view is set to query orders and if orders contains the simple product.

I see you created a ticket before as well and I already updated you that there is no such feature exists with Toolset to display the variable product within orders:
=> https://toolset.com/forums/topic/list-all-orders-of-a-variable-product/#post-2111983

Either you will require custom code that is beyond the scope of our support policy or you can also raise a new feature request to add a feature to display variable product under orders:
=> https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

#2326771

Pat

Hi Minesh.
Thanks for your return.
I have raised a feature request as to me, Toolset is saying that products and orders can be managed from the front end, but what is not explained is that this is working only for single products !!!
I'm still convinced that Toolset should benefit from proposing variable product to be managed in front end also as this could avoid letting customers having access to WC product admin, which is not really user friendly !
Regards
Pat

#2326773

Minesh
Supporter

Languages: Englisch (English )

Timezone: Asia/Kolkata (GMT+05:30)

Thanks for filing the feature request.

Our product manager will review it and they are the decision makers unfortunately not the supporters (myself). Supporter role is to follow the protocols and guide users to right direction thats what we can do.

You're welcome to mark resolve the ticket.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.