简体   繁体   English

Woocommerce 中可变产品的所有变体的总库存

[英]Total stock of all variations from a variable product In Woocommerce

I've tried to use Get the total stock of all variations from a variable product In Woocommerce , trying to make working this code:我尝试使用Get the total stock from a variable product In Woocommerce ,尝试使用以下代码:

add_action( 'woocommerce_after_shop_loop_item_title', 'display_variable_product_stock_quantity', 20 );
function display_variable_product_stock_quantity(){
    wc_get_variable_product_stock_quantity( 'echo_html' );
} 

with this one:有了这个:

add_action( 'woocommerce_single_product_summary', 'display_variable_product_stock_quantity', 15 );
function display_variable_product_stock_quantity(){
    wc_get_variable_product_stock_quantity( 'echo_html' );
}

Or is it possible to get the total stock in the default element of quantities?或者是否可以在数量的默认元素中获得总库存? for example.例如。 The stocks will be displayed in the highlighted below:股票将显示在下面突出显示的位置:

在此处输入图片说明

Just use the following, changing of hook this way (for archive pages as shop) :只需使用以下内容,以这种方式更改钩子(对于作为商店的存档页面)

add_action( 'woocommerce_after_shop_loop_item', 'display_variable_product_stock_quantity', 20 );
function display_variable_product_stock_quantity(){
    wc_get_variable_product_stock_quantity( 'echo_html' );
} 

Code goes in function.php file of your active child theme (or active theme).代码位于活动子主题(或活动主题)的 function.php 文件中。 It should work as asked.它应该按要求工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从可变产品中获取所有变体的总库存 In Woocommerce - Get the total stock of all variations from a variable product In Woocommerce 如果所有变体都缺货,则从目录中隐藏 WooCommerce 可变产品 - Hide WooCommerce variable product from catalog if all variations are out of stock 获取Woocommerce中可变产品的“库存”产品变量 - Get the count of “in stock” product variations for a variable product in Woocommerce 显示在 WooCommerce 可变产品上售罄,当所有变体都缺货时 - Display sold out on WooCommerce variable product when all variations are out of stock 更新 Woocommerce 中可变产品的所有变体价格 - Update all variations prices of a variable product in Woocommerce 从Woocommerce 3中的可变产品获取版本ID - Get variations IDs from a variable product in Woocommerce 3 Woocommerce产品变化:更改“库存”的位置 - Woocommerce product variations: Change position of „in stock“ 从 WooCommerce 中的可变产品中获取产品变体 skus - Get the product variations skus from a variable product in WooCommerce 从Woocommerce中的可变产品变体获取产品属性标签 - Get product attribute labels from variations of a variable product in Woocommerce 获取WooCommerce中变量产品价格的所有变体属性 - Get all variations attributes with prices for a variable product in WooCommerce
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM