Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    This isn’t possible out of the box. Since orders can contain multiple products, this type of query is very advanced and resource intensive. It would require custom coding into a plugin or special page.

    jobs.wordpress.net if you need someone to do this.

    Thread Starter sahilg

    (@sahilg)

    Please if you don’t provide me with code at least give me an idea or steps in words to follow , i will proceed myself . But please help i’m badly stuck into it..

    Thread Starter sahilg

    (@sahilg)

    I only want to show two order table for two different products for particular user in two different templates…

    Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    Without attempting to code this myself, I don’t know the steps. As I said, this is a complex query because you’re looking at data within orders, not the orders themselves.

    I’d suggest starting by looking at the order_line_items order_line_itemmeta DB tables so you can see how the product IDs are stored for line items.

    Thread Starter sahilg

    (@sahilg)

    I had tried lot with all these tables but nothing achieved and at last always stuck with get query woocommerce_my_account_my_orders_query . Ok i will wait for your reply with required solution. Thanks.

    Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    woocommerce_my_account_my_orders_query won’t be suitable. You need to do a completely custom query to get the ids, then loop over them via your own code.

    Not sure if this is the right forum for what I’m about to ask. I’m having a problem. On a site that I’m building it has a number of selection options which includes Turnaround, Quantity, Color/Inks, Paper Stock etc. I use variants for the Turnaround and Quantity and Product Add Ons for everything else. When I submit an order the options that I select are displayed up to a point but once I place the order the only thing that shows are the labels and not the options. In the order email it’s the same thing, only the labels but not the options that were selected. Do you know what could be causing this?

    Plugin Contributor Mike Jolley (a11n)

    (@mikejolley)

    damion1980 its the right forum, but you’re hijacking someone elses thread which is unrelated. Make your own.

    Thread Starter sahilg

    (@sahilg)

    I got the solution , made custom query and assign product id to it and after that use while loop to get results.

    <?php

    global $wpdb;
    $produto_id = 8704; // Product ID
    $consulta = “SELECT order_id FROM {$wpdb->prefix}woocommerce_order_itemmeta woim
    LEFT JOIN {$wpdb->prefix}woocommerce_order_items oi
    ON woim.order_item_id = oi.order_item_id
    WHERE meta_key = ‘_product_id’ AND meta_value = %d

    GROUP BY order_id;”;
    $order_ids = $wpdb->get_col( $wpdb->prepare( $consulta, $produto_id ) );
    if( $order_ids ) {
    $args = array(
    ‘post_type’ =>’shop_order’,
    ‘post__in’ => $order_ids,
    ‘post_status’ => ‘publish’,
    ‘posts_per_page’ => 20,
    ‘order’ => ‘DESC’,
    ‘meta_key’ => ‘_customer_user’,
    ‘meta_value’ => get_current_user_id(),
    ‘tax_query’ => array(
    array( ‘taxonomy’ => ‘shop_order_status’,
    ‘field’ => ‘slug’,
    ‘terms’ => array (‘Pending’ , ‘Failed’ , ‘Processing’ , ‘Completed’, ‘On-Hold’ , ‘Cancelled’ , ‘Refunded’)
    )
    )
    );
    $orders = new WP_Query( $args );
    }
    ?>

    This code will help you to retrieve orders for single product. For any more help contact me .

    @sahilg : How can I make this a custom field? I also want to only show a specific product order’s table on a SportsPress ‘Club’ page, and this seems to be the code I needed.

    @sahilg thanks! works like magic!

    chad480

    (@chad480)

    @sahilg Thank you!

    The line: ‘Pending’ , ‘Failed’ , ‘Processing’ , ‘Completed’, ‘On-Hold’ , ‘Cancelled’ , ‘Refunded’

    Can be replaced with: wc_get_order_statuses()

    I want to achieve in my WooCommerce store limited access to the different sellers and they can only see their orders and products NOT whole store orders and products, in other words, each seller can have their exclusive products and orders individually and their customers in my store can order with any seller they want. I’ve been struggling with this plugin with no succeed, I only can manage access to products and orders but it shows everything published with each seller, Any suggestions?

    @yehanny
    You might do better to start a new thread for your question.

    Thanks I’ll do that (=

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘How to show all orders details for specific or particular product in wooCommerce’ is closed to new replies.