Php 将点改为逗号

Php 将点改为逗号,php,wordpress,woocommerce,Php,Wordpress,Woocommerce,我做了一个新的领域,以价格的功能,以争取商业。 该字段在我的数据库上用点打印,我想用逗号打印 错误:R$40.00 正确:R$40,00 function addSlubField() { global $post; $args = array( 'label' => 'Slub Price', // Text in Label 'label' => __('Slub Price', 'woocommerce') , 'placeholder' => 'Sl

我做了一个新的领域,以价格的功能,以争取商业。 该字段在我的数据库上用点打印,我想用逗号打印

错误:R$40.00 正确:R$40,00

function addSlubField() {
    global $post;
$args = array(
  'label' => 'Slub Price', // Text in Label
  'label' => __('Slub Price', 'woocommerce') ,
  'placeholder' => 'Slub Price',
  'class' => 'short',
  'style' => '',
  'wrapper_class' => '',
  'value'=>get_post_meta($post->ID,'slub_price',true),
  'id' => 'slub_price', // required
  'name' => 'slub_price', //name will set from id if empty
  'type' => 'number',
  'desc_tip' => '',
  'data_type' => '',
  'custom_attributes' => array('step'=>'0.01'), // array of attributes
  'description' => ''
);
woocommerce_wp_text_input( $args );
}
add_action( 'woocommerce_product_options_general_product_data', 'addSlubField',1);

add_action( 'woocommerce_process_product_meta', 'save_slub_field' );
function save_slub_field( $post_id ) {

  $custom_field_value = isset( $_POST['slub_price'] ) ? $_POST['slub_price'] : '';

  $product = wc_get_product( $post_id );
  $product->update_meta_data( 'slub_price', $custom_field_value );
  $product->save();
}

不要更改数据库架构。数据库使用句点而不是逗号作为十进制分隔符,在数据库中更改它会把事情搞砸。相反,通过(我认为)更改PHP语言环境或使用
number\u格式
来改变它的打印方式。如果您的Woocommerce货币设置中已经有逗号作为分隔符,您可以使用wc\u price($slub\u price)打印;