I have added a few input fields in the backend:
class WC_Settings_Tab_Demo {
/**
* Bootstraps the class and hooks required actions & filters.
*
*/
public static function init() {
add_filter( 'woocommerce_settings_tabs_array', __CLASS__ . '::add_settings_tab', 50 );
add_action( 'woocommerce_settings_tabs_settings_tab_demo', __CLASS__ . '::settings_tab' );
add_action( 'woocommerce_update_options_settings_tab_demo', __CLASS__ . '::update_settings' );
add_action('woocommerce_process_product_meta', __CLASS__ . '::process_meta');
}
/**
* Add a new settings tab to the WooCommerce settings tabs array.
*
* @param array $settings_tabs Array of WooCommerce setting tabs & their labels, excluding the Subscription tab.
* @return array $settings_tabs Array of WooCommerce setting tabs & their labels, including the Subscription tab.
*/
public static function add_settings_tab( $settings_tabs ) {
$settings_tabs['settings_tab_demo'] = __( 'Pricing', 'woocommerce-settings-tab-demo' );
return $settings_tabs;
}
/**
* Uses the WooCommerce admin fields API to output settings via the @see woocommerce_admin_fields() function.
*
* @uses woocommerce_admin_fields()
* @uses self::get_settings()
*/
public static function settings_tab() {
woocommerce_admin_fields( self::get_settings() );
}
/**
* Uses the WooCommerce options API to save settings via the @see woocommerce_update_options() function.
*
* @uses woocommerce_update_options()
* @uses self::get_settings()
*/
public static function update_settings() {
woocommerce_update_options( self::get_settings() );
}
/**
* Uses the WooCommerce options API to save settings via the @see woocommerce_update_options() function.
*
* @uses woocommerce_update_options()
* @uses self::get_settings()
*/
public static function process_meta() {
}
/**
* Get all the settings for this plugin for @see woocommerce_admin_fields() function.
*
* @return array Array of settings for @see woocommerce_admin_fields() function.
*/
public static function get_settings() {
$settings[] = array( 'name' => __( 'Margin settings', 'text-domain' ), 'type' => 'title', 'desc' => __( 'The following options are to configure our margin on top of prices', 'text-domain' ), 'id' => 'wcslider' );
$settings[] = array(
'name' => __( 'Canvas', 'text-domain' ),
'desc_tip' => __( 'Margin profit in percents added on top of Canvases!', 'text-domain' ),
'id' => 'canvas',
'type' => 'text',
);
// Add second text field option
$settings[] = array(
'name' => __( 'Framed Posters', 'text-domain' ),
'desc_tip' => __( 'Margin profit in percents added on top of Framed Posters!', 'text-domain' ),
'id' => 'framed',
'type' => 'text',
);
// Add second text field option
$settings[] = array(
'name' => __( 'Posters', 'text-domain' ),
'desc_tip' => __( 'Margin profit in percents added on top of Posters!', 'text-domain' ),
'id' => 'posters',
'type' => 'text',
);
$settings[] = array( 'type' => 'sectionend', 'id' => 'posters' );
return apply_filters( 'wc_settings_tab_demo_settings', $settings );
}
}
WC_Settings_Tab_Demo::init();
this is how it looks in the backend: https://ibb.co/cNd7BF
My only question is how to retrieve these values from input field with php code?