• I tried finding lot of options and used lot of functions so far in my woocommerce theme but i am unable to find any solution for this issue. This platform is my my only hope so far.

    What I want? I have multiple authors that I have created using roles. In my shopping website these authors are publishing their products and each product has a user role assigned with the following function in my theme:

    <strong>add_action('init', 'wpse_74054_add_author_woocommerce', 999 );
    function wpse_74054_add_author_woocommerce() {
    add_post_type_support( 'product', 'author' );
    }</strong>

    I used the same function for Order post type but it is not working as per my requirements.

    My Requirements: Now when someone order’s a product then the individual product or a multiple product get’s displayed in the order section of admin and in all my author’s dashboard. What I want is: Specific author should only see it’s own product orders and not other author product orders, and admin should be the only one who should see every product orders.

    A prompt reply would be much appreciated.

    https://wordpress.org/plugins/woocommerce/

Viewing 11 replies - 1 through 11 (of 11 total)
  • borie88

    (@borie88)

    I’m going to bring this back because I am interested too.

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    There is no backend view for customers – you must use the frontend my account shortcode.

    Lock down manage_woocommerce capability to prevent them seeing orders.

    borie88

    (@borie88)

    What about for filtering order queries for the product author on the frontend?

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    O I think you’re talking about a vendors plugin solution, not the users own placed orders.

    borie88

    (@borie88)

    Sort of like vendors, except users can create products (tickets for events) through the frontend with a form, so they become the post author. I’d like for them to be able to see orders made from those products, so they know who is coming to their events.

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    Yeah thats vendors. Some might not have frontend editor – you’d have to see what each vendors solution offers.

    borie88

    (@borie88)

    I thought vendors makes you create a ‘vendor’ first and then displays orders by vendor, regardless of the post author. That would be an extra step in this case because users would have to create a vendor for themselves first, correct?

    Maybe a better question would be: how are orders linked to products? I found out they do not have a hierarchical relationship. Is there a custom field in each order linking it to the product?

    borie88

    (@borie88)

    Better yet, is there a way to get the author id for a product of an order with a shortcode so I can pass it into a query filter for the shop_order post type in Toolset Views? I tried using this:

    function display_author_shortcode() {
    
    	// Code
    	$order = $order_id;
    	$items = $order->get_items();
    	foreach ( $items as $item ) {
    	    $product_id = $item['product_id'];
    	}
    	$product_author_id = $product_id->post_author;
    
    	return $product_author_id;
    }
    add_shortcode( 'product-author', 'display_author_shortcode' );

    Thanks!

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    You’re confusing me now.

    Sort of like vendors, except users can create products (tickets for events) through the frontend with a form, so they become the post author. I’d like for them to be able to see orders made from those products, so they know who is coming to their events.

    If it were a vendor, they’d create a product, that product would be linked to them as a vendor (not necessarily author), they would control this product, and they would see orders which contain this product.

    Maybe a better question would be: how are orders linked to products?

    Line Items within orders are linked to the product ID. Line items are stored in their own DB table.

    borie88

    (@borie88)

    If it were a vendor, they’d create a product, that product would be linked to them as a vendor (not necessarily author), they would control this product, and they would see orders which contain this product.

    Exactly. I’m cutting out the step of making them a vendor and letting them create products regardless.

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    So you need a custom query to pull line items from orders where the product ID is one they author. I would have thought the vendors plugins would have done this but since you’re not using one, this is something you’ll need to code…

    Get product IDs for X user. Then query line items table for line items with that product ID and display them.

    The other complexity you’ll run into (again probably handled by vendors) is that orders would be able to contain a mix of products from different authors.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Display Woocommerce Orders for specific author’ is closed to new replies.