在单页 woocommerce 中删除价格中的文本
remove the text in the price in single page woocommerce
你能帮帮我吗?我一直在 functions.php 文件的 woocommerce/product 页面中添加一些自定义代码。我的产品价格为 0,但它在产品列表商店页面上显示了免费文本。当我添加此代码时
function woo_my_custom_free_message() {
return "This product is FREE!";
}
add_filter('woocommerce_free_price_html', 'woo_my_custom_free_message');
当我将产品悬停在商店页面上时,它显示文本是免费的,我喜欢它。但是如果您单击该自由文本的产品,它还会显示我在我的函数代码中添加的自由文本。 php。我的想法是删除该文本,但如果我隐藏 css 上的价格,所有价格都将消失。这是我遇到的最后一个问题。
伙计们请帮助我。
先感谢您。你们太棒了! :D
这是正确的方法。
function woo_my_custom_free_message($price) {
$price = is_product()?'':'This product is FREE!';
return $price;
}
add_filter('woocommerce_free_price_html', 'woo_my_custom_free_message', 10, 1);
您还可以使用:
add_filter( 'woocommerce_variable_free_price_html', 'hide_free_price' );
add_filter( 'woocommerce_free_price_html', 'hide_free_price' );
add_filter( 'woocommerce_variation_free_price_html', 'hide_free_price' );
function hide_free_price($price){
return 'This product is FREE!';
}
你能帮帮我吗?我一直在 functions.php 文件的 woocommerce/product 页面中添加一些自定义代码。我的产品价格为 0,但它在产品列表商店页面上显示了免费文本。当我添加此代码时
function woo_my_custom_free_message() {
return "This product is FREE!";
}
add_filter('woocommerce_free_price_html', 'woo_my_custom_free_message');
当我将产品悬停在商店页面上时,它显示文本是免费的,我喜欢它。但是如果您单击该自由文本的产品,它还会显示我在我的函数代码中添加的自由文本。 php。我的想法是删除该文本,但如果我隐藏 css 上的价格,所有价格都将消失。这是我遇到的最后一个问题。
伙计们请帮助我。 先感谢您。你们太棒了! :D
这是正确的方法。
function woo_my_custom_free_message($price) {
$price = is_product()?'':'This product is FREE!';
return $price;
}
add_filter('woocommerce_free_price_html', 'woo_my_custom_free_message', 10, 1);
您还可以使用:
add_filter( 'woocommerce_variable_free_price_html', 'hide_free_price' );
add_filter( 'woocommerce_free_price_html', 'hide_free_price' );
add_filter( 'woocommerce_variation_free_price_html', 'hide_free_price' );
function hide_free_price($price){
return 'This product is FREE!';
}