Ema*_*ira 2 php wordpress product woocommerce price
在 WooCommerce 中,我使用此代码在价格显示中放置文本:
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)
页面显示如下 "$99,99 TEXT"
我想让它显示如下: "TEXT $99,99"
感谢您的帮助。
您只需反转价格和文本:
add_filter( 'woocommerce_get_price_html', 'cw_change_product_price_display' );
add_filter( 'woocommerce_cart_item_price', 'cw_change_product_price_display' );
function cw_change_product_price_display( $price ) {
// Your additional text in a translatable string
$text = __('TEXT');
// returning the text before the price
return $text . ' ' . $price;
}
Run Code Online (Sandbox Code Playgroud)
这应该像你期望的那样工作......
归档时间: |
|
查看次数: |
7703 次 |
最近记录: |