woocommerce 在价格前自动添加一个词
woocommerce automatically adding a word before price
我的 woocommerce 商店的价格前面自动添加了 “起始于”字样,我想删除这些字样。
这发生在所有产品上,包括可变产品和常规产品。我需要一个代码,可以让我完全删除价格之前的单词。
屏幕截图:
screen shot - regular product
screen shot - variable product
谢谢。
要从显示的价格中删除 "starting from" 前缀,请在您的活动子主题(或活动主题)的 function.php 文件中尝试以下代码。
add_filter( 'woocommerce_get_price_html', 'filter_get_price_html_callback', 10, 2 );
function filter_get_price_html_callback( $price, $product ) {
return str_replace( __('starting from'), '', $price );
}
与单个产品页面类似:
add_filter( 'woocommerce_get_price_html', 'filter_get_price_html_callback', 10, 2 );
function filter_get_price_html_callback( $price, $product ) {
if ( is_product() )
$price = str_replace( __('starting from'), '', $price );
return $price;
}
注意:请根据需要替换'starting from'。
我的 woocommerce 商店的价格前面自动添加了 “起始于”字样,我想删除这些字样。
这发生在所有产品上,包括可变产品和常规产品。我需要一个代码,可以让我完全删除价格之前的单词。
屏幕截图:
screen shot - regular product
screen shot - variable product
谢谢。
要从显示的价格中删除 "starting from" 前缀,请在您的活动子主题(或活动主题)的 function.php 文件中尝试以下代码。
add_filter( 'woocommerce_get_price_html', 'filter_get_price_html_callback', 10, 2 );
function filter_get_price_html_callback( $price, $product ) {
return str_replace( __('starting from'), '', $price );
}
与单个产品页面类似:
add_filter( 'woocommerce_get_price_html', 'filter_get_price_html_callback', 10, 2 );
function filter_get_price_html_callback( $price, $product ) {
if ( is_product() )
$price = str_replace( __('starting from'), '', $price );
return $price;
}
注意:请根据需要替换'starting from'。