3
使用WooCommerce,我有这样的代码,输出产品列表报告:获取SKU的产品列表销售报告
$args = array(
'post_type' => 'product',
'posts_per_page' => -1,
'meta_key' => 'total_sales',
'orderby' => 'meta_value_num',
'order' => 'DESC',
'meta_query' => array(
array(
'key' => 'total_sales',
'value' => 0,
'compare' => '>'
)
)
);
$output = array_reduce(get_posts($args), function($result, $post) {
return $result .= '<tr><td>' . $post->post_title . '</td><td>' . get_post_meta($post->ID, 'total_sales', true) . '</td></tr>';
});
echo '<table><thead><tr><th>' . __('Product', 'woocommerce') . '</th><th>' . __('Units Sold', 'woocommerce') . '</th></tr></thead>' . $output . '</table>';
与该代码我想列出一个WordPress页面上的销售。
我的问题:如何将SKU添加到表格中?
感谢
我已经轻轻地更新我的代码......有一个语法错误...让我知道它是否适合你的感谢... – LoicTheAztec