Change order author
-
Hello,
What would be the best approach to change the author of an order? By default all orders are assigned to the admin.Currently i’ve added
add_post_type_support( 'product', 'author' ); add_post_type_support( 'shop_order', 'author' );
I cant understand this hook “woocommerce_checkout_create_order” and how to update the author meta based on the product author.
What i tried is:add_action('woocommerce_checkout_create_order', 'custom_set_order_author', 20, 2); function custom_set_order_author( $order, $data ) { $items = $order->get_items(); foreach ( $items as $item ) { $product_id = wc_get_product($item->get_product_id()); $author_id = get_post_field( 'post_author', $product_id ); } $order_id = $order->get_order_number(); update_post_meta( $order_id,'post_author', $author_id ); }
I already restricted customer to add products only if they are from the same author so it will have same author for order and product.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Change order author’ is closed to new replies.