php - (Woocommerce)在除购物车和结帐页面之外的所有地方都显示价格
问题描述
我想在价格产品类别/单品页面之前添加一些内容。我以这段代码为例:
function cw_change_product_price_display( $price ) {
$price .= ' Starts At';
return $price;
}
add_filter( 'woocommerce_get_price_html', 'cw_change_product_price_display' );
但它显示为“RM49.00 Starts At”,我需要在价格之前显示这些词。我如何实现这一目标?我真的需要这方面的帮助。
解决方案
您只需要在价格 html 之前附加它。您可以检查单个产品页面使用is_product()
和类别页面使用is_product_category()
。
function cw_change_product_price_display( $price ) {
if ( is_product() || is_product_category() ) {
return 'Starts At ' . $price;
}
return $price;
}
推荐阅读
- java - Java:围绕“+”拆分字符串
- marklogic - Apache Nifi Marklogic 查询处理器
- split - 拆分数字并在左侧添加零
- python - 根据多个条件替换 groupby 中的值
- java - 尝试在空对象引用上调用虚拟方法“MaterialEditText.getText()”
- linux - ARM 工具链
- asp.net-web-api - Angular 5 从 c# web api 下载 docx 文件
- c++ - 使用带有 QDataStream 的自定义 QMetaType
- react-native - 反应本机-TypeError:未定义不是函数
- php - 来自 Laravel 的 SOAP 请求