我正在为我的电子商务网站设计突出主题。我想在 woocommerce 产品页面的价格后显示“B”。
该页面显示为 "$99,99"
我想让它像这样显示:"$99,99 TEXT"
我有它的代码:
function change_product_price( $price ) {
$price .= ' TEXT';
return $price;
}
add_filter( 'woocommerce_get_price_html', 'cw_change_product_price_display' );
add_filter( 'woocommerce_cart_item_price', 'cw_change_product_price_display' );
现在我想知道在 woo-commerce 目录中的什么地方添加代码。任何帮助,将不胜感激。
谢谢
最佳答案
将此代码添加到主题的 functions.php
中:
function cw_change_product_price_display( $price ) {
$price .= ' TEXT';
return $price;
}
add_filter( 'woocommerce_get_price_html', 'cw_change_product_price_display' );
add_filter( 'woocommerce_cart_item_price', 'cw_change_product_price_display' );
关于php - 在 woocommerce 产品页面的价格后添加自定义文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47290161/