Problem:
The issue here is that the user wanted to filter the list of orders by the current product author. This means that if an author views his profile then he can view all the orders that were made on his product.
Solution:
I've made a custom shortcode that should be able to get the product id of the current order and pass it to your list orders view.
Add the following to your functions.php file
// Add Shortcode function get_ordered_products_id( $atts ) { // Attributes $atts = shortcode_atts( array( 'order_id' => '', ), $atts ); $order = wc_get_order( $atts['order_id'] ); $product_ids = array( );; // Iterating through each "line" items in the order foreach ($order->get_items() as $item_id => $item_data) { // Get an instance of corresponding the WC_Product object $product = $item_data->get_product(); array_push($product_ids, $product->get_ID()); // Get the product name } //$new_product_ids = str_replace(" ",",",$product_ids); return implode(',',$product_ids); } add_shortcode( 'get_ordered_products_id', 'get_ordered_products_id' );
This shortcode is used by calling it like this [get_ordered_products_id order_id='192'] where 192 will be the order id. You can also use it with the views [wpv-post-id] shortcode by passing it into the shortcode like this [get_ordered_products_id order_id='[wpv-post-id]']
So to use this in the view you need to add "get_ordered_products_id" shortcode name to the views 3rd party shortcode arguements that can be found in Toolset->Settings->Frontend Content.
So this should be added to your Orders view inside the
[wpv-view name="list-of-ordered-products" ids="[get_ordered_products_id order_id='[wpv-post-id]']"]
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 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | - |
- | 13:00 – 18:00 | 13:00 – 18:00 | 13:00 – 18:00 | 14:00 – 18:00 | 13:00 – 18:00 | - |
Supporter timezone: America/Jamaica (GMT-05:00)
This topic contains 16 replies, has 3 voices.
Last updated by 6 years, 7 months ago.
Assisted by: Shane.