簡體   English   中英

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM