[英]Get the total stock of all variations from a variable product In Woocommerce
[英]Total stock of all variations from a variable product In Woocommerce
我尝试使用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' );
}
有了这个:
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' );
}
或者是否可以在数量的默认元素中获得总库存? 例如。 股票将显示在下面突出显示的位置:
只需使用以下内容,以这种方式更改钩子(对于作为商店的存档页面) :
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' );
}
代码位于活动子主题(或活动主题)的 function.php 文件中。 它应该按要求工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.