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