Чтобы добавить свой собственный раздел с настройками на панели настройки WooCommerce, просто добавьте следующие фрагменты кодов в функции вашей активной темы. Php -
add_action( 'customize_register', 'my_custom_customize_register', 99 );
function my_custom_customize_register( $wp_customize ) {
$wp_customize->add_section(
'my_wc_custom_section',
array(
'title' => __( 'My Custom Section', 'text-domain' ),
'priority' => 20,
'panel' => 'woocommerce',
'description' => '',
)
);
$wp_customize->add_setting( 'my_wc_custom_section_settings', array( 'transport' => 'postMessage' ) );
$wp_customize->add_control( 'my_wc_custom_section_settings_control',
array(
'label' => __( 'Custom Text', 'text-domain' ),
'type' => 'text',
'settings' => 'my_wc_custom_section_settings',
'section' => 'my_wc_custom_section',
'priority' => 20,
)
);
}
Чтобы отобразить значение сохраненного поля из настроек пользовательского раздела, простоиспользуйте следующее -
echo get_theme_mod( 'my_wc_custom_section_settings' );
Вот так.