Я сделал новое поле для цен на функции WooCommerce. Это поле печатается в моей базе данных с DOT, и я хочу печатать с COMMA.
Неправильно: 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();
}