add_action( 'woocommerce_product_options_general_product_data', 'art_woo_add_custom_fields' );
function art_woo_add_custom_fields() {
global $product, $post;
echo '<div class="options_group">';
woocommerce_wp_select( array(
'id' => '_select',
'label' => 'Значение перед ценой',
'options' => array(
'' => __( 'нет', 'woocommerce' ),
'от' => __( 'от', 'woocommerce' ),
),
) );
echo '</div>';
}
add_action( 'woocommerce_process_product_meta', 'art_woo_custom_fields_save', 10 );
function art_woo_custom_fields_save( $post_id ) {
$woocommerce_select = $_POST['_select'];
if ( $woocommerce_select ) {
update_post_meta( $post_id, '_select', esc_attr( $woocommerce_select ) );
}else {
delete_post_meta( $post_id, '_select');
}
}
add_action( 'woocommerce_get_price_suffix', 'art_get_select_before_add_card' );
function art_get_select_before_add_card() {
global $post;
echo '<span class="price_suffix">';
echo get_post_meta( $post->ID, '_select', true );
echo '</span>';
}
...
'от1' => __( 'от2', 'woocommerce' ),
...