在woocommerce产品页面中添加价格后的自定义文字

在woocommerce产品页面中添加价格后的自定义文字

问题描述:

I am working on salient theme for my E-commerce website. I want to show "B" after price in woocommerce product page. The page displays like "$99,99"
I want to make it displays like this: "$99,99 TEXT"

I have the code for it :

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' );

Now I want to know where to add the code in woo-commerce directory. Any help would be appreciated.

thanks

我正在研究我的电子商务网站的主题。 我想在woocommerce产品页面中显示价格后的“B”。 页面显示如“$ 99,99” code>
我想让它显示如下:“$ 99, 99 TEXT“ code> p>

我有代码: p>

  function change_product_price($ price){
 $ price  。='TEXT'; 
返回$ price; 
} 
add_filter('woocommerce_get_price_html','cw_change_product_price_display'); 
add_filter('woocommerce_cart_item_price','cw_change_product_price_display'); 
  code>  pre> \  n 
 

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

谢谢 p> div>

add this code to the functions.php of your theme, in the end

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' );

The name of the function you're calling in add_filter isn't the same as the name of your actual function. It seems you've forgotten the _display in the function name.

In the following code, the function is name cw_change_product_price_display and cw_change_product_price_display is called in add_filter

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' );