![仿牌独立站出海专家](data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%20100%20100%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3C%2Fsvg%3E)
function bbloomer_show_sales_to_admin_325() {
global $product, $post;
if ( current_user_can( 'administrator' ) ) {
echo '<div class="sales-admin"><b>SALES (admin-only):</b><ol>';
$orders = get_posts( array(
'post_type' => 'shop_order',
'post_status' => 'wc-completed'
) );
foreach ($orders as $order) {
$order = new WC_Order( $order->ID );
$items = $order->get_items();
foreach( $items as $item ) {
$product_id = $item['product_id'];
if ( $post->ID == $product_id ) { echo '<li>' . $order->get_billing_first_name() . ' ' . $order->get_billing_last_name() . '</li>'; }
}
}
echo '</ol></div>';
}
}
add_action( 'woocommerce_after_shop_loop_item', 'bbloomer_show_sales_to_admin_325', 10 );