简体   繁体   English

WooCommerce店铺页面显示最大数量

[英]Display Maximum Quantity in WooCommerce Shop page

I am trying to display Maximum Quantity on the WooCommerce Shop page (home page) I used a [get_max_purchase_quantity()] but I do not think that is, I need just to display the value.我试图在 WooCommerce 商店页面(主页)上显示最大数量我使用了 [get_max_purchase_quantity()] 但我不认为那是,我只需要显示值。 like that plz help像那样请帮助

You can use woocommerce_after_shop_loop_item action hook.您可以使用woocommerce_after_shop_loop_item动作挂钩。 code goes in your active theme functions.php file.代码进入您的活动主题函数。php 文件。

function show_max_quantity_after_price(){
    global $product;
    if( $product->get_max_purchase_quantity() > 0 ){
        echo $product->get_max_purchase_quantity();         
    }
}
add_action( 'woocommerce_after_shop_loop_item', 'show_max_quantity_after_price', 10, 1 );

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM