Woocommerce根据订单商品获得卖家/作者ID

时间:2017-09-18 02:41:03

标签: php woocommerce

我正在尝试获取作者姓名,我希望根据订单商品从中获取产品的卖家ID。我虽然使用yith多供应商。我尝试了'getuserdata',但它返回'0'值。我的代码:

function short_add_vendor_to_order_item_meta( $item_id, $cart_item) {   
$order = new WC_Order( $order_id );
$items = $order->get_items();

    $vendor_id = $items->post->post_author;
    $vendor_data = get_userdata( $vendor_id );
    $vendor_GST = get_the_author_meta( 'tin_number', $vendor_id );
    $sold_by = WCV_Vendors::is_vendor( $vendor_id ) ? sprintf( WCV_Vendors::get_vendor_sold_by( $vendor_id ) ): get_bloginfo( 'name' );
    $sold_by_and_GST = $sold_by . ' <br /> ' . 'GST: '.$vendor_GST;

    $tinshortes = wc_add_order_item_meta( $item_id, apply_filters('wcvendors_sold_by_in_email', __('Sold_by', 'wcvendors')), $sold_by_and_GST);
    echo $tinshortes;

}
add_shortcode('tinshorte','short_add_vendor_to_order_item_meta');

0 个答案:

没有答案