繁体   English   中英

当库存设置为“ 0”或“无库存”时,WooCommerce隐藏价格

[英]WooCommerce Hide Prices When Inventory is set to '0' or 'out of stock'

我知道我可以使用css属性“ visibility:hidden”来隐藏产品列表页面上的价格(我已将其分配给特定的页面ID,仅在已售商品页面上。

但是在单个产品页面上,有一段我可以使用的PHP,上面写着“如果物品缺货/数量设置为0,则隐藏价格”?

主要售罄的产品清单:
http://www.montagemodern.com/sold

个别缺货产品页面示例:
http://www.montagewestport.com/product/pair-of-glass-bubble-lamps/

尝试这个:

add_filter( "woocommerce_variable_sale_price_html", "theanand_remove_prices", 10, 2 );
add_filter( "woocommerce_variable_price_html", "theanand_remove_prices", 10, 2 );
add_filter( "woocommerce_get_price_html", "theanand_remove_prices", 10, 2 );

function theanand_remove_prices( $price, $product ) {
    if ( ! $product->is_in_stock()) {
        $price = "";
    }
    return $price;
}

http://wwweb.jextensions.com/theanand.com/blog%252Fhide-price-out-of-stock-woocommerce%252F

暂无
暂无

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

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