我在 WooCommerce 中创建了这个函数,它用一些后续文本替换当前价格,然后是价格。它工作得很好。
但是,我们在 WPML 中设置了两种不同的语言,而这两种语言中的任何一种都没有显示出来。
如何使用 WPML 进行翻译?
add_filter( 'woocommerce_get_price_html', 'new_custom_price_message' );
function new_custom_price_message( $price ) {
$regular_price = get_post_meta( get_the_ID(), '_price', true);
$s = 100000;
if ( $regular_price >= $s ) {
$ss = __('Starting at: Price Upon Request', 'my-theme-slug');
return $ss;
}
else if ($regular_price < $s ){
$price_text = __('Starting at: ', 'my-theme-slug');
return $price_text . $price;
}
}
谢谢。