Php 如何计算所有库存?

Php 如何计算所有库存?,php,wordpress,Php,Wordpress,有人能帮我数一数所有的库存水平吗?我下面的代码统计Woocommerce产品的post类型,在我的例子中,当前返回6,因为只有6个产品。是否有可能计算所有产品的所有库存水平及其变化,因此理论上这将返回一个更接近500的数字 function uce_number_events_tickets() { $count_events = wp_count_posts( $post_type = 'event' ); $count_products = wp_count_posts( $post_typ

有人能帮我数一数所有的库存水平吗?我下面的代码统计Woocommerce产品的post类型,在我的例子中,当前返回6,因为只有6个产品。是否有可能计算所有产品的所有库存水平及其变化,因此理论上这将返回一个更接近500的数字

function uce_number_events_tickets() {
$count_events = wp_count_posts( $post_type = 'event' );
$count_products = wp_count_posts( $post_type = 'product' );
echo ('<div id="uce-counter">We currently have ' . '<span>' . $count_events->publish . '</span>' . ' events listed with ' . '&amp; ' . '<span>' . $count_products->publish . '</span>' . ' tickets available to buy!</div>');
}
add_shortcode('uce_number_events_tickets', 'uce_number_events_tickets');
函数uce\u number\u events\u tickets(){
$count_events=wp_count_posts($post_type='event');
$count_products=wp_count_posts($post_type='product');
echo(“我们目前有“.”.$count\u事件->发布“.”.$count\u事件与“.”和“.”一起列出。”$count\u产品->发布“.”.“可购买的门票!”);
}
添加快捷码(“uce\U编号\U事件\U票证”,“uce\U编号\U事件\U票证”);