T
T
Tereverda2022-04-12 17:22:16
WooCommerce
Tereverda, 2022-04-12 17:22:16

Setting fields in Woocommerce plugin?

I created a plugin for woocommerce, the plugin itself works correctly, but there is a problem with the menu.
When the plugin is activated, the empty content of the settings root tab is displayed.
The settings tab of the plugin itself works correctly.

62558aef53cdb114558612.png

// Добавляем во вкладку Интеграции настройки плагина
add_filter('woocommerce_get_sections_products', 'ronbel_ms_add_section');
function ronbel_ms_add_section($sections)
{
    $sections["ronbel_ms_plugin"] = __('Ронбел + Мой Склад');
    return ($sections);
}


// Добавляем настройки плагина
add_filter('woocommerce_get_settings_products', 'ronbel_ms_add_settings', 10, 2);
function ronbel_ms_add_settings($settings, $current_section)
{
    $settings = array();

    if ($current_section == "ronbel_ms_plugin") {
        // Заголовок плагина
        $settings[] = array(
          "name" => __('Ронбел + Мой Склад'),
          "type" => "title",
          "desc" => __('Настройки плагина для WooCommerce'),
        );

        $settings[] = array(
          "id"    => "ronbel_ms_user",
          "title" => "Логин Мой Склад",
          "type"  => "text"
        );

        $settings[] = array(
          "id"    => "ronbel_ms_password",
          "title" => "Пароль Мой Склад",
          "type"  => "password"
        );

        // Конец настроек
        $settings[] = array(
          "type"  => "sectionend"
        );
    }


    return ($settings);
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question