WooCommerce-从仪表板删除销售价格字段
2 个回复
最合适的回答,由SO网友:tushonline 整理而成
您不能使用代码删除该字段,但可以禁用在整个商店中使用销售价格。
To disable sale price
function custom_wc_get_sale_price( $sale_price, $product ) {
return $product->get_regular_price();
return $sale_price;
}
add_filter( \'woocommerce_get_sale_price\', \'custom_wc_get_sale_price\', 50, 2 );
add_filter( \'woocommerce_get_price\', \'custom_wc_get_sale_price\', 50, 2 );
To hide this field, 您可以使用CSS在产品编辑屏幕中隐藏它。但是CSS需要在管理端加载,所以将其放在主题样式表中可能不起作用。SO网友:T.Todua
您可以将CSS样式应用于仪表板:
add_action(\'admin_head\', function(){ ?>
<style> #woocommerce-product-data ._sale_price_field {display:none;} </style> <?php
});
输入此代码functions.php
结束