在 woocommerce 产品页面中的价格后添加客户文本

Asi*_*eer 2 php wordpress

我正在为我的电子商务网站设计突出主题。我想在 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' );
Run Code Online (Sandbox Code Playgroud)

现在我想知道在woo-commerce目录中添加代码的位置。任何帮助,将不胜感激。

谢谢

小智 6

将此代码添加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' );
Run Code Online (Sandbox Code Playgroud)